author | wenzelm |
Wed, 08 Jun 2011 17:42:07 +0200 | |
changeset 43282 | 5d294220ca43 |
parent 42839 | src/Tools/jEdit/src/jedit/document_view.scala@19df8385f38d |
child 43369 | 4c86b3405010 |
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 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
13 |
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
|
14 |
|
39740 | 15 |
import java.awt.{BorderLayout, Graphics, Color, Dimension, Graphics2D, Point} |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
16 |
import java.awt.event.{MouseAdapter, MouseMotionAdapter, MouseEvent, |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
17 |
FocusAdapter, FocusEvent, WindowEvent, WindowAdapter} |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
18 |
import javax.swing.{JPanel, ToolTipManager, 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
|
19 |
import javax.swing.event.{CaretListener, CaretEvent} |
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
20 |
import java.util.ArrayList |
34734 | 21 |
|
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
22 |
import org.gjt.sp.jedit.{jEdit, OperatingSystem, Debug} |
34709 | 23 |
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
|
24 |
import org.gjt.sp.jedit.options.GutterOptionPane |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
25 |
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea, TextAreaExtension, TextAreaPainter} |
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
26 |
import org.gjt.sp.jedit.syntax.{SyntaxStyle, DisplayTokenHandler, Chunk, Token} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
27 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
28 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
29 |
object Document_View |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
30 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
31 |
/* 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
|
32 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
33 |
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
|
34 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
35 |
def init(model: Document_Model, text_area: JEditTextArea): Document_View = |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
36 |
{ |
38223 | 37 |
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
|
38 |
val doc_view = new Document_View(model, text_area) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
39 |
text_area.putClientProperty(key, doc_view) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
40 |
doc_view.activate() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
41 |
doc_view |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
42 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
43 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
44 |
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
|
45 |
{ |
38223 | 46 |
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
|
47 |
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
|
48 |
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
|
49 |
case _ => None |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
50 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
51 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
52 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
53 |
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
|
54 |
{ |
38223 | 55 |
Swing_Thread.require() |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34784
diff
changeset
|
56 |
apply(text_area) match { |
39636 | 57 |
case None => |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
58 |
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
|
59 |
doc_view.deactivate() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
60 |
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
|
61 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
62 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
63 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
64 |
|
34733 | 65 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
66 |
class Document_View(val model: Document_Model, text_area: JEditTextArea) |
34654 | 67 |
{ |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
68 |
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
|
69 |
|
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
70 |
|
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
71 |
/** token handling **/ |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
72 |
|
37241
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
73 |
/* extended token styles */ |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
74 |
|
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
75 |
private var styles: Array[SyntaxStyle] = null // owned by Swing thread |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
76 |
|
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
77 |
def extend_styles() |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
78 |
{ |
38223 | 79 |
Swing_Thread.require() |
38158 | 80 |
styles = Document_Model.Token_Markup.extend_styles(text_area.getPainter.getStyles) |
37241
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
81 |
} |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
82 |
extend_styles() |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
83 |
|
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
84 |
def set_styles() |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
85 |
{ |
38223 | 86 |
Swing_Thread.require() |
37241
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
87 |
text_area.getPainter.setStyles(styles) |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
88 |
} |
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
89 |
|
04d2521e79b0
basic support for sub/superscript token markup -- NB: need to maintain extended token types eagerly, since jEdit occasionally reinstalls a style array that is too short;
wenzelm
parents:
37201
diff
changeset
|
90 |
|
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
91 |
/* wrap_margin -- cf. org.gjt.sp.jedit.textarea.TextArea.propertiesChanged */ |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
92 |
|
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
93 |
def wrap_margin(): Int = |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
94 |
{ |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
95 |
val buffer = text_area.getBuffer |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
96 |
val painter = text_area.getPainter |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
97 |
val font = painter.getFont |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
98 |
val font_context = painter.getFontRenderContext |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
99 |
|
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
100 |
val soft_wrap = buffer.getStringProperty("wrap") == "soft" |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
101 |
val max = buffer.getIntegerProperty("maxLineLen", 0) |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
102 |
|
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
103 |
if (max > 0) font.getStringBounds(" " * max, font_context).getWidth.toInt |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
104 |
else if (soft_wrap) |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
105 |
painter.getWidth - (font.getStringBounds(" ", font_context).getWidth.round.toInt) * 3 |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
106 |
else 0 |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
107 |
} |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
108 |
|
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
109 |
|
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
110 |
/* chunks */ |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
111 |
|
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
112 |
def line_chunks(physical_lines: Set[Int]): Map[Text.Offset, Chunk] = |
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
113 |
{ |
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
114 |
import scala.collection.JavaConversions._ |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
115 |
|
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
116 |
val buffer = text_area.getBuffer |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
117 |
val painter = text_area.getPainter |
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
118 |
val margin = wrap_margin().toFloat |
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
119 |
|
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
120 |
val out = new ArrayList[Chunk] |
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
121 |
val handler = new DisplayTokenHandler |
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
122 |
|
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
123 |
var result = Map[Text.Offset, Chunk]() |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
124 |
for (line <- physical_lines) { |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
125 |
out.clear |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
126 |
handler.init(painter.getStyles, painter.getFontRenderContext, painter, out, margin) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
127 |
buffer.markTokens(line, handler) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
128 |
|
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
129 |
val line_start = buffer.getLineStartOffset(line) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
130 |
for (chunk <- handler.getChunkList.iterator) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
131 |
result += (line_start + chunk.offset -> chunk) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
132 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
133 |
result |
42838
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
134 |
} |
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
135 |
|
15727655bee2
some support for token/chunk handling, imitating jEdit internals;
wenzelm
parents:
42825
diff
changeset
|
136 |
|
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
137 |
/* visible line ranges */ |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
138 |
|
38883
0998a635684a
refined proper_line_range (again), to make text_area_extension work with soft wwrap;
wenzelm
parents:
38881
diff
changeset
|
139 |
// simplify slightly odd result of TextArea.getScreenLineEndOffset etc. |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
140 |
// NB: jEdit already normalizes \r\n and \r to \n |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
141 |
def proper_line_range(start: Text.Offset, end: Text.Offset): Text.Range = |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
142 |
{ |
38883
0998a635684a
refined proper_line_range (again), to make text_area_extension work with soft wwrap;
wenzelm
parents:
38881
diff
changeset
|
143 |
val stop = if (start < end) end - 1 else end min model.buffer.getLength |
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
144 |
Text.Range(start, stop) |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
145 |
} |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
146 |
|
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
147 |
def screen_lines_range(): Text.Range = |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
148 |
{ |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
149 |
val start = text_area.getScreenLineStartOffset(0) |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
150 |
val raw_end = text_area.getScreenLineEndOffset(text_area.getVisibleLines - 1 max 0) |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
151 |
proper_line_range(start, if (raw_end >= 0) raw_end else model.buffer.getLength) |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
152 |
} |
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
153 |
|
39132 | 154 |
def invalidate_line_range(range: Text.Range) |
155 |
{ |
|
156 |
text_area.invalidateLineRange( |
|
157 |
model.buffer.getLineOfOffset(range.start), |
|
158 |
model.buffer.getLineOfOffset(range.stop)) |
|
159 |
} |
|
160 |
||
38881
c8123e77acc5
tuned commands_changed_actor: more precise/efficient handling of visible screen lines;
wenzelm
parents:
38880
diff
changeset
|
161 |
|
39740 | 162 |
/* HTML popups */ |
163 |
||
164 |
private var html_popup: Option[Popup] = None |
|
34834
df9af932e418
slightly more uniform/robust handling of visible document;
wenzelm
parents:
34832
diff
changeset
|
165 |
|
39740 | 166 |
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
|
167 |
|
39740 | 168 |
private val html_panel = |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
169 |
new HTML_Panel(Isabelle.system, Isabelle.font_family(), scala.math.round(Isabelle.font_size())) |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
170 |
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
|
171 |
|
39740 | 172 |
private def html_panel_resize() |
173 |
{ |
|
174 |
Swing_Thread.now { |
|
175 |
html_panel.resize(Isabelle.font_family(), scala.math.round(Isabelle.font_size())) |
|
176 |
} |
|
177 |
} |
|
38884
9ec5f6010d6e
Document_View: repaint overview for any command change of this node (again);
wenzelm
parents:
38883
diff
changeset
|
178 |
|
39740 | 179 |
private def init_popup(snapshot: Document.Snapshot, x: Int, y: Int) |
180 |
{ |
|
181 |
exit_popup() |
|
40154 | 182 |
/* FIXME broken |
39740 | 183 |
val offset = text_area.xyToOffset(x, y) |
184 |
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
|
185 |
|
39740 | 186 |
// FIXME snapshot.cumulate |
187 |
snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Markup.popup) match { |
|
188 |
case Text.Info(_, Some(msg)) #:: _ => |
|
189 |
val popup = PopupFactory.getSharedInstance().getPopup(text_area, html_panel, p.x, p.y + 60) |
|
190 |
html_panel.render_sync(List(msg)) |
|
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
191 |
Thread.sleep(10) // FIXME !? |
39740 | 192 |
popup.show |
193 |
html_popup = Some(popup) |
|
194 |
case _ => |
|
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
195 |
} |
40154 | 196 |
*/ |
34678 | 197 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
198 |
|
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
199 |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
200 |
/* subexpression highlighting */ |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
201 |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
202 |
private def subexp_range(snapshot: Document.Snapshot, x: Int, y: Int) |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
203 |
: Option[(Text.Range, Color)] = |
39132 | 204 |
{ |
205 |
val offset = text_area.xyToOffset(x, y) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
206 |
snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Markup.subexp) match { |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
207 |
case Text.Info(_, Some((range, color))) #:: _ => Some((snapshot.convert(range), color)) |
39177
0468964aec11
simplified Markup_Tree.select: Stream instead of Iterator (again), explicit Option instead of default;
wenzelm
parents:
39176
diff
changeset
|
208 |
case _ => None |
0468964aec11
simplified Markup_Tree.select: Stream instead of Iterator (again), explicit Option instead of default;
wenzelm
parents:
39176
diff
changeset
|
209 |
} |
39132 | 210 |
} |
211 |
||
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
212 |
private var highlight_range: Option[(Text.Range, Color)] = None |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
213 |
|
39740 | 214 |
|
215 |
/* CONTROL-mouse management */ |
|
216 |
||
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
217 |
private var control: Boolean = false |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
218 |
|
39740 | 219 |
private def exit_control() |
220 |
{ |
|
221 |
exit_popup() |
|
222 |
highlight_range = None |
|
223 |
} |
|
224 |
||
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
225 |
private val focus_listener = new FocusAdapter { |
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
226 |
override def focusLost(e: FocusEvent) { |
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
227 |
highlight_range = None // FIXME exit_control !? |
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
228 |
} |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
229 |
} |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
230 |
|
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
231 |
private val window_listener = new WindowAdapter { |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
232 |
override def windowIconified(e: WindowEvent) { exit_control() } |
39742
b59e064e32c3
CONTROL-mouse management: handle windowDeactivated as well;
wenzelm
parents:
39741
diff
changeset
|
233 |
override def windowDeactivated(e: WindowEvent) { exit_control() } |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
234 |
} |
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
235 |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
236 |
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
|
237 |
override def mouseMoved(e: MouseEvent) { |
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
238 |
control = if (OperatingSystem.isMacOS()) e.isMetaDown else e.isControlDown |
39740 | 239 |
val x = e.getX() |
240 |
val y = e.getY() |
|
241 |
||
242 |
if (!model.buffer.isLoaded) exit_control() |
|
39132 | 243 |
else |
244 |
Isabelle.swing_buffer_lock(model.buffer) { |
|
39740 | 245 |
val snapshot = model.snapshot |
246 |
||
247 |
if (control) init_popup(snapshot, x, y) |
|
248 |
||
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
249 |
highlight_range map { case (range, _) => invalidate_line_range(range) } |
39740 | 250 |
highlight_range = if (control) subexp_range(snapshot, x, y) else None |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
39177
diff
changeset
|
251 |
highlight_range map { case (range, _) => invalidate_line_range(range) } |
39132 | 252 |
} |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
253 |
} |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
254 |
} |
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
255 |
|
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
256 |
|
42825 | 257 |
/* TextArea painters */ |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
258 |
|
42825 | 259 |
private val background_painter = new TextAreaExtension |
34678 | 260 |
{ |
37685
305c326db33b
more efficient document model/view -- avoid repeated iteration over commands from start, prefer bulk operations;
wenzelm
parents:
37555
diff
changeset
|
261 |
override def paintScreenLineRange(gfx: Graphics2D, |
305c326db33b
more efficient document model/view -- avoid repeated iteration over commands from start, prefer bulk operations;
wenzelm
parents:
37555
diff
changeset
|
262 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
38886 | 263 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
264 |
{ |
38843 | 265 |
Isabelle.swing_buffer_lock(model.buffer) { |
266 |
val snapshot = model.snapshot() |
|
39044 | 267 |
val ascent = text_area.getPainter.getFontMetrics.getAscent |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
268 |
|
39182 | 269 |
for (i <- 0 until physical_lines.length) { |
270 |
if (physical_lines(i) != -1) { |
|
271 |
val line_range = proper_line_range(start(i), end(i)) |
|
39044 | 272 |
|
39182 | 273 |
// background color: status |
274 |
val cmds = snapshot.node.command_range(snapshot.revert(line_range)) |
|
275 |
for { |
|
276 |
(command, command_start) <- cmds if !command.is_ignored |
|
277 |
val range = line_range.restrict(snapshot.convert(command.range + command_start)) |
|
278 |
r <- Isabelle.gfx_range(text_area, range) |
|
279 |
color <- Isabelle_Markup.status_color(snapshot, command) |
|
280 |
} { |
|
281 |
gfx.setColor(color) |
|
282 |
gfx.fillRect(r.x, y + i * line_height, r.length, line_height) |
|
283 |
} |
|
39044 | 284 |
|
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
285 |
// background color (1): markup |
39182 | 286 |
for { |
287 |
Text.Info(range, Some(color)) <- |
|
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
288 |
snapshot.select_markup(line_range)(Isabelle_Markup.background1).iterator |
39182 | 289 |
r <- Isabelle.gfx_range(text_area, range) |
290 |
} { |
|
291 |
gfx.setColor(color) |
|
292 |
gfx.fillRect(r.x, y + i * line_height, r.length, line_height) |
|
293 |
} |
|
39171
525a13b9ac74
highlight bad range of nested error (here from inner parsing);
wenzelm
parents:
39169
diff
changeset
|
294 |
|
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
295 |
// background color (2): markup |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
296 |
for { |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
297 |
Text.Info(range, Some(color)) <- |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
298 |
snapshot.select_markup(line_range)(Isabelle_Markup.background2).iterator |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
299 |
r <- Isabelle.gfx_range(text_area, range) |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
300 |
} { |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
301 |
gfx.setColor(color) |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
302 |
gfx.fillRect(r.x + 2, y + i * line_height + 2, r.length - 4, line_height - 4) |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
303 |
} |
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
304 |
|
39182 | 305 |
// sub-expression highlighting -- potentially from other snapshot |
306 |
highlight_range match { |
|
307 |
case Some((range, color)) if line_range.overlaps(range) => |
|
308 |
Isabelle.gfx_range(text_area, line_range.restrict(range)) match { |
|
309 |
case None => |
|
310 |
case Some(r) => |
|
311 |
gfx.setColor(color) |
|
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39690
diff
changeset
|
312 |
gfx.drawRect(r.x, y + i * line_height, r.length - 1, line_height - 1) |
39182 | 313 |
} |
314 |
case _ => |
|
315 |
} |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
316 |
|
39182 | 317 |
// squiggly underline |
318 |
for { |
|
319 |
Text.Info(range, Some(color)) <- |
|
320 |
snapshot.select_markup(line_range)(Isabelle_Markup.message).iterator |
|
321 |
r <- Isabelle.gfx_range(text_area, range) |
|
322 |
} { |
|
323 |
gfx.setColor(color) |
|
324 |
val x0 = (r.x / 2) * 2 |
|
325 |
val y0 = r.y + ascent + 1 |
|
326 |
for (x1 <- Range(x0, x0 + r.length, 2)) { |
|
327 |
val y1 = if (x1 % 4 < 2) y0 else y0 + 1 |
|
328 |
gfx.drawLine(x1, y1, x1 + 1, y1) |
|
38843 | 329 |
} |
330 |
} |
|
38223 | 331 |
} |
332 |
} |
|
333 |
} |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
334 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
335 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
336 |
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
|
337 |
{ |
38845
a9e37daf5bd0
added Document.Snapshot.select_markup, which includes command iteration, range conversion etc.;
wenzelm
parents:
38843
diff
changeset
|
338 |
Isabelle.swing_buffer_lock(model.buffer) { |
a9e37daf5bd0
added Document.Snapshot.select_markup, which includes command iteration, range conversion etc.;
wenzelm
parents:
38843
diff
changeset
|
339 |
val snapshot = model.snapshot() |
a9e37daf5bd0
added Document.Snapshot.select_markup, which includes command iteration, range conversion etc.;
wenzelm
parents:
38843
diff
changeset
|
340 |
val offset = text_area.xyToOffset(x, y) |
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
341 |
if (control) { |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
342 |
snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Markup.tooltip) match |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
343 |
{ |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
344 |
case Text.Info(_, Some(text)) #:: _ => Isabelle.tooltip(text) |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
345 |
case _ => null |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
346 |
} |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
347 |
} |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
348 |
else { |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
349 |
// FIXME snapshot.cumulate |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
350 |
snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Markup.popup) match |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
351 |
{ |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
352 |
case Text.Info(_, Some(text)) #:: _ => Isabelle.tooltip(text) |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
353 |
case _ => null |
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
40154
diff
changeset
|
354 |
} |
39174
b95cf3892483
Document_View: some markup for main inner syntax categories;
wenzelm
parents:
39171
diff
changeset
|
355 |
} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
356 |
} |
34734 | 357 |
} |
34678 | 358 |
} |
34513 | 359 |
|
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
360 |
var use_text_painter = false |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
361 |
|
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
362 |
private val text_painter = new TextAreaExtension |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
363 |
{ |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
364 |
override def paintScreenLineRange(gfx: Graphics2D, |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
365 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
366 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
367 |
{ |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
368 |
if (use_text_painter) { |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
369 |
Isabelle.swing_buffer_lock(model.buffer) { |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
370 |
val painter = text_area.getPainter |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
371 |
val fm = painter.getFontMetrics |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
372 |
|
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
373 |
val all_chunks = line_chunks(Set[Int]() ++ physical_lines.iterator.filter(i => i != -1)) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
374 |
|
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
375 |
val x0 = text_area.getHorizontalOffset |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
376 |
var y0 = y + fm.getHeight - (fm.getLeading + 1) - fm.getDescent |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
377 |
for (i <- 0 until physical_lines.length) { |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
378 |
if (physical_lines(i) != -1) { |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
379 |
all_chunks.get(start(i)) match { |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
380 |
case Some(chunk) => |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
381 |
Chunk.paintChunkList(chunk, gfx, x0, y0, !Debug.DISABLE_GLYPH_VECTOR) |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
382 |
case None => |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
383 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
384 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
385 |
y0 += line_height |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
386 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
387 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
388 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
389 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
390 |
} |
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
391 |
|
42825 | 392 |
private val gutter_painter = new TextAreaExtension |
39175 | 393 |
{ |
394 |
override def paintScreenLineRange(gfx: Graphics2D, |
|
395 |
first_line: Int, last_line: Int, physical_lines: Array[Int], |
|
396 |
start: Array[Int], end: Array[Int], y: Int, line_height: Int) |
|
397 |
{ |
|
39176
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
398 |
val gutter = text_area.getGutter |
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
399 |
val width = GutterOptionPane.getSelectionAreaWidth |
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
400 |
val border_width = jEdit.getIntegerProperty("view.gutter.borderWidth", 3) |
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
401 |
val FOLD_MARKER_SIZE = 12 |
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
402 |
|
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
403 |
if (gutter.isSelectionAreaEnabled && !gutter.isExpanded && width >= 12 && line_height >= 12) { |
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
404 |
Isabelle.swing_buffer_lock(model.buffer) { |
b8fdd3ae8815
Document_View: more precise painting of gutter icons, only if line selection area is sufficiently large;
wenzelm
parents:
39175
diff
changeset
|
405 |
val snapshot = model.snapshot() |
39175 | 406 |
for (i <- 0 until physical_lines.length) { |
407 |
if (physical_lines(i) != -1) { |
|
408 |
val line_range = proper_line_range(start(i), end(i)) |
|
409 |
||
410 |
// gutter icons |
|
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
411 |
val icons = |
39740 | 412 |
(for (Text.Info(_, Some(icon)) <- // FIXME snapshot.cumulate |
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
413 |
snapshot.select_markup(line_range)(Isabelle_Markup.gutter_message).iterator) |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
414 |
yield icon).toList.sortWith(_ >= _) |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
415 |
icons match { |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
416 |
case icon :: _ => |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
417 |
val icn = icon.icon |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
418 |
val x0 = (FOLD_MARKER_SIZE + width - border_width - icn.getIconWidth) max 10 |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
419 |
val y0 = y + i * line_height + (((line_height - icn.getIconHeight) / 2) max 0) |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
420 |
icn.paintIcon(gutter, gfx, x0, y0) |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39178
diff
changeset
|
421 |
case Nil => |
39175 | 422 |
} |
423 |
} |
|
424 |
} |
|
425 |
} |
|
426 |
} |
|
427 |
} |
|
428 |
} |
|
429 |
||
430 |
||
37129 | 431 |
/* caret handling */ |
34810 | 432 |
|
37849 | 433 |
def selected_command(): Option[Command] = |
38223 | 434 |
{ |
435 |
Swing_Thread.require() |
|
38151 | 436 |
model.snapshot().node.proper_command_at(text_area.getCaretPosition) |
38223 | 437 |
} |
34810 | 438 |
|
37849 | 439 |
private val caret_listener = new CaretListener { |
440 |
private val delay = Swing_Thread.delay_last(session.input_delay) { |
|
441 |
session.perspective.event(Session.Perspective) |
|
34810 | 442 |
} |
37849 | 443 |
override def caretUpdate(e: CaretEvent) { delay() } |
34810 | 444 |
} |
445 |
||
446 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
447 |
/* overview of command status left of scrollbar */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
448 |
|
34834
df9af932e418
slightly more uniform/robust handling of visible document;
wenzelm
parents:
34832
diff
changeset
|
449 |
private val overview = new JPanel(new BorderLayout) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
450 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
451 |
private val WIDTH = 10 |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
452 |
private val HEIGHT = 2 |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
453 |
|
34806 | 454 |
setPreferredSize(new Dimension(WIDTH, 0)) |
455 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
456 |
setRequestFocusEnabled(false) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
457 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
458 |
addMouseListener(new MouseAdapter { |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
459 |
override def mousePressed(event: MouseEvent) { |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
460 |
val line = y_to_line(event.getY) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
461 |
if (line >= 0 && line < text_area.getLineCount) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
462 |
text_area.setCaretPosition(text_area.getLineStartOffset(line)) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
463 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
464 |
}) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
465 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
466 |
override def addNotify() { |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
467 |
super.addNotify() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
468 |
ToolTipManager.sharedInstance.registerComponent(this) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
469 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
470 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
471 |
override def removeNotify() { |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
472 |
ToolTipManager.sharedInstance.unregisterComponent(this) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
473 |
super.removeNotify |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
474 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
475 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
476 |
override def paintComponent(gfx: Graphics) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
477 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
478 |
super.paintComponent(gfx) |
38640 | 479 |
Swing_Thread.assert() |
39737
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
480 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
481 |
val buffer = model.buffer |
38843 | 482 |
Isabelle.buffer_lock(buffer) { |
38640 | 483 |
val snapshot = model.snapshot() |
39737
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
484 |
|
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
485 |
def line_range(command: Command, start: Text.Offset): Option[(Int, Int)] = |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
486 |
{ |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
487 |
try { |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
488 |
val line1 = buffer.getLineOfOffset(snapshot.convert(start)) |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
489 |
val line2 = buffer.getLineOfOffset(snapshot.convert(start + command.length)) + 1 |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
490 |
Some((line1, line2)) |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
491 |
} |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
492 |
catch { case e: ArrayIndexOutOfBoundsException => None } |
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
493 |
} |
39182 | 494 |
for { |
495 |
(command, start) <- snapshot.node.command_starts |
|
496 |
if !command.is_ignored |
|
39737
8c312f064223
more defensive overview.paintComponent: avoid potential crash due to buffer change while painting;
wenzelm
parents:
39700
diff
changeset
|
497 |
(line1, line2) <- line_range(command, start) |
39182 | 498 |
val y = line_to_y(line1) |
499 |
val height = HEIGHT * (line2 - line1) |
|
500 |
color <- Isabelle_Markup.overview_color(snapshot, command) |
|
501 |
} { |
|
502 |
gfx.setColor(color) |
|
503 |
gfx.fillRect(0, y, getWidth - 1, height) |
|
37188 | 504 |
} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
505 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
506 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
507 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
508 |
private def line_to_y(line: Int): Int = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
509 |
(line * getHeight) / (text_area.getBuffer.getLineCount max text_area.getVisibleLines) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
510 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
511 |
private def y_to_line(y: Int): Int = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
512 |
(y * (text_area.getBuffer.getLineCount max text_area.getVisibleLines)) / getHeight |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
513 |
} |
34403
6c812a3cb170
information on command-phase left of scrollbar (with panel)
immler@in.tum.de
parents:
diff
changeset
|
514 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
515 |
|
39740 | 516 |
/* main actor */ |
517 |
||
518 |
private val main_actor = actor { |
|
519 |
loop { |
|
520 |
react { |
|
521 |
case Session.Commands_Changed(changed) => |
|
522 |
val buffer = model.buffer |
|
523 |
Isabelle.swing_buffer_lock(buffer) { |
|
524 |
val snapshot = model.snapshot() |
|
525 |
||
526 |
if (changed.exists(snapshot.node.commands.contains)) |
|
527 |
overview.repaint() |
|
528 |
||
529 |
val visible_range = screen_lines_range() |
|
530 |
val visible_cmds = snapshot.node.command_range(snapshot.revert(visible_range)).map(_._1) |
|
531 |
if (visible_cmds.exists(changed)) { |
|
532 |
for { |
|
533 |
line <- 0 until text_area.getVisibleLines |
|
534 |
val start = text_area.getScreenLineStartOffset(line) if start >= 0 |
|
535 |
val end = text_area.getScreenLineEndOffset(line) if end >= 0 |
|
536 |
val range = proper_line_range(start, end) |
|
537 |
val line_cmds = snapshot.node.command_range(snapshot.revert(range)).map(_._1) |
|
538 |
if line_cmds.exists(changed) |
|
539 |
} text_area.invalidateScreenLineRange(line, line) |
|
540 |
||
541 |
// FIXME danger of deadlock!? |
|
542 |
// FIXME potentially slow!? |
|
543 |
model.buffer.propertiesChanged() |
|
544 |
} |
|
545 |
} |
|
546 |
||
547 |
case Session.Global_Settings => html_panel_resize() |
|
548 |
||
549 |
case bad => System.err.println("command_change_actor: ignoring bad message " + bad) |
|
550 |
} |
|
551 |
} |
|
552 |
} |
|
553 |
||
554 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
555 |
/* activation */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
556 |
|
34808
e462572536e9
eliminated global Session.document_0 -- did not work due to hardwired id;
wenzelm
parents:
34806
diff
changeset
|
557 |
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
|
558 |
{ |
42825 | 559 |
val painter = text_area.getPainter |
560 |
painter.addExtension(TextAreaPainter.LINE_BACKGROUND_LAYER + 1, background_painter) |
|
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
561 |
painter.addExtension(TextAreaPainter.TEXT_LAYER + 1, text_painter) |
42825 | 562 |
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
|
563 |
text_area.addFocusListener(focus_listener) |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
564 |
text_area.getView.addWindowListener(window_listener) |
42825 | 565 |
painter.addMouseMotionListener(mouse_motion_listener) |
34810 | 566 |
text_area.addCaretListener(caret_listener) |
567 |
text_area.addLeftOfScrollBar(overview) |
|
39740 | 568 |
session.commands_changed += main_actor |
569 |
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
|
570 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
571 |
|
34808
e462572536e9
eliminated global Session.document_0 -- did not work due to hardwired id;
wenzelm
parents:
34806
diff
changeset
|
572 |
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
|
573 |
{ |
42825 | 574 |
val painter = text_area.getPainter |
39740 | 575 |
session.commands_changed -= main_actor |
576 |
session.global_settings -= main_actor |
|
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
577 |
text_area.removeFocusListener(focus_listener) |
39741
62b91eb2d39a
CONTROL-mouse management: handle windowIconified;
wenzelm
parents:
39740
diff
changeset
|
578 |
text_area.getView.removeWindowListener(window_listener) |
42825 | 579 |
painter.removeMouseMotionListener(mouse_motion_listener) |
39131
947c62440026
basic support for subexpression highlighting (see also gatchan.jedit.hyperlinks.HyperlinkManager/HyperlinkTextAreaPainter);
wenzelm
parents:
39044
diff
changeset
|
580 |
text_area.removeCaretListener(caret_listener) |
34810 | 581 |
text_area.removeLeftOfScrollBar(overview) |
42825 | 582 |
text_area.getGutter.removeExtension(gutter_painter) |
42839
19df8385f38d
basic support for overpainting of text, imitating jEdit internals;
wenzelm
parents:
42838
diff
changeset
|
583 |
painter.removeExtension(text_painter) |
42825 | 584 |
painter.removeExtension(background_painter) |
39740 | 585 |
exit_popup() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
586 |
} |
42825 | 587 |
} |