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