author | wenzelm |
Wed, 16 Apr 2014 09:38:40 +0200 | |
changeset 56599 | c4424d8c890f |
parent 56564 | 94c55cc73747 |
child 56600 | 628e039cc34d |
permissions | -rw-r--r-- |
50202 | 1 |
/* Title: Tools/jEdit/src/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 |
|
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
4 |
Isabelle-specific implementation of quasi-abstract rendering and |
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} |
53272 | 17 |
import org.gjt.sp.jedit.{jEdit, View} |
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 |
|
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
22 |
object Rendering |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
23 |
{ |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
24 |
def apply(snapshot: Document.Snapshot, options: Options): Rendering = |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
25 |
new 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 |
|
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
|
30 |
private val writeln_pri = 1 |
52644 | 31 |
private val information_pri = 2 |
32 |
private val tracing_pri = 3 |
|
33 |
private val warning_pri = 4 |
|
34 |
private val legacy_pri = 5 |
|
35 |
private val error_pri = 6 |
|
49474 | 36 |
|
37 |
private val message_pri = Map( |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
38 |
Markup.WRITELN -> writeln_pri, Markup.WRITELN_MESSAGE -> writeln_pri, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
39 |
Markup.TRACING -> tracing_pri, Markup.TRACING_MESSAGE -> tracing_pri, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
40 |
Markup.WARNING -> warning_pri, Markup.WARNING_MESSAGE -> warning_pri, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
41 |
Markup.ERROR -> error_pri, Markup.ERROR_MESSAGE -> error_pri) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
42 |
|
49406 | 43 |
|
53230 | 44 |
/* popup window bounds */ |
45 |
||
46 |
def popup_bounds: Double = (PIDE.options.real("jedit_popup_bounds") max 0.2) min 0.8 |
|
47 |
||
48 |
||
55501 | 49 |
/* Isabelle/Isar token markup */ |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
50 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
51 |
private val command_style: Map[String, Byte] = |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
52 |
{ |
43414 | 53 |
import JEditToken._ |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
54 |
Map[String, Byte]( |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
55 |
Keyword.THY_END -> KEYWORD2, |
53571
e58ca0311c0f
more explicit indication of 'done' as proof script element;
wenzelm
parents:
53371
diff
changeset
|
56 |
Keyword.QED_SCRIPT -> DIGIT, |
50643 | 57 |
Keyword.PRF_SCRIPT -> DIGIT, |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
58 |
Keyword.PRF_ASM -> KEYWORD3, |
53371
47b23c582127
more explicit indication of 'guess' as improper Isar (aka "script") element;
wenzelm
parents:
53272
diff
changeset
|
59 |
Keyword.PRF_ASM_GOAL -> KEYWORD3, |
47b23c582127
more explicit indication of 'guess' as improper Isar (aka "script") element;
wenzelm
parents:
53272
diff
changeset
|
60 |
Keyword.PRF_ASM_GOAL_SCRIPT -> DIGIT |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
61 |
).withDefaultValue(KEYWORD1) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
62 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
63 |
|
43414 | 64 |
private val token_style: Map[Token.Kind.Value, Byte] = |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
65 |
{ |
43414 | 66 |
import JEditToken._ |
67 |
Map[Token.Kind.Value, Byte]( |
|
68 |
Token.Kind.KEYWORD -> KEYWORD2, |
|
69 |
Token.Kind.IDENT -> NULL, |
|
70 |
Token.Kind.LONG_IDENT -> NULL, |
|
71 |
Token.Kind.SYM_IDENT -> NULL, |
|
72 |
Token.Kind.VAR -> NULL, |
|
73 |
Token.Kind.TYPE_IDENT -> NULL, |
|
74 |
Token.Kind.TYPE_VAR -> NULL, |
|
75 |
Token.Kind.NAT -> NULL, |
|
76 |
Token.Kind.FLOAT -> NULL, |
|
43431 | 77 |
Token.Kind.STRING -> LITERAL1, |
78 |
Token.Kind.ALT_STRING -> LITERAL2, |
|
43414 | 79 |
Token.Kind.VERBATIM -> COMMENT3, |
55033 | 80 |
Token.Kind.CARTOUCHE -> COMMENT4, |
43414 | 81 |
Token.Kind.SPACE -> NULL, |
82 |
Token.Kind.COMMENT -> COMMENT1, |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48751
diff
changeset
|
83 |
Token.Kind.ERROR -> INVALID |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
84 |
).withDefaultValue(NULL) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
85 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
86 |
|
43414 | 87 |
def token_markup(syntax: Outer_Syntax, token: Token): Byte = |
43430
1ed88ddf1268
more uniform treatment of "keyword" vs. "operator";
wenzelm
parents:
43418
diff
changeset
|
88 |
if (token.is_command) command_style(syntax.keyword_kind(token.content).getOrElse("")) |
55505 | 89 |
else if (token.is_delimiter) JEditToken.OPERATOR |
43414 | 90 |
else token_style(token.kind) |
55500 | 91 |
|
55501 | 92 |
|
93 |
/* Isabelle/ML token markup */ |
|
94 |
||
55500 | 95 |
private val ml_token_style: Map[ML_Lex.Kind.Value, Byte] = |
96 |
{ |
|
97 |
import JEditToken._ |
|
98 |
Map[ML_Lex.Kind.Value, Byte]( |
|
55505 | 99 |
ML_Lex.Kind.KEYWORD -> NULL, |
55500 | 100 |
ML_Lex.Kind.IDENT -> NULL, |
101 |
ML_Lex.Kind.LONG_IDENT -> NULL, |
|
102 |
ML_Lex.Kind.TYPE_VAR -> NULL, |
|
55503 | 103 |
ML_Lex.Kind.WORD -> DIGIT, |
104 |
ML_Lex.Kind.INT -> DIGIT, |
|
105 |
ML_Lex.Kind.REAL -> DIGIT, |
|
55500 | 106 |
ML_Lex.Kind.CHAR -> LITERAL2, |
107 |
ML_Lex.Kind.STRING -> LITERAL1, |
|
108 |
ML_Lex.Kind.SPACE -> NULL, |
|
109 |
ML_Lex.Kind.COMMENT -> COMMENT1, |
|
55512 | 110 |
ML_Lex.Kind.ANTIQ -> NULL, |
111 |
ML_Lex.Kind.ANTIQ_START -> LITERAL4, |
|
112 |
ML_Lex.Kind.ANTIQ_STOP -> LITERAL4, |
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
ML_Lex.Kind.ANTIQ_CARTOUCHE -> NULL, |
55500 | 117 |
ML_Lex.Kind.ERROR -> INVALID |
118 |
).withDefaultValue(NULL) |
|
119 |
} |
|
120 |
||
121 |
def ml_token_markup(token: ML_Lex.Token): Byte = |
|
55501 | 122 |
if (!token.is_keyword) ml_token_style(token.kind) |
55505 | 123 |
else if (token.is_delimiter) JEditToken.OPERATOR |
124 |
else if (ML_Lex.keywords2(token.source)) JEditToken.KEYWORD2 |
|
125 |
else if (ML_Lex.keywords3(token.source)) JEditToken.KEYWORD3 |
|
55501 | 126 |
else JEditToken.KEYWORD1 |
55647 | 127 |
|
128 |
||
129 |
/* markup elements */ |
|
130 |
||
56173 | 131 |
private val semantic_completion_elements = |
55914
c5b752d549e3
clarified init_assignable: make double-sure that initial values are reset;
wenzelm
parents:
55883
diff
changeset
|
132 |
Document.Elements(Markup.COMPLETION, Markup.NO_COMPLETION) |
55674 | 133 |
|
56173 | 134 |
private val language_context_elements = |
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
135 |
Document.Elements(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM, |
55647 | 136 |
Markup.CARTOUCHE, Markup.COMMENT, Markup.LANGUAGE, |
137 |
Markup.ML_STRING, Markup.ML_COMMENT) |
|
138 |
||
139 |
private val highlight_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
140 |
Document.Elements(Markup.LANGUAGE, Markup.ML_TYPING, Markup.TOKEN_RANGE, |
55647 | 141 |
Markup.ENTITY, Markup.PATH, Markup.URL, Markup.SORTING, |
142 |
Markup.TYPING, Markup.FREE, Markup.SKOLEM, Markup.BOUND, |
|
143 |
Markup.VAR, Markup.TFREE, Markup.TVAR) |
|
144 |
||
145 |
private val hyperlink_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
146 |
Document.Elements(Markup.ENTITY, Markup.PATH, Markup.POSITION, Markup.URL) |
55647 | 147 |
|
148 |
private val active_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
149 |
Document.Elements(Markup.DIALOG, Markup.BROWSER, Markup.GRAPHVIEW, |
55647 | 150 |
Markup.SENDBACK, Markup.SIMP_TRACE) |
151 |
||
152 |
private val tooltip_message_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
153 |
Document.Elements(Markup.WRITELN, Markup.WARNING, Markup.ERROR, Markup.BAD) |
55647 | 154 |
|
155 |
private val tooltip_descriptions = |
|
156 |
Map( |
|
157 |
Markup.TOKEN_RANGE -> "inner syntax token", |
|
158 |
Markup.FREE -> "free variable", |
|
159 |
Markup.SKOLEM -> "skolem variable", |
|
160 |
Markup.BOUND -> "bound variable", |
|
161 |
Markup.VAR -> "schematic variable", |
|
162 |
Markup.TFREE -> "free type variable", |
|
163 |
Markup.TVAR -> "schematic type variable") |
|
164 |
||
165 |
private val tooltip_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
166 |
Document.Elements(Markup.LANGUAGE, Markup.TIMING, Markup.ENTITY, Markup.SORTING, |
55647 | 167 |
Markup.TYPING, Markup.ML_TYPING, Markup.PATH, Markup.URL) ++ |
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
168 |
Document.Elements(tooltip_descriptions.keySet) |
55647 | 169 |
|
170 |
private val gutter_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
171 |
Document.Elements(Markup.WRITELN, Markup.WARNING, Markup.ERROR) |
55647 | 172 |
|
173 |
private val squiggly_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
174 |
Document.Elements(Markup.WRITELN, Markup.WARNING, Markup.ERROR) |
55647 | 175 |
|
176 |
private val line_background_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
177 |
Document.Elements(Markup.WRITELN_MESSAGE, Markup.TRACING_MESSAGE, |
55647 | 178 |
Markup.WARNING_MESSAGE, Markup.ERROR_MESSAGE, |
179 |
Markup.INFORMATION) |
|
180 |
||
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
181 |
private val separator_elements = |
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
182 |
Document.Elements(Markup.SEPARATOR) |
55647 | 183 |
|
55790
4670f18baba5
simplified rendering -- no need to over-emphasize "token_range";
wenzelm
parents:
55765
diff
changeset
|
184 |
private val background_elements = |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
185 |
Protocol.proper_status_elements + Markup.WRITELN_MESSAGE + |
55647 | 186 |
Markup.TRACING_MESSAGE + Markup.WARNING_MESSAGE + |
187 |
Markup.ERROR_MESSAGE + Markup.BAD + Markup.INTENSIFY ++ |
|
188 |
active_elements |
|
189 |
||
190 |
private val foreground_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
191 |
Document.Elements(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM, |
55647 | 192 |
Markup.CARTOUCHE, Markup.ANTIQUOTED) |
193 |
||
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
194 |
private val bullet_elements = |
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
195 |
Document.Elements(Markup.BULLET) |
55647 | 196 |
|
197 |
private val fold_depth_elements = |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
198 |
Document.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
|
199 |
} |
49356 | 200 |
|
201 |
||
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
202 |
class Rendering private(val snapshot: Document.Snapshot, val options: Options) |
49356 | 203 |
{ |
55710 | 204 |
override def toString: String = "Rendering(" + snapshot.toString + ")" |
205 |
||
206 |
||
49356 | 207 |
/* colors */ |
208 |
||
209 |
def color_value(s: String): Color = Color_Value(options.string(s)) |
|
210 |
||
211 |
val outdated_color = color_value("outdated_color") |
|
212 |
val unprocessed_color = color_value("unprocessed_color") |
|
213 |
val unprocessed1_color = color_value("unprocessed1_color") |
|
214 |
val running_color = color_value("running_color") |
|
215 |
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
|
216 |
val bullet_color = color_value("bullet_color") |
49706 | 217 |
val tooltip_color = color_value("tooltip_color") |
49356 | 218 |
val writeln_color = color_value("writeln_color") |
52650 | 219 |
val information_color = color_value("information_color") |
49356 | 220 |
val warning_color = color_value("warning_color") |
221 |
val error_color = color_value("error_color") |
|
222 |
val error1_color = color_value("error1_color") |
|
49418 | 223 |
val writeln_message_color = color_value("writeln_message_color") |
52650 | 224 |
val information_message_color = color_value("information_message_color") |
49418 | 225 |
val tracing_message_color = color_value("tracing_message_color") |
226 |
val warning_message_color = color_value("warning_message_color") |
|
227 |
val error_message_color = color_value("error_message_color") |
|
56550 | 228 |
val spell_checker_color = color_value("spell_checker_color") |
49356 | 229 |
val bad_color = color_value("bad_color") |
49358 | 230 |
val intensify_color = color_value("intensify_color") |
49356 | 231 |
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
|
232 |
val antiquoted_color = color_value("antiquoted_color") |
55526 | 233 |
val antiquote_color = color_value("antiquote_color") |
49358 | 234 |
val highlight_color = color_value("highlight_color") |
49356 | 235 |
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
|
236 |
val active_color = color_value("active_color") |
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
237 |
val active_hover_color = color_value("active_hover_color") |
50498 | 238 |
val active_result_color = color_value("active_result_color") |
49356 | 239 |
val keyword1_color = color_value("keyword1_color") |
240 |
val keyword2_color = color_value("keyword2_color") |
|
55505 | 241 |
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
|
242 |
val quasi_keyword_color = color_value("quasi_keyword_color") |
56202 | 243 |
val improper_color = color_value("improper_color") |
56064 | 244 |
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
|
245 |
val caret_invisible_color = color_value("caret_invisible_color") |
55747
bef19c929ba5
more completion rendering: active, semantic, syntactic;
wenzelm
parents:
55746
diff
changeset
|
246 |
val completion_color = color_value("completion_color") |
49356 | 247 |
|
248 |
val tfree_color = color_value("tfree_color") |
|
249 |
val tvar_color = color_value("tvar_color") |
|
250 |
val free_color = color_value("free_color") |
|
251 |
val skolem_color = color_value("skolem_color") |
|
252 |
val bound_color = color_value("bound_color") |
|
253 |
val var_color = color_value("var_color") |
|
254 |
val inner_numeral_color = color_value("inner_numeral_color") |
|
255 |
val inner_quoted_color = color_value("inner_quoted_color") |
|
55033 | 256 |
val inner_cartouche_color = color_value("inner_cartouche_color") |
49356 | 257 |
val inner_comment_color = color_value("inner_comment_color") |
258 |
val dynamic_color = color_value("dynamic_color") |
|
259 |
||
260 |
||
55674 | 261 |
/* completion */ |
262 |
||
56173 | 263 |
def semantic_completion(range: Text.Range): Option[Text.Info[Completion.Semantic]] = |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
264 |
if (snapshot.is_outdated) None |
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
265 |
else { |
56173 | 266 |
snapshot.select(range, Rendering.semantic_completion_elements, _ => |
55688 | 267 |
{ |
56173 | 268 |
case Completion.Semantic.Info(info) => Some(info) |
55688 | 269 |
case _ => None |
270 |
}).headOption.map(_.info) |
|
55674 | 271 |
} |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
272 |
|
56173 | 273 |
def language_context(range: Text.Range): Option[Completion.Language_Context] = |
274 |
snapshot.select(range, Rendering.language_context_elements, _ => |
|
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
275 |
{ |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
276 |
case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes, delimited), _)) => |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
277 |
if (delimited) Some(Completion.Language_Context(language, symbols, antiquotes)) |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
278 |
else None |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
279 |
case Text.Info(_, elem) |
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
280 |
if elem.name == Markup.ML_STRING || elem.name == Markup.ML_COMMENT => |
55749 | 281 |
Some(Completion.Language_Context.ML_inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
282 |
case Text.Info(_, _) => |
55749 | 283 |
Some(Completion.Language_Context.inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
284 |
}).headOption.map(_.info) |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
285 |
|
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
286 |
|
56551 | 287 |
/* spell checker */ |
56548 | 288 |
|
56551 | 289 |
private lazy val spell_checker_elements = |
290 |
Document.Elements(space_explode(',', options.string("spell_checker_elements")): _*) |
|
291 |
||
292 |
def spell_checker_ranges(range: Text.Range): List[Text.Range] = |
|
293 |
snapshot.select(range, spell_checker_elements, _ => _ => Some(())).map(_.range) |
|
56548 | 294 |
|
56564
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
295 |
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
|
296 |
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
|
297 |
{ |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
298 |
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
|
299 |
}).headOption.map(_.info) |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
300 |
|
56548 | 301 |
|
55626 | 302 |
/* command status overview */ |
49356 | 303 |
|
55647 | 304 |
def overview_limit: Int = options.int("jedit_text_overview_limit") |
49969
72216713733a
further attempts to cope with large files via option jedit_text_overview_limit;
wenzelm
parents:
49827
diff
changeset
|
305 |
|
49356 | 306 |
def overview_color(range: Text.Range): Option[Color] = |
307 |
{ |
|
308 |
if (snapshot.is_outdated) None |
|
309 |
else { |
|
310 |
val results = |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
311 |
snapshot.cumulate[List[Markup]](range, Nil, Protocol.liberal_status_elements, _ => |
49356 | 312 |
{ |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
313 |
case (status, Text.Info(_, elem)) => Some(elem.markup :: status) |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
314 |
}, status = true) |
49356 | 315 |
if (results.isEmpty) None |
316 |
else { |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
317 |
val status = Protocol.Status.make(results.iterator.flatMap(_.info)) |
49356 | 318 |
|
50895 | 319 |
if (status.is_running) Some(running_color) |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
320 |
else if (status.is_warned) Some(warning_color) |
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
321 |
else if (status.is_failed) Some(error_color) |
49356 | 322 |
else if (status.is_unprocessed) Some(unprocessed_color) |
323 |
else None |
|
324 |
} |
|
325 |
} |
|
326 |
} |
|
327 |
||
328 |
||
55626 | 329 |
/* highlighted area */ |
49356 | 330 |
|
49358 | 331 |
def highlight(range: Text.Range): Option[Text.Info[Color]] = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
332 |
snapshot.select(range, Rendering.highlight_elements, _ => |
55620 | 333 |
{ |
334 |
case info => Some(Text.Info(snapshot.convert(info.range), highlight_color)) |
|
55689 | 335 |
}).headOption.map(_.info) |
49356 | 336 |
|
337 |
||
55626 | 338 |
/* hyperlinks */ |
339 |
||
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
340 |
private def jedit_file(name: String): String = |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
341 |
if (Path.is_valid(name)) |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
342 |
PIDE.resources.append(snapshot.node_name.master_dir, Path.explode(name)) |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
343 |
else name |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
344 |
|
52980 | 345 |
def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] = |
49356 | 346 |
{ |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
347 |
snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]]( |
55647 | 348 |
range, Vector.empty, Rendering.hyperlink_elements, _ => |
49356 | 349 |
{ |
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
350 |
case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) => |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
351 |
val link = PIDE.editor.hyperlink_file(jedit_file(name)) |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
352 |
Some(links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 353 |
|
54702
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
358 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _))) |
49815 | 359 |
if !props.exists( |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
360 |
{ case (Markup.KIND, Markup.ML_OPEN) => true |
55837 | 361 |
case (Markup.KIND, Markup.ML_STRUCTURE) => true |
49815 | 362 |
case _ => false }) => |
55883
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
363 |
val opt_link = |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
364 |
props match { |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
365 |
case Position.Def_Line_File(line, name) => |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
366 |
val offset = Position.Def_Offset.unapply(props) getOrElse 0 |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
367 |
PIDE.editor.hyperlink_source_file(name, line, offset) |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
368 |
case Position.Def_Id_Offset(id, offset) => |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
369 |
PIDE.editor.hyperlink_command_id(snapshot, id, offset) |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
370 |
case _ => None |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
371 |
} |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
372 |
opt_link.map(link => (links :+ Text.Info(snapshot.convert(info_range), link))) |
49356 | 373 |
|
55545 | 374 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) => |
55883
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
375 |
val opt_link = |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
376 |
props match { |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
377 |
case Position.Line_File(line, name) => |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
378 |
val offset = Position.Offset.unapply(props) getOrElse 0 |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
379 |
PIDE.editor.hyperlink_source_file(name, line, offset) |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
380 |
case Position.Id_Offset(id, offset) => |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
381 |
PIDE.editor.hyperlink_command_id(snapshot, id, offset) |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
382 |
case _ => None |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
383 |
} |
6f50d445f0e3
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents:
55879
diff
changeset
|
384 |
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
|
385 |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
386 |
case _ => None |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
387 |
}) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None } |
49356 | 388 |
} |
389 |
||
390 |
||
55626 | 391 |
/* active elements */ |
392 |
||
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
393 |
def active(range: Text.Range): Option[Text.Info[XML.Elem]] = |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
394 |
snapshot.select(range, Rendering.active_elements, command_states => |
55620 | 395 |
{ |
396 |
case Text.Info(info_range, elem) => |
|
55623 | 397 |
if (elem.name == Markup.DIALOG) { |
398 |
elem match { |
|
399 |
case Protocol.Dialog(_, serial, _) |
|
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
400 |
if !command_states.exists(st => st.results.defined(serial)) => |
55623 | 401 |
Some(Text.Info(snapshot.convert(info_range), elem)) |
402 |
case _ => None |
|
403 |
} |
|
404 |
} |
|
405 |
else Some(Text.Info(snapshot.convert(info_range), elem)) |
|
55689 | 406 |
}).headOption.map(_.info) |
49492 | 407 |
|
50502 | 408 |
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
|
409 |
Command.State.merge_results( |
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
410 |
snapshot.select[List[Command.State]](range, Document.Elements.full, command_states => |
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
411 |
{ case _ => Some(command_states) }).flatMap(_.info)) |
50502 | 412 |
|
55626 | 413 |
|
414 |
/* tooltip messages */ |
|
415 |
||
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
|
416 |
def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 417 |
{ |
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
|
418 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
419 |
snapshot.cumulate[List[Text.Info[Command.Results.Entry]]]( |
55647 | 420 |
range, Nil, 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
|
421 |
{ |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
422 |
case (msgs, Text.Info(info_range, |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
423 |
XML.Elem(Markup(name, props @ Markup.Serial(serial)), body))) |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
424 |
if name == Markup.WRITELN || name == Markup.WARNING || name == Markup.ERROR => |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
425 |
val entry: Command.Results.Entry = |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
426 |
(serial -> XML.Elem(Markup(Markup.message(name), props), body)) |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
427 |
Some(Text.Info(snapshot.convert(info_range), entry) :: msgs) |
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
|
428 |
|
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
429 |
case (msgs, Text.Info(info_range, msg @ XML.Elem(Markup(Markup.BAD, _), body))) |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
430 |
if !body.isEmpty => |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52472
diff
changeset
|
431 |
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
|
432 |
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
|
433 |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
434 |
case _ => None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
435 |
}).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
|
436 |
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
|
437 |
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
|
438 |
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
|
439 |
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
|
440 |
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
|
441 |
} |
49356 | 442 |
} |
443 |
||
444 |
||
55626 | 445 |
/* tooltips */ |
446 |
||
49700
2d1cbdf6a68b
Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents:
49674
diff
changeset
|
447 |
private def pretty_typing(kind: String, body: XML.Body): XML.Tree = |
2d1cbdf6a68b
Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents:
49674
diff
changeset
|
448 |
Pretty.block(XML.Text(kind) :: Pretty.Break(1) :: body) |
49356 | 449 |
|
55647 | 450 |
private def timing_threshold: Double = options.real("jedit_timing_threshold") |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
451 |
|
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
|
452 |
def tooltip(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 453 |
{ |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
454 |
def add(prev: Text.Info[(Timing, Vector[(Boolean, XML.Tree)])], |
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
455 |
r0: Text.Range, p: (Boolean, XML.Tree)): Text.Info[(Timing, Vector[(Boolean, XML.Tree)])] = |
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
|
456 |
{ |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
457 |
val r = snapshot.convert(r0) |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
458 |
val (t, info) = prev.info |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
459 |
if (prev.range == r) |
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
460 |
Text.Info(r, (t, info :+ p)) |
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
461 |
else Text.Info(r, (t, Vector(p))) |
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
|
462 |
} |
49356 | 463 |
|
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
|
464 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
465 |
snapshot.cumulate[Text.Info[(Timing, Vector[(Boolean, XML.Tree)])]]( |
55647 | 466 |
range, Text.Info(range, (Timing.zero, Vector.empty)), Rendering.tooltip_elements, _ => |
49356 | 467 |
{ |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
468 |
case (Text.Info(r, (t1, info)), Text.Info(_, XML.Elem(Markup.Timing(t2), _))) => |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
469 |
Some(Text.Info(r, (t1 + t2, info))) |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
470 |
case (prev, Text.Info(r, XML.Elem(Markup.Entity(kind, name), _))) => |
56599 | 471 |
val kind1 = Word.plain_words(kind) |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
472 |
val txt1 = kind1 + " " + quote(name) |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
473 |
val t = prev.info._1 |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
474 |
val txt2 = |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
475 |
if (kind == Markup.COMMAND && t.elapsed.seconds >= timing_threshold) |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
476 |
"\n" + t.message |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
477 |
else "" |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
478 |
Some(add(prev, r, (true, XML.Text(txt1 + txt2)))) |
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
479 |
case (prev, Text.Info(r, XML.Elem(Markup.Path(name), _))) => |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
480 |
val file = jedit_file(name) |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
481 |
val text = |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
482 |
if (name == file) "file " + quote(file) |
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
483 |
else "path " + quote(name) + "\nfile " + quote(file) |
56134 | 484 |
Some(add(prev, r, (true, XML.Text(text)))) |
54702
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
485 |
case (prev, Text.Info(r, XML.Elem(Markup.Url(name), _))) => |
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
486 |
Some(add(prev, r, (true, XML.Text("URL " + quote(name))))) |
49674
dbadb4d03cbc
report sort assignment of visible type variables;
wenzelm
parents:
49554
diff
changeset
|
487 |
case (prev, Text.Info(r, XML.Elem(Markup(name, _), body))) |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
488 |
if name == Markup.SORTING || name == Markup.TYPING => |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
489 |
Some(add(prev, r, (true, pretty_typing("::", body)))) |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
490 |
case (prev, Text.Info(r, XML.Elem(Markup(Markup.ML_TYPING, _), body))) => |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
491 |
Some(add(prev, r, (false, pretty_typing("ML:", body)))) |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
492 |
case (prev, Text.Info(r, XML.Elem(Markup.Language(language, _, _, _), _))) => |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
493 |
Some(add(prev, r, (true, XML.Text("language: " + language)))) |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
494 |
case (prev, Text.Info(r, XML.Elem(Markup(name, _), _))) => |
55647 | 495 |
Rendering.tooltip_descriptions.get(name). |
496 |
map(descr => add(prev, r, (true, XML.Text(descr)))) |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
497 |
}).map(_.info) |
49356 | 498 |
|
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
499 |
results.map(_.info).flatMap(res => res._2.toList) match { |
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
|
500 |
case Nil => 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
|
501 |
case tips => |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
502 |
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
|
503 |
val all_tips = (tips.filter(_._1) ++ tips.filter(!_._1).lastOption.toList).map(_._2) |
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 |
Some(Text.Info(r, Library.separate(Pretty.FBreak, all_tips))) |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
505 |
} |
49356 | 506 |
} |
507 |
||
55647 | 508 |
def tooltip_margin: Int = options.int("jedit_tooltip_margin") |
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
|
509 |
|
52873 | 510 |
lazy val tooltip_close_icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon")) |
511 |
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
|
512 |
|
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
513 |
|
56495 | 514 |
/* gutter */ |
515 |
||
516 |
private def gutter_message_pri(msg: XML.Tree): Int = |
|
517 |
if (Protocol.is_error(msg)) Rendering.error_pri |
|
518 |
else if (Protocol.is_legacy(msg)) Rendering.legacy_pri |
|
519 |
else if (Protocol.is_warning(msg)) Rendering.warning_pri |
|
520 |
else if (Protocol.is_information(msg)) Rendering.information_pri |
|
521 |
else 0 |
|
55626 | 522 |
|
52472
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
523 |
private lazy val gutter_icons = Map( |
52873 | 524 |
Rendering.information_pri -> JEdit_Lib.load_icon(options.string("gutter_information_icon")), |
525 |
Rendering.warning_pri -> JEdit_Lib.load_icon(options.string("gutter_warning_icon")), |
|
526 |
Rendering.legacy_pri -> JEdit_Lib.load_icon(options.string("gutter_legacy_icon")), |
|
527 |
Rendering.error_pri -> JEdit_Lib.load_icon(options.string("gutter_error_icon"))) |
|
49356 | 528 |
|
56495 | 529 |
def gutter_icon(range: Text.Range): Option[Icon] = |
49356 | 530 |
{ |
56495 | 531 |
val pris = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
532 |
snapshot.cumulate[Int](range, 0, Rendering.gutter_elements, _ => |
49356 | 533 |
{ |
56495 | 534 |
case (pri, Text.Info(_, msg @ XML.Elem(Markup(_, Markup.Serial(serial)), _))) => |
535 |
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
|
536 |
case _ => None |
56495 | 537 |
}).map(_.info) |
538 |
||
539 |
gutter_icons.get((0 /: pris)(_ max _)) |
|
49356 | 540 |
} |
541 |
||
542 |
||
55626 | 543 |
/* squiggly underline */ |
544 |
||
55647 | 545 |
private lazy val squiggly_colors = Map( |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
546 |
Rendering.writeln_pri -> writeln_color, |
52650 | 547 |
Rendering.information_pri -> information_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
548 |
Rendering.warning_pri -> warning_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
549 |
Rendering.error_pri -> error_color) |
49356 | 550 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
551 |
def squiggly_underline(range: Text.Range): List[Text.Info[Color]] = |
49356 | 552 |
{ |
553 |
val results = |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
554 |
snapshot.cumulate[Int](range, 0, Rendering.squiggly_elements, _ => |
49356 | 555 |
{ |
52890 | 556 |
case (pri, Text.Info(_, elem)) => |
557 |
if (Protocol.is_information(elem)) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
558 |
Some(pri max Rendering.information_pri) |
55620 | 559 |
else |
52890 | 560 |
Some(pri max Rendering.message_pri(elem.name)) |
49356 | 561 |
}) |
562 |
for { |
|
563 |
Text.Info(r, pri) <- results |
|
564 |
color <- squiggly_colors.get(pri) |
|
565 |
} yield Text.Info(r, color) |
|
566 |
} |
|
567 |
||
49474 | 568 |
|
55626 | 569 |
/* message output */ |
570 |
||
55647 | 571 |
private lazy val message_colors = Map( |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
572 |
Rendering.writeln_pri -> writeln_message_color, |
52650 | 573 |
Rendering.information_pri -> information_message_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
574 |
Rendering.tracing_pri -> tracing_message_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
575 |
Rendering.warning_pri -> warning_message_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
576 |
Rendering.error_pri -> error_message_color) |
49474 | 577 |
|
49473 | 578 |
def line_background(range: Text.Range): Option[(Color, Boolean)] = |
579 |
{ |
|
49474 | 580 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
581 |
snapshot.cumulate[Int](range, 0, Rendering.line_background_elements, _ => |
49473 | 582 |
{ |
52890 | 583 |
case (pri, Text.Info(_, elem)) => |
55623 | 584 |
if (elem.name == Markup.INFORMATION) |
52890 | 585 |
Some(pri max Rendering.information_pri) |
55623 | 586 |
else |
587 |
Some(pri max Rendering.message_pri(elem.name)) |
|
49474 | 588 |
}) |
589 |
val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
|
590 |
||
55623 | 591 |
val is_separator = |
592 |
pri > 0 && |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
593 |
snapshot.cumulate[Boolean](range, false, Rendering.separator_elements, _ => |
49473 | 594 |
{ |
55623 | 595 |
case _ => Some(true) |
49473 | 596 |
}).exists(_.info) |
597 |
||
49474 | 598 |
message_colors.get(pri).map((_, is_separator)) |
49473 | 599 |
} |
49356 | 600 |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
601 |
def output_messages(results: Command.Results): List[XML.Tree] = |
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
56359
diff
changeset
|
602 |
results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
603 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
604 |
|
55626 | 605 |
/* text background */ |
606 |
||
55790
4670f18baba5
simplified rendering -- no need to over-emphasize "token_range";
wenzelm
parents:
55765
diff
changeset
|
607 |
def background(range: Text.Range): List[Text.Info[Color]] = |
49356 | 608 |
{ |
56176
0bc9b0ad6287
tuned rendering -- avoid flashing background of aux. files that are disconnected from the document model;
wenzelm
parents:
56173
diff
changeset
|
609 |
if (snapshot.is_outdated && snapshot.is_loaded) List(Text.Info(range, outdated_color)) |
49356 | 610 |
else |
611 |
for { |
|
612 |
Text.Info(r, result) <- |
|
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
613 |
snapshot.cumulate[(List[Markup], Option[Color])]( |
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
614 |
range, (List(Markup.Empty), None), Rendering.background_elements, |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
615 |
command_states => |
55647 | 616 |
{ |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
617 |
case (((status, color), Text.Info(_, XML.Elem(markup, _)))) |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
618 |
if !status.isEmpty && Protocol.proper_status_elements(markup.name) => |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
619 |
Some((markup :: status, color)) |
55647 | 620 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) => |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
621 |
Some((Nil, Some(bad_color))) |
55647 | 622 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) => |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
623 |
Some((Nil, Some(intensify_color))) |
55647 | 624 |
case (acc, Text.Info(_, Protocol.Dialog(_, serial, result))) => |
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
625 |
command_states.collectFirst( |
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
626 |
{ case st if st.results.defined(serial) => st.results.get(serial).get }) match |
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
627 |
{ |
55647 | 628 |
case Some(Protocol.Dialog_Result(res)) if res == result => |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
629 |
Some((Nil, Some(active_result_color))) |
55647 | 630 |
case _ => |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
631 |
Some((Nil, Some(active_color))) |
55647 | 632 |
} |
633 |
case (_, Text.Info(_, elem)) => |
|
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
634 |
if (Rendering.active_elements(elem.name)) Some((Nil, Some(active_color))) |
55647 | 635 |
else None |
636 |
}) |
|
49356 | 637 |
color <- |
638 |
(result match { |
|
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
639 |
case (markups, opt_color) if !markups.isEmpty => |
56359
bca016a9a18d
persistent protocol_status, to improve performance of node_status a little;
wenzelm
parents:
56354
diff
changeset
|
640 |
val status = Protocol.Status.make(markups.iterator) |
49356 | 641 |
if (status.is_unprocessed) Some(unprocessed1_color) |
642 |
else if (status.is_running) Some(running1_color) |
|
643 |
else opt_color |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
644 |
case (_, opt_color) => opt_color |
49356 | 645 |
}) |
646 |
} yield Text.Info(r, color) |
|
647 |
} |
|
648 |
||
649 |
||
55626 | 650 |
/* text foreground */ |
51574
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
651 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
652 |
def foreground(range: Text.Range): List[Text.Info[Color]] = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
653 |
snapshot.select(range, Rendering.foreground_elements, _ => |
49356 | 654 |
{ |
52890 | 655 |
case Text.Info(_, elem) => |
55620 | 656 |
if (elem.name == Markup.ANTIQUOTED) Some(antiquoted_color) else Some(quoted_color) |
49356 | 657 |
}) |
658 |
||
659 |
||
55626 | 660 |
/* text color */ |
661 |
||
55647 | 662 |
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
|
663 |
Markup.KEYWORD1 -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
664 |
Markup.KEYWORD2 -> keyword2_color, |
55765 | 665 |
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
|
666 |
Markup.QUASI_KEYWORD -> quasi_keyword_color, |
56202 | 667 |
Markup.IMPROPER -> improper_color, |
56064 | 668 |
Markup.OPERATOR -> operator_color, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
669 |
Markup.STRING -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
670 |
Markup.ALTSTRING -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
671 |
Markup.VERBATIM -> Color.BLACK, |
55514
8ef781e282d9
more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents:
55512
diff
changeset
|
672 |
Markup.CARTOUCHE -> Color.BLACK, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
673 |
Markup.LITERAL -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
674 |
Markup.DELIMITER -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
675 |
Markup.TFREE -> tfree_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
676 |
Markup.TVAR -> tvar_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
677 |
Markup.FREE -> free_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
678 |
Markup.SKOLEM -> skolem_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
679 |
Markup.BOUND -> bound_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
680 |
Markup.VAR -> var_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
681 |
Markup.INNER_STRING -> inner_quoted_color, |
55033 | 682 |
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
|
683 |
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
|
684 |
Markup.DYNAMIC_FACT -> dynamic_color, |
55526 | 685 |
Markup.ANTIQUOTE -> antiquote_color, |
55505 | 686 |
Markup.ML_KEYWORD1 -> keyword1_color, |
687 |
Markup.ML_KEYWORD2 -> keyword2_color, |
|
688 |
Markup.ML_KEYWORD3 -> keyword3_color, |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
689 |
Markup.ML_DELIMITER -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
690 |
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
|
691 |
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
|
692 |
Markup.ML_STRING -> inner_quoted_color, |
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
693 |
Markup.ML_COMMENT -> inner_comment_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
694 |
Markup.SML_STRING -> inner_quoted_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
695 |
Markup.SML_COMMENT -> inner_comment_color) |
49356 | 696 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
697 |
private lazy val text_color_elements = |
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
698 |
Document.Elements(text_colors.keySet) |
49356 | 699 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
700 |
def text_color(range: Text.Range, color: Color): List[Text.Info[Color]] = |
49356 | 701 |
{ |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
702 |
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
|
703 |
else |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
704 |
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
|
705 |
{ |
52890 | 706 |
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
|
707 |
}) |
49356 | 708 |
} |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
709 |
|
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
710 |
|
55626 | 711 |
/* virtual bullets */ |
712 |
||
713 |
def bullet(range: Text.Range): List[Text.Info[Color]] = |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
714 |
snapshot.select(range, Rendering.bullet_elements, _ => _ => Some(bullet_color)) |
55626 | 715 |
|
716 |
||
717 |
/* text folds */ |
|
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
718 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
719 |
def fold_depth(range: Text.Range): List[Text.Info[Int]] = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
720 |
snapshot.cumulate[Int](range, 0, 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
|
721 |
{ |
55620 | 722 |
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
|
723 |
}) |
49356 | 724 |
} |