author | wenzelm |
Sat, 07 Aug 2010 16:44:52 +0200 | |
changeset 38224 | 809578d7f6af |
parent 38223 | 2a368e8e0a80 |
child 38225 | ee0f46c45c19 |
permissions | -rw-r--r-- |
36760 | 1 |
/* Title: Tools/jEdit/src/jedit/document_model.scala |
2 |
Author: Fabian Immler, TU Munich |
|
3 |
Author: Makarius |
|
4 |
||
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
5 |
Document model connected to jEdit buffer -- single node in theory graph. |
36760 | 6 |
*/ |
34407 | 7 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
8 |
package isabelle.jedit |
34760 | 9 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
10 |
|
36015 | 11 |
import isabelle._ |
12 |
||
34703 | 13 |
import scala.actors.Actor, Actor._ |
34693 | 14 |
import scala.collection.mutable |
34446 | 15 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
16 |
import org.gjt.sp.jedit.Buffer |
34783
cb95d6bbf5f1
clarified BufferListener: use adapter, listen to contentInserted instead of preContentInserted;
wenzelm
parents:
34778
diff
changeset
|
17 |
import org.gjt.sp.jedit.buffer.{BufferAdapter, BufferListener, JEditBuffer} |
38158 | 18 |
import org.gjt.sp.jedit.syntax.{SyntaxStyle, Token, TokenMarker, TokenHandler, ParserRuleSet} |
19 |
import org.gjt.sp.jedit.textarea.TextArea |
|
20 |
||
21 |
import java.awt.font.TextAttribute |
|
22 |
import javax.swing.text.Segment; |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
23 |
|
34760 | 24 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
25 |
object Document_Model |
34588 | 26 |
{ |
38158 | 27 |
object Token_Markup |
28 |
{ |
|
29 |
/* extended token styles */ |
|
30 |
||
31 |
private val plain_range: Int = Token.ID_COUNT |
|
32 |
private val full_range: Int = 3 * plain_range |
|
33 |
private def check_range(i: Int) { require(0 <= i && i < plain_range) } |
|
34 |
||
35 |
def subscript(i: Byte): Byte = { check_range(i); (i + plain_range).toByte } |
|
36 |
def superscript(i: Byte): Byte = { check_range(i); (i + 2 * plain_range).toByte } |
|
37 |
||
38 |
private def script_style(style: SyntaxStyle, i: Int): SyntaxStyle = |
|
39 |
{ |
|
40 |
import scala.collection.JavaConversions._ |
|
41 |
val script_font = |
|
42 |
style.getFont.deriveFont(Map(TextAttribute.SUPERSCRIPT -> new java.lang.Integer(i))) |
|
43 |
new SyntaxStyle(style.getForegroundColor, style.getBackgroundColor, script_font) |
|
44 |
} |
|
45 |
||
46 |
def extend_styles(styles: Array[SyntaxStyle]): Array[SyntaxStyle] = |
|
47 |
{ |
|
48 |
val new_styles = new Array[SyntaxStyle](full_range) |
|
49 |
for (i <- 0 until plain_range) { |
|
50 |
val style = styles(i) |
|
51 |
new_styles(i) = style |
|
52 |
new_styles(subscript(i.toByte)) = script_style(style, -1) |
|
53 |
new_styles(superscript(i.toByte)) = script_style(style, 1) |
|
54 |
} |
|
55 |
new_styles |
|
56 |
} |
|
57 |
||
58 |
||
59 |
/* line context */ |
|
60 |
||
61 |
private val rule_set = new ParserRuleSet("isabelle", "MAIN") |
|
62 |
class LineContext(val line: Int, prev: LineContext) |
|
63 |
extends TokenMarker.LineContext(rule_set, prev) |
|
64 |
||
65 |
||
66 |
/* mapping to jEdit token types */ |
|
67 |
// TODO: as properties or CSS style sheet |
|
68 |
||
69 |
val command_style: Map[String, Byte] = |
|
70 |
{ |
|
71 |
import Token._ |
|
72 |
Map[String, Byte]( |
|
73 |
Keyword.THY_END -> KEYWORD2, |
|
74 |
Keyword.THY_SCRIPT -> LABEL, |
|
75 |
Keyword.PRF_SCRIPT -> LABEL, |
|
76 |
Keyword.PRF_ASM -> KEYWORD3, |
|
77 |
Keyword.PRF_ASM_GOAL -> KEYWORD3 |
|
78 |
).withDefaultValue(KEYWORD1) |
|
79 |
} |
|
80 |
||
81 |
val token_style: Map[String, Byte] = |
|
82 |
{ |
|
83 |
import Token._ |
|
84 |
Map[String, Byte]( |
|
85 |
// logical entities |
|
86 |
Markup.TCLASS -> NULL, |
|
87 |
Markup.TYCON -> NULL, |
|
88 |
Markup.FIXED_DECL -> FUNCTION, |
|
89 |
Markup.FIXED -> NULL, |
|
90 |
Markup.CONST_DECL -> FUNCTION, |
|
91 |
Markup.CONST -> NULL, |
|
92 |
Markup.FACT_DECL -> FUNCTION, |
|
93 |
Markup.FACT -> NULL, |
|
94 |
Markup.DYNAMIC_FACT -> LABEL, |
|
95 |
Markup.LOCAL_FACT_DECL -> FUNCTION, |
|
96 |
Markup.LOCAL_FACT -> NULL, |
|
97 |
// inner syntax |
|
98 |
Markup.TFREE -> NULL, |
|
99 |
Markup.FREE -> NULL, |
|
100 |
Markup.TVAR -> NULL, |
|
101 |
Markup.SKOLEM -> NULL, |
|
102 |
Markup.BOUND -> NULL, |
|
103 |
Markup.VAR -> NULL, |
|
104 |
Markup.NUM -> DIGIT, |
|
105 |
Markup.FLOAT -> DIGIT, |
|
106 |
Markup.XNUM -> DIGIT, |
|
107 |
Markup.XSTR -> LITERAL4, |
|
108 |
Markup.LITERAL -> OPERATOR, |
|
109 |
Markup.INNER_COMMENT -> COMMENT1, |
|
110 |
Markup.SORT -> NULL, |
|
111 |
Markup.TYP -> NULL, |
|
112 |
Markup.TERM -> NULL, |
|
113 |
Markup.PROP -> NULL, |
|
114 |
Markup.ATTRIBUTE -> NULL, |
|
115 |
Markup.METHOD -> NULL, |
|
116 |
// ML syntax |
|
117 |
Markup.ML_KEYWORD -> KEYWORD1, |
|
118 |
Markup.ML_DELIMITER -> OPERATOR, |
|
119 |
Markup.ML_IDENT -> NULL, |
|
120 |
Markup.ML_TVAR -> NULL, |
|
121 |
Markup.ML_NUMERAL -> DIGIT, |
|
122 |
Markup.ML_CHAR -> LITERAL1, |
|
123 |
Markup.ML_STRING -> LITERAL1, |
|
124 |
Markup.ML_COMMENT -> COMMENT1, |
|
125 |
Markup.ML_MALFORMED -> INVALID, |
|
126 |
// embedded source text |
|
127 |
Markup.ML_SOURCE -> COMMENT3, |
|
128 |
Markup.DOC_SOURCE -> COMMENT3, |
|
129 |
Markup.ANTIQ -> COMMENT4, |
|
130 |
Markup.ML_ANTIQ -> COMMENT4, |
|
131 |
Markup.DOC_ANTIQ -> COMMENT4, |
|
132 |
// outer syntax |
|
133 |
Markup.KEYWORD -> KEYWORD2, |
|
134 |
Markup.OPERATOR -> OPERATOR, |
|
135 |
Markup.COMMAND -> KEYWORD1, |
|
136 |
Markup.IDENT -> NULL, |
|
137 |
Markup.VERBATIM -> COMMENT3, |
|
138 |
Markup.COMMENT -> COMMENT1, |
|
139 |
Markup.CONTROL -> COMMENT3, |
|
140 |
Markup.MALFORMED -> INVALID, |
|
141 |
Markup.STRING -> LITERAL3, |
|
142 |
Markup.ALTSTRING -> LITERAL1 |
|
143 |
).withDefaultValue(NULL) |
|
144 |
} |
|
145 |
} |
|
146 |
||
147 |
||
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
148 |
/* document model of buffer */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
149 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
150 |
private val key = "isabelle.document_model" |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
151 |
|
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
152 |
def init(session: Session, buffer: Buffer, thy_name: String): Document_Model = |
34716 | 153 |
{ |
38223 | 154 |
Swing_Thread.require() |
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
155 |
val model = new Document_Model(session, buffer, thy_name) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
156 |
buffer.setProperty(key, model) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
157 |
model.activate() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
158 |
model |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
159 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
160 |
|
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34784
diff
changeset
|
161 |
def apply(buffer: Buffer): Option[Document_Model] = |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
162 |
{ |
38223 | 163 |
Swing_Thread.require() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
164 |
buffer.getProperty(key) match { |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
165 |
case model: Document_Model => Some(model) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
166 |
case _ => None |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
167 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
168 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
169 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
170 |
def exit(buffer: Buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
171 |
{ |
38223 | 172 |
Swing_Thread.require() |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34784
diff
changeset
|
173 |
apply(buffer) match { |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
174 |
case None => error("No document model for buffer: " + buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
175 |
case Some(model) => |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
176 |
model.deactivate() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
177 |
buffer.unsetProperty(key) |
34653 | 178 |
} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
179 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
180 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
181 |
|
38151 | 182 |
|
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
183 |
class Document_Model(val session: Session, val buffer: Buffer, val thy_name: String) |
34588 | 184 |
{ |
37555
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
185 |
/* visible line end */ |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
186 |
|
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
187 |
// simplify slightly odd result of TextArea.getLineEndOffset |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
188 |
// NB: jEdit already normalizes \r\n and \r to \n |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
189 |
def visible_line_end(start: Int, end: Int): Int = |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
190 |
{ |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
191 |
val end1 = end - 1 |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
192 |
if (start <= end1 && end1 < buffer.getLength && |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
193 |
buffer.getSegment(end1, 1).charAt(0) == '\n') end1 |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
194 |
else end |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
195 |
} |
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
196 |
|
d57d0f581d38
simplified text_area_painter, with more precise treatment of visible line end;
wenzelm
parents:
37132
diff
changeset
|
197 |
|
38224 | 198 |
/* pending text edits */ |
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
199 |
|
38224 | 200 |
object pending_edits // owned by Swing thread |
201 |
{ |
|
202 |
private val pending = new mutable.ListBuffer[Text_Edit] |
|
203 |
def snapshot(): List[Text_Edit] = pending.toList |
|
204 |
||
205 |
private val delay_flush = Swing_Thread.delay_last(session.input_delay) { |
|
206 |
if (!pending.isEmpty) session.edit_document(List((thy_name, flush()))) |
|
207 |
} |
|
38152
eab0d1c2e46e
Change.Snapshot: include from_current/to_current here, with precomputed changes;
wenzelm
parents:
38151
diff
changeset
|
208 |
|
38224 | 209 |
def flush(): List[Text_Edit] = |
210 |
{ |
|
211 |
Swing_Thread.require() |
|
212 |
val edits = snapshot() |
|
213 |
pending.clear |
|
214 |
edits |
|
215 |
} |
|
216 |
||
217 |
def +=(edit: Text_Edit) |
|
218 |
{ |
|
219 |
Swing_Thread.require() |
|
220 |
pending += edit |
|
221 |
delay_flush() |
|
38222
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
222 |
} |
dac5fa0ac971
replaced individual Document_Model history by all-inclusive one in Session;
wenzelm
parents:
38158
diff
changeset
|
223 |
} |
38152
eab0d1c2e46e
Change.Snapshot: include from_current/to_current here, with precomputed changes;
wenzelm
parents:
38151
diff
changeset
|
224 |
|
eab0d1c2e46e
Change.Snapshot: include from_current/to_current here, with precomputed changes;
wenzelm
parents:
38151
diff
changeset
|
225 |
|
eab0d1c2e46e
Change.Snapshot: include from_current/to_current here, with precomputed changes;
wenzelm
parents:
38151
diff
changeset
|
226 |
/* snapshot */ |
34731
c0cb6bd10eec
keep BufferListener and TextAreaExtension private;
wenzelm
parents:
34724
diff
changeset
|
227 |
|
38223 | 228 |
def snapshot(): Change.Snapshot = { |
229 |
Swing_Thread.require() |
|
38224 | 230 |
session.current_change().snapshot(thy_name, pending_edits.snapshot()) |
38223 | 231 |
} |
34828 | 232 |
|
233 |
||
234 |
/* buffer listener */ |
|
235 |
||
236 |
private val buffer_listener: BufferListener = new BufferAdapter |
|
237 |
{ |
|
238 |
override def contentInserted(buffer: JEditBuffer, |
|
239 |
start_line: Int, offset: Int, num_lines: Int, length: Int) |
|
240 |
{ |
|
38224 | 241 |
pending_edits += new Text_Edit(true, offset, buffer.getText(offset, length)) |
34828 | 242 |
} |
243 |
||
244 |
override def preContentRemoved(buffer: JEditBuffer, |
|
245 |
start_line: Int, start: Int, num_lines: Int, removed_length: Int) |
|
246 |
{ |
|
38224 | 247 |
pending_edits += new Text_Edit(false, start, buffer.getText(start, removed_length)) |
34828 | 248 |
} |
249 |
} |
|
250 |
||
251 |
||
38158 | 252 |
/* semantic token marker */ |
253 |
||
254 |
private val token_marker = new TokenMarker |
|
255 |
{ |
|
256 |
override def markTokens(prev: TokenMarker.LineContext, |
|
257 |
handler: TokenHandler, line_segment: Segment): TokenMarker.LineContext = |
|
258 |
{ |
|
259 |
val previous = prev.asInstanceOf[Document_Model.Token_Markup.LineContext] |
|
260 |
val line = if (prev == null) 0 else previous.line + 1 |
|
261 |
val context = new Document_Model.Token_Markup.LineContext(line, previous) |
|
262 |
val start = buffer.getLineStartOffset(line) |
|
263 |
val stop = start + line_segment.count |
|
264 |
||
38223 | 265 |
val snapshot = Swing_Thread.now { Document_Model.this.snapshot() } |
38158 | 266 |
|
267 |
/* FIXME |
|
268 |
for (text_area <- Isabelle.jedit_text_areas(buffer) |
|
269 |
if Document_View(text_area).isDefined) |
|
270 |
Document_View(text_area).get.set_styles() |
|
271 |
*/ |
|
272 |
||
273 |
def handle_token(style: Byte, offset: Int, length: Int) = |
|
274 |
handler.handleToken(line_segment, style, offset, length, context) |
|
34680 | 275 |
|
38158 | 276 |
var next_x = start |
277 |
for { |
|
278 |
(command, command_start) <- |
|
279 |
snapshot.node.command_range(snapshot.revert(start), snapshot.revert(stop)) |
|
280 |
markup <- snapshot.document.current_state(command).highlight.flatten |
|
281 |
val abs_start = snapshot.convert(command_start + markup.start) |
|
282 |
val abs_stop = snapshot.convert(command_start + markup.stop) |
|
283 |
if (abs_stop > start) |
|
284 |
if (abs_start < stop) |
|
285 |
val token_start = (abs_start - start) max 0 |
|
286 |
val token_length = |
|
287 |
(abs_stop - abs_start) - |
|
288 |
((start - abs_start) max 0) - |
|
289 |
((abs_stop - stop) max 0) |
|
290 |
} |
|
291 |
{ |
|
292 |
val token_type = |
|
293 |
markup.info match { |
|
294 |
case Command.HighlightInfo(Markup.COMMAND, Some(kind)) => |
|
295 |
Document_Model.Token_Markup.command_style(kind) |
|
296 |
case Command.HighlightInfo(kind, _) => |
|
297 |
Document_Model.Token_Markup.token_style(kind) |
|
298 |
case _ => Token.NULL |
|
299 |
} |
|
300 |
if (start + token_start > next_x) |
|
301 |
handle_token(Token.COMMENT1, next_x - start, start + token_start - next_x) |
|
302 |
handle_token(token_type, token_start, token_length) |
|
303 |
next_x = start + token_start + token_length |
|
304 |
} |
|
305 |
if (next_x < stop) |
|
306 |
handle_token(Token.COMMENT1, next_x - start, stop - next_x) |
|
307 |
||
308 |
handle_token(Token.END, line_segment.count, 0) |
|
309 |
handler.setLineContext(context) |
|
310 |
context |
|
311 |
} |
|
312 |
} |
|
313 |
||
314 |
||
315 |
/* activation */ |
|
37557
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
316 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
317 |
def activate() |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
318 |
{ |
37557
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
319 |
buffer.setTokenMarker(token_marker) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
320 |
buffer.addBufferListener(buffer_listener) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
321 |
buffer.propertiesChanged() |
38224 | 322 |
pending_edits += new Text_Edit(true, 0, buffer.getText(0, buffer.getLength)) |
34680 | 323 |
} |
324 |
||
37557
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
325 |
def refresh() |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
326 |
{ |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
327 |
buffer.setTokenMarker(token_marker) |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
328 |
} |
1ae272fd4082
refresh Isabelle token marker after buffer properties changed, e.g. when fold mode is switched;
wenzelm
parents:
37555
diff
changeset
|
329 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
330 |
def deactivate() |
34680 | 331 |
{ |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
332 |
buffer.setTokenMarker(buffer.getMode.getTokenMarker) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34783
diff
changeset
|
333 |
buffer.removeBufferListener(buffer_listener) |
34680 | 334 |
} |
34447 | 335 |
} |