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