author | wenzelm |
Sun, 04 Mar 2012 19:16:09 +0100 | |
changeset 46814 | d68ea01d5084 |
parent 46812 | 3d55ef732cd7 |
child 46815 | 6bccb1dc9bc3 |
permissions | -rw-r--r-- |
43282
5d294220ca43
moved sources -- eliminated Netbeans artifact of jedit package directory;
wenzelm
parents:
42839
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/document_view.scala |
36760 | 2 |
Author: Fabian Immler, TU Munich |
3 |
Author: Makarius |
|
4 |
||
5 |
Document view connected to jEdit text area. |
|
6 |
*/ |
|
34408 | 7 |
|
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
8 |
package isabelle.jedit |
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
9 |
|
34760 | 10 |
|
36015 | 11 |
import isabelle._ |
12 |
||
44379 | 13 |
import scala.collection.mutable |
45460 | 14 |
import scala.collection.immutable.SortedMap |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
15 |
import scala.actors.Actor._ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
16 |
|
43520
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
wenzelm
parents:
43510
diff
changeset
|
17 |
import java.lang.System |
45744
0ad063afa3d6
caret_range based on BreakIterator, which handles combined unicode characters as well;
wenzelm
parents:
45665
diff
changeset
|
18 |
import java.text.BreakIterator |
46572 | 19 |
import java.awt.{Color, Graphics2D, Point} |
20 |
import java.awt.event.{MouseMotionAdapter, MouseEvent, |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
21 |
FocusAdapter, FocusEvent, WindowEvent, WindowAdapter} |
46572 | 22 |
import javax.swing.{Popup, PopupFactory, SwingUtilities, BorderFactory} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
23 |
import javax.swing.event.{CaretListener, CaretEvent} |
34734 | 24 |
|
43404 | 25 |
import org.gjt.sp.util.Log |
26 |
||
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
27 |
import org.gjt.sp.jedit.{jEdit, OperatingSystem, Debug} |
34709 | 28 |
import org.gjt.sp.jedit.gui.RolloverButton |
39176
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
29 |
import org.gjt.sp.jedit.options.GutterOptionPane |
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44379
diff
changeset
|
30 |
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea, TextAreaExtension, TextAreaPainter, |
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44379
diff
changeset
|
31 |
ScrollListener} |
43369
4c86b3405010
separate isabelle.jedit.Text_Painter, which actually replaces the original TextAreaPainter$PaintText instance;
wenzelm
parents:
43282
diff
changeset
|
32 |
import org.gjt.sp.jedit.syntax.{SyntaxStyle} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
33 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
34 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
35 |
object Document_View |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
36 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
37 |
/* document view of text area */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
38 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
39 |
private val key = new Object |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
40 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
41 |
def apply(text_area: JEditTextArea): Option[Document_View] = |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
42 |
{ |
38223 | 43 |
Swing_Thread.require() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
44 |
text_area.getClientProperty(key) match { |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
45 |
case doc_view: Document_View => Some(doc_view) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
46 |
case _ => None |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
47 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
48 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
49 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
50 |
def exit(text_area: JEditTextArea) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
51 |
{ |
38223 | 52 |
Swing_Thread.require() |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34784
diff
changeset
|
53 |
apply(text_area) match { |
39636 | 54 |
case None => |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
55 |
case Some(doc_view) => |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
56 |
doc_view.deactivate() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
57 |
text_area.putClientProperty(key, null) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
58 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
59 |
} |
43397 | 60 |
|
61 |
def init(model: Document_Model, text_area: JEditTextArea): Document_View = |
|
62 |
{ |
|
63 |
exit(text_area) |
|
64 |
val doc_view = new Document_View(model, text_area) |
|
65 |
text_area.putClientProperty(key, doc_view) |
|
66 |
doc_view.activate() |
|
67 |
doc_view |
|
68 |
} |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
69 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
70 |
|
34733 | 71 |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43369
diff
changeset
|
72 |
class Document_View(val model: Document_Model, val text_area: JEditTextArea) |
34654 | 73 |
{ |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
74 |
private val session = model.session |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
75 |
|
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
76 |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
77 |
/* robust extension body */ |
43404 | 78 |
|
79 |
def robust_body[A](default: A)(body: => A): A = |
|
43417
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
80 |
{ |
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
81 |
try { |
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
82 |
Swing_Thread.require() |
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
83 |
if (model.buffer == text_area.getBuffer) body |
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
84 |
else { |
43650 | 85 |
Log.log(Log.ERROR, this, ERROR("Inconsistent document model")) |
43417
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
86 |
default |
43404 | 87 |
} |
88 |
} |
|
43417
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
89 |
catch { case t: Throwable => Log.log(Log.ERROR, this, t); default } |
83be997a11d6
more precise imitation of original TextAreaPainter: no locking;
wenzelm
parents:
43414
diff
changeset
|
90 |
} |
43404 | 91 |
|
92 |
||
44378 | 93 |
/* visible text range */ |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
94 |
|
46812
3d55ef732cd7
clarified special eol treatment and moved to gfx_range -- enables error messages at end of input, e.g. "prop PROP";
wenzelm
parents:
46740
diff
changeset
|
95 |
// FIXME remove!? |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
96 |
def proper_line_range(start: Text.Offset, end: Text.Offset): Text.Range = |
46812
3d55ef732cd7
clarified special eol treatment and moved to gfx_range -- enables error messages at end of input, e.g. "prop PROP";
wenzelm
parents:
46740
diff
changeset
|
97 |
Text.Range(start, end min model.buffer.getLength) |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
98 |
|
46583 | 99 |
def visible_range(): Option[Text.Range] = |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
100 |
{ |
46583 | 101 |
val n = text_area.getVisibleLines |
102 |
if (n > 0) { |
|
103 |
val start = text_area.getScreenLineStartOffset(0) |
|
104 |
val raw_end = text_area.getScreenLineEndOffset(n - 1) |
|
105 |
Some(proper_line_range(start, if (raw_end >= 0) raw_end else model.buffer.getLength)) |
|
106 |
} |
|
107 |
else None |
|
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
108 |
} |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
109 |
|
44378 | 110 |
def invalidate_range(range: Text.Range) |
39132 | 111 |
{ |
112 |
text_area.invalidateLineRange( |
|
113 |
model.buffer.getLineOfOffset(range.start), |
|
114 |
model.buffer.getLineOfOffset(range.stop)) |
|
115 |
} |
|
116 |
||
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
117 |
|
44379 | 118 |
/* perspective */ |
119 |
||
120 |
def perspective(): Text.Perspective = |
|
121 |
{ |
|
122 |
Swing_Thread.require() |
|
44776
47e8c8daccae
added "check" button: adhoc change to full buffer perspective;
wenzelm
parents:
44615
diff
changeset
|
123 |
val buffer_range = model.buffer_range() |
44473 | 124 |
Text.Perspective( |
44379 | 125 |
for { |
126 |
i <- 0 until text_area.getVisibleLines |
|
127 |
val start = text_area.getScreenLineStartOffset(i) |
|
128 |
val stop = text_area.getScreenLineEndOffset(i) |
|
129 |
if start >= 0 && stop >= 0 |
|
44583
022509c908fb
restrict perspective to actual buffer_range, to avoid spurious edits due to faulty last_exec_offset (NB: jEdit screenlines may be silently extended by trailing newline);
wenzelm
parents:
44473
diff
changeset
|
130 |
val range <- buffer_range.try_restrict(Text.Range(start, stop)) |
022509c908fb
restrict perspective to actual buffer_range, to avoid spurious edits due to faulty last_exec_offset (NB: jEdit screenlines may be silently extended by trailing newline);
wenzelm
parents:
44473
diff
changeset
|
131 |
if !range.is_singularity |
44379 | 132 |
} |
44583
022509c908fb
restrict perspective to actual buffer_range, to avoid spurious edits due to faulty last_exec_offset (NB: jEdit screenlines may be silently extended by trailing newline);
wenzelm
parents:
44473
diff
changeset
|
133 |
yield range) |
44379 | 134 |
} |
135 |
||
44437
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
136 |
private def update_perspective = new TextAreaExtension |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
137 |
{ |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
138 |
override def paintScreenLineRange(gfx: Graphics2D, |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
139 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
140 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
141 |
{ |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
142 |
model.update_perspective() |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
143 |
} |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
144 |
} |
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
145 |
|
44379 | 146 |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
147 |
/* snapshot */ |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
148 |
|
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
149 |
// owned by Swing thread |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
150 |
@volatile private var was_outdated = false |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
151 |
@volatile private var was_updated = false |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
152 |
|
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
153 |
def update_snapshot(): Document.Snapshot = |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
154 |
{ |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
155 |
Swing_Thread.require() |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
156 |
val snapshot = model.snapshot() |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
157 |
was_updated = was_outdated && !snapshot.is_outdated |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
158 |
was_outdated = was_outdated || snapshot.is_outdated |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
159 |
snapshot |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
160 |
} |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
161 |
|
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
162 |
def flush_snapshot(): (Boolean, Document.Snapshot) = |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
163 |
{ |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
164 |
Swing_Thread.require() |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
165 |
val snapshot = update_snapshot() |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
166 |
val updated = was_updated |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
167 |
if (updated) { was_outdated = false; was_updated = false } |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
168 |
(updated, snapshot) |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
169 |
} |
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
170 |
|
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
171 |
|
39740 | 172 |
/* HTML popups */ |
173 |
||
174 |
private var html_popup: Option[Popup] = None |
|
34834
df9af932e418
slightly more uniform/robust handling of visible document;
wenzelm
parents:
34832
diff
changeset
|
175 |
|
39740 | 176 |
private def exit_popup() { html_popup.map(_.hide) } |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
177 |
|
39740 | 178 |
private val html_panel = |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43650
diff
changeset
|
179 |
new HTML_Panel(Isabelle.font_family(), scala.math.round(Isabelle.font_size())) |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
180 |
html_panel.setBorder(BorderFactory.createLineBorder(Color.black)) |
38884
9ec5f6010d6e
Document_View: repaint overview for any command change of this node (again);
wenzelm
parents:
38883
diff
changeset
|
181 |
|
39740 | 182 |
private def html_panel_resize() |
183 |
{ |
|
184 |
Swing_Thread.now { |
|
185 |
html_panel.resize(Isabelle.font_family(), scala.math.round(Isabelle.font_size())) |
|
186 |
} |
|
187 |
} |
|
38884
9ec5f6010d6e
Document_View: repaint overview for any command change of this node (again);
wenzelm
parents:
38883
diff
changeset
|
188 |
|
39740 | 189 |
private def init_popup(snapshot: Document.Snapshot, x: Int, y: Int) |
190 |
{ |
|
191 |
exit_popup() |
|
40154 | 192 |
/* FIXME broken |
39740 | 193 |
val offset = text_area.xyToOffset(x, y) |
194 |
val p = new Point(x, y); SwingUtilities.convertPointToScreen(p, text_area.getPainter) |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
195 |
|
39740 | 196 |
// FIXME snapshot.cumulate |
45665
129db1416717
renamed Isabelle_Markup to Isabelle_Rendering to emphasize its meaning and make room for Pure Isabelle_Markup module;
wenzelm
parents:
45467
diff
changeset
|
197 |
snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Rendering.popup) match { |
39740 | 198 |
case Text.Info(_, Some(msg)) #:: _ => |
199 |
val popup = PopupFactory.getSharedInstance().getPopup(text_area, html_panel, p.x, p.y + 60) |
|
200 |
html_panel.render_sync(List(msg)) |
|
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
201 |
Thread.sleep(10) // FIXME !? |
39740 | 202 |
popup.show |
203 |
html_popup = Some(popup) |
|
204 |
case _ => |
|
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
205 |
} |
40154 | 206 |
*/ |
34678 | 207 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
208 |
|
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
209 |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
210 |
/* subexpression highlighting */ |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
211 |
|
46205 | 212 |
@volatile private var _highlight_range: Option[Text.Info[Color]] = None |
213 |
def highlight_range(): Option[Text.Info[Color]] = _highlight_range |
|
39740 | 214 |
|
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
215 |
private var control: Boolean = false |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
216 |
|
39740 | 217 |
private def exit_control() |
218 |
{ |
|
219 |
exit_popup() |
|
43381 | 220 |
_highlight_range = None |
39740 | 221 |
} |
222 |
||
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
223 |
private val focus_listener = new FocusAdapter { |
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
224 |
override def focusLost(e: FocusEvent) { |
43381 | 225 |
_highlight_range = None // FIXME exit_control !? |
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
226 |
} |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
227 |
} |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
228 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
229 |
private val window_listener = new WindowAdapter { |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
230 |
override def windowIconified(e: WindowEvent) { exit_control() } |
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
231 |
override def windowDeactivated(e: WindowEvent) { exit_control() } |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
232 |
} |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
233 |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
234 |
private val mouse_motion_listener = new MouseMotionAdapter { |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
235 |
override def mouseMoved(e: MouseEvent) { |
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
236 |
control = if (OperatingSystem.isMacOS()) e.isMetaDown else e.isControlDown |
39740 | 237 |
val x = e.getX() |
238 |
val y = e.getY() |
|
239 |
||
240 |
if (!model.buffer.isLoaded) exit_control() |
|
39132 | 241 |
else |
242 |
Isabelle.swing_buffer_lock(model.buffer) { |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
243 |
val snapshot = update_snapshot() |
39740 | 244 |
|
245 |
if (control) init_popup(snapshot, x, y) |
|
246 |
||
46205 | 247 |
for (Text.Info(range, _) <- _highlight_range) invalidate_range(range) |
248 |
_highlight_range = |
|
249 |
if (control) { |
|
250 |
val offset = text_area.xyToOffset(x, y) |
|
251 |
Isabelle_Rendering.subexp(snapshot, Text.Range(offset, offset + 1)) |
|
252 |
} |
|
253 |
else None |
|
254 |
for (Text.Info(range, _) <- _highlight_range) invalidate_range(range) |
|
39132 | 255 |
} |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
256 |
} |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
257 |
} |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
258 |
|
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
259 |
|
43381 | 260 |
/* text area painting */ |
39044 | 261 |
|
43381 | 262 |
private val text_area_painter = new Text_Area_Painter(this) |
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
263 |
|
43381 | 264 |
private val tooltip_painter = new TextAreaExtension |
265 |
{ |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
266 |
override def getToolTipText(x: Int, y: Int): String = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
267 |
{ |
43404 | 268 |
robust_body(null: String) { |
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
269 |
val snapshot = update_snapshot() |
38845
a9e37daf5bd0
added Document.Snapshot.select_markup, which includes command iteration, range conversion etc.;
wenzelm
parents:
38843
diff
changeset
|
270 |
val offset = text_area.xyToOffset(x, y) |
45460 | 271 |
val range = Text.Range(offset, offset + 1) |
46178
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
272 |
val tip = |
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
273 |
if (control) Isabelle_Rendering.tooltip(snapshot, range) |
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
274 |
else Isabelle_Rendering.tooltip_message(snapshot, range) |
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
275 |
tip.map(Isabelle.tooltip(_)) getOrElse null |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
276 |
} |
34734 | 277 |
} |
34678 | 278 |
} |
34513 | 279 |
|
42825 | 280 |
private val gutter_painter = new TextAreaExtension |
39175 | 281 |
{ |
282 |
override def paintScreenLineRange(gfx: Graphics2D, |
|
283 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
|
284 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
|
285 |
{ |
|
43404 | 286 |
robust_body(()) { |
287 |
val gutter = text_area.getGutter |
|
288 |
val width = GutterOptionPane.getSelectionAreaWidth |
|
289 |
val border_width = jEdit.getIntegerProperty("view.gutter.borderWidth", 3) |
|
290 |
val FOLD_MARKER_SIZE = 12 |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
291 |
|
43404 | 292 |
if (gutter.isSelectionAreaEnabled && !gutter.isExpanded && width >= 12 && line_height >= 12) { |
293 |
Isabelle.swing_buffer_lock(model.buffer) { |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
294 |
val snapshot = update_snapshot() |
43404 | 295 |
for (i <- 0 until physical_lines.length) { |
296 |
if (physical_lines(i) != -1) { |
|
297 |
val line_range = proper_line_range(start(i), end(i)) |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
298 |
|
43404 | 299 |
// gutter icons |
46178
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
300 |
Isabelle_Rendering.gutter_message(snapshot, line_range) match { |
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
301 |
case Some(icon) => |
46227
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46205
diff
changeset
|
302 |
val x0 = (FOLD_MARKER_SIZE + width - border_width - icon.getIconWidth) max 10 |
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46205
diff
changeset
|
303 |
val y0 = y + i * line_height + (((line_height - icon.getIconHeight) / 2) max 0) |
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46205
diff
changeset
|
304 |
icon.paintIcon(gutter, gfx, x0, y0) |
46178
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
45744
diff
changeset
|
305 |
case None => |
43404 | 306 |
} |
39175 | 307 |
} |
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
} |
|
312 |
} |
|
313 |
} |
|
314 |
||
315 |
||
43448
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43419
diff
changeset
|
316 |
/* caret range */ |
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43419
diff
changeset
|
317 |
|
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43419
diff
changeset
|
318 |
def caret_range(): Text.Range = |
46229
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
319 |
Isabelle.buffer_lock(model.buffer) { |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
320 |
def text(i: Text.Offset): Char = model.buffer.getText(i, 1).charAt(0) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
321 |
val caret = text_area.getCaretPosition |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
322 |
try { |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
323 |
val c = text(caret) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
324 |
if (Character.isHighSurrogate(c) && Character.isLowSurrogate(text(caret + 1))) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
325 |
Text.Range(caret, caret + 2) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
326 |
else if (Character.isLowSurrogate(c) && Character.isHighSurrogate(text(caret - 1))) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
327 |
Text.Range(caret - 1, caret + 1) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
328 |
else Text.Range(caret, caret + 1) |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
329 |
} |
d8286601e7df
back to more basic caret_range (reverting 0ad063afa3d6) -- BreakIterator crashes due to non-zero text.offset when deleting the first character of the buffer;
wenzelm
parents:
46227
diff
changeset
|
330 |
catch { case _: ArrayIndexOutOfBoundsException => Text.Range(caret, caret + 1) } |
43448
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43419
diff
changeset
|
331 |
} |
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43419
diff
changeset
|
332 |
|
90aec5043461
more robust caret painting wrt. surrogate characters;
wenzelm
parents:
43419
diff
changeset
|
333 |
|
37129 | 334 |
/* caret handling */ |
34810 | 335 |
|
37849 | 336 |
def selected_command(): Option[Command] = |
38223 | 337 |
{ |
338 |
Swing_Thread.require() |
|
46814
d68ea01d5084
removed obsolete proper_command_at (cf. 03a2dc9e0624);
wenzelm
parents:
46812
diff
changeset
|
339 |
update_snapshot().node.command_at(text_area.getCaretPosition).map(_._1) |
38223 | 340 |
} |
34810 | 341 |
|
46740
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
342 |
private val delay_caret_update = |
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
343 |
Swing_Thread.delay_last(session.input_delay) { |
44805 | 344 |
session.caret_focus.event(Session.Caret_Focus) |
34810 | 345 |
} |
46740
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
346 |
|
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
347 |
private val caret_listener = new CaretListener { |
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
348 |
override def caretUpdate(e: CaretEvent) { delay_caret_update(true) } |
34810 | 349 |
} |
350 |
||
351 |
||
46572 | 352 |
/* text status overview left of scrollbar */ |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
353 |
|
46572 | 354 |
private val overview = new Text_Overview(this) |
355 |
{ |
|
46571
edcccd7a9eee
overview.delay_repaint: avoid wasting GUI cycles via update_delay;
wenzelm
parents:
46550
diff
changeset
|
356 |
val delay_repaint = |
edcccd7a9eee
overview.delay_repaint: avoid wasting GUI cycles via update_delay;
wenzelm
parents:
46550
diff
changeset
|
357 |
Swing_Thread.delay_first(Isabelle.session.update_delay) { repaint() } |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
358 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
359 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
360 |
|
39740 | 361 |
/* main actor */ |
362 |
||
363 |
private val main_actor = actor { |
|
364 |
loop { |
|
365 |
react { |
|
44608 | 366 |
case changed: Session.Commands_Changed => |
39740 | 367 |
val buffer = model.buffer |
368 |
Isabelle.swing_buffer_lock(buffer) { |
|
43419
6ed49c52d463
flush snapshot on falling edge of is_outdated -- recover effect of former buffer.propertiesChanged on text area (cf. f0770743b7ec);
wenzelm
parents:
43417
diff
changeset
|
369 |
val (updated, snapshot) = flush_snapshot() |
39740 | 370 |
|
44608 | 371 |
if (updated || |
44615 | 372 |
(changed.nodes.contains(model.name) && |
44608 | 373 |
changed.commands.exists(snapshot.node.commands.contains))) |
46740
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
374 |
overview.delay_repaint(true) |
39740 | 375 |
|
46583 | 376 |
visible_range() match { |
377 |
case None => |
|
378 |
case Some(visible) => |
|
379 |
if (updated) invalidate_range(visible) |
|
380 |
else { |
|
381 |
val visible_cmds = |
|
382 |
snapshot.node.command_range(snapshot.revert(visible)).map(_._1) |
|
383 |
if (visible_cmds.exists(changed.commands)) { |
|
384 |
for { |
|
385 |
line <- 0 until text_area.getVisibleLines |
|
386 |
val start = text_area.getScreenLineStartOffset(line) if start >= 0 |
|
387 |
val end = text_area.getScreenLineEndOffset(line) if end >= 0 |
|
388 |
val range = proper_line_range(start, end) |
|
389 |
val line_cmds = snapshot.node.command_range(snapshot.revert(range)).map(_._1) |
|
390 |
if line_cmds.exists(changed.commands) |
|
391 |
} text_area.invalidateScreenLineRange(line, line) |
|
392 |
} |
|
393 |
} |
|
39740 | 394 |
} |
395 |
} |
|
396 |
||
397 |
case Session.Global_Settings => html_panel_resize() |
|
398 |
||
399 |
case bad => System.err.println("command_change_actor: ignoring bad message " + bad) |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
||
404 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
405 |
/* activation */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
406 |
|
34808
e462572536e9
eliminated global Session.document_0 -- did not work due to hardwired id;
wenzelm
parents:
34806
diff
changeset
|
407 |
private def activate() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
408 |
{ |
42825 | 409 |
val painter = text_area.getPainter |
44437
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
410 |
painter.addExtension(TextAreaPainter.LOWEST_LAYER, update_perspective) |
43387
a59ae768249e
recovered tooltip Entity content (odd effect of layer change!? cf. 806878ae2219);
wenzelm
parents:
43381
diff
changeset
|
411 |
painter.addExtension(TextAreaPainter.LINE_BACKGROUND_LAYER + 1, tooltip_painter) |
43381 | 412 |
text_area_painter.activate() |
42825 | 413 |
text_area.getGutter.addExtension(gutter_painter) |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
414 |
text_area.addFocusListener(focus_listener) |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
415 |
text_area.getView.addWindowListener(window_listener) |
42825 | 416 |
painter.addMouseMotionListener(mouse_motion_listener) |
34810 | 417 |
text_area.addCaretListener(caret_listener) |
418 |
text_area.addLeftOfScrollBar(overview) |
|
39740 | 419 |
session.commands_changed += main_actor |
420 |
session.global_settings += main_actor |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
421 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
422 |
|
34808
e462572536e9
eliminated global Session.document_0 -- did not work due to hardwired id;
wenzelm
parents:
34806
diff
changeset
|
423 |
private def deactivate() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
424 |
{ |
42825 | 425 |
val painter = text_area.getPainter |
39740 | 426 |
session.commands_changed -= main_actor |
427 |
session.global_settings -= main_actor |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
428 |
text_area.removeFocusListener(focus_listener) |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
429 |
text_area.getView.removeWindowListener(window_listener) |
42825 | 430 |
painter.removeMouseMotionListener(mouse_motion_listener) |
46740
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
431 |
text_area.removeCaretListener(caret_listener); delay_caret_update(false) |
852baa599351
explicitly revoke delay, to avoid spurious timer events after deactivation of related components;
wenzelm
parents:
46583
diff
changeset
|
432 |
text_area.removeLeftOfScrollBar(overview); overview.delay_repaint(false) |
42825 | 433 |
text_area.getGutter.removeExtension(gutter_painter) |
43381 | 434 |
text_area_painter.deactivate() |
435 |
painter.removeExtension(tooltip_painter) |
|
44437
bebe15799192
more reliable update_perspective handler based on actual text visibility (e.g. on startup or when resizing without scrolling);
wenzelm
parents:
44436
diff
changeset
|
436 |
painter.removeExtension(update_perspective) |
39740 | 437 |
exit_popup() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
438 |
} |
42825 | 439 |
} |