author | wenzelm |
Fri, 02 Sep 2011 22:48:56 +0200 | |
changeset 44662 | c8f1d943bfc5 |
parent 44545 | 3c40007aa031 |
child 45665 | 129db1416717 |
permissions | -rw-r--r-- |
43381 | 1 |
/* Title: Tools/jEdit/src/text_area_painter.scala |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
3 |
|
43381 | 4 |
Painter setup for main jEdit text area. |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
6 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle.jedit |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
8 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
9 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
10 |
import isabelle._ |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
11 |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
12 |
import java.awt.{Graphics2D, Shape} |
43392 | 13 |
import java.awt.font.TextAttribute |
14 |
import java.text.AttributedString |
|
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
15 |
import java.util.ArrayList |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
16 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
17 |
import org.gjt.sp.jedit.Debug |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
18 |
import org.gjt.sp.jedit.syntax.{DisplayTokenHandler, Chunk} |
43392 | 19 |
import org.gjt.sp.jedit.textarea.{TextAreaExtension, TextAreaPainter, JEditTextArea} |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
20 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
21 |
|
43381 | 22 |
class Text_Area_Painter(doc_view: Document_View) |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
23 |
{ |
43381 | 24 |
private val model = doc_view.model |
43382 | 25 |
private val buffer = model.buffer |
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
26 |
private val text_area = doc_view.text_area |
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
27 |
|
43392 | 28 |
|
29 |
/* original painters */ |
|
30 |
||
31 |
private def pick_extension(name: String): TextAreaExtension = |
|
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
32 |
{ |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
33 |
text_area.getPainter.getExtensions.iterator.filter(x => x.getClass.getName == name).toList |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
34 |
match { |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
35 |
case List(x) => x |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
36 |
case _ => error("Expected exactly one " + name) |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
37 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
38 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
39 |
|
43392 | 40 |
private val orig_text_painter = |
41 |
pick_extension("org.gjt.sp.jedit.textarea.TextAreaPainter$PaintText") |
|
42 |
||
43 |
||
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
44 |
/* common painter state */ |
43381 | 45 |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
46 |
@volatile private var painter_snapshot: Document.Snapshot = null |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
47 |
@volatile private var painter_clip: Shape = null |
43381 | 48 |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
49 |
private val set_state = new TextAreaExtension |
43381 | 50 |
{ |
51 |
override def paintScreenLineRange(gfx: Graphics2D, |
|
52 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
|
53 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
|
54 |
{ |
|
43404 | 55 |
doc_view.robust_body(()) { |
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43415
diff
changeset
|
56 |
painter_snapshot = doc_view.update_snapshot() |
43404 | 57 |
painter_clip = gfx.getClip |
58 |
} |
|
43381 | 59 |
} |
60 |
} |
|
61 |
||
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
62 |
private val reset_state = new TextAreaExtension |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
63 |
{ |
43381 | 64 |
override def paintScreenLineRange(gfx: Graphics2D, |
65 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
|
66 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
|
67 |
{ |
|
43404 | 68 |
doc_view.robust_body(()) { |
69 |
painter_snapshot = null |
|
70 |
painter_clip = null |
|
71 |
} |
|
43381 | 72 |
} |
73 |
} |
|
74 |
||
75 |
||
76 |
/* text background */ |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
77 |
|
43381 | 78 |
private val background_painter = new TextAreaExtension |
79 |
{ |
|
80 |
override def paintScreenLineRange(gfx: Graphics2D, |
|
81 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
|
82 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
|
83 |
{ |
|
43404 | 84 |
doc_view.robust_body(()) { |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
85 |
val snapshot = painter_snapshot |
43381 | 86 |
val ascent = text_area.getPainter.getFontMetrics.getAscent |
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
87 |
|
43381 | 88 |
for (i <- 0 until physical_lines.length) { |
89 |
if (physical_lines(i) != -1) { |
|
90 |
val line_range = doc_view.proper_line_range(start(i), end(i)) |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
91 |
|
43381 | 92 |
// background color: status |
93 |
for { |
|
43428
b41dea5772c6
more robust treatment of partial range restriction;
wenzelm
parents:
43426
diff
changeset
|
94 |
(command, command_start) <- snapshot.node.command_range(snapshot.revert(line_range)) |
b41dea5772c6
more robust treatment of partial range restriction;
wenzelm
parents:
43426
diff
changeset
|
95 |
if !command.is_ignored |
b41dea5772c6
more robust treatment of partial range restriction;
wenzelm
parents:
43426
diff
changeset
|
96 |
range <- line_range.try_restrict(snapshot.convert(command.range + command_start)) |
43381 | 97 |
r <- Isabelle.gfx_range(text_area, range) |
98 |
color <- Isabelle_Markup.status_color(snapshot, command) |
|
99 |
} { |
|
100 |
gfx.setColor(color) |
|
101 |
gfx.fillRect(r.x, y + i * line_height, r.length, line_height) |
|
102 |
} |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
103 |
|
43381 | 104 |
// background color (1): markup |
105 |
for { |
|
106 |
Text.Info(range, Some(color)) <- |
|
107 |
snapshot.select_markup(line_range)(Isabelle_Markup.background1).iterator |
|
108 |
r <- Isabelle.gfx_range(text_area, range) |
|
109 |
} { |
|
110 |
gfx.setColor(color) |
|
111 |
gfx.fillRect(r.x, y + i * line_height, r.length, line_height) |
|
112 |
} |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
113 |
|
43381 | 114 |
// background color (2): markup |
115 |
for { |
|
116 |
Text.Info(range, Some(color)) <- |
|
117 |
snapshot.select_markup(line_range)(Isabelle_Markup.background2).iterator |
|
118 |
r <- Isabelle.gfx_range(text_area, range) |
|
119 |
} { |
|
120 |
gfx.setColor(color) |
|
121 |
gfx.fillRect(r.x + 2, y + i * line_height + 2, r.length - 4, line_height - 4) |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
122 |
} |
43381 | 123 |
|
124 |
// squiggly underline |
|
125 |
for { |
|
126 |
Text.Info(range, Some(color)) <- |
|
127 |
snapshot.select_markup(line_range)(Isabelle_Markup.message).iterator |
|
128 |
r <- Isabelle.gfx_range(text_area, range) |
|
129 |
} { |
|
130 |
gfx.setColor(color) |
|
131 |
val x0 = (r.x / 2) * 2 |
|
132 |
val y0 = r.y + ascent + 1 |
|
133 |
for (x1 <- Range(x0, x0 + r.length, 2)) { |
|
134 |
val y1 = if (x1 % 4 < 2) y0 else y0 + 1 |
|
135 |
gfx.drawLine(x1, y1, x1 + 1, y1) |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
136 |
} |
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
137 |
} |
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
138 |
} |
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
139 |
} |
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43375
diff
changeset
|
140 |
} |
43381 | 141 |
} |
142 |
} |
|
143 |
||
144 |
||
145 |
/* text */ |
|
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
146 |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
147 |
def char_width(): Int = |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
148 |
{ |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
149 |
val painter = text_area.getPainter |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
150 |
val font = painter.getFont |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
151 |
val font_context = painter.getFontRenderContext |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
152 |
font.getStringBounds(" ", font_context).getWidth.round.toInt |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
153 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
154 |
|
43382 | 155 |
private def line_infos(physical_lines: Iterator[Int]): Map[Text.Offset, Chunk] = |
156 |
{ |
|
157 |
val painter = text_area.getPainter |
|
158 |
val font = painter.getFont |
|
159 |
val font_context = painter.getFontRenderContext |
|
160 |
||
161 |
// see org.gjt.sp.jedit.textarea.TextArea.propertiesChanged |
|
162 |
// see org.gjt.sp.jedit.textarea.TextArea.setMaxLineLength |
|
163 |
val margin = |
|
164 |
if (buffer.getStringProperty("wrap") != "soft") 0.0f |
|
165 |
else { |
|
166 |
val max = buffer.getIntegerProperty("maxLineLen", 0) |
|
167 |
if (max > 0) font.getStringBounds(" " * max, font_context).getWidth.toInt |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
168 |
else painter.getWidth - char_width() * 3 |
43382 | 169 |
}.toFloat |
170 |
||
171 |
val out = new ArrayList[Chunk] |
|
172 |
val handler = new DisplayTokenHandler |
|
173 |
||
174 |
var result = Map[Text.Offset, Chunk]() |
|
175 |
for (line <- physical_lines) { |
|
176 |
out.clear |
|
177 |
handler.init(painter.getStyles, font_context, painter, out, margin) |
|
178 |
buffer.markTokens(line, handler) |
|
179 |
||
180 |
val line_start = buffer.getLineStartOffset(line) |
|
181 |
for (i <- 0 until out.size) { |
|
182 |
val chunk = out.get(i) |
|
183 |
result += (line_start + chunk.offset -> chunk) |
|
184 |
} |
|
185 |
} |
|
186 |
result |
|
187 |
} |
|
188 |
||
43448
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
189 |
private def paint_chunk_list( |
43505 | 190 |
gfx: Graphics2D, line_start: Text.Offset, head: Chunk, x: Float, y: Float): Float = |
43382 | 191 |
{ |
192 |
val clip_rect = gfx.getClipBounds |
|
43392 | 193 |
val painter = text_area.getPainter |
194 |
val font_context = painter.getFontRenderContext |
|
43382 | 195 |
|
196 |
var w = 0.0f |
|
197 |
var chunk = head |
|
198 |
while (chunk != null) { |
|
43505 | 199 |
val chunk_offset = line_start + chunk.offset |
43382 | 200 |
if (x + w + chunk.width > clip_rect.x && |
43506 | 201 |
x + w < clip_rect.x + clip_rect.width && chunk.accessable) |
43382 | 202 |
{ |
43505 | 203 |
val chunk_range = Text.Range(chunk_offset, chunk_offset + chunk.length) |
44662
c8f1d943bfc5
more robust chunk painting wrt. hard tabs, when chunk.str == null;
wenzelm
parents:
44545
diff
changeset
|
204 |
val chunk_str = if (chunk.str == null) " " * chunk.length else chunk.str |
43382 | 205 |
val chunk_font = chunk.style.getFont |
206 |
val chunk_color = chunk.style.getForegroundColor |
|
207 |
||
44056
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
208 |
def string_width(s: String): Float = |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
209 |
if (s.isEmpty) 0.0f |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
210 |
else chunk_font.getStringBounds(s, font_context).getWidth.toFloat |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
211 |
|
43448
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
212 |
val caret_range = |
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
213 |
if (text_area.hasFocus) doc_view.caret_range() |
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
214 |
else Text.Range(-1) |
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
215 |
|
43426
24e2e2f0032b
more explicit treatment of ranges after revert/convert, which may well distort the overall start/end positions;
wenzelm
parents:
43419
diff
changeset
|
216 |
val markup = |
43428
b41dea5772c6
more robust treatment of partial range restriction;
wenzelm
parents:
43426
diff
changeset
|
217 |
for { |
43450 | 218 |
r1 <- painter_snapshot.select_markup(chunk_range)(Isabelle_Markup.text_color) |
219 |
r2 <- r1.try_restrict(chunk_range) |
|
220 |
} yield r2 |
|
43382 | 221 |
|
43759
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
222 |
val padded_markup = |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
223 |
if (markup.isEmpty) |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
224 |
Iterator(Text.Info(chunk_range, None)) |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
225 |
else |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
226 |
Iterator(Text.Info(Text.Range(chunk_range.start, markup.head.range.start), None)) ++ |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
227 |
markup.iterator ++ |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
228 |
Iterator(Text.Info(Text.Range(markup.last.range.stop, chunk_range.stop), None)) |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
229 |
|
43450 | 230 |
var x1 = x + w |
43382 | 231 |
gfx.setFont(chunk_font) |
43759
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
232 |
for (Text.Info(range, info) <- padded_markup if !range.is_singularity) { |
44662
c8f1d943bfc5
more robust chunk painting wrt. hard tabs, when chunk.str == null;
wenzelm
parents:
44545
diff
changeset
|
233 |
val str = chunk_str.substring(range.start - chunk_offset, range.stop - chunk_offset) |
43759
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
234 |
gfx.setColor(info.getOrElse(chunk_color)) |
43448
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
235 |
|
43759
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
236 |
range.try_restrict(caret_range) match { |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
237 |
case Some(r) if !r.is_singularity => |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
238 |
val i = r.start - range.start |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
239 |
val j = r.stop - range.start |
44056
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
240 |
val s1 = str.substring(0, i) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
241 |
val s2 = str.substring(i, j) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
242 |
val s3 = str.substring(j) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
243 |
|
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
244 |
if (!s1.isEmpty) gfx.drawString(s1, x1, y) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
245 |
|
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
246 |
val astr = new AttributedString(s2) |
43759
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
247 |
astr.addAttribute(TextAttribute.FONT, chunk_font) |
44056
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
248 |
astr.addAttribute(TextAttribute.FOREGROUND, painter.getCaretColor) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
249 |
astr.addAttribute(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
250 |
gfx.drawString(astr.getIterator, x1 + string_width(s1), y) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
251 |
|
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
252 |
if (!s3.isEmpty) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
253 |
gfx.drawString(s3, x1 + string_width(str.substring(0, j)), y) |
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
254 |
|
43759
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
255 |
case _ => |
d93a69672362
more uniform padded_markup, which is important for caret visibility despite absence of markup;
wenzelm
parents:
43506
diff
changeset
|
256 |
gfx.drawString(str, x1, y) |
43382 | 257 |
} |
44056
be825a69fc67
less ambitious use of AttributedString, for proper caret painting within \<^sup>\<foobar>;
wenzelm
parents:
43759
diff
changeset
|
258 |
x1 += string_width(str) |
43382 | 259 |
} |
260 |
} |
|
261 |
w += chunk.width |
|
262 |
chunk = chunk.next.asInstanceOf[Chunk] |
|
263 |
} |
|
264 |
w |
|
265 |
} |
|
266 |
||
43381 | 267 |
private val text_painter = new TextAreaExtension |
268 |
{ |
|
269 |
override def paintScreenLineRange(gfx: Graphics2D, |
|
270 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
|
43382 | 271 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
43381 | 272 |
{ |
43404 | 273 |
doc_view.robust_body(()) { |
43381 | 274 |
val clip = gfx.getClip |
275 |
val x0 = text_area.getHorizontalOffset |
|
43382 | 276 |
val fm = text_area.getPainter.getFontMetrics |
277 |
var y0 = y + fm.getHeight - (fm.getLeading + 1) - fm.getDescent |
|
43372
2df2144b0910
use orig_text_painter for extras outside main text (also required to update internal line infos);
wenzelm
parents:
43371
diff
changeset
|
278 |
|
43382 | 279 |
val infos = line_infos(physical_lines.iterator.filter(i => i != -1)) |
43381 | 280 |
for (i <- 0 until physical_lines.length) { |
281 |
if (physical_lines(i) != -1) { |
|
43392 | 282 |
val x1 = |
283 |
infos.get(start(i)) match { |
|
284 |
case None => x0 |
|
285 |
case Some(chunk) => |
|
286 |
gfx.clipRect(x0, y + line_height * i, Integer.MAX_VALUE, line_height) |
|
43448
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43435
diff
changeset
|
287 |
val w = paint_chunk_list(gfx, start(i), chunk, x0, y0).toInt |
43392 | 288 |
x0 + w.toInt |
289 |
} |
|
290 |
gfx.clipRect(x1, 0, Integer.MAX_VALUE, Integer.MAX_VALUE) |
|
291 |
orig_text_painter.paintValidLine(gfx, |
|
292 |
first_line + i, physical_lines(i), start(i), end(i), y + line_height * i) |
|
293 |
gfx.setClip(clip) |
|
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
294 |
} |
43381 | 295 |
y0 += line_height |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
296 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
297 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
298 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
299 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
300 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
301 |
|
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
302 |
/* foreground */ |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
303 |
|
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
304 |
private val foreground_painter = new TextAreaExtension |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
305 |
{ |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
306 |
override def paintScreenLineRange(gfx: Graphics2D, |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
307 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
308 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
309 |
{ |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
310 |
doc_view.robust_body(()) { |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
311 |
val snapshot = painter_snapshot |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
312 |
|
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
313 |
for (i <- 0 until physical_lines.length) { |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
314 |
if (physical_lines(i) != -1) { |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
315 |
val line_range = doc_view.proper_line_range(start(i), end(i)) |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
316 |
|
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
317 |
// foreground color |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
318 |
for { |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
319 |
Text.Info(range, Some(color)) <- |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
320 |
snapshot.select_markup(line_range)(Isabelle_Markup.foreground).iterator |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
321 |
r <- Isabelle.gfx_range(text_area, range) |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
322 |
} { |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
323 |
gfx.setColor(color) |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
324 |
gfx.fillRect(r.x, y + i * line_height, r.length, line_height) |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
325 |
} |
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44056
diff
changeset
|
326 |
|
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
327 |
// highlighted range -- potentially from other snapshot |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
328 |
doc_view.highlight_range match { |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
329 |
case Some((range, color)) if line_range.overlaps(range) => |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
330 |
Isabelle.gfx_range(text_area, line_range.restrict(range)) match { |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
331 |
case None => |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
332 |
case Some(r) => |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
333 |
gfx.setColor(color) |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
334 |
gfx.fillRect(r.x, y + i * line_height, r.length, line_height) |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
335 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
336 |
case _ => |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
337 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
338 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
339 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
340 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
341 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
342 |
} |
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
343 |
|
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
344 |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
345 |
/* caret -- outside of text range */ |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
346 |
|
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
347 |
private class Caret_Painter(before: Boolean) extends TextAreaExtension |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
348 |
{ |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
349 |
override def paintValidLine(gfx: Graphics2D, |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
350 |
screen_line: Int, physical_line: Int, start: Int, end: Int, y: Int) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
351 |
{ |
43404 | 352 |
doc_view.robust_body(()) { |
353 |
if (before) gfx.clipRect(0, 0, 0, 0) |
|
354 |
else gfx.setClip(painter_clip) |
|
355 |
} |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
356 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
357 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
358 |
|
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
359 |
private val before_caret_painter1 = new Caret_Painter(true) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
360 |
private val after_caret_painter1 = new Caret_Painter(false) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
361 |
private val before_caret_painter2 = new Caret_Painter(true) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
362 |
private val after_caret_painter2 = new Caret_Painter(false) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
363 |
|
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
364 |
private val caret_painter = new TextAreaExtension |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
365 |
{ |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
366 |
override def paintValidLine(gfx: Graphics2D, |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
367 |
screen_line: Int, physical_line: Int, start: Int, end: Int, y: Int) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
368 |
{ |
43404 | 369 |
doc_view.robust_body(()) { |
43398
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
370 |
if (text_area.hasFocus) { |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
371 |
val caret = text_area.getCaretPosition |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
372 |
if (start <= caret && caret == end - 1) { |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
373 |
val painter = text_area.getPainter |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
374 |
val fm = painter.getFontMetrics |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
375 |
|
43398
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
376 |
val offset = caret - text_area.getLineStartOffset(physical_line) |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
377 |
val x = text_area.offsetToXY(physical_line, offset).x |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
378 |
gfx.setColor(painter.getCaretColor) |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
379 |
gfx.drawRect(x, y, char_width() - 1, fm.getHeight - 1) |
c3e2a361b418
more robust painter_body wrt. EBP races and spurious exceptions (which causes jEdit to remove the extension);
wenzelm
parents:
43396
diff
changeset
|
380 |
} |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
381 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
382 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
383 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
384 |
} |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
385 |
|
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
386 |
|
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
387 |
/* activation */ |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
388 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
389 |
def activate() |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
390 |
{ |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
391 |
val painter = text_area.getPainter |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
392 |
painter.addExtension(TextAreaPainter.LOWEST_LAYER, set_state) |
43381 | 393 |
painter.addExtension(TextAreaPainter.LINE_BACKGROUND_LAYER + 1, background_painter) |
394 |
painter.addExtension(TextAreaPainter.TEXT_LAYER, text_painter) |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
395 |
painter.addExtension(TextAreaPainter.CARET_LAYER - 1, before_caret_painter1) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
396 |
painter.addExtension(TextAreaPainter.CARET_LAYER + 1, after_caret_painter1) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
397 |
painter.addExtension(TextAreaPainter.BLOCK_CARET_LAYER - 1, before_caret_painter2) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
398 |
painter.addExtension(TextAreaPainter.BLOCK_CARET_LAYER + 1, after_caret_painter2) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
399 |
painter.addExtension(TextAreaPainter.BLOCK_CARET_LAYER + 2, caret_painter) |
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
400 |
painter.addExtension(500, foreground_painter) |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
401 |
painter.addExtension(TextAreaPainter.HIGHEST_LAYER, reset_state) |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
402 |
painter.removeExtension(orig_text_painter) |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
403 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
404 |
|
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
405 |
def deactivate() |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
406 |
{ |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
407 |
val painter = text_area.getPainter |
43396 | 408 |
painter.addExtension(TextAreaPainter.TEXT_LAYER, orig_text_painter) |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
409 |
painter.removeExtension(reset_state) |
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
410 |
painter.removeExtension(foreground_painter) |
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
411 |
painter.removeExtension(caret_painter) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
412 |
painter.removeExtension(after_caret_painter2) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
413 |
painter.removeExtension(before_caret_painter2) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
414 |
painter.removeExtension(after_caret_painter1) |
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
415 |
painter.removeExtension(before_caret_painter1) |
43381 | 416 |
painter.removeExtension(text_painter) |
417 |
painter.removeExtension(background_painter) |
|
43393
f4141da52e92
more precise caret painting, working around existing painter (which is reinstalled by jEdit occasionally);
wenzelm
parents:
43392
diff
changeset
|
418 |
painter.removeExtension(set_state) |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
419 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
420 |
} |
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
diff
changeset
|
421 |