author | wenzelm |
Mon, 14 Sep 2015 18:03:43 +0200 | |
changeset 61175 | 1d9c121cbe4d |
parent 61011 | 018b0c996b54 |
child 61196 | 67c20ce71d22 |
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} |
61175 | 17 |
import org.gjt.sp.jedit.jEdit |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
18 |
|
45460 | 19 |
import scala.collection.immutable.SortedMap |
20 |
||
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
21 |
|
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") |
|
61011 | 254 |
val caret_debugger_color = color_value("caret_debugger_color") |
49356 | 255 |
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
|
256 |
val antiquoted_color = color_value("antiquoted_color") |
55526 | 257 |
val antiquote_color = color_value("antiquote_color") |
49358 | 258 |
val highlight_color = color_value("highlight_color") |
49356 | 259 |
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
|
260 |
val active_color = color_value("active_color") |
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
261 |
val active_hover_color = color_value("active_hover_color") |
50498 | 262 |
val active_result_color = color_value("active_result_color") |
49356 | 263 |
val keyword1_color = color_value("keyword1_color") |
264 |
val keyword2_color = color_value("keyword2_color") |
|
55505 | 265 |
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
|
266 |
val quasi_keyword_color = color_value("quasi_keyword_color") |
56202 | 267 |
val improper_color = color_value("improper_color") |
56064 | 268 |
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
|
269 |
val caret_invisible_color = color_value("caret_invisible_color") |
55747
bef19c929ba5
more completion rendering: active, semantic, syntactic;
wenzelm
parents:
55746
diff
changeset
|
270 |
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
|
271 |
val search_color = color_value("search_color") |
49356 | 272 |
|
273 |
val tfree_color = color_value("tfree_color") |
|
274 |
val tvar_color = color_value("tvar_color") |
|
275 |
val free_color = color_value("free_color") |
|
276 |
val skolem_color = color_value("skolem_color") |
|
277 |
val bound_color = color_value("bound_color") |
|
278 |
val var_color = color_value("var_color") |
|
279 |
val inner_numeral_color = color_value("inner_numeral_color") |
|
280 |
val inner_quoted_color = color_value("inner_quoted_color") |
|
55033 | 281 |
val inner_cartouche_color = color_value("inner_cartouche_color") |
49356 | 282 |
val inner_comment_color = color_value("inner_comment_color") |
283 |
val dynamic_color = color_value("dynamic_color") |
|
284 |
||
285 |
||
55674 | 286 |
/* completion */ |
287 |
||
56173 | 288 |
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
|
289 |
if (snapshot.is_outdated) None |
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
290 |
else { |
56173 | 291 |
snapshot.select(range, Rendering.semantic_completion_elements, _ => |
55688 | 292 |
{ |
56173 | 293 |
case Completion.Semantic.Info(info) => Some(info) |
55688 | 294 |
case _ => None |
295 |
}).headOption.map(_.info) |
|
55674 | 296 |
} |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
297 |
|
56173 | 298 |
def language_context(range: Text.Range): Option[Completion.Language_Context] = |
299 |
snapshot.select(range, Rendering.language_context_elements, _ => |
|
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
300 |
{ |
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
301 |
case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes, delimited), _)) => |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
302 |
if (delimited) Some(Completion.Language_Context(language, symbols, antiquotes)) |
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
303 |
else None |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
304 |
case Text.Info(_, elem) |
59118
fe7f91f85789
clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents:
59112
diff
changeset
|
305 |
if elem.name == Markup.ML_STRING || |
fe7f91f85789
clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents:
59112
diff
changeset
|
306 |
elem.name == Markup.ML_CARTOUCHE || |
fe7f91f85789
clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents:
59112
diff
changeset
|
307 |
elem.name == Markup.ML_COMMENT => |
55749 | 308 |
Some(Completion.Language_Context.ML_inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
309 |
case Text.Info(_, _) => |
55749 | 310 |
Some(Completion.Language_Context.inner) |
55690
d73949233c2e
clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents:
55689
diff
changeset
|
311 |
}).headOption.map(_.info) |
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
312 |
|
56843
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
313 |
def language_path(range: Text.Range): Option[Text.Range] = |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
314 |
snapshot.select(range, Rendering.language_elements, _ => |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
315 |
{ |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
316 |
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
|
317 |
Some(snapshot.convert(info_range)) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
318 |
case _ => None |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
319 |
}).headOption.map(_.info) |
b2bfcd8cda80
support for path completion based on file-system content;
wenzelm
parents:
56743
diff
changeset
|
320 |
|
58592 | 321 |
def citation(range: Text.Range): Option[Text.Info[String]] = |
322 |
snapshot.select(range, Rendering.citation_elements, _ => |
|
323 |
{ |
|
324 |
case Text.Info(info_range, XML.Elem(Markup.Citation(name), _)) => |
|
325 |
Some(Text.Info(snapshot.convert(info_range), name)) |
|
326 |
case _ => None |
|
327 |
}).headOption.map(_.info) |
|
328 |
||
55615
bf4bbe72f740
completion of keywords and symbols based on language context;
wenzelm
parents:
55550
diff
changeset
|
329 |
|
56551 | 330 |
/* spell checker */ |
56548 | 331 |
|
56551 | 332 |
private lazy val spell_checker_elements = |
56743 | 333 |
Markup.Elements(space_explode(',', options.string("spell_checker_elements")): _*) |
56551 | 334 |
|
335 |
def spell_checker_ranges(range: Text.Range): List[Text.Range] = |
|
336 |
snapshot.select(range, spell_checker_elements, _ => _ => Some(())).map(_.range) |
|
56548 | 337 |
|
56564
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
338 |
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
|
339 |
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
|
340 |
{ |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
341 |
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
|
342 |
}).headOption.map(_.info) |
94c55cc73747
added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents:
56551
diff
changeset
|
343 |
|
56548 | 344 |
|
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
345 |
/* breakpoints */ |
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
346 |
|
60880
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
347 |
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
|
348 |
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
|
349 |
else |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
350 |
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
|
351 |
{ |
60882 | 352 |
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
|
353 |
command_states match { |
60882 | 354 |
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
|
355 |
case _ => None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
356 |
} |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
357 |
case _ => None |
fa958e24ff24
set breakpoint state on ML side, relying on stable situation within the PIDE editing queue;
wenzelm
parents:
60878
diff
changeset
|
358 |
}).headOption.map(_.info) |
60878
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
359 |
|
1f0d2bbcf38b
added action to toggle breakpoints (on editor side);
wenzelm
parents:
60876
diff
changeset
|
360 |
|
55626 | 361 |
/* command status overview */ |
49356 | 362 |
|
55647 | 363 |
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
|
364 |
|
49356 | 365 |
def overview_color(range: Text.Range): Option[Color] = |
366 |
{ |
|
367 |
if (snapshot.is_outdated) None |
|
368 |
else { |
|
369 |
val results = |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
370 |
snapshot.cumulate[List[Markup]](range, Nil, Protocol.liberal_status_elements, _ => |
49356 | 371 |
{ |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
372 |
case (status, Text.Info(_, elem)) => Some(elem.markup :: status) |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
373 |
}, status = true) |
49356 | 374 |
if (results.isEmpty) None |
375 |
else { |
|
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
376 |
val status = Protocol.Status.make(results.iterator.flatMap(_.info)) |
49356 | 377 |
|
50895 | 378 |
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
|
379 |
else if (status.is_failed) Some(error_color) |
56395
0546e036d1c0
more direct warning within persistent Protocol.Status;
wenzelm
parents:
56372
diff
changeset
|
380 |
else if (status.is_warned) Some(warning_color) |
49356 | 381 |
else if (status.is_unprocessed) Some(unprocessed_color) |
382 |
else None |
|
383 |
} |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
||
55626 | 388 |
/* highlighted area */ |
49356 | 389 |
|
49358 | 390 |
def highlight(range: Text.Range): Option[Text.Info[Color]] = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
391 |
snapshot.select(range, Rendering.highlight_elements, _ => |
55620 | 392 |
{ |
393 |
case info => Some(Text.Info(snapshot.convert(info.range), highlight_color)) |
|
55689 | 394 |
}).headOption.map(_.info) |
49356 | 395 |
|
396 |
||
55626 | 397 |
/* hyperlinks */ |
398 |
||
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
399 |
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
|
400 |
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
|
401 |
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
|
402 |
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
|
403 |
|
52980 | 404 |
def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] = |
49356 | 405 |
{ |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
406 |
snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]]( |
55647 | 407 |
range, Vector.empty, Rendering.hyperlink_elements, _ => |
49356 | 408 |
{ |
56458
a8d960baa5c2
simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents:
56395
diff
changeset
|
409 |
case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) => |
60893 | 410 |
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
|
411 |
Some(links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 412 |
|
54702
3daeba5130f0
added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents:
54515
diff
changeset
|
413 |
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
|
414 |
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
|
415 |
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
|
416 |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
417 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _))) |
49815 | 418 |
if !props.exists( |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
419 |
{ case (Markup.KIND, Markup.ML_OPEN) => true |
55837 | 420 |
case (Markup.KIND, Markup.ML_STRUCTURE) => true |
49815 | 421 |
case _ => false }) => |
60893 | 422 |
val opt_link = PIDE.editor.hyperlink_def_position(true, snapshot, props) |
60215 | 423 |
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link)) |
49356 | 424 |
|
55545 | 425 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) => |
60893 | 426 |
val opt_link = PIDE.editor.hyperlink_position(true, snapshot, props) |
60215 | 427 |
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
|
428 |
|
58545
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
429 |
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
|
430 |
val opt_link = |
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
431 |
Bibtex_JEdit.entries_iterator.collectFirst( |
30b75b7958d6
citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents:
58464
diff
changeset
|
432 |
{ case (a, buffer, offset) if a == name => |
60893 | 433 |
PIDE.editor.hyperlink_buffer(true, buffer, offset) }) |
60215 | 434 |
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
|
435 |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
436 |
case _ => None |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
437 |
}) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None } |
49356 | 438 |
} |
439 |
||
440 |
||
55626 | 441 |
/* active elements */ |
442 |
||
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
443 |
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
|
444 |
snapshot.select(range, Rendering.active_elements, command_states => |
55620 | 445 |
{ |
446 |
case Text.Info(info_range, elem) => |
|
55623 | 447 |
if (elem.name == Markup.DIALOG) { |
448 |
elem match { |
|
449 |
case Protocol.Dialog(_, serial, _) |
|
56354
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
450 |
if !command_states.exists(st => st.results.defined(serial)) => |
55623 | 451 |
Some(Text.Info(snapshot.convert(info_range), elem)) |
452 |
case _ => None |
|
453 |
} |
|
454 |
} |
|
455 |
else Some(Text.Info(snapshot.convert(info_range), elem)) |
|
55689 | 456 |
}).headOption.map(_.info) |
49492 | 457 |
|
50502 | 458 |
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
|
459 |
Command.State.merge_results( |
56743 | 460 |
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
|
461 |
{ case _ => Some(command_states) }).flatMap(_.info)) |
50502 | 462 |
|
55626 | 463 |
|
464 |
/* tooltip messages */ |
|
465 |
||
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
|
466 |
def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 467 |
{ |
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
|
468 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
469 |
snapshot.cumulate[List[Text.Info[Command.Results.Entry]]]( |
55647 | 470 |
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
|
471 |
{ |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
472 |
case (msgs, Text.Info(info_range, msg @ XML.Elem(Markup(Markup.BAD, _), body))) |
59319 | 473 |
if body.nonEmpty => |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52472
diff
changeset
|
474 |
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
|
475 |
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
|
476 |
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
477 |
case (msgs, Text.Info(info_range, |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
478 |
XML.Elem(Markup(name, props @ Markup.Serial(serial)), body))) => |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
479 |
val entry: Command.Results.Entry = |
60215 | 480 |
serial -> XML.Elem(Markup(Markup.message(name), props), body) |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
481 |
Some(Text.Info(snapshot.convert(info_range), entry) :: msgs) |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
482 |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
483 |
case _ => None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
484 |
}).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
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
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
|
489 |
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
|
490 |
} |
49356 | 491 |
} |
492 |
||
493 |
||
55626 | 494 |
/* tooltips */ |
495 |
||
49700
2d1cbdf6a68b
Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents:
49674
diff
changeset
|
496 |
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
|
497 |
Pretty.block(XML.Text(kind) :: Pretty.Break(1) :: body) |
49356 | 498 |
|
55647 | 499 |
private def timing_threshold: Double = options.real("jedit_timing_threshold") |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
500 |
|
51496
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
501 |
def tooltip(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 502 |
{ |
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
{ |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
506 |
val r = snapshot.convert(r0) |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
} |
49356 | 512 |
|
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
|
513 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
514 |
snapshot.cumulate[Text.Info[(Timing, Vector[(Boolean, XML.Tree)])]]( |
55647 | 515 |
range, Text.Info(range, (Timing.zero, Vector.empty)), Rendering.tooltip_elements, _ => |
49356 | 516 |
{ |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
517 |
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
|
518 |
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
|
519 |
case (prev, Text.Info(r, XML.Elem(Markup.Entity(kind, name), _))) => |
56600 | 520 |
val kind1 = Word.implode(Word.explode('_', kind)) |
58048
aa6296d09e0e
more explicit Method.modifier with reported position;
wenzelm
parents:
57931
diff
changeset
|
521 |
val txt1 = |
aa6296d09e0e
more explicit Method.modifier with reported position;
wenzelm
parents:
57931
diff
changeset
|
522 |
if (name == "") kind1 |
aa6296d09e0e
more explicit Method.modifier with reported position;
wenzelm
parents:
57931
diff
changeset
|
523 |
else kind1 + " " + quote(name) |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
524 |
val t = prev.info._1 |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
525 |
val txt2 = |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
526 |
if (kind == Markup.COMMAND && t.elapsed.seconds >= timing_threshold) |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
527 |
"\n" + t.message |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
528 |
else "" |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
529 |
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
|
530 |
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
|
531 |
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
|
532 |
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
|
533 |
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
|
534 |
else "path " + quote(name) + "\nfile " + quote(file) |
56134 | 535 |
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
|
536 |
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
|
537 |
Some(add(prev, r, (true, XML.Text("URL " + quote(name))))) |
49674
dbadb4d03cbc
report sort assignment of visible type variables;
wenzelm
parents:
49554
diff
changeset
|
538 |
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
|
539 |
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
|
540 |
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
|
541 |
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
|
542 |
Some(add(prev, r, (false, pretty_typing("ML:", body)))) |
60882 | 543 |
case (prev, Text.Info(r, Protocol.ML_Breakpoint(breakpoint))) => |
544 |
val text = |
|
545 |
if (Debugger.breakpoint_state(breakpoint)) "breakpoint (enabled)" |
|
546 |
else "breakpoint (disabled)" |
|
547 |
Some(add(prev, r, (true, XML.Text(text)))) |
|
55828
42ac3cfb89f6
clarified language markup: added "delimited" property;
wenzelm
parents:
55825
diff
changeset
|
548 |
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
|
549 |
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
|
550 |
case (prev, Text.Info(r, XML.Elem(Markup(name, _), _))) => |
55647 | 551 |
Rendering.tooltip_descriptions.get(name). |
552 |
map(descr => add(prev, r, (true, XML.Text(descr)))) |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
553 |
}).map(_.info) |
49356 | 554 |
|
55622
ce575c2212fc
clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents:
55620
diff
changeset
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
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
|
561 |
} |
49356 | 562 |
} |
563 |
||
55647 | 564 |
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
|
565 |
|
52873 | 566 |
lazy val tooltip_close_icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon")) |
567 |
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
|
568 |
|
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
569 |
|
56495 | 570 |
/* gutter */ |
571 |
||
572 |
private def gutter_message_pri(msg: XML.Tree): Int = |
|
573 |
if (Protocol.is_error(msg)) Rendering.error_pri |
|
574 |
else if (Protocol.is_legacy(msg)) Rendering.legacy_pri |
|
575 |
else if (Protocol.is_warning(msg)) Rendering.warning_pri |
|
576 |
else if (Protocol.is_information(msg)) Rendering.information_pri |
|
577 |
else 0 |
|
55626 | 578 |
|
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
579 |
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
|
580 |
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
|
581 |
(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
|
582 |
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
|
583 |
(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
|
584 |
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
|
585 |
(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
|
586 |
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
|
587 |
(JEdit_Lib.load_icon(options.string("gutter_error_icon")), error_message_color)) |
49356 | 588 |
|
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
589 |
def gutter_content(range: Text.Range): Option[(Icon, Color)] = |
49356 | 590 |
{ |
56495 | 591 |
val pris = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
592 |
snapshot.cumulate[Int](range, 0, Rendering.gutter_elements, _ => |
49356 | 593 |
{ |
56495 | 594 |
case (pri, Text.Info(_, msg @ XML.Elem(Markup(_, Markup.Serial(serial)), _))) => |
595 |
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
|
596 |
case _ => None |
56495 | 597 |
}).map(_.info) |
598 |
||
59129
6959ceb53ac8
more informative gutter content: fall-back on background color, e.g. when line numbers are enabled;
wenzelm
parents:
59125
diff
changeset
|
599 |
gutter_message_content.get((0 /: pris)(_ max _)) |
49356 | 600 |
} |
601 |
||
602 |
||
55626 | 603 |
/* squiggly underline */ |
604 |
||
55647 | 605 |
private lazy val squiggly_colors = Map( |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
606 |
Rendering.writeln_pri -> writeln_color, |
52650 | 607 |
Rendering.information_pri -> information_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
608 |
Rendering.warning_pri -> warning_color, |
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
609 |
Rendering.legacy_pri -> legacy_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
610 |
Rendering.error_pri -> error_color) |
49356 | 611 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
612 |
def squiggly_underline(range: Text.Range): List[Text.Info[Color]] = |
49356 | 613 |
{ |
614 |
val results = |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
615 |
snapshot.cumulate[Int](range, 0, Rendering.squiggly_elements, _ => |
49356 | 616 |
{ |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
617 |
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name)) |
49356 | 618 |
}) |
619 |
for { |
|
620 |
Text.Info(r, pri) <- results |
|
621 |
color <- squiggly_colors.get(pri) |
|
622 |
} yield Text.Info(r, color) |
|
623 |
} |
|
624 |
||
49474 | 625 |
|
55626 | 626 |
/* message output */ |
627 |
||
55647 | 628 |
private lazy val message_colors = Map( |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
629 |
Rendering.writeln_pri -> writeln_message_color, |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
630 |
Rendering.state_pri -> state_message_color, |
52650 | 631 |
Rendering.information_pri -> information_message_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
632 |
Rendering.tracing_pri -> tracing_message_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
633 |
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
|
634 |
Rendering.legacy_pri -> legacy_message_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
635 |
Rendering.error_pri -> error_message_color) |
49474 | 636 |
|
49473 | 637 |
def line_background(range: Text.Range): Option[(Color, Boolean)] = |
638 |
{ |
|
49474 | 639 |
val results = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
640 |
snapshot.cumulate[Int](range, 0, Rendering.line_background_elements, _ => |
49473 | 641 |
{ |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59129
diff
changeset
|
642 |
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name)) |
49474 | 643 |
}) |
644 |
val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
|
645 |
||
55623 | 646 |
val is_separator = |
647 |
pri > 0 && |
|
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
648 |
snapshot.cumulate[Boolean](range, false, Rendering.separator_elements, _ => |
49473 | 649 |
{ |
55623 | 650 |
case _ => Some(true) |
49473 | 651 |
}).exists(_.info) |
652 |
||
49474 | 653 |
message_colors.get(pri).map((_, is_separator)) |
49473 | 654 |
} |
49356 | 655 |
|
56299
8201790fdeb9
more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents:
56298
diff
changeset
|
656 |
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
|
657 |
{ |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
658 |
val (states, other) = |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
659 |
results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
660 |
.partition(Protocol.is_state(_)) |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
661 |
states ::: other |
9616643a3032
output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents:
57595
diff
changeset
|
662 |
} |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
663 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
664 |
|
55626 | 665 |
/* text background */ |
666 |
||
55790
4670f18baba5
simplified rendering -- no need to over-emphasize "token_range";
wenzelm
parents:
55765
diff
changeset
|
667 |
def background(range: Text.Range): List[Text.Info[Color]] = |
49356 | 668 |
{ |
56176
0bc9b0ad6287
tuned rendering -- avoid flashing background of aux. files that are disconnected from the document model;
wenzelm
parents:
56173
diff
changeset
|
669 |
if (snapshot.is_outdated && snapshot.is_loaded) List(Text.Info(range, outdated_color)) |
49356 | 670 |
else |
671 |
for { |
|
672 |
Text.Info(r, result) <- |
|
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
673 |
snapshot.cumulate[(List[Markup], Option[Color])]( |
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
674 |
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
|
675 |
command_states => |
55647 | 676 |
{ |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
677 |
case (((status, color), Text.Info(_, XML.Elem(markup, _)))) |
59319 | 678 |
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
|
679 |
Some((markup :: status, color)) |
55647 | 680 |
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
|
681 |
Some((Nil, Some(bad_color))) |
55647 | 682 |
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
|
683 |
Some((Nil, Some(intensify_color))) |
55647 | 684 |
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
|
685 |
command_states.collectFirst( |
a6f8c3566560
more direct command states -- merge_results is hardly ever needed;
wenzelm
parents:
56352
diff
changeset
|
686 |
{ 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
|
687 |
{ |
55647 | 688 |
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
|
689 |
Some((Nil, Some(active_result_color))) |
55647 | 690 |
case _ => |
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
691 |
Some((Nil, Some(active_color))) |
55647 | 692 |
} |
693 |
case (_, Text.Info(_, elem)) => |
|
56352
abdc524db8b4
more frugal command_status, which is often used in a tight loop;
wenzelm
parents:
56299
diff
changeset
|
694 |
if (Rendering.active_elements(elem.name)) Some((Nil, Some(active_color))) |
55647 | 695 |
else None |
696 |
}) |
|
49356 | 697 |
color <- |
698 |
(result match { |
|
59319 | 699 |
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
|
700 |
val status = Protocol.Status.make(markups.iterator) |
49356 | 701 |
if (status.is_unprocessed) Some(unprocessed1_color) |
702 |
else if (status.is_running) Some(running1_color) |
|
703 |
else opt_color |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
704 |
case (_, opt_color) => opt_color |
49356 | 705 |
}) |
706 |
} yield Text.Info(r, color) |
|
707 |
} |
|
708 |
||
709 |
||
55626 | 710 |
/* text foreground */ |
51574
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
711 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
712 |
def foreground(range: Text.Range): List[Text.Info[Color]] = |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
713 |
snapshot.select(range, Rendering.foreground_elements, _ => |
49356 | 714 |
{ |
52890 | 715 |
case Text.Info(_, elem) => |
55620 | 716 |
if (elem.name == Markup.ANTIQUOTED) Some(antiquoted_color) else Some(quoted_color) |
49356 | 717 |
}) |
718 |
||
719 |
||
55626 | 720 |
/* text color */ |
721 |
||
61175 | 722 |
val foreground_color = jEdit.getColorProperty("view.fgColor") |
723 |
||
55647 | 724 |
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
|
725 |
Markup.KEYWORD1 -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
726 |
Markup.KEYWORD2 -> keyword2_color, |
55765 | 727 |
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
|
728 |
Markup.QUASI_KEYWORD -> quasi_keyword_color, |
56202 | 729 |
Markup.IMPROPER -> improper_color, |
56064 | 730 |
Markup.OPERATOR -> operator_color, |
61175 | 731 |
Markup.STRING -> foreground_color, |
732 |
Markup.ALT_STRING -> foreground_color, |
|
733 |
Markup.VERBATIM -> foreground_color, |
|
734 |
Markup.CARTOUCHE -> foreground_color, |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
735 |
Markup.LITERAL -> keyword1_color, |
61175 | 736 |
Markup.DELIMITER -> foreground_color, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
737 |
Markup.TFREE -> tfree_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
738 |
Markup.TVAR -> tvar_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
739 |
Markup.FREE -> free_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
740 |
Markup.SKOLEM -> skolem_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
741 |
Markup.BOUND -> bound_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
742 |
Markup.VAR -> var_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
743 |
Markup.INNER_STRING -> inner_quoted_color, |
55033 | 744 |
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
|
745 |
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
|
746 |
Markup.DYNAMIC_FACT -> dynamic_color, |
55526 | 747 |
Markup.ANTIQUOTE -> antiquote_color, |
55505 | 748 |
Markup.ML_KEYWORD1 -> keyword1_color, |
749 |
Markup.ML_KEYWORD2 -> keyword2_color, |
|
750 |
Markup.ML_KEYWORD3 -> keyword3_color, |
|
61175 | 751 |
Markup.ML_DELIMITER -> foreground_color, |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
752 |
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
|
753 |
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
|
754 |
Markup.ML_STRING -> inner_quoted_color, |
59112 | 755 |
Markup.ML_CARTOUCHE -> inner_cartouche_color, |
56278
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
756 |
Markup.ML_COMMENT -> inner_comment_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
757 |
Markup.SML_STRING -> inner_quoted_color, |
2576d3a40ed6
separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents:
56208
diff
changeset
|
758 |
Markup.SML_COMMENT -> inner_comment_color) |
49356 | 759 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55790
diff
changeset
|
760 |
private lazy val text_color_elements = |
56743 | 761 |
Markup.Elements(text_colors.keySet) |
49356 | 762 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
763 |
def text_color(range: Text.Range, color: Color): List[Text.Info[Color]] = |
49356 | 764 |
{ |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
765 |
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
|
766 |
else |
55651
fa42cf3fe79b
tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents:
55649
diff
changeset
|
767 |
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
|
768 |
{ |
52890 | 769 |
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
|
770 |
}) |
49356 | 771 |
} |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
772 |
|
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
773 |
|
55626 | 774 |
/* virtual bullets */ |
775 |
||
776 |
def bullet(range: Text.Range): List[Text.Info[Color]] = |
|
60913 | 777 |
snapshot.select(range, Rendering.bullet_elements, _ => |
778 |
{ |
|
779 |
case Text.Info(_, Protocol.ML_Breakpoint(breakpoint)) => |
|
780 |
Debugger.active_breakpoint_state(breakpoint).map(b => |
|
781 |
if (b) breakpoint_enabled_color else breakpoint_disabled_color) |
|
782 |
case _ => Some(bullet_color) |
|
783 |
}) |
|
55626 | 784 |
|
785 |
||
786 |
/* text folds */ |
|
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
787 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
788 |
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
|
789 |
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
|
790 |
{ |
55620 | 791 |
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
|
792 |
}) |
49356 | 793 |
} |