author | wenzelm |
Mon, 02 Jan 2017 11:42:15 +0100 | |
changeset 64748 | 155bf8632104 |
parent 64677 | 8dc24130e8fe |
child 64767 | f5c4ffdb1124 |
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 semantic_completion_elements = |
56743 | 117 |
Markup.Elements(Markup.COMPLETION, Markup.NO_COMPLETION) |
55674 | 118 |
|
56173 | 119 |
private val language_context_elements = |
59081 | 120 |
Markup.Elements(Markup.STRING, Markup.ALT_STRING, Markup.VERBATIM, |
55647 | 121 |
Markup.CARTOUCHE, Markup.COMMENT, Markup.LANGUAGE, |
61598 | 122 |
Markup.ML_STRING, Markup.ML_COMMENT) |
55647 | 123 |
|
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
124 |
private val language_elements = Markup.Elements(Markup.LANGUAGE) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
125 |
|
58592 | 126 |
private val citation_elements = Markup.Elements(Markup.CITATION) |
127 |
||
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
128 |
private val breakpoint_elements = Markup.Elements(Markup.ML_BREAKPOINT) |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
129 |
|
62986 | 130 |
private val caret_focus_elements = Markup.Elements(Markup.ENTITY) |
131 |
||
55647 | 132 |
private val highlight_elements = |
58545
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
133 |
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
|
134 |
Markup.TOKEN_RANGE, Markup.ENTITY, Markup.PATH, Markup.DOC, Markup.URL, Markup.SORTING, |
63347 | 135 |
Markup.TYPING, Markup.CLASS_PARAMETER, Markup.FREE, Markup.SKOLEM, Markup.BOUND, |
61450 | 136 |
Markup.VAR, Markup.TFREE, Markup.TVAR, Markup.ML_BREAKPOINT, |
137 |
Markup.MARKDOWN_PARAGRAPH, Markup.Markdown_List.name) |
|
55647 | 138 |
|
139 |
private val hyperlink_elements = |
|
61660
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
140 |
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
|
141 |
Markup.CITATION, Markup.URL) |
55647 | 142 |
|
143 |
private val active_elements = |
|
56743 | 144 |
Markup.Elements(Markup.DIALOG, Markup.BROWSER, Markup.GRAPHVIEW, |
63681 | 145 |
Markup.SENDBACK, Markup.JEDIT_ACTION, Markup.SIMP_TRACE_PANEL) |
55647 | 146 |
|
147 |
private val tooltip_message_elements = |
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
148 |
Markup.Elements(Markup.WRITELN, Markup.INFORMATION, Markup.WARNING, Markup.LEGACY, Markup.ERROR, |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
149 |
Markup.BAD) |
55647 | 150 |
|
151 |
private val gutter_elements = |
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
152 |
Markup.Elements(Markup.WRITELN, Markup.INFORMATION, Markup.WARNING, Markup.LEGACY, Markup.ERROR) |
55647 | 153 |
|
154 |
private val squiggly_elements = |
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
155 |
Markup.Elements(Markup.WRITELN, Markup.INFORMATION, Markup.WARNING, Markup.LEGACY, Markup.ERROR) |
55647 | 156 |
|
157 |
private val line_background_elements = |
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
158 |
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
|
159 |
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
|
160 |
Markup.ERROR_MESSAGE) |
55647 | 161 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
162 |
private val separator_elements = |
56743 | 163 |
Markup.Elements(Markup.SEPARATOR) |
55647 | 164 |
|
55790
4670f18baba5
simplified rendering -- no need to over-emphasize "token_range";
wenzelm
parents:
55765
diff
changeset
|
165 |
private val background_elements = |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
166 |
Protocol.proper_status_elements + Markup.WRITELN_MESSAGE + |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
167 |
Markup.STATE_MESSAGE + Markup.INFORMATION_MESSAGE + |
55647 | 168 |
Markup.TRACING_MESSAGE + Markup.WARNING_MESSAGE + |
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
169 |
Markup.LEGACY_MESSAGE + Markup.ERROR_MESSAGE + |
62986 | 170 |
Markup.BAD + Markup.INTENSIFY + Markup.ENTITY + |
171 |
Markup.Markdown_Item.name ++ active_elements |
|
55647 | 172 |
|
173 |
private val foreground_elements = |
|
59081 | 174 |
Markup.Elements(Markup.STRING, Markup.ALT_STRING, Markup.VERBATIM, |
55647 | 175 |
Markup.CARTOUCHE, Markup.ANTIQUOTED) |
176 |
||
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
177 |
private val bullet_elements = |
60913 | 178 |
Markup.Elements(Markup.BULLET, Markup.ML_BREAKPOINT) |
55647 | 179 |
|
180 |
private val fold_depth_elements = |
|
56743 | 181 |
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
|
182 |
} |
49356 | 183 |
|
184 |
||
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
185 |
class JEdit_Rendering(snapshot: Document.Snapshot, options: Options) |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
64621
diff
changeset
|
186 |
extends Rendering(snapshot, options, PIDE.resources) |
49356 | 187 |
{ |
188 |
/* colors */ |
|
189 |
||
190 |
def color_value(s: String): Color = Color_Value(options.string(s)) |
|
191 |
||
192 |
val outdated_color = color_value("outdated_color") |
|
193 |
val unprocessed_color = color_value("unprocessed_color") |
|
194 |
val unprocessed1_color = color_value("unprocessed1_color") |
|
195 |
val running_color = color_value("running_color") |
|
196 |
val running1_color = color_value("running1_color") |
|
51574
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
197 |
val bullet_color = color_value("bullet_color") |
49706 | 198 |
val tooltip_color = color_value("tooltip_color") |
49356 | 199 |
val writeln_color = color_value("writeln_color") |
52650 | 200 |
val information_color = color_value("information_color") |
49356 | 201 |
val warning_color = color_value("warning_color") |
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
202 |
val legacy_color = color_value("legacy_color") |
49356 | 203 |
val error_color = color_value("error_color") |
49418 | 204 |
val writeln_message_color = color_value("writeln_message_color") |
52650 | 205 |
val information_message_color = color_value("information_message_color") |
49418 | 206 |
val tracing_message_color = color_value("tracing_message_color") |
207 |
val warning_message_color = color_value("warning_message_color") |
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
208 |
val legacy_message_color = color_value("legacy_message_color") |
49418 | 209 |
val error_message_color = color_value("error_message_color") |
56550 | 210 |
val spell_checker_color = color_value("spell_checker_color") |
49356 | 211 |
val bad_color = color_value("bad_color") |
49358 | 212 |
val intensify_color = color_value("intensify_color") |
62988 | 213 |
val entity_color = color_value("entity_color") |
62991 | 214 |
val entity_ref_color = color_value("entity_ref_color") |
60913 | 215 |
val breakpoint_disabled_color = color_value("breakpoint_disabled_color") |
216 |
val breakpoint_enabled_color = color_value("breakpoint_enabled_color") |
|
61011 | 217 |
val caret_debugger_color = color_value("caret_debugger_color") |
49356 | 218 |
val quoted_color = color_value("quoted_color") |
52101
7679178b0aa5
less intrusive rendering of antiquoted text -- avoid visual clash with "blue variables" in particular;
wenzelm
parents:
52081
diff
changeset
|
219 |
val antiquoted_color = color_value("antiquoted_color") |
55526 | 220 |
val antiquote_color = color_value("antiquote_color") |
49358 | 221 |
val highlight_color = color_value("highlight_color") |
49356 | 222 |
val hyperlink_color = color_value("hyperlink_color") |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
223 |
val active_color = color_value("active_color") |
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
224 |
val active_hover_color = color_value("active_hover_color") |
50498 | 225 |
val active_result_color = color_value("active_result_color") |
49356 | 226 |
val keyword1_color = color_value("keyword1_color") |
227 |
val keyword2_color = color_value("keyword2_color") |
|
55505 | 228 |
val keyword3_color = color_value("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
|
229 |
val quasi_keyword_color = color_value("quasi_keyword_color") |
56202 | 230 |
val improper_color = color_value("improper_color") |
56064 | 231 |
val operator_color = color_value("operator_color") |
55713
734ac5709fbe
clarified painting of invisible caret, e.g. focus change due to popup;
wenzelm
parents:
55710
diff
changeset
|
232 |
val caret_invisible_color = color_value("caret_invisible_color") |
55747
bef19c929ba5
more completion rendering: active, semantic, syntactic;
wenzelm
parents:
55746
diff
changeset
|
233 |
val completion_color = color_value("completion_color") |
56883
38c6b70e5e53
common support for search field, which is actually a light-weight Highlighter;
wenzelm
parents:
56843
diff
changeset
|
234 |
val search_color = color_value("search_color") |
49356 | 235 |
|
236 |
val tfree_color = color_value("tfree_color") |
|
237 |
val tvar_color = color_value("tvar_color") |
|
238 |
val free_color = color_value("free_color") |
|
239 |
val skolem_color = color_value("skolem_color") |
|
240 |
val bound_color = color_value("bound_color") |
|
241 |
val var_color = color_value("var_color") |
|
242 |
val inner_numeral_color = color_value("inner_numeral_color") |
|
243 |
val inner_quoted_color = color_value("inner_quoted_color") |
|
55033 | 244 |
val inner_cartouche_color = color_value("inner_cartouche_color") |
49356 | 245 |
val inner_comment_color = color_value("inner_comment_color") |
246 |
val dynamic_color = color_value("dynamic_color") |
|
63347 | 247 |
val class_parameter_color = color_value("class_parameter_color") |
49356 | 248 |
|
61449 | 249 |
val markdown_item_color1 = color_value("markdown_item_color1") |
250 |
val markdown_item_color2 = color_value("markdown_item_color2") |
|
251 |
val markdown_item_color3 = color_value("markdown_item_color3") |
|
252 |
val markdown_item_color4 = color_value("markdown_item_color4") |
|
253 |
||
49356 | 254 |
|
63474
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
255 |
/* indentation */ |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
256 |
|
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
257 |
def indentation(range: Text.Range): Int = |
64621 | 258 |
snapshot.select(range, JEdit_Rendering.indentation_elements, _ => |
63474
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
259 |
{ |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
260 |
case Text.Info(_, XML.Elem(Markup.Command_Indent(i), _)) => Some(i) |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
261 |
case _ => None |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
262 |
}).headOption.map(_.info).getOrElse(0) |
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
263 |
|
f66e3c3b0fb1
semantic indentation for unstructured proof scripts;
wenzelm
parents:
63441
diff
changeset
|
264 |
|
55674 | 265 |
/* completion */ |
266 |
||
61601
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
267 |
def semantic_completion(completed_range: Option[Text.Range], range: Text.Range) |
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
268 |
: Option[Text.Info[Completion.Semantic]] = |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
269 |
if (snapshot.is_outdated) None |
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
270 |
else { |
64621 | 271 |
snapshot.select(range, JEdit_Rendering.semantic_completion_elements, _ => |
55688 | 272 |
{ |
61601
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
273 |
case Completion.Semantic.Info(info) => |
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
274 |
completed_range match { |
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
275 |
case Some(range0) if range0.contains(info.range) && range0 != info.range => None |
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
276 |
case _ => Some(info) |
15952a05133c
syntactic completion may supersede semantic completion, e.g. relevant for "\undefined" vs. "undefined" in ML;
wenzelm
parents:
61598
diff
changeset
|
277 |
} |
55688 | 278 |
case _ => None |
279 |
}).headOption.map(_.info) |
|
55674 | 280 |
} |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
281 |
|
56173 | 282 |
def language_context(range: Text.Range): Option[Completion.Language_Context] = |
64621 | 283 |
snapshot.select(range, JEdit_Rendering.language_context_elements, _ => |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
284 |
{ |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
285 |
case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes, delimited), _)) => |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
286 |
if (delimited) Some(Completion.Language_Context(language, symbols, antiquotes)) |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
287 |
else None |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
288 |
case Text.Info(_, elem) |
61598 | 289 |
if elem.name == Markup.ML_STRING || elem.name == Markup.ML_COMMENT => |
55749 | 290 |
Some(Completion.Language_Context.ML_inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
291 |
case Text.Info(_, _) => |
55749 | 292 |
Some(Completion.Language_Context.inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
293 |
}).headOption.map(_.info) |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
294 |
|
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
295 |
def language_path(range: Text.Range): Option[Text.Range] = |
64621 | 296 |
snapshot.select(range, JEdit_Rendering.language_elements, _ => |
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
297 |
{ |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
298 |
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
|
299 |
Some(snapshot.convert(info_range)) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
300 |
case _ => None |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
301 |
}).headOption.map(_.info) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
302 |
|
58592 | 303 |
def citation(range: Text.Range): Option[Text.Info[String]] = |
64621 | 304 |
snapshot.select(range, JEdit_Rendering.citation_elements, _ => |
58592 | 305 |
{ |
306 |
case Text.Info(info_range, XML.Elem(Markup.Citation(name), _)) => |
|
307 |
Some(Text.Info(snapshot.convert(info_range), name)) |
|
308 |
case _ => None |
|
309 |
}).headOption.map(_.info) |
|
310 |
||
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
311 |
|
56551 | 312 |
/* spell checker */ |
56548 | 313 |
|
56551 | 314 |
private lazy val spell_checker_elements = |
56743 | 315 |
Markup.Elements(space_explode(',', options.string("spell_checker_elements")): _*) |
56551 | 316 |
|
317 |
def spell_checker_ranges(range: Text.Range): List[Text.Range] = |
|
318 |
snapshot.select(range, spell_checker_elements, _ => _ => Some(())).map(_.range) |
|
56548 | 319 |
|
56564
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
320 |
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
|
321 |
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
|
322 |
{ |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
323 |
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
|
324 |
}).headOption.map(_.info) |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
325 |
|
56548 | 326 |
|
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
327 |
/* breakpoints */ |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
328 |
|
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
329 |
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
|
330 |
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
|
331 |
else |
64621 | 332 |
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
|
333 |
{ |
60882 | 334 |
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
|
335 |
command_states match { |
60882 | 336 |
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
|
337 |
case _ => None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
338 |
} |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
339 |
case _ => None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
340 |
}).headOption.map(_.info) |
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
341 |
|
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
342 |
|
55626 | 343 |
/* command status overview */ |
49356 | 344 |
|
345 |
def overview_color(range: Text.Range): Option[Color] = |
|
346 |
{ |
|
347 |
if (snapshot.is_outdated) None |
|
348 |
else { |
|
349 |
val results = |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
350 |
snapshot.cumulate[List[Markup]](range, Nil, Protocol.liberal_status_elements, _ => |
49356 | 351 |
{ |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
352 |
case (status, Text.Info(_, elem)) => Some(elem.markup :: status) |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
353 |
}, status = true) |
49356 | 354 |
if (results.isEmpty) None |
355 |
else { |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
356 |
val status = Protocol.Status.make(results.iterator.flatMap(_.info)) |
49356 | 357 |
|
50895 | 358 |
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
|
359 |
else if (status.is_failed) Some(error_color) |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
360 |
else if (status.is_warned) Some(warning_color) |
49356 | 361 |
else if (status.is_unprocessed) Some(unprocessed_color) |
362 |
else None |
|
363 |
} |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
||
62986 | 368 |
/* caret focus */ |
369 |
||
63544
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
370 |
def entity_focus(range: Text.Range, |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
371 |
check: (Boolean, Long) => Boolean = (is_def: Boolean, i: Long) => is_def): Set[Long] = |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
372 |
{ |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
373 |
val results = |
64621 | 374 |
snapshot.cumulate[Set[Long]](range, Set.empty, JEdit_Rendering.caret_focus_elements, _ => |
63544
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
375 |
{ |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
376 |
case (serials, Text.Info(_, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
377 |
props match { |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
378 |
case Markup.Entity.Def(i) if check(true, i) => Some(serials + i) |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
379 |
case Markup.Entity.Ref(i) if check(false, i) => Some(serials + i) |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
380 |
case _ => None |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
381 |
} |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
382 |
case _ => None |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
383 |
}) |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
384 |
(Set.empty[Long] /: results){ case (s1, Text.Info(_, s2)) => s1 ++ s2 } |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
385 |
} |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
386 |
|
62986 | 387 |
def caret_focus(caret_range: Text.Range, visible_range: Text.Range): Set[Long] = |
388 |
{ |
|
63544
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
389 |
val focus_defs = entity_focus(caret_range) |
63234
2eb2ff479cfe
clarified focus_defs vs. focus_refs, e.g. relevant for @{here} where this overlaps;
wenzelm
parents:
62991
diff
changeset
|
390 |
if (focus_defs.nonEmpty) focus_defs |
2eb2ff479cfe
clarified focus_defs vs. focus_refs, e.g. relevant for @{here} where this overlaps;
wenzelm
parents:
62991
diff
changeset
|
391 |
else { |
63544
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
392 |
val visible_defs = entity_focus(visible_range) |
e0cd6469a6b8
clarified def vs. ref focus, e.g. for calculation vs. command refs;
wenzelm
parents:
63474
diff
changeset
|
393 |
entity_focus(caret_range, (is_def: Boolean, i: Long) => !is_def && visible_defs.contains(i)) |
63234
2eb2ff479cfe
clarified focus_defs vs. focus_refs, e.g. relevant for @{here} where this overlaps;
wenzelm
parents:
62991
diff
changeset
|
394 |
} |
62986 | 395 |
} |
396 |
||
63236 | 397 |
def caret_focus_ranges(caret_range: Text.Range, visible_range: Text.Range): List[Text.Range] = |
398 |
{ |
|
399 |
val focus = caret_focus(caret_range, visible_range) |
|
400 |
if (focus.nonEmpty) { |
|
401 |
val results = |
|
64621 | 402 |
snapshot.cumulate[Boolean](visible_range, false, JEdit_Rendering.caret_focus_elements, _ => |
63236 | 403 |
{ |
404 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
|
405 |
props match { |
|
406 |
case Markup.Entity.Def(i) if focus(i) => Some(true) |
|
407 |
case Markup.Entity.Ref(i) if focus(i) => Some(true) |
|
408 |
case _ => None |
|
409 |
} |
|
410 |
}) |
|
411 |
for (info <- results if info.info) yield info.range |
|
412 |
} |
|
413 |
else Nil |
|
414 |
} |
|
415 |
||
62991 | 416 |
def entity_ref(range: Text.Range, focus: Set[Long]): List[Text.Info[Color]] = |
64621 | 417 |
snapshot.select(range, JEdit_Rendering.caret_focus_elements, _ => |
62988 | 418 |
{ |
62991 | 419 |
case Text.Info(_, XML.Elem(Markup(Markup.ENTITY, Markup.Entity.Ref(i)), _)) if focus(i) => |
420 |
Some(entity_ref_color) |
|
62988 | 421 |
case _ => None |
422 |
}) |
|
423 |
||
62986 | 424 |
|
55626 | 425 |
/* highlighted area */ |
49356 | 426 |
|
49358 | 427 |
def highlight(range: Text.Range): Option[Text.Info[Color]] = |
64621 | 428 |
snapshot.select(range, JEdit_Rendering.highlight_elements, _ => |
55620 | 429 |
{ |
430 |
case info => Some(Text.Info(snapshot.convert(info.range), highlight_color)) |
|
55689 | 431 |
}).headOption.map(_.info) |
49356 | 432 |
|
433 |
||
55626 | 434 |
/* hyperlinks */ |
435 |
||
52980 | 436 |
def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] = |
49356 | 437 |
{ |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
438 |
snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]]( |
64621 | 439 |
range, Vector.empty, JEdit_Rendering.hyperlink_elements, _ => |
49356 | 440 |
{ |
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
441 |
case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) => |
64654 | 442 |
val file = resources.append_file(snapshot.node_name.master_dir, name) |
443 |
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
|
444 |
Some(links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 445 |
|
61660
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
446 |
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
|
447 |
PIDE.editor.hyperlink_doc(name).map(link => |
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
448 |
(links :+ Text.Info(snapshot.convert(info_range), link))) |
78b371644654
added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents:
61603
diff
changeset
|
449 |
|
54702
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
|
64660 | 454 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
60893 | 455 |
val opt_link = PIDE.editor.hyperlink_def_position(true, snapshot, props) |
60215 | 456 |
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 457 |
|
55545 | 458 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) => |
60893 | 459 |
val opt_link = PIDE.editor.hyperlink_position(true, snapshot, props) |
60215 | 460 |
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
|
461 |
|
58545
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
462 |
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
|
463 |
val opt_link = |
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
464 |
Bibtex_JEdit.entries_iterator.collectFirst( |
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
465 |
{ case (a, buffer, offset) if a == name => |
60893 | 466 |
PIDE.editor.hyperlink_buffer(true, buffer, offset) }) |
60215 | 467 |
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
|
468 |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
469 |
case _ => None |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
470 |
}) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None } |
49356 | 471 |
} |
472 |
||
473 |
||
55626 | 474 |
/* active elements */ |
475 |
||
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
476 |
def active(range: Text.Range): Option[Text.Info[XML.Elem]] = |
64621 | 477 |
snapshot.select(range, JEdit_Rendering.active_elements, command_states => |
55620 | 478 |
{ |
479 |
case Text.Info(info_range, elem) => |
|
55623 | 480 |
if (elem.name == Markup.DIALOG) { |
481 |
elem match { |
|
482 |
case Protocol.Dialog(_, serial, _) |
|
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
483 |
if !command_states.exists(st => st.results.defined(serial)) => |
55623 | 484 |
Some(Text.Info(snapshot.convert(info_range), elem)) |
485 |
case _ => None |
|
486 |
} |
|
487 |
} |
|
488 |
else Some(Text.Info(snapshot.convert(info_range), elem)) |
|
55689 | 489 |
}).headOption.map(_.info) |
49492 | 490 |
|
50502 | 491 |
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
|
492 |
Command.State.merge_results( |
56743 | 493 |
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
|
494 |
{ case _ => Some(command_states) }).flatMap(_.info)) |
50502 | 495 |
|
55626 | 496 |
|
497 |
/* tooltip messages */ |
|
498 |
||
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
499 |
def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 500 |
{ |
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
501 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
502 |
snapshot.cumulate[List[Text.Info[Command.Results.Entry]]]( |
64621 | 503 |
range, Nil, JEdit_Rendering.tooltip_message_elements, _ => |
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
504 |
{ |
64677
8dc24130e8fe
more uniform treatment of "bad" like other messages (with serial number);
wenzelm
parents:
64676
diff
changeset
|
505 |
case (msgs, Text.Info(info_range, |
8dc24130e8fe
more uniform treatment of "bad" like other messages (with serial number);
wenzelm
parents:
64676
diff
changeset
|
506 |
XML.Elem(Markup(name, props @ Markup.Serial(serial)), body))) |
59319 | 507 |
if body.nonEmpty => |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
508 |
val entry: Command.Results.Entry = |
60215 | 509 |
serial -> XML.Elem(Markup(Markup.message(name), props), body) |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
510 |
Some(Text.Info(snapshot.convert(info_range), entry) :: msgs) |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
511 |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
512 |
case _ => None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
513 |
}).flatMap(_.info) |
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
514 |
if (results.isEmpty) None |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
515 |
else { |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
516 |
val r = Text.Range(results.head.range.start, results.last.range.stop) |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
517 |
val msgs = Command.Results.make(results.map(_.info)) |
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
518 |
Some(Text.Info(r, Pretty.separate(msgs.iterator.map(_._2).toList))) |
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
519 |
} |
49356 | 520 |
} |
521 |
||
522 |
||
55626 | 523 |
/* tooltips */ |
524 |
||
55647 | 525 |
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
|
526 |
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
|
527 |
|
64748 | 528 |
def tooltip(range: Text.Range): Option[Text.Info[XML.Body]] = |
529 |
tooltips(range).map({ case Text.Info(r, all_tips) => |
|
530 |
Text.Info(r, Library.separate(Pretty.fbrk, all_tips)) }) |
|
531 |
||
52873 | 532 |
lazy val tooltip_close_icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon")) |
533 |
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
|
534 |
|
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
535 |
|
56495 | 536 |
/* gutter */ |
537 |
||
538 |
private def gutter_message_pri(msg: XML.Tree): Int = |
|
64676 | 539 |
if (Protocol.is_error(msg)) Rendering.error_pri |
540 |
else if (Protocol.is_legacy(msg)) Rendering.legacy_pri |
|
541 |
else if (Protocol.is_warning(msg)) Rendering.warning_pri |
|
542 |
else if (Protocol.is_information(msg)) Rendering.information_pri |
|
56495 | 543 |
else 0 |
55626 | 544 |
|
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
545 |
private lazy val gutter_message_content = Map( |
64676 | 546 |
Rendering.information_pri -> |
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
547 |
(JEdit_Lib.load_icon(options.string("gutter_information_icon")), information_message_color), |
64676 | 548 |
Rendering.warning_pri -> |
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
549 |
(JEdit_Lib.load_icon(options.string("gutter_warning_icon")), warning_message_color), |
64676 | 550 |
Rendering.legacy_pri -> |
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
551 |
(JEdit_Lib.load_icon(options.string("gutter_legacy_icon")), warning_message_color), |
64676 | 552 |
Rendering.error_pri -> |
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
553 |
(JEdit_Lib.load_icon(options.string("gutter_error_icon")), error_message_color)) |
49356 | 554 |
|
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
555 |
def gutter_content(range: Text.Range): Option[(Icon, Color)] = |
49356 | 556 |
{ |
56495 | 557 |
val pris = |
64621 | 558 |
snapshot.cumulate[Int](range, 0, JEdit_Rendering.gutter_elements, _ => |
49356 | 559 |
{ |
56495 | 560 |
case (pri, Text.Info(_, msg @ XML.Elem(Markup(_, Markup.Serial(serial)), _))) => |
561 |
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
|
562 |
case _ => None |
56495 | 563 |
}).map(_.info) |
564 |
||
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
565 |
gutter_message_content.get((0 /: pris)(_ max _)) |
49356 | 566 |
} |
567 |
||
568 |
||
55626 | 569 |
/* squiggly underline */ |
570 |
||
55647 | 571 |
private lazy val squiggly_colors = Map( |
64676 | 572 |
Rendering.writeln_pri -> writeln_color, |
573 |
Rendering.information_pri -> information_color, |
|
574 |
Rendering.warning_pri -> warning_color, |
|
575 |
Rendering.legacy_pri -> legacy_color, |
|
576 |
Rendering.error_pri -> error_color) |
|
49356 | 577 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
578 |
def squiggly_underline(range: Text.Range): List[Text.Info[Color]] = |
49356 | 579 |
{ |
580 |
val results = |
|
64621 | 581 |
snapshot.cumulate[Int](range, 0, JEdit_Rendering.squiggly_elements, _ => |
49356 | 582 |
{ |
64676 | 583 |
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name)) |
49356 | 584 |
}) |
585 |
for { |
|
586 |
Text.Info(r, pri) <- results |
|
587 |
color <- squiggly_colors.get(pri) |
|
588 |
} yield Text.Info(r, color) |
|
589 |
} |
|
590 |
||
49474 | 591 |
|
55626 | 592 |
/* message output */ |
593 |
||
55647 | 594 |
private lazy val message_colors = Map( |
64676 | 595 |
Rendering.writeln_pri -> writeln_message_color, |
596 |
Rendering.information_pri -> information_message_color, |
|
597 |
Rendering.tracing_pri -> tracing_message_color, |
|
598 |
Rendering.warning_pri -> warning_message_color, |
|
599 |
Rendering.legacy_pri -> legacy_message_color, |
|
600 |
Rendering.error_pri -> error_message_color) |
|
49474 | 601 |
|
49473 | 602 |
def line_background(range: Text.Range): Option[(Color, Boolean)] = |
603 |
{ |
|
49474 | 604 |
val results = |
64621 | 605 |
snapshot.cumulate[Int](range, 0, JEdit_Rendering.line_background_elements, _ => |
49473 | 606 |
{ |
64676 | 607 |
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name)) |
49474 | 608 |
}) |
609 |
val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
|
610 |
||
61719
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
611 |
message_colors.get(pri).map(message_color => |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
612 |
{ |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
613 |
val is_separator = |
64621 | 614 |
snapshot.cumulate[Boolean](range, false, JEdit_Rendering.separator_elements, _ => |
61719
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
615 |
{ |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
616 |
case _ => Some(true) |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
617 |
}).exists(_.info) |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
618 |
(message_color, is_separator) |
318f324d41f5
less intrusive rendering, notably for State dockable;
wenzelm
parents:
61718
diff
changeset
|
619 |
}) |
49473 | 620 |
} |
49356 | 621 |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
622 |
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
|
623 |
{ |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
624 |
val (states, other) = |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
625 |
results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
626 |
.partition(Protocol.is_state(_)) |
61727
6f1a84d78865
reverted 2abbe7d700e9: "state" output is not necessarily proof state;
wenzelm
parents:
61722
diff
changeset
|
627 |
states ::: other |
57691
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
628 |
} |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
629 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
630 |
|
55626 | 631 |
/* text background */ |
632 |
||
62986 | 633 |
def background(range: Text.Range, focus: Set[Long]): List[Text.Info[Color]] = |
49356 | 634 |
{ |
61722
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
635 |
for { |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
636 |
Text.Info(r, result) <- |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
637 |
snapshot.cumulate[(List[Markup], Option[Color])]( |
64621 | 638 |
range, (List(Markup.Empty), None), JEdit_Rendering.background_elements, |
61722
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
639 |
command_states => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
640 |
{ |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
641 |
case (((status, color), Text.Info(_, XML.Elem(markup, _)))) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
642 |
if status.nonEmpty && Protocol.proper_status_elements(markup.name) => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
643 |
Some((markup :: status, color)) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
644 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
645 |
Some((Nil, Some(bad_color))) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
646 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
647 |
Some((Nil, Some(intensify_color))) |
62986 | 648 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
649 |
props match { |
|
62988 | 650 |
case Markup.Entity.Def(i) if focus(i) => Some((Nil, Some(entity_color))) |
651 |
case Markup.Entity.Ref(i) if focus(i) => Some((Nil, Some(entity_color))) |
|
62986 | 652 |
case _ => None |
653 |
} |
|
61722
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
654 |
case (_, Text.Info(_, XML.Elem(Markup.Markdown_Item(depth), _))) => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
655 |
val color = |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
656 |
depth match { |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
657 |
case 1 => markdown_item_color1 |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
658 |
case 2 => markdown_item_color2 |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
659 |
case 3 => markdown_item_color3 |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
660 |
case _ => markdown_item_color4 |
55647 | 661 |
} |
61722
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
662 |
Some((Nil, Some(color))) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
663 |
case (acc, Text.Info(_, Protocol.Dialog(_, serial, result))) => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
664 |
command_states.collectFirst( |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
665 |
{ case st if st.results.defined(serial) => st.results.get(serial).get }) match |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
666 |
{ |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
667 |
case Some(Protocol.Dialog_Result(res)) if res == result => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
668 |
Some((Nil, Some(active_result_color))) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
669 |
case _ => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
670 |
Some((Nil, Some(active_color))) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
671 |
} |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
672 |
case (_, Text.Info(_, elem)) => |
64621 | 673 |
if (JEdit_Rendering.active_elements(elem.name)) Some((Nil, Some(active_color))) |
61722
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
674 |
else None |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
675 |
}) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
676 |
color <- |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
677 |
(result match { |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
678 |
case (markups, opt_color) if markups.nonEmpty => |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
679 |
val status = Protocol.Status.make(markups.iterator) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
680 |
if (status.is_unprocessed) Some(unprocessed1_color) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
681 |
else if (status.is_running) Some(running1_color) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
682 |
else opt_color |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
683 |
case (_, opt_color) => opt_color |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
684 |
}) |
a8fb3e379ba7
avoid flashing of main text area (visual "grey-out") due to spurious edits, e.g. State panel auto-update;
wenzelm
parents:
61719
diff
changeset
|
685 |
} yield Text.Info(r, color) |
49356 | 686 |
} |
687 |
||
688 |
||
55626 | 689 |
/* text foreground */ |
51574
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
690 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
691 |
def foreground(range: Text.Range): List[Text.Info[Color]] = |
64621 | 692 |
snapshot.select(range, JEdit_Rendering.foreground_elements, _ => |
49356 | 693 |
{ |
52890 | 694 |
case Text.Info(_, elem) => |
55620 | 695 |
if (elem.name == Markup.ANTIQUOTED) Some(antiquoted_color) else Some(quoted_color) |
49356 | 696 |
}) |
697 |
||
698 |
||
55626 | 699 |
/* text color */ |
700 |
||
61175 | 701 |
val foreground_color = jEdit.getColorProperty("view.fgColor") |
702 |
||
55647 | 703 |
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
|
704 |
Markup.KEYWORD1 -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
705 |
Markup.KEYWORD2 -> keyword2_color, |
55765 | 706 |
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
|
707 |
Markup.QUASI_KEYWORD -> quasi_keyword_color, |
56202 | 708 |
Markup.IMPROPER -> improper_color, |
56064 | 709 |
Markup.OPERATOR -> operator_color, |
61175 | 710 |
Markup.STRING -> foreground_color, |
711 |
Markup.ALT_STRING -> foreground_color, |
|
712 |
Markup.VERBATIM -> foreground_color, |
|
713 |
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
|
714 |
Markup.LITERAL -> keyword1_color, |
61175 | 715 |
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
|
716 |
Markup.TFREE -> tfree_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
717 |
Markup.TVAR -> tvar_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
718 |
Markup.FREE -> free_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
719 |
Markup.SKOLEM -> skolem_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
720 |
Markup.BOUND -> bound_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
721 |
Markup.VAR -> var_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
722 |
Markup.INNER_STRING -> inner_quoted_color, |
55033 | 723 |
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
|
724 |
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
|
725 |
Markup.DYNAMIC_FACT -> dynamic_color, |
63347 | 726 |
Markup.CLASS_PARAMETER -> class_parameter_color, |
55526 | 727 |
Markup.ANTIQUOTE -> antiquote_color, |
55505 | 728 |
Markup.ML_KEYWORD1 -> keyword1_color, |
729 |
Markup.ML_KEYWORD2 -> keyword2_color, |
|
730 |
Markup.ML_KEYWORD3 -> keyword3_color, |
|
61175 | 731 |
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
|
732 |
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
|
733 |
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
|
734 |
Markup.ML_STRING -> inner_quoted_color, |
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
735 |
Markup.ML_COMMENT -> inner_comment_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
736 |
Markup.SML_STRING -> inner_quoted_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
737 |
Markup.SML_COMMENT -> inner_comment_color) |
49356 | 738 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
739 |
private lazy val text_color_elements = |
56743 | 740 |
Markup.Elements(text_colors.keySet) |
49356 | 741 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
742 |
def text_color(range: Text.Range, color: Color): List[Text.Info[Color]] = |
49356 | 743 |
{ |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
744 |
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
|
745 |
else |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
746 |
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
|
747 |
{ |
52890 | 748 |
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
|
749 |
}) |
49356 | 750 |
} |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
751 |
|
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
752 |
|
55626 | 753 |
/* virtual bullets */ |
754 |
||
755 |
def bullet(range: Text.Range): List[Text.Info[Color]] = |
|
64621 | 756 |
snapshot.select(range, JEdit_Rendering.bullet_elements, _ => |
60913 | 757 |
{ |
758 |
case Text.Info(_, Protocol.ML_Breakpoint(breakpoint)) => |
|
759 |
Debugger.active_breakpoint_state(breakpoint).map(b => |
|
760 |
if (b) breakpoint_enabled_color else breakpoint_disabled_color) |
|
761 |
case _ => Some(bullet_color) |
|
762 |
}) |
|
55626 | 763 |
|
764 |
||
765 |
/* text folds */ |
|
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
766 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
767 |
def fold_depth(range: Text.Range): List[Text.Info[Int]] = |
64621 | 768 |
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
|
769 |
{ |
55620 | 770 |
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
|
771 |
}) |
49356 | 772 |
} |