author | wenzelm |
Tue, 08 Jun 2010 13:51:25 +0200 | |
changeset 37366 | 5c6695de35ba |
parent 37241 | 04d2521e79b0 |
child 38150 | 67fc24df3721 |
permissions | -rw-r--r-- |
36760 | 1 |
/* Title: Tools/jEdit/src/jedit/isabelle_token_marker.scala |
2 |
Author: Fabian Immler, TU Munich |
|
3 |
||
4 |
Include isabelle's command- and keyword-declarations live in jEdits |
|
5 |
syntax-highlighting. |
|
6 |
*/ |
|
34467 | 7 |
|
8 |
package isabelle.jedit |
|
9 |
||
34700 | 10 |
|
37196 | 11 |
import isabelle._ |
34467 | 12 |
|
34517 | 13 |
import org.gjt.sp.jedit.buffer.JEditBuffer |
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:
37197
diff
changeset
|
14 |
import org.gjt.sp.jedit.syntax.{Token, TokenMarker, TokenHandler, ParserRuleSet, SyntaxStyle} |
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:
37197
diff
changeset
|
15 |
import org.gjt.sp.jedit.textarea.TextArea |
34467 | 16 |
|
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:
37197
diff
changeset
|
17 |
import java.awt.Font |
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:
37197
diff
changeset
|
18 |
import java.awt.font.TextAttribute |
34517 | 19 |
import javax.swing.text.Segment; |
20 |
||
34588 | 21 |
|
34760 | 22 |
object Isabelle_Token_Marker |
34588 | 23 |
{ |
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:
37197
diff
changeset
|
24 |
/* 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:
37197
diff
changeset
|
25 |
|
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:
37197
diff
changeset
|
26 |
private val plain_range: Int = Token.ID_COUNT |
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:
37197
diff
changeset
|
27 |
private val full_range: Int = 3 * plain_range |
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:
37197
diff
changeset
|
28 |
private def check_range(i: Int) { require(0 <= i && i < plain_range) } |
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:
37197
diff
changeset
|
29 |
|
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:
37197
diff
changeset
|
30 |
def subscript(i: Byte): Byte = { check_range(i); (i + plain_range).toByte } |
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:
37197
diff
changeset
|
31 |
def superscript(i: Byte): Byte = { check_range(i); (i + 2 * plain_range).toByte } |
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:
37197
diff
changeset
|
32 |
|
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:
37197
diff
changeset
|
33 |
private def script_style(style: SyntaxStyle, i: Int): SyntaxStyle = |
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:
37197
diff
changeset
|
34 |
{ |
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:
37197
diff
changeset
|
35 |
import scala.collection.JavaConversions._ |
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:
37197
diff
changeset
|
36 |
val script_font = |
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:
37197
diff
changeset
|
37 |
style.getFont.deriveFont(Map(TextAttribute.SUPERSCRIPT -> new java.lang.Integer(i))) |
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:
37197
diff
changeset
|
38 |
new SyntaxStyle(style.getForegroundColor, style.getBackgroundColor, script_font) |
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:
37197
diff
changeset
|
39 |
} |
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:
37197
diff
changeset
|
40 |
|
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:
37197
diff
changeset
|
41 |
def extend_styles(styles: Array[SyntaxStyle]): Array[SyntaxStyle] = |
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:
37197
diff
changeset
|
42 |
{ |
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:
37197
diff
changeset
|
43 |
val new_styles = new Array[SyntaxStyle](full_range) |
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:
37197
diff
changeset
|
44 |
for (i <- 0 until plain_range) { |
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:
37197
diff
changeset
|
45 |
val style = styles(i) |
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:
37197
diff
changeset
|
46 |
new_styles(i) = style |
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:
37197
diff
changeset
|
47 |
new_styles(subscript(i.toByte)) = script_style(style, -1) |
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:
37197
diff
changeset
|
48 |
new_styles(superscript(i.toByte)) = script_style(style, 1) |
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:
37197
diff
changeset
|
49 |
} |
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:
37197
diff
changeset
|
50 |
new_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:
37197
diff
changeset
|
51 |
} |
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:
37197
diff
changeset
|
52 |
|
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:
37197
diff
changeset
|
53 |
|
34709 | 54 |
/* line context */ |
55 |
||
34727 | 56 |
private val rule_set = new ParserRuleSet("isabelle", "MAIN") |
34709 | 57 |
private class LineContext(val line: Int, prev: LineContext) |
34727 | 58 |
extends TokenMarker.LineContext(rule_set, prev) |
34709 | 59 |
|
60 |
||
61 |
/* mapping to jEdit token types */ |
|
34638 | 62 |
// TODO: as properties or CSS style sheet |
34709 | 63 |
|
37197
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
64 |
private val command_style: Map[String, Byte] = |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
65 |
{ |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
66 |
import Token._ |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
67 |
Map[String, Byte]( |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
68 |
Keyword.THY_END -> KEYWORD2, |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
69 |
Keyword.THY_SCRIPT -> LABEL, |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
70 |
Keyword.PRF_SCRIPT -> LABEL, |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
71 |
Keyword.PRF_ASM -> KEYWORD3, |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
72 |
Keyword.PRF_ASM_GOAL -> KEYWORD3 |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
73 |
).withDefaultValue(KEYWORD1) |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
74 |
} |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
75 |
|
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
76 |
private val token_style: Map[String, Byte] = |
34638 | 77 |
{ |
34861
309d545295d3
eliminated obsolete isabelle.proofdocument.Token;
wenzelm
parents:
34855
diff
changeset
|
78 |
import Token._ |
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
79 |
Map[String, Byte]( |
34549 | 80 |
// logical entities |
37194 | 81 |
Markup.TCLASS -> NULL, |
82 |
Markup.TYCON -> NULL, |
|
83 |
Markup.FIXED_DECL -> FUNCTION, |
|
84 |
Markup.FIXED -> NULL, |
|
85 |
Markup.CONST_DECL -> FUNCTION, |
|
86 |
Markup.CONST -> NULL, |
|
87 |
Markup.FACT_DECL -> FUNCTION, |
|
88 |
Markup.FACT -> NULL, |
|
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
89 |
Markup.DYNAMIC_FACT -> LABEL, |
37194 | 90 |
Markup.LOCAL_FACT_DECL -> FUNCTION, |
91 |
Markup.LOCAL_FACT -> NULL, |
|
34549 | 92 |
// inner syntax |
37194 | 93 |
Markup.TFREE -> NULL, |
94 |
Markup.FREE -> NULL, |
|
95 |
Markup.TVAR -> NULL, |
|
96 |
Markup.SKOLEM -> NULL, |
|
97 |
Markup.BOUND -> NULL, |
|
98 |
Markup.VAR -> NULL, |
|
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
99 |
Markup.NUM -> DIGIT, |
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
100 |
Markup.FLOAT -> DIGIT, |
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
101 |
Markup.XNUM -> DIGIT, |
34638 | 102 |
Markup.XSTR -> LITERAL4, |
37194 | 103 |
Markup.LITERAL -> OPERATOR, |
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
104 |
Markup.INNER_COMMENT -> COMMENT1, |
37194 | 105 |
Markup.SORT -> NULL, |
106 |
Markup.TYP -> NULL, |
|
107 |
Markup.TERM -> NULL, |
|
108 |
Markup.PROP -> NULL, |
|
109 |
Markup.ATTRIBUTE -> NULL, |
|
110 |
Markup.METHOD -> NULL, |
|
34549 | 111 |
// ML syntax |
37194 | 112 |
Markup.ML_KEYWORD -> KEYWORD1, |
37195 | 113 |
Markup.ML_DELIMITER -> OPERATOR, |
34640 | 114 |
Markup.ML_IDENT -> NULL, |
37194 | 115 |
Markup.ML_TVAR -> NULL, |
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
116 |
Markup.ML_NUMERAL -> DIGIT, |
34638 | 117 |
Markup.ML_CHAR -> LITERAL1, |
118 |
Markup.ML_STRING -> LITERAL1, |
|
119 |
Markup.ML_COMMENT -> COMMENT1, |
|
120 |
Markup.ML_MALFORMED -> INVALID, |
|
34549 | 121 |
// embedded source text |
37194 | 122 |
Markup.ML_SOURCE -> COMMENT3, |
123 |
Markup.DOC_SOURCE -> COMMENT3, |
|
34638 | 124 |
Markup.ANTIQ -> COMMENT4, |
125 |
Markup.ML_ANTIQ -> COMMENT4, |
|
126 |
Markup.DOC_ANTIQ -> COMMENT4, |
|
34549 | 127 |
// outer syntax |
37194 | 128 |
Markup.KEYWORD -> KEYWORD2, |
129 |
Markup.OPERATOR -> OPERATOR, |
|
130 |
Markup.COMMAND -> KEYWORD1, |
|
34640 | 131 |
Markup.IDENT -> NULL, |
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
132 |
Markup.VERBATIM -> COMMENT3, |
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
133 |
Markup.COMMENT -> COMMENT1, |
34638 | 134 |
Markup.CONTROL -> COMMENT3, |
135 |
Markup.MALFORMED -> INVALID, |
|
34639
051635fa7b7e
tuned token styles, according to some earlier Isabelle/jEdit experiments;
wenzelm
parents:
34638
diff
changeset
|
136 |
Markup.STRING -> LITERAL3, |
34638 | 137 |
Markup.ALTSTRING -> LITERAL1 |
34640 | 138 |
).withDefaultValue(NULL) |
34517 | 139 |
} |
34467 | 140 |
} |
34517 | 141 |
|
34700 | 142 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
143 |
class Isabelle_Token_Marker(model: Document_Model) extends TokenMarker |
34588 | 144 |
{ |
34517 | 145 |
override def markTokens(prev: TokenMarker.LineContext, |
34638 | 146 |
handler: TokenHandler, line_segment: Segment): TokenMarker.LineContext = |
147 |
{ |
|
34760 | 148 |
val previous = prev.asInstanceOf[Isabelle_Token_Marker.LineContext] |
34582 | 149 |
val line = if (prev == null) 0 else previous.line + 1 |
34760 | 150 |
val context = new Isabelle_Token_Marker.LineContext(line, previous) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
151 |
val start = model.buffer.getLineStartOffset(line) |
34517 | 152 |
val stop = start + line_segment.count |
34541 | 153 |
|
34824
ac35eee85f5c
renamed current_document to recent_document (might be a bit older than current_change);
wenzelm
parents:
34784
diff
changeset
|
154 |
val document = model.recent_document() |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
155 |
def to: Int => Int = model.to_current(document, _) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34777
diff
changeset
|
156 |
def from: Int => Int = model.from_current(document, _) |
34517 | 157 |
|
37366
5c6695de35ba
disable set_styles for now -- there are still some race conditions of PropertiesChanged vs. TextArea painting (NB: without it Isabelle_Token_Marker will crash if sub/superscript is actually used);
wenzelm
parents:
37241
diff
changeset
|
158 |
/* FIXME |
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:
37197
diff
changeset
|
159 |
for (text_area <- Isabelle.jedit_text_areas(model.buffer) |
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:
37197
diff
changeset
|
160 |
if Document_View(text_area).isDefined) |
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:
37197
diff
changeset
|
161 |
Document_View(text_area).get.set_styles() |
37366
5c6695de35ba
disable set_styles for now -- there are still some race conditions of PropertiesChanged vs. TextArea painting (NB: without it Isabelle_Token_Marker will crash if sub/superscript is actually used);
wenzelm
parents:
37241
diff
changeset
|
162 |
*/ |
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:
37197
diff
changeset
|
163 |
|
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:
37197
diff
changeset
|
164 |
def handle_token(style: Byte, offset: Int, length: Int) = |
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:
37197
diff
changeset
|
165 |
handler.handleToken(line_segment, style, offset, length, context) |
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:
37197
diff
changeset
|
166 |
|
34522 | 167 |
var next_x = start |
34855
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
168 |
for { |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
169 |
(command, command_start) <- document.command_range(from(start), from(stop)) |
36990
449628c148cf
explicit Command.Status.UNDEFINED -- avoid fragile/cumbersome treatment of Option[State];
wenzelm
parents:
36760
diff
changeset
|
170 |
markup <- document.current_state(command).highlight.flatten |
34855
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
171 |
val abs_start = to(command_start + markup.start) |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
172 |
val abs_stop = to(command_start + markup.stop) |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
173 |
if (abs_stop > start) |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
174 |
if (abs_start < stop) |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
175 |
val token_start = (abs_start - start) max 0 |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
176 |
val token_length = |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
177 |
(abs_stop - abs_start) - |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
178 |
((start - abs_start) max 0) - |
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
179 |
((abs_stop - stop) max 0) |
37197
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
180 |
} |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
181 |
{ |
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:
37197
diff
changeset
|
182 |
val token_type = |
37197
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
183 |
markup.info match { |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
184 |
case Command.HighlightInfo(Markup.COMMAND, Some(kind)) => |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
185 |
Isabelle_Token_Marker.command_style(kind) |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
186 |
case Command.HighlightInfo(kind, _) => |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
187 |
Isabelle_Token_Marker.token_style(kind) |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
188 |
case _ => Token.NULL |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
189 |
} |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
190 |
if (start + token_start > next_x) |
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:
37197
diff
changeset
|
191 |
handle_token(Token.COMMENT1, next_x - start, start + token_start - next_x) |
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:
37197
diff
changeset
|
192 |
handle_token(token_type, token_start, token_length) |
37197
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
193 |
next_x = start + token_start + token_length |
953fc4983439
more detailed token markup, including command kind as sub_kind;
wenzelm
parents:
37196
diff
changeset
|
194 |
} |
34522 | 195 |
if (next_x < stop) |
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:
37197
diff
changeset
|
196 |
handle_token(Token.COMMENT1, next_x - start, stop - next_x) |
34517 | 197 |
|
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:
37197
diff
changeset
|
198 |
handle_token(Token.END, line_segment.count, 0) |
34517 | 199 |
handler.setLineContext(context) |
34855
81d0410dc3ac
iterators for ranges of commands/starts -- avoid extra array per document;
wenzelm
parents:
34832
diff
changeset
|
200 |
context |
34517 | 201 |
} |
34700 | 202 |
} |