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