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