211 if (text_area.hasFocus) doc_view.caret_range() |
211 if (text_area.hasFocus) doc_view.caret_range() |
212 else Text.Range(-1) |
212 else Text.Range(-1) |
213 |
213 |
214 val markup = |
214 val markup = |
215 for { |
215 for { |
216 x <- painter_snapshot.select_markup(chunk_range)(Isabelle_Markup.text_color) |
216 r1 <- painter_snapshot.select_markup(chunk_range)(Isabelle_Markup.text_color) |
217 y <- x.try_restrict(chunk_range) |
217 r2 <- r1.try_restrict(chunk_range) |
218 } yield y |
218 } yield r2 |
219 |
219 |
|
220 var x1 = x + w |
220 gfx.setFont(chunk_font) |
221 gfx.setFont(chunk_font) |
221 if (markup.isEmpty) |
222 if (markup.isEmpty) gfx.drawString(chunk.str, x1, y) |
222 gfx.drawString(chunk.str, x.toInt, y.toInt) |
|
223 else { |
223 else { |
224 var x1 = x + w |
|
225 for { |
224 for { |
226 Text.Info(range, info) <- |
225 Text.Info(range, info) <- |
227 Iterator(Text.Info(Text.Range(chunk_range.start, markup.head.range.start), None)) ++ |
226 Iterator(Text.Info(Text.Range(chunk_range.start, markup.head.range.start), None)) ++ |
228 markup.iterator ++ |
227 markup.iterator ++ |
229 Iterator(Text.Info(Text.Range(markup.last.range.stop, chunk_range.stop), None)) |
228 Iterator(Text.Info(Text.Range(markup.last.range.stop, chunk_range.stop), None)) |
238 val i = r.start - range.start |
237 val i = r.start - range.start |
239 val j = r.stop - range.start |
238 val j = r.stop - range.start |
240 astr.addAttribute(TextAttribute.FONT, chunk_font) |
239 astr.addAttribute(TextAttribute.FONT, chunk_font) |
241 astr.addAttribute(TextAttribute.FOREGROUND, painter.getCaretColor, i, j) |
240 astr.addAttribute(TextAttribute.FOREGROUND, painter.getCaretColor, i, j) |
242 astr.addAttribute(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON, i, j) |
241 astr.addAttribute(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON, i, j) |
243 gfx.drawString(astr.getIterator, x1.toInt, y.toInt) |
242 gfx.drawString(astr.getIterator, x1, y) |
244 case _ => |
243 case _ => |
245 gfx.drawString(str, x1.toInt, y.toInt) |
244 gfx.drawString(str, x1, y) |
246 } |
245 } |
247 x1 += chunk_font.getStringBounds(str, font_context).getWidth.toFloat |
246 x1 += chunk_font.getStringBounds(str, font_context).getWidth.toFloat |
248 } |
247 } |
249 } |
248 } |
250 } |
249 } |