author | wenzelm |
Mon, 06 Mar 2017 17:10:37 +0100 | |
changeset 65132 | 60e7072b8dbe |
parent 65129 | 06a7c2d316cf |
child 65139 | 0a2c0712e432 |
permissions | -rw-r--r-- |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/jedit_rendering.scala |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
3 |
|
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
4 |
Isabelle/jEdit-specific implementation of quasi-abstract rendering and |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
5 |
markup interpretation. |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
6 |
*/ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
7 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle.jedit |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
9 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
10 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
11 |
import isabelle._ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
12 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
13 |
import java.awt.Color |
46227
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46224
diff
changeset
|
14 |
import javax.swing.Icon |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
15 |
|
43414 | 16 |
import org.gjt.sp.jedit.syntax.{Token => JEditToken} |
61175 | 17 |
import org.gjt.sp.jedit.jEdit |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
18 |
|
45460 | 19 |
import scala.collection.immutable.SortedMap |
20 |
||
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
21 |
|
64621 | 22 |
object JEdit_Rendering |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
23 |
{ |
64621 | 24 |
def apply(snapshot: Document.Snapshot, options: Options): JEdit_Rendering = |
25 |
new JEdit_Rendering(snapshot, options) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
26 |
|
49356 | 27 |
|
53230 | 28 |
/* popup window bounds */ |
29 |
||
30 |
def popup_bounds: Double = (PIDE.options.real("jedit_popup_bounds") max 0.2) min 0.8 |
|
31 |
||
32 |
||
55501 | 33 |
/* Isabelle/Isar token markup */ |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
34 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
35 |
private val command_style: Map[String, Byte] = |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
36 |
{ |
43414 | 37 |
import JEditToken._ |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
38 |
Map[String, Byte]( |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
39 |
Keyword.THY_END -> KEYWORD2, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
40 |
Keyword.PRF_ASM -> KEYWORD3, |
59125 | 41 |
Keyword.PRF_ASM_GOAL -> KEYWORD3 |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
42 |
).withDefaultValue(KEYWORD1) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
43 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
44 |
|
43414 | 45 |
private val token_style: Map[Token.Kind.Value, Byte] = |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
46 |
{ |
43414 | 47 |
import JEditToken._ |
48 |
Map[Token.Kind.Value, Byte]( |
|
49 |
Token.Kind.KEYWORD -> KEYWORD2, |
|
50 |
Token.Kind.IDENT -> NULL, |
|
51 |
Token.Kind.LONG_IDENT -> NULL, |
|
52 |
Token.Kind.SYM_IDENT -> NULL, |
|
53 |
Token.Kind.VAR -> NULL, |
|
54 |
Token.Kind.TYPE_IDENT -> NULL, |
|
55 |
Token.Kind.TYPE_VAR -> NULL, |
|
56 |
Token.Kind.NAT -> NULL, |
|
57 |
Token.Kind.FLOAT -> NULL, |
|
59081 | 58 |
Token.Kind.SPACE -> NULL, |
43431 | 59 |
Token.Kind.STRING -> LITERAL1, |
60 |
Token.Kind.ALT_STRING -> LITERAL2, |
|
43414 | 61 |
Token.Kind.VERBATIM -> COMMENT3, |
55033 | 62 |
Token.Kind.CARTOUCHE -> COMMENT4, |
43414 | 63 |
Token.Kind.COMMENT -> COMMENT1, |
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48751
diff
changeset
|
64 |
Token.Kind.ERROR -> INVALID |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
65 |
).withDefaultValue(NULL) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
66 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
67 |
|
43414 | 68 |
def token_markup(syntax: Outer_Syntax, token: Token): Byte = |
63441 | 69 |
if (token.is_command) command_style(syntax.keywords.kinds.getOrElse(token.content, "")) |
61579 | 70 |
else if (token.is_keyword && token.source == Symbol.comment_decoded) JEditToken.NULL |
55505 | 71 |
else if (token.is_delimiter) JEditToken.OPERATOR |
43414 | 72 |
else token_style(token.kind) |
55500 | 73 |
|
55501 | 74 |
|
75 |
/* Isabelle/ML token markup */ |
|
76 |
||
55500 | 77 |
private val ml_token_style: Map[ML_Lex.Kind.Value, Byte] = |
78 |
{ |
|
79 |
import JEditToken._ |
|
80 |
Map[ML_Lex.Kind.Value, Byte]( |
|
55505 | 81 |
ML_Lex.Kind.KEYWORD -> NULL, |
55500 | 82 |
ML_Lex.Kind.IDENT -> NULL, |
83 |
ML_Lex.Kind.LONG_IDENT -> NULL, |
|
84 |
ML_Lex.Kind.TYPE_VAR -> NULL, |
|
55503 | 85 |
ML_Lex.Kind.WORD -> DIGIT, |
86 |
ML_Lex.Kind.INT -> DIGIT, |
|
87 |
ML_Lex.Kind.REAL -> DIGIT, |
|
55500 | 88 |
ML_Lex.Kind.CHAR -> LITERAL2, |
89 |
ML_Lex.Kind.STRING -> LITERAL1, |
|
90 |
ML_Lex.Kind.SPACE -> NULL, |
|
91 |
ML_Lex.Kind.COMMENT -> COMMENT1, |
|
55512 | 92 |
ML_Lex.Kind.ANTIQ -> NULL, |
93 |
ML_Lex.Kind.ANTIQ_START -> LITERAL4, |
|
94 |
ML_Lex.Kind.ANTIQ_STOP -> LITERAL4, |
|
95 |
ML_Lex.Kind.ANTIQ_OTHER -> NULL, |
|
55514
8ef781e282d9
more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents:
55512
diff
changeset
|
96 |
ML_Lex.Kind.ANTIQ_STRING -> NULL, |
8ef781e282d9
more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents:
55512
diff
changeset
|
97 |
ML_Lex.Kind.ANTIQ_ALT_STRING -> NULL, |
8ef781e282d9
more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents:
55512
diff
changeset
|
98 |
ML_Lex.Kind.ANTIQ_CARTOUCHE -> NULL, |
55500 | 99 |
ML_Lex.Kind.ERROR -> INVALID |
100 |
).withDefaultValue(NULL) |
|
101 |
} |
|
102 |
||
103 |
def ml_token_markup(token: ML_Lex.Token): Byte = |
|
55501 | 104 |
if (!token.is_keyword) ml_token_style(token.kind) |
55505 | 105 |
else if (token.is_delimiter) JEditToken.OPERATOR |
106 |
else if (ML_Lex.keywords2(token.source)) JEditToken.KEYWORD2 |
|
107 |
else if (ML_Lex.keywords3(token.source)) JEditToken.KEYWORD3 |
|
55501 | 108 |
else JEditToken.KEYWORD1 |
55647 | 109 |
|
110 |
||
111 |
/* markup elements */ |
|
112 |
||
63474
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
113 |
private val indentation_elements = |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
114 |
Markup.Elements(Markup.Command_Indent.name) |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
115 |
|
56173 | 116 |
private val language_context_elements = |
59081 | 117 |
Markup.Elements(Markup.STRING, Markup.ALT_STRING, Markup.VERBATIM, |
55647 | 118 |
Markup.CARTOUCHE, Markup.COMMENT, Markup.LANGUAGE, |
61598 | 119 |
Markup.ML_STRING, Markup.ML_COMMENT) |
55647 | 120 |
|
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
121 |
private val language_elements = Markup.Elements(Markup.LANGUAGE) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
122 |
|
58592 | 123 |
private val citation_elements = Markup.Elements(Markup.CITATION) |
124 |
||
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
125 |
private val breakpoint_elements = Markup.Elements(Markup.ML_BREAKPOINT) |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
126 |
|
55647 | 127 |
private val highlight_elements = |
58545
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
128 |
Markup.Elements(Markup.EXPRESSION, Markup.CITATION, Markup.LANGUAGE, Markup.ML_TYPING, |
61718
309c20b21451
clarified rendering of Markup.DOC: like Markup.PATH / Markup.URL;
wenzelm
parents:
61660
diff
changeset
|
129 |
Markup.TOKEN_RANGE, Markup.ENTITY, Markup.PATH, Markup.DOC, Markup.URL, Markup.SORTING, |
63347 | 130 |
Markup.TYPING, Markup.CLASS_PARAMETER, Markup.FREE, Markup.SKOLEM, Markup.BOUND, |
61450 | 131 |
Markup.VAR, Markup.TFREE, Markup.TVAR, Markup.ML_BREAKPOINT, |
132 |
Markup.MARKDOWN_PARAGRAPH, Markup.Markdown_List.name) |
|
55647 | 133 |
|
134 |
private val hyperlink_elements = |
|
61660
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
135 |
Markup.Elements(Markup.ENTITY, Markup.PATH, Markup.DOC, Markup.POSITION, |
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
136 |
Markup.CITATION, Markup.URL) |
55647 | 137 |
|
138 |
private val gutter_elements = |
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
139 |
Markup.Elements(Markup.WRITELN, Markup.INFORMATION, Markup.WARNING, Markup.LEGACY, Markup.ERROR) |
55647 | 140 |
|
141 |
private val squiggly_elements = |
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
142 |
Markup.Elements(Markup.WRITELN, Markup.INFORMATION, Markup.WARNING, Markup.LEGACY, Markup.ERROR) |
55647 | 143 |
|
144 |
private val line_background_elements = |
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
145 |
Markup.Elements(Markup.WRITELN_MESSAGE, Markup.STATE_MESSAGE, Markup.INFORMATION_MESSAGE, |
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
146 |
Markup.TRACING_MESSAGE, Markup.WARNING_MESSAGE, Markup.LEGACY_MESSAGE, |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
147 |
Markup.ERROR_MESSAGE) |
55647 | 148 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
149 |
private val separator_elements = |
56743 | 150 |
Markup.Elements(Markup.SEPARATOR) |
55647 | 151 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
152 |
private val bullet_elements = |
60913 | 153 |
Markup.Elements(Markup.BULLET, Markup.ML_BREAKPOINT) |
55647 | 154 |
|
155 |
private val fold_depth_elements = |
|
56743 | 156 |
Markup.Elements(Markup.TEXT_FOLD, Markup.GOAL, Markup.SUBGOAL) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
157 |
} |
49356 | 158 |
|
159 |
||
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
160 |
class JEdit_Rendering(snapshot: Document.Snapshot, options: Options) |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
161 |
extends Rendering(snapshot, options, PIDE.resources) |
49356 | 162 |
{ |
163 |
/* colors */ |
|
164 |
||
65102 | 165 |
def color(s: String): Color = Color_Value(options.string(s)) |
49356 | 166 |
|
65101 | 167 |
lazy val _rendering_colors: Map[Rendering.Color.Value, Color] = |
65102 | 168 |
Rendering.Color.values.iterator.map(c => c -> color(c.toString + "_color")).toMap |
65101 | 169 |
|
170 |
def color(c: Rendering.Color.Value): Color = _rendering_colors(c) |
|
171 |
||
65102 | 172 |
val outdated_color = color("outdated_color") |
173 |
val unprocessed_color = color("unprocessed_color") |
|
174 |
val running_color = color("running_color") |
|
175 |
val bullet_color = color("bullet_color") |
|
176 |
val tooltip_color = color("tooltip_color") |
|
177 |
val warning_color = color("warning_color") |
|
178 |
val error_color = color("error_color") |
|
179 |
val spell_checker_color = color("spell_checker_color") |
|
180 |
val entity_ref_color = color("entity_ref_color") |
|
181 |
val breakpoint_disabled_color = color("breakpoint_disabled_color") |
|
182 |
val breakpoint_enabled_color = color("breakpoint_enabled_color") |
|
183 |
val caret_debugger_color = color("caret_debugger_color") |
|
184 |
val antiquote_color = color("antiquote_color") |
|
185 |
val highlight_color = color("highlight_color") |
|
186 |
val hyperlink_color = color("hyperlink_color") |
|
187 |
val active_hover_color = color("active_hover_color") |
|
188 |
val keyword1_color = color("keyword1_color") |
|
189 |
val keyword2_color = color("keyword2_color") |
|
190 |
val keyword3_color = color("keyword3_color") |
|
191 |
val quasi_keyword_color = color("quasi_keyword_color") |
|
192 |
val improper_color = color("improper_color") |
|
193 |
val operator_color = color("operator_color") |
|
194 |
val caret_invisible_color = color("caret_invisible_color") |
|
195 |
val completion_color = color("completion_color") |
|
196 |
val search_color = color("search_color") |
|
49356 | 197 |
|
65102 | 198 |
val tfree_color = color("tfree_color") |
199 |
val tvar_color = color("tvar_color") |
|
200 |
val free_color = color("free_color") |
|
201 |
val skolem_color = color("skolem_color") |
|
202 |
val bound_color = color("bound_color") |
|
203 |
val var_color = color("var_color") |
|
204 |
val inner_numeral_color = color("inner_numeral_color") |
|
205 |
val inner_quoted_color = color("inner_quoted_color") |
|
206 |
val inner_cartouche_color = color("inner_cartouche_color") |
|
207 |
val inner_comment_color = color("inner_comment_color") |
|
208 |
val dynamic_color = color("dynamic_color") |
|
209 |
val class_parameter_color = color("class_parameter_color") |
|
49356 | 210 |
|
211 |
||
63474
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
212 |
/* indentation */ |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
213 |
|
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
214 |
def indentation(range: Text.Range): Int = |
64621 | 215 |
snapshot.select(range, JEdit_Rendering.indentation_elements, _ => |
63474
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
216 |
{ |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
217 |
case Text.Info(_, XML.Elem(Markup.Command_Indent(i), _)) => Some(i) |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
218 |
case _ => None |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
219 |
}).headOption.map(_.info).getOrElse(0) |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
220 |
|
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
221 |
|
55674 | 222 |
/* completion */ |
223 |
||
56173 | 224 |
def language_context(range: Text.Range): Option[Completion.Language_Context] = |
64621 | 225 |
snapshot.select(range, JEdit_Rendering.language_context_elements, _ => |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
226 |
{ |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
227 |
case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes, delimited), _)) => |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
228 |
if (delimited) Some(Completion.Language_Context(language, symbols, antiquotes)) |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
229 |
else None |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
230 |
case Text.Info(_, elem) |
61598 | 231 |
if elem.name == Markup.ML_STRING || elem.name == Markup.ML_COMMENT => |
55749 | 232 |
Some(Completion.Language_Context.ML_inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
233 |
case Text.Info(_, _) => |
55749 | 234 |
Some(Completion.Language_Context.inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
235 |
}).headOption.map(_.info) |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
236 |
|
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
237 |
def language_path(range: Text.Range): Option[Text.Range] = |
64621 | 238 |
snapshot.select(range, JEdit_Rendering.language_elements, _ => |
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
239 |
{ |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
240 |
case Text.Info(info_range, XML.Elem(Markup.Language(Markup.Language.PATH, _, _, _), _)) => |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
241 |
Some(snapshot.convert(info_range)) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
242 |
case _ => None |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
243 |
}).headOption.map(_.info) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
244 |
|
58592 | 245 |
def citation(range: Text.Range): Option[Text.Info[String]] = |
64621 | 246 |
snapshot.select(range, JEdit_Rendering.citation_elements, _ => |
58592 | 247 |
{ |
248 |
case Text.Info(info_range, XML.Elem(Markup.Citation(name), _)) => |
|
249 |
Some(Text.Info(snapshot.convert(info_range), name)) |
|
250 |
case _ => None |
|
251 |
}).headOption.map(_.info) |
|
252 |
||
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
253 |
|
56551 | 254 |
/* spell checker */ |
56548 | 255 |
|
56551 | 256 |
private lazy val spell_checker_elements = |
56743 | 257 |
Markup.Elements(space_explode(',', options.string("spell_checker_elements")): _*) |
56551 | 258 |
|
259 |
def spell_checker_ranges(range: Text.Range): List[Text.Range] = |
|
260 |
snapshot.select(range, spell_checker_elements, _ => _ => Some(())).map(_.range) |
|
56548 | 261 |
|
56564
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
262 |
def spell_checker_point(range: Text.Range): Option[Text.Range] = |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
263 |
snapshot.select(range, spell_checker_elements, _ => |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
264 |
{ |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
265 |
case info => Some(snapshot.convert(info.range)) |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
266 |
}).headOption.map(_.info) |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
267 |
|
56548 | 268 |
|
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
269 |
/* breakpoints */ |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
270 |
|
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
271 |
def breakpoint(range: Text.Range): Option[(Command, Long)] = |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
272 |
if (snapshot.is_outdated) None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
273 |
else |
64621 | 274 |
snapshot.select(range, JEdit_Rendering.breakpoint_elements, command_states => |
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
275 |
{ |
60882 | 276 |
case Text.Info(_, Protocol.ML_Breakpoint(breakpoint)) => |
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
277 |
command_states match { |
60882 | 278 |
case st :: _ => Some((st.command, breakpoint)) |
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
279 |
case _ => None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
280 |
} |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
281 |
case _ => None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
282 |
}).headOption.map(_.info) |
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
283 |
|
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
284 |
|
55626 | 285 |
/* command status overview */ |
49356 | 286 |
|
287 |
def overview_color(range: Text.Range): Option[Color] = |
|
288 |
{ |
|
289 |
if (snapshot.is_outdated) None |
|
290 |
else { |
|
291 |
val results = |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
292 |
snapshot.cumulate[List[Markup]](range, Nil, Protocol.liberal_status_elements, _ => |
49356 | 293 |
{ |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
294 |
case (status, Text.Info(_, elem)) => Some(elem.markup :: status) |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
295 |
}, status = true) |
49356 | 296 |
if (results.isEmpty) None |
297 |
else { |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
298 |
val status = Protocol.Status.make(results.iterator.flatMap(_.info)) |
49356 | 299 |
|
50895 | 300 |
if (status.is_running) Some(running_color) |
56980
9c5220e05e04
proper priority for error over warning, which got mixed up in 0546e036d1c0 and 4df2727a0b5f;
wenzelm
parents:
56883
diff
changeset
|
301 |
else if (status.is_failed) Some(error_color) |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
302 |
else if (status.is_warned) Some(warning_color) |
49356 | 303 |
else if (status.is_unprocessed) Some(unprocessed_color) |
304 |
else None |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
||
62986 | 310 |
/* caret focus */ |
311 |
||
62991 | 312 |
def entity_ref(range: Text.Range, focus: Set[Long]): List[Text.Info[Color]] = |
64767 | 313 |
snapshot.select(range, Rendering.caret_focus_elements, _ => |
62988 | 314 |
{ |
62991 | 315 |
case Text.Info(_, XML.Elem(Markup(Markup.ENTITY, Markup.Entity.Ref(i)), _)) if focus(i) => |
316 |
Some(entity_ref_color) |
|
62988 | 317 |
case _ => None |
318 |
}) |
|
319 |
||
62986 | 320 |
|
55626 | 321 |
/* highlighted area */ |
49356 | 322 |
|
49358 | 323 |
def highlight(range: Text.Range): Option[Text.Info[Color]] = |
64621 | 324 |
snapshot.select(range, JEdit_Rendering.highlight_elements, _ => |
55620 | 325 |
{ |
326 |
case info => Some(Text.Info(snapshot.convert(info.range), highlight_color)) |
|
55689 | 327 |
}).headOption.map(_.info) |
49356 | 328 |
|
329 |
||
55626 | 330 |
/* hyperlinks */ |
331 |
||
52980 | 332 |
def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] = |
49356 | 333 |
{ |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
334 |
snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]]( |
64621 | 335 |
range, Vector.empty, JEdit_Rendering.hyperlink_elements, _ => |
49356 | 336 |
{ |
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
337 |
case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) => |
64654 | 338 |
val file = resources.append_file(snapshot.node_name.master_dir, name) |
339 |
val link = PIDE.editor.hyperlink_file(true, file) |
|
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
340 |
Some(links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 341 |
|
61660
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
342 |
case (links, Text.Info(info_range, XML.Elem(Markup.Doc(name), _))) => |
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
343 |
PIDE.editor.hyperlink_doc(name).map(link => |
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
344 |
(links :+ Text.Info(snapshot.convert(info_range), link))) |
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
345 |
|
54702
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
346 |
case (links, Text.Info(info_range, XML.Elem(Markup.Url(name), _))) => |
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
347 |
val link = PIDE.editor.hyperlink_url(name) |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
348 |
Some(links :+ Text.Info(snapshot.convert(info_range), link)) |
54702
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
349 |
|
64660 | 350 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
60893 | 351 |
val opt_link = PIDE.editor.hyperlink_def_position(true, snapshot, props) |
60215 | 352 |
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 353 |
|
55545 | 354 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) => |
60893 | 355 |
val opt_link = PIDE.editor.hyperlink_position(true, snapshot, props) |
60215 | 356 |
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link)) |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
357 |
|
58545
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
358 |
case (links, Text.Info(info_range, XML.Elem(Markup.Citation(name), _))) => |
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
359 |
val opt_link = |
64829
07f209e957bc
refer to bibtex entries via general Document_Model, instead of editor buffers;
wenzelm
parents:
64767
diff
changeset
|
360 |
Document_Model.bibtex_entries_iterator.collectFirst( |
64831 | 361 |
{ case Text.Info(entry_range, (entry, model)) if entry == name => |
362 |
PIDE.editor.hyperlink_model(true, model, entry_range.start) }) |
|
60215 | 363 |
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link)) |
58545
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
364 |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
365 |
case _ => None |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
366 |
}) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None } |
49356 | 367 |
} |
368 |
||
369 |
||
55626 | 370 |
/* active elements */ |
371 |
||
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
372 |
def active(range: Text.Range): Option[Text.Info[XML.Elem]] = |
65101 | 373 |
snapshot.select(range, Rendering.active_elements, command_states => |
55620 | 374 |
{ |
375 |
case Text.Info(info_range, elem) => |
|
55623 | 376 |
if (elem.name == Markup.DIALOG) { |
377 |
elem match { |
|
378 |
case Protocol.Dialog(_, serial, _) |
|
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
379 |
if !command_states.exists(st => st.results.defined(serial)) => |
55623 | 380 |
Some(Text.Info(snapshot.convert(info_range), elem)) |
381 |
case _ => None |
|
382 |
} |
|
383 |
} |
|
384 |
else Some(Text.Info(snapshot.convert(info_range), elem)) |
|
55689 | 385 |
}).headOption.map(_.info) |
49492 | 386 |
|
50502 | 387 |
def command_results(range: Text.Range): Command.Results = |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
388 |
Command.State.merge_results( |
56743 | 389 |
snapshot.select[List[Command.State]](range, Markup.Elements.full, command_states => |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
390 |
{ case _ => Some(command_states) }).flatMap(_.info)) |
50502 | 391 |
|
55626 | 392 |
|
393 |
/* tooltips */ |
|
394 |
||
55647 | 395 |
def tooltip_margin: Int = options.int("jedit_tooltip_margin") |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
396 |
def timing_threshold: Double = options.real("jedit_timing_threshold") |
50554
0493efcc97e9
more general handling of graphics configurations, to increase chance of proper positioning of tooltips in multi-screen environment;
wenzelm
parents:
50547
diff
changeset
|
397 |
|
64748 | 398 |
def tooltip(range: Text.Range): Option[Text.Info[XML.Body]] = |
65132 | 399 |
tooltips(Rendering.tooltip_elements, range).map(info => info.map(Pretty.fbreaks(_))) |
65129
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65128
diff
changeset
|
400 |
|
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65128
diff
changeset
|
401 |
def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] = |
65132 | 402 |
tooltips(Rendering.tooltip_message_elements, range).map(info => info.map(Pretty.fbreaks(_))) |
64748 | 403 |
|
52873 | 404 |
lazy val tooltip_close_icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon")) |
405 |
lazy val tooltip_detach_icon = JEdit_Lib.load_icon(options.string("tooltip_detach_icon")) |
|
52472
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
406 |
|
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
407 |
|
56495 | 408 |
/* gutter */ |
409 |
||
410 |
private def gutter_message_pri(msg: XML.Tree): Int = |
|
64676 | 411 |
if (Protocol.is_error(msg)) Rendering.error_pri |
412 |
else if (Protocol.is_legacy(msg)) Rendering.legacy_pri |
|
413 |
else if (Protocol.is_warning(msg)) Rendering.warning_pri |
|
414 |
else if (Protocol.is_information(msg)) Rendering.information_pri |
|
56495 | 415 |
else 0 |
55626 | 416 |
|
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
417 |
private lazy val gutter_message_content = Map( |
64676 | 418 |
Rendering.information_pri -> |
65127 | 419 |
(JEdit_Lib.load_icon(options.string("gutter_information_icon")), |
420 |
color(Rendering.Color.information_message)), |
|
64676 | 421 |
Rendering.warning_pri -> |
65127 | 422 |
(JEdit_Lib.load_icon(options.string("gutter_warning_icon")), |
423 |
color(Rendering.Color.warning_message)), |
|
64676 | 424 |
Rendering.legacy_pri -> |
65127 | 425 |
(JEdit_Lib.load_icon(options.string("gutter_legacy_icon")), |
426 |
color(Rendering.Color.legacy_message)), |
|
64676 | 427 |
Rendering.error_pri -> |
65127 | 428 |
(JEdit_Lib.load_icon(options.string("gutter_error_icon")), |
429 |
color(Rendering.Color.error_message))) |
|
49356 | 430 |
|
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
431 |
def gutter_content(range: Text.Range): Option[(Icon, Color)] = |
49356 | 432 |
{ |
56495 | 433 |
val pris = |
64621 | 434 |
snapshot.cumulate[Int](range, 0, JEdit_Rendering.gutter_elements, _ => |
49356 | 435 |
{ |
56495 | 436 |
case (pri, Text.Info(_, msg @ XML.Elem(Markup(_, Markup.Serial(serial)), _))) => |
437 |
Some(pri max gutter_message_pri(msg)) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
438 |
case _ => None |
56495 | 439 |
}).map(_.info) |
440 |
||
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
441 |
gutter_message_content.get((0 /: pris)(_ max _)) |
49356 | 442 |
} |
443 |
||
444 |
||
65128 | 445 |
/* message output */ |
55626 | 446 |
|
65121 | 447 |
def squiggly_underline(range: Text.Range): List[Text.Info[Rendering.Color.Value]] = |
448 |
message_underline_color(JEdit_Rendering.squiggly_elements, range) |
|
49356 | 449 |
|
65124 | 450 |
def line_background(range: Text.Range): Option[(Rendering.Color.Value, Boolean)] = |
49473 | 451 |
{ |
49474 | 452 |
val results = |
64621 | 453 |
snapshot.cumulate[Int](range, 0, JEdit_Rendering.line_background_elements, _ => |
49473 | 454 |
{ |
64676 | 455 |
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name)) |
49474 | 456 |
}) |
457 |
val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
|
458 |
||
65124 | 459 |
Rendering.message_background_color.get(pri).map(message_color => |
61719
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
460 |
{ |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
461 |
val is_separator = |
64621 | 462 |
snapshot.cumulate[Boolean](range, false, JEdit_Rendering.separator_elements, _ => |
61719
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
463 |
{ |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
464 |
case _ => Some(true) |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
465 |
}).exists(_.info) |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
466 |
(message_color, is_separator) |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
467 |
}) |
49473 | 468 |
} |
49356 | 469 |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
470 |
def output_messages(results: Command.Results): List[XML.Tree] = |
57691
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
471 |
{ |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
472 |
val (states, other) = |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
473 |
results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
474 |
.partition(Protocol.is_state(_)) |
61727
6f1a84d78865
reverted 2abbe7d700e9: "state" output is not necessarily proof state;
wenzelm
parents:
61722
diff
changeset
|
475 |
states ::: other |
57691
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
476 |
} |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
477 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
478 |
|
55626 | 479 |
/* text color */ |
480 |
||
61175 | 481 |
val foreground_color = jEdit.getColorProperty("view.fgColor") |
482 |
||
55647 | 483 |
private lazy val text_colors: Map[String, Color] = Map( |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
484 |
Markup.KEYWORD1 -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
485 |
Markup.KEYWORD2 -> keyword2_color, |
55765 | 486 |
Markup.KEYWORD3 -> keyword3_color, |
55919
2eb8c13339a5
more explicit quasi_keyword markup, for Args.$$$ material, which is somewhere in between of outer and inner syntax;
wenzelm
parents:
55914
diff
changeset
|
487 |
Markup.QUASI_KEYWORD -> quasi_keyword_color, |
56202 | 488 |
Markup.IMPROPER -> improper_color, |
56064 | 489 |
Markup.OPERATOR -> operator_color, |
61175 | 490 |
Markup.STRING -> foreground_color, |
491 |
Markup.ALT_STRING -> foreground_color, |
|
492 |
Markup.VERBATIM -> foreground_color, |
|
493 |
Markup.CARTOUCHE -> foreground_color, |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
494 |
Markup.LITERAL -> keyword1_color, |
61175 | 495 |
Markup.DELIMITER -> foreground_color, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
496 |
Markup.TFREE -> tfree_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
497 |
Markup.TVAR -> tvar_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
498 |
Markup.FREE -> free_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
499 |
Markup.SKOLEM -> skolem_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
500 |
Markup.BOUND -> bound_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
501 |
Markup.VAR -> var_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
502 |
Markup.INNER_STRING -> inner_quoted_color, |
55033 | 503 |
Markup.INNER_CARTOUCHE -> inner_cartouche_color, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
504 |
Markup.INNER_COMMENT -> inner_comment_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
505 |
Markup.DYNAMIC_FACT -> dynamic_color, |
63347 | 506 |
Markup.CLASS_PARAMETER -> class_parameter_color, |
55526 | 507 |
Markup.ANTIQUOTE -> antiquote_color, |
55505 | 508 |
Markup.ML_KEYWORD1 -> keyword1_color, |
509 |
Markup.ML_KEYWORD2 -> keyword2_color, |
|
510 |
Markup.ML_KEYWORD3 -> keyword3_color, |
|
61175 | 511 |
Markup.ML_DELIMITER -> foreground_color, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
512 |
Markup.ML_NUMERAL -> inner_numeral_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
513 |
Markup.ML_CHAR -> inner_quoted_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
514 |
Markup.ML_STRING -> inner_quoted_color, |
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
515 |
Markup.ML_COMMENT -> inner_comment_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
516 |
Markup.SML_STRING -> inner_quoted_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
517 |
Markup.SML_COMMENT -> inner_comment_color) |
49356 | 518 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
519 |
private lazy val text_color_elements = |
56743 | 520 |
Markup.Elements(text_colors.keySet) |
49356 | 521 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
522 |
def text_color(range: Text.Range, color: Color): List[Text.Info[Color]] = |
49356 | 523 |
{ |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
524 |
if (color == Token_Markup.hidden_color) List(Text.Info(range, color)) |
50196
94886ebf090f
retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents:
50164
diff
changeset
|
525 |
else |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
526 |
snapshot.cumulate(range, color, text_color_elements, _ => |
50196
94886ebf090f
retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents:
50164
diff
changeset
|
527 |
{ |
52890 | 528 |
case (_, Text.Info(_, elem)) => text_colors.get(elem.name) |
50196
94886ebf090f
retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents:
50164
diff
changeset
|
529 |
}) |
49356 | 530 |
} |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
531 |
|
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
532 |
|
55626 | 533 |
/* virtual bullets */ |
534 |
||
535 |
def bullet(range: Text.Range): List[Text.Info[Color]] = |
|
64621 | 536 |
snapshot.select(range, JEdit_Rendering.bullet_elements, _ => |
60913 | 537 |
{ |
538 |
case Text.Info(_, Protocol.ML_Breakpoint(breakpoint)) => |
|
539 |
Debugger.active_breakpoint_state(breakpoint).map(b => |
|
540 |
if (b) breakpoint_enabled_color else breakpoint_disabled_color) |
|
541 |
case _ => Some(bullet_color) |
|
542 |
}) |
|
55626 | 543 |
|
544 |
||
545 |
/* text folds */ |
|
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
546 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
547 |
def fold_depth(range: Text.Range): List[Text.Info[Int]] = |
64621 | 548 |
snapshot.cumulate[Int](range, 0, JEdit_Rendering.fold_depth_elements, _ => |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
549 |
{ |
55620 | 550 |
case (depth, _) => Some(depth + 1) |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
551 |
}) |
49356 | 552 |
} |