author | wenzelm |
Mon, 27 Aug 2018 19:29:07 +0200 | |
changeset 68822 | 253f04c1e814 |
parent 68758 | a110e7e24e55 |
child 68871 | f5c76072db55 |
permissions | -rw-r--r-- |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/PIDE/rendering.scala |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
3 |
|
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
4 |
Isabelle-specific implementation of quasi-abstract rendering and |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
5 |
markup interpretation. |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
6 |
*/ |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
7 |
|
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
9 |
|
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
10 |
|
66158 | 11 |
import java.io.{File => JFile} |
12 |
import java.nio.file.FileSystems |
|
13 |
||
14 |
||
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
15 |
object Rendering |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
16 |
{ |
65101 | 17 |
/* color */ |
18 |
||
19 |
object Color extends Enumeration |
|
20 |
{ |
|
65104
66b19d05dcee
decorations for background and foreground colors;
wenzelm
parents:
65101
diff
changeset
|
21 |
// background |
65637 | 22 |
val unprocessed1, running1, bad, intensify, entity, active, active_result, |
67322 | 23 |
markdown_bullet1, markdown_bullet2, markdown_bullet3, markdown_bullet4 = Value |
65143 | 24 |
val background_colors = values |
65104
66b19d05dcee
decorations for background and foreground colors;
wenzelm
parents:
65101
diff
changeset
|
25 |
|
66b19d05dcee
decorations for background and foreground colors;
wenzelm
parents:
65101
diff
changeset
|
26 |
// foreground |
65637 | 27 |
val quoted, antiquoted = Value |
65143 | 28 |
val foreground_colors = values -- background_colors |
65121 | 29 |
|
65124 | 30 |
// message underline |
65637 | 31 |
val writeln, information, warning, legacy, error = Value |
65143 | 32 |
val message_underline_colors = values -- background_colors -- foreground_colors |
65124 | 33 |
|
34 |
// message background |
|
65637 | 35 |
val writeln_message, information_message, tracing_message, |
36 |
warning_message, legacy_message, error_message = Value |
|
65143 | 37 |
val message_background_colors = |
38 |
values -- background_colors -- foreground_colors -- message_underline_colors |
|
65144 | 39 |
|
40 |
// text |
|
65637 | 41 |
val main, keyword1, keyword2, keyword3, quasi_keyword, improper, operator, |
42 |
tfree, tvar, free, skolem, bound, `var`, inner_numeral, inner_quoted, |
|
43 |
inner_cartouche, inner_comment, dynamic, class_parameter, antiquote = Value |
|
65144 | 44 |
val text_colors = |
45 |
values -- background_colors -- foreground_colors -- message_underline_colors -- |
|
46 |
message_background_colors |
|
65911 | 47 |
|
65913 | 48 |
// text overview |
65911 | 49 |
val unprocessed, running = Value |
65913 | 50 |
val text_overview_colors = Set(unprocessed, running, error, warning) |
65101 | 51 |
} |
52 |
||
53 |
||
65190 | 54 |
/* output messages */ |
64676 | 55 |
|
56 |
val state_pri = 1 |
|
57 |
val writeln_pri = 2 |
|
58 |
val information_pri = 3 |
|
59 |
val tracing_pri = 4 |
|
60 |
val warning_pri = 5 |
|
61 |
val legacy_pri = 6 |
|
62 |
val error_pri = 7 |
|
63 |
||
64 |
val message_pri = Map( |
|
65 |
Markup.STATE -> state_pri, |
|
66 |
Markup.STATE_MESSAGE -> state_pri, |
|
67 |
Markup.WRITELN -> writeln_pri, |
|
68 |
Markup.WRITELN_MESSAGE -> writeln_pri, |
|
69 |
Markup.INFORMATION -> information_pri, |
|
70 |
Markup.INFORMATION_MESSAGE -> information_pri, |
|
71 |
Markup.TRACING -> tracing_pri, |
|
72 |
Markup.TRACING_MESSAGE -> tracing_pri, |
|
73 |
Markup.WARNING -> warning_pri, |
|
74 |
Markup.WARNING_MESSAGE -> warning_pri, |
|
75 |
Markup.LEGACY -> legacy_pri, |
|
76 |
Markup.LEGACY_MESSAGE -> legacy_pri, |
|
77 |
Markup.ERROR -> error_pri, |
|
65133 | 78 |
Markup.ERROR_MESSAGE -> error_pri |
79 |
).withDefaultValue(0) |
|
64676 | 80 |
|
65121 | 81 |
val message_underline_color = Map( |
82 |
writeln_pri -> Color.writeln, |
|
83 |
information_pri -> Color.information, |
|
84 |
warning_pri -> Color.warning, |
|
85 |
legacy_pri -> Color.legacy, |
|
86 |
error_pri -> Color.error) |
|
87 |
||
65124 | 88 |
val message_background_color = Map( |
89 |
writeln_pri -> Color.writeln_message, |
|
90 |
information_pri -> Color.information_message, |
|
91 |
tracing_pri -> Color.tracing_message, |
|
92 |
warning_pri -> Color.warning_message, |
|
93 |
legacy_pri -> Color.legacy_message, |
|
94 |
error_pri -> Color.error_message) |
|
95 |
||
65190 | 96 |
def output_messages(results: Command.Results): List[XML.Tree] = |
97 |
{ |
|
98 |
val (states, other) = |
|
99 |
results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList |
|
100 |
.partition(Protocol.is_state(_)) |
|
101 |
states ::: other |
|
102 |
} |
|
103 |
||
64676 | 104 |
|
65144 | 105 |
/* text color */ |
106 |
||
107 |
val text_color = Map( |
|
108 |
Markup.KEYWORD1 -> Color.keyword1, |
|
109 |
Markup.KEYWORD2 -> Color.keyword2, |
|
110 |
Markup.KEYWORD3 -> Color.keyword3, |
|
111 |
Markup.QUASI_KEYWORD -> Color.quasi_keyword, |
|
112 |
Markup.IMPROPER -> Color.improper, |
|
113 |
Markup.OPERATOR -> Color.operator, |
|
65145 | 114 |
Markup.STRING -> Color.main, |
115 |
Markup.ALT_STRING -> Color.main, |
|
116 |
Markup.VERBATIM -> Color.main, |
|
117 |
Markup.CARTOUCHE -> Color.main, |
|
65144 | 118 |
Markup.LITERAL -> Color.keyword1, |
65145 | 119 |
Markup.DELIMITER -> Color.main, |
65144 | 120 |
Markup.TFREE -> Color.tfree, |
121 |
Markup.TVAR -> Color.tvar, |
|
122 |
Markup.FREE -> Color.free, |
|
123 |
Markup.SKOLEM -> Color.skolem, |
|
124 |
Markup.BOUND -> Color.bound, |
|
65637 | 125 |
Markup.VAR -> Color.`var`, |
65144 | 126 |
Markup.INNER_STRING -> Color.inner_quoted, |
127 |
Markup.INNER_CARTOUCHE -> Color.inner_cartouche, |
|
128 |
Markup.INNER_COMMENT -> Color.inner_comment, |
|
129 |
Markup.DYNAMIC_FACT -> Color.dynamic, |
|
130 |
Markup.CLASS_PARAMETER -> Color.class_parameter, |
|
131 |
Markup.ANTIQUOTE -> Color.antiquote, |
|
132 |
Markup.ML_KEYWORD1 -> Color.keyword1, |
|
133 |
Markup.ML_KEYWORD2 -> Color.keyword2, |
|
134 |
Markup.ML_KEYWORD3 -> Color.keyword3, |
|
65145 | 135 |
Markup.ML_DELIMITER -> Color.main, |
65144 | 136 |
Markup.ML_NUMERAL -> Color.inner_numeral, |
137 |
Markup.ML_CHAR -> Color.inner_quoted, |
|
138 |
Markup.ML_STRING -> Color.inner_quoted, |
|
68822 | 139 |
Markup.ML_COMMENT -> Color.inner_comment) |
65144 | 140 |
|
66074 | 141 |
val foreground = |
142 |
Map( |
|
143 |
Markup.STRING -> Color.quoted, |
|
144 |
Markup.ALT_STRING -> Color.quoted, |
|
145 |
Markup.VERBATIM -> Color.quoted, |
|
146 |
Markup.CARTOUCHE -> Color.quoted, |
|
147 |
Markup.ANTIQUOTED -> Color.antiquoted) |
|
148 |
||
65144 | 149 |
|
65149 | 150 |
/* tooltips */ |
65101 | 151 |
|
65149 | 152 |
val tooltip_descriptions = |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
153 |
Map( |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
154 |
Markup.CITATION -> "citation", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
155 |
Markup.TOKEN_RANGE -> "inner syntax token", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
156 |
Markup.FREE -> "free variable", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
157 |
Markup.SKOLEM -> "skolem variable", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
158 |
Markup.BOUND -> "bound variable", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
159 |
Markup.VAR -> "schematic variable", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
160 |
Markup.TFREE -> "free type variable", |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
161 |
Markup.TVAR -> "schematic type variable") |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
162 |
|
65149 | 163 |
|
164 |
/* markup elements */ |
|
165 |
||
66053 | 166 |
val semantic_completion_elements = |
167 |
Markup.Elements(Markup.COMPLETION, Markup.NO_COMPLETION) |
|
168 |
||
169 |
val language_context_elements = |
|
170 |
Markup.Elements(Markup.STRING, Markup.ALT_STRING, Markup.VERBATIM, |
|
171 |
Markup.CARTOUCHE, Markup.COMMENT, Markup.LANGUAGE, |
|
172 |
Markup.ML_STRING, Markup.ML_COMMENT) |
|
173 |
||
174 |
val language_elements = Markup.Elements(Markup.LANGUAGE) |
|
175 |
||
176 |
val citation_elements = Markup.Elements(Markup.CITATION) |
|
177 |
||
65149 | 178 |
val active_elements = |
179 |
Markup.Elements(Markup.DIALOG, Markup.BROWSER, Markup.GRAPHVIEW, |
|
180 |
Markup.SENDBACK, Markup.JEDIT_ACTION, Markup.SIMP_TRACE_PANEL) |
|
181 |
||
182 |
val background_elements = |
|
68758 | 183 |
Document_Status.Command_Status.proper_elements + Markup.WRITELN_MESSAGE + |
65149 | 184 |
Markup.STATE_MESSAGE + Markup.INFORMATION_MESSAGE + |
185 |
Markup.TRACING_MESSAGE + Markup.WARNING_MESSAGE + |
|
186 |
Markup.LEGACY_MESSAGE + Markup.ERROR_MESSAGE + |
|
187 |
Markup.BAD + Markup.INTENSIFY + Markup.ENTITY + |
|
67322 | 188 |
Markup.Markdown_Bullet.name ++ active_elements |
65149 | 189 |
|
66074 | 190 |
val foreground_elements = Markup.Elements(foreground.keySet) |
191 |
||
192 |
val text_color_elements = Markup.Elements(text_color.keySet) |
|
65149 | 193 |
|
65129
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
194 |
val tooltip_elements = |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
195 |
Markup.Elements(Markup.LANGUAGE, Markup.EXPRESSION, Markup.TIMING, Markup.ENTITY, |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
196 |
Markup.SORTING, Markup.TYPING, Markup.CLASS_PARAMETER, Markup.ML_TYPING, |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
197 |
Markup.ML_BREAKPOINT, Markup.PATH, Markup.DOC, Markup.URL, Markup.MARKDOWN_PARAGRAPH, |
67323
d02208cefbdb
PIDE markup for Markdown items (which may consist of multiple paragraphs or lists);
wenzelm
parents:
67322
diff
changeset
|
198 |
Markup.MARKDOWN_ITEM, Markup.Markdown_List.name) ++ |
d02208cefbdb
PIDE markup for Markdown items (which may consist of multiple paragraphs or lists);
wenzelm
parents:
67322
diff
changeset
|
199 |
Markup.Elements(tooltip_descriptions.keySet) |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
200 |
|
65129
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
201 |
val tooltip_message_elements = |
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
202 |
Markup.Elements(Markup.WRITELN, Markup.INFORMATION, Markup.WARNING, Markup.LEGACY, Markup.ERROR, |
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
203 |
Markup.BAD) |
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
204 |
|
64767 | 205 |
val caret_focus_elements = Markup.Elements(Markup.ENTITY) |
67132 | 206 |
|
207 |
val antiquoted_elements = Markup.Elements(Markup.ANTIQUOTED) |
|
67336 | 208 |
|
209 |
val markdown_elements = |
|
210 |
Markup.Elements(Markup.MARKDOWN_PARAGRAPH, Markup.MARKDOWN_ITEM, Markup.Markdown_List.name, |
|
211 |
Markup.Markdown_Bullet.name) |
|
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
212 |
} |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
213 |
|
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
214 |
abstract class Rendering( |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
215 |
val snapshot: Document.Snapshot, |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
216 |
val options: Options, |
65213
51c0f094dc02
proper local debugger state, depending on session;
wenzelm
parents:
65190
diff
changeset
|
217 |
val session: Session) |
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
218 |
{ |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
219 |
override def toString: String = "Rendering(" + snapshot.toString + ")" |
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
220 |
|
66114 | 221 |
def model: Document.Model |
222 |
||
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
223 |
|
66117 | 224 |
/* caret */ |
225 |
||
226 |
def before_caret_range(caret: Text.Offset): Text.Range = |
|
227 |
{ |
|
228 |
val former_caret = snapshot.revert(caret) |
|
229 |
snapshot.convert(Text.Range(former_caret - 1, former_caret)) |
|
230 |
} |
|
231 |
||
232 |
||
64877 | 233 |
/* completion */ |
234 |
||
66054
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
235 |
def semantic_completion(completed_range: Option[Text.Range], caret_range: Text.Range) |
64877 | 236 |
: Option[Text.Info[Completion.Semantic]] = |
237 |
if (snapshot.is_outdated) None |
|
238 |
else { |
|
66054
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
239 |
snapshot.select(caret_range, Rendering.semantic_completion_elements, _ => |
64877 | 240 |
{ |
241 |
case Completion.Semantic.Info(info) => |
|
242 |
completed_range match { |
|
243 |
case Some(range0) if range0.contains(info.range) && range0 != info.range => None |
|
244 |
case _ => Some(info) |
|
245 |
} |
|
246 |
case _ => None |
|
247 |
}).headOption.map(_.info) |
|
248 |
} |
|
249 |
||
66054
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
250 |
def semantic_completion_result( |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
251 |
history: Completion.History, |
66055 | 252 |
unicode: Boolean, |
66054
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
253 |
completed_range: Option[Text.Range], |
66114 | 254 |
caret_range: Text.Range): (Boolean, Option[Completion.Result]) = |
66054
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
255 |
{ |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
256 |
semantic_completion(completed_range, caret_range) match { |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
257 |
case Some(Text.Info(_, Completion.No_Completion)) => (true, None) |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
258 |
case Some(Text.Info(range, names: Completion.Names)) => |
67014 | 259 |
model.get_text(range) match { |
66055 | 260 |
case Some(original) => (false, names.complete(range, history, unicode, original)) |
66054
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
261 |
case None => (false, None) |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
262 |
} |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
263 |
case None => (false, None) |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
264 |
} |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
265 |
} |
fb0eea226a4d
more uniform syntax_completion + semantic_completion;
wenzelm
parents:
66053
diff
changeset
|
266 |
|
66053 | 267 |
def language_context(range: Text.Range): Option[Completion.Language_Context] = |
268 |
snapshot.select(range, Rendering.language_context_elements, _ => |
|
269 |
{ |
|
270 |
case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes, delimited), _)) => |
|
271 |
if (delimited) Some(Completion.Language_Context(language, symbols, antiquotes)) |
|
272 |
else None |
|
273 |
case Text.Info(_, elem) |
|
274 |
if elem.name == Markup.ML_STRING || elem.name == Markup.ML_COMMENT => |
|
275 |
Some(Completion.Language_Context.ML_inner) |
|
276 |
case Text.Info(_, _) => |
|
277 |
Some(Completion.Language_Context.inner) |
|
278 |
}).headOption.map(_.info) |
|
279 |
||
66158 | 280 |
def citation(range: Text.Range): Option[Text.Info[String]] = |
281 |
snapshot.select(range, Rendering.citation_elements, _ => |
|
282 |
{ |
|
283 |
case Text.Info(info_range, XML.Elem(Markup.Citation(name), _)) => |
|
284 |
Some(Text.Info(snapshot.convert(info_range), name)) |
|
285 |
case _ => None |
|
286 |
}).headOption.map(_.info) |
|
287 |
||
288 |
||
289 |
/* file-system path completion */ |
|
290 |
||
66053 | 291 |
def language_path(range: Text.Range): Option[Text.Range] = |
292 |
snapshot.select(range, Rendering.language_elements, _ => |
|
293 |
{ |
|
294 |
case Text.Info(info_range, XML.Elem(Markup.Language(Markup.Language.PATH, _, _, _), _)) => |
|
295 |
Some(snapshot.convert(info_range)) |
|
296 |
case _ => None |
|
297 |
}).headOption.map(_.info) |
|
298 |
||
66158 | 299 |
def path_completion(caret: Text.Offset): Option[Completion.Result] = |
300 |
{ |
|
301 |
def complete(text: String): List[(String, List[String])] = |
|
302 |
{ |
|
303 |
try { |
|
304 |
val path = Path.explode(text) |
|
305 |
val (dir, base_name) = |
|
306 |
if (text == "" || text.endsWith("/")) (path, "") |
|
307 |
else (path.dir, path.base_name) |
|
308 |
||
309 |
val directory = new JFile(session.resources.append(snapshot.node_name, dir)) |
|
310 |
val files = directory.listFiles |
|
311 |
if (files == null) Nil |
|
312 |
else { |
|
313 |
val ignore = |
|
66923 | 314 |
space_explode(':', options.string("completion_path_ignore")). |
66158 | 315 |
map(s => FileSystems.getDefault.getPathMatcher("glob:" + s)) |
316 |
(for { |
|
317 |
file <- files.iterator |
|
318 |
||
319 |
name = file.getName |
|
320 |
if name.startsWith(base_name) |
|
321 |
path_name = new JFile(name).toPath |
|
322 |
if !ignore.exists(matcher => matcher.matches(path_name)) |
|
323 |
||
324 |
text1 = (dir + Path.basic(name)).implode_short |
|
325 |
if text != text1 |
|
326 |
||
327 |
is_dir = new JFile(directory, name).isDirectory |
|
328 |
replacement = text1 + (if (is_dir) "/" else "") |
|
329 |
descr = List(text1, if (is_dir) "(directory)" else "(file)") |
|
330 |
} yield (replacement, descr)).take(options.int("completion_limit")).toList |
|
331 |
} |
|
332 |
} |
|
333 |
catch { case ERROR(_) => Nil } |
|
334 |
} |
|
335 |
||
336 |
def is_wrapped(s: String): Boolean = |
|
337 |
s.startsWith("\"") && s.endsWith("\"") || |
|
338 |
s.startsWith(Symbol.open_decoded) && s.endsWith(Symbol.close_decoded) |
|
339 |
||
340 |
for { |
|
341 |
r1 <- language_path(before_caret_range(caret)) |
|
67014 | 342 |
s1 <- model.get_text(r1) |
66158 | 343 |
if is_wrapped(s1) |
344 |
r2 = Text.Range(r1.start + 1, r1.stop - 1) |
|
345 |
s2 = s1.substring(1, s1.length - 1) |
|
346 |
if Path.is_valid(s2) |
|
347 |
paths = complete(s2) |
|
348 |
if paths.nonEmpty |
|
349 |
items = paths.map(p => Completion.Item(r2, s2, "", p._2, p._1, 0, false)) |
|
350 |
} yield Completion.Result(r2, s2, false, items) |
|
351 |
} |
|
66053 | 352 |
|
64877 | 353 |
|
65139 | 354 |
/* spell checker */ |
355 |
||
67395
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
356 |
private lazy val spell_checker_include = |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
357 |
Markup.Elements(space_explode(',', options.string("spell_checker_include")): _*) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
358 |
|
65139 | 359 |
private lazy val spell_checker_elements = |
67395
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
360 |
spell_checker_include ++ |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
361 |
Markup.Elements(space_explode(',', options.string("spell_checker_exclude")): _*) |
65139 | 362 |
|
67395
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
363 |
def spell_checker(range: Text.Range): List[Text.Info[Text.Range]] = |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
364 |
{ |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
365 |
val result = |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
366 |
snapshot.select(range, spell_checker_elements, _ => |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
367 |
{ |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
368 |
case info => |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
369 |
Some( |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
370 |
if (spell_checker_include(info.info.name)) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
371 |
Some(snapshot.convert(info.range)) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
372 |
else None) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
373 |
}) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
374 |
for (Text.Info(range, Some(range1)) <- result) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
375 |
yield Text.Info(range, range1) |
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
376 |
} |
65139 | 377 |
|
378 |
def spell_checker_point(range: Text.Range): Option[Text.Range] = |
|
67395
b39d596b77ce
more accurate spell-checking for nested quotations / antiquotations, notably in formal comments;
wenzelm
parents:
67336
diff
changeset
|
379 |
spell_checker(range).headOption.map(_.info) |
65139 | 380 |
|
381 |
||
65101 | 382 |
/* text background */ |
383 |
||
65176 | 384 |
def background(elements: Markup.Elements, range: Text.Range, focus: Set[Long]) |
385 |
: List[Text.Info[Rendering.Color.Value]] = |
|
65101 | 386 |
{ |
387 |
for { |
|
388 |
Text.Info(r, result) <- |
|
389 |
snapshot.cumulate[(List[Markup], Option[Rendering.Color.Value])]( |
|
390 |
range, (List(Markup.Empty), None), Rendering.background_elements, |
|
391 |
command_states => |
|
392 |
{ |
|
393 |
case (((markups, color), Text.Info(_, XML.Elem(markup, _)))) |
|
68758 | 394 |
if markups.nonEmpty && Document_Status.Command_Status.proper_elements(markup.name) => |
65101 | 395 |
Some((markup :: markups, color)) |
396 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) => |
|
397 |
Some((Nil, Some(Rendering.Color.bad))) |
|
398 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) => |
|
399 |
Some((Nil, Some(Rendering.Color.intensify))) |
|
400 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
|
401 |
props match { |
|
402 |
case Markup.Entity.Def(i) if focus(i) => Some((Nil, Some(Rendering.Color.entity))) |
|
403 |
case Markup.Entity.Ref(i) if focus(i) => Some((Nil, Some(Rendering.Color.entity))) |
|
404 |
case _ => None |
|
405 |
} |
|
67322 | 406 |
case (_, Text.Info(_, XML.Elem(Markup.Markdown_Bullet(depth), _))) => |
65101 | 407 |
val color = |
65150 | 408 |
depth % 4 match { |
67322 | 409 |
case 1 => Rendering.Color.markdown_bullet1 |
410 |
case 2 => Rendering.Color.markdown_bullet2 |
|
411 |
case 3 => Rendering.Color.markdown_bullet3 |
|
412 |
case _ => Rendering.Color.markdown_bullet4 |
|
65101 | 413 |
} |
414 |
Some((Nil, Some(color))) |
|
415 |
case (acc, Text.Info(_, Protocol.Dialog(_, serial, result))) => |
|
416 |
command_states.collectFirst( |
|
417 |
{ case st if st.results.defined(serial) => st.results.get(serial).get }) match |
|
418 |
{ |
|
419 |
case Some(Protocol.Dialog_Result(res)) if res == result => |
|
420 |
Some((Nil, Some(Rendering.Color.active_result))) |
|
421 |
case _ => |
|
422 |
Some((Nil, Some(Rendering.Color.active))) |
|
423 |
} |
|
424 |
case (_, Text.Info(_, elem)) => |
|
425 |
if (Rendering.active_elements(elem.name)) |
|
426 |
Some((Nil, Some(Rendering.Color.active))) |
|
427 |
else None |
|
428 |
}) |
|
429 |
color <- |
|
430 |
(result match { |
|
431 |
case (markups, opt_color) if markups.nonEmpty => |
|
68758 | 432 |
val status = Document_Status.Command_Status.make(markups.iterator) |
65101 | 433 |
if (status.is_unprocessed) Some(Rendering.Color.unprocessed1) |
434 |
else if (status.is_running) Some(Rendering.Color.running1) |
|
435 |
else opt_color |
|
436 |
case (_, opt_color) => opt_color |
|
437 |
}) |
|
438 |
} yield Text.Info(r, color) |
|
439 |
} |
|
440 |
||
441 |
||
442 |
/* text foreground */ |
|
443 |
||
444 |
def foreground(range: Text.Range): List[Text.Info[Rendering.Color.Value]] = |
|
445 |
snapshot.select(range, Rendering.foreground_elements, _ => |
|
446 |
{ |
|
66074 | 447 |
case info => Some(Rendering.foreground(info.info.name)) |
65101 | 448 |
}) |
449 |
||
450 |
||
64767 | 451 |
/* caret focus */ |
452 |
||
453 |
private def entity_focus(range: Text.Range, |
|
454 |
check: (Boolean, Long) => Boolean = (is_def: Boolean, i: Long) => is_def): Set[Long] = |
|
455 |
{ |
|
456 |
val results = |
|
457 |
snapshot.cumulate[Set[Long]](range, Set.empty, Rendering.caret_focus_elements, _ => |
|
458 |
{ |
|
459 |
case (serials, Text.Info(_, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
|
460 |
props match { |
|
461 |
case Markup.Entity.Def(i) if check(true, i) => Some(serials + i) |
|
462 |
case Markup.Entity.Ref(i) if check(false, i) => Some(serials + i) |
|
463 |
case _ => None |
|
464 |
} |
|
465 |
case _ => None |
|
466 |
}) |
|
467 |
(Set.empty[Long] /: results){ case (s1, Text.Info(_, s2)) => s1 ++ s2 } |
|
468 |
} |
|
469 |
||
470 |
def caret_focus(caret_range: Text.Range, visible_range: Text.Range): Set[Long] = |
|
471 |
{ |
|
472 |
val focus_defs = entity_focus(caret_range) |
|
473 |
if (focus_defs.nonEmpty) focus_defs |
|
474 |
else { |
|
475 |
val visible_defs = entity_focus(visible_range) |
|
476 |
entity_focus(caret_range, (is_def: Boolean, i: Long) => !is_def && visible_defs.contains(i)) |
|
477 |
} |
|
478 |
} |
|
479 |
||
480 |
def caret_focus_ranges(caret_range: Text.Range, visible_range: Text.Range): List[Text.Range] = |
|
481 |
{ |
|
482 |
val focus = caret_focus(caret_range, visible_range) |
|
483 |
if (focus.nonEmpty) { |
|
484 |
val results = |
|
485 |
snapshot.cumulate[Boolean](visible_range, false, Rendering.caret_focus_elements, _ => |
|
486 |
{ |
|
487 |
case (_, Text.Info(_, XML.Elem(Markup(Markup.ENTITY, props), _))) => |
|
488 |
props match { |
|
489 |
case Markup.Entity.Def(i) if focus(i) => Some(true) |
|
490 |
case Markup.Entity.Ref(i) if focus(i) => Some(true) |
|
491 |
case _ => None |
|
492 |
} |
|
493 |
}) |
|
494 |
for (info <- results if info.info) yield info.range |
|
495 |
} |
|
496 |
else Nil |
|
497 |
} |
|
65121 | 498 |
|
499 |
||
500 |
/* message underline color */ |
|
501 |
||
65129
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
502 |
def message_underline_color(elements: Markup.Elements, range: Text.Range) |
06a7c2d316cf
more general tooltips, with uniform info range handling;
wenzelm
parents:
65126
diff
changeset
|
503 |
: List[Text.Info[Rendering.Color.Value]] = |
65121 | 504 |
{ |
505 |
val results = |
|
506 |
snapshot.cumulate[Int](range, 0, elements, _ => |
|
507 |
{ |
|
508 |
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name)) |
|
509 |
}) |
|
510 |
for { |
|
511 |
Text.Info(r, pri) <- results |
|
512 |
color <- Rendering.message_underline_color.get(pri) |
|
513 |
} yield Text.Info(r, color) |
|
514 |
} |
|
65149 | 515 |
|
516 |
||
517 |
/* tooltips */ |
|
518 |
||
519 |
def timing_threshold: Double |
|
520 |
||
521 |
private sealed case class Tooltip_Info( |
|
522 |
range: Text.Range, |
|
523 |
timing: Timing = Timing.zero, |
|
524 |
messages: List[Command.Results.Entry] = Nil, |
|
525 |
rev_infos: List[(Boolean, XML.Tree)] = Nil) |
|
526 |
{ |
|
527 |
def + (t: Timing): Tooltip_Info = copy(timing = timing + t) |
|
528 |
def + (r0: Text.Range, serial: Long, tree: XML.Tree): Tooltip_Info = |
|
529 |
{ |
|
530 |
val r = snapshot.convert(r0) |
|
531 |
if (range == r) copy(messages = (serial -> tree) :: messages) |
|
532 |
else copy(range = r, messages = List(serial -> tree)) |
|
533 |
} |
|
534 |
def + (r0: Text.Range, important: Boolean, tree: XML.Tree): Tooltip_Info = |
|
535 |
{ |
|
536 |
val r = snapshot.convert(r0) |
|
537 |
if (range == r) copy(rev_infos = (important -> tree) :: rev_infos) |
|
538 |
else copy (range = r, rev_infos = List(important -> tree)) |
|
539 |
} |
|
67933
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
540 |
|
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
541 |
def timing_info(tree: XML.Tree): Option[XML.Tree] = |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
542 |
tree match { |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
543 |
case XML.Elem(Markup(Markup.TIMING, _), _) => |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
544 |
if (timing.elapsed.seconds >= timing_threshold) Some(XML.Text(timing.message)) else None |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
545 |
case _ => Some(tree) |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
546 |
} |
65149 | 547 |
def infos(important: Boolean): List[XML.Tree] = |
67933
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
548 |
for { |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
549 |
(is_important, tree) <- rev_infos.reverse if is_important == important |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
550 |
tree1 <- timing_info(tree) |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
551 |
} yield tree1 |
65149 | 552 |
} |
553 |
||
65488 | 554 |
def perhaps_append_file(node_name: Document.Node.Name, name: String): String = |
555 |
if (Path.is_valid(name)) session.resources.append(node_name, Path.explode(name)) else name |
|
65487 | 556 |
|
65149 | 557 |
def tooltips(elements: Markup.Elements, range: Text.Range): Option[Text.Info[List[XML.Tree]]] = |
558 |
{ |
|
559 |
val results = |
|
67824
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
560 |
snapshot.cumulate[Tooltip_Info](range, Tooltip_Info(range), elements, command_states => |
65149 | 561 |
{ |
562 |
case (info, Text.Info(_, XML.Elem(Markup.Timing(t), _))) => Some(info + t) |
|
563 |
||
67824
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
564 |
case (info, Text.Info(r0, msg @ XML.Elem(Markup(Markup.BAD, Markup.Serial(i)), body))) |
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
565 |
if body.nonEmpty => Some(info + (r0, i, msg)) |
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
566 |
|
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
567 |
case (info, Text.Info(r0, XML.Elem(Markup(name, props), _))) |
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
568 |
if Rendering.tooltip_message_elements(name) => |
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
569 |
for ((i, tree) <- Command.State.get_result_proper(command_states, props)) |
661cd25304ae
more compact markup tree: output messages are already stored in command results (e.g. relevant for XML data representation);
wenzelm
parents:
67395
diff
changeset
|
570 |
yield (info + (r0, i, tree)) |
65149 | 571 |
|
572 |
case (info, Text.Info(r0, XML.Elem(Markup.Entity(kind, name), _))) |
|
573 |
if kind != "" && kind != Markup.ML_DEF => |
|
574 |
val kind1 = Word.implode(Word.explode('_', kind)) |
|
575 |
val txt1 = |
|
576 |
if (name == "") kind1 |
|
577 |
else if (kind1 == "") quote(name) |
|
578 |
else kind1 + " " + quote(name) |
|
67933
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
579 |
val info1 = info + (r0, true, XML.Text(txt1)) |
604da273e18d
more robust timing info: do not rely on order of markup;
wenzelm
parents:
67824
diff
changeset
|
580 |
Some(if (kind == Markup.COMMAND) info1 + (r0, true, XML.elem(Markup.TIMING)) else info1) |
65149 | 581 |
|
582 |
case (info, Text.Info(r0, XML.Elem(Markup.Path(name), _))) => |
|
65488 | 583 |
val file = perhaps_append_file(snapshot.node_name, name) |
65149 | 584 |
val text = |
585 |
if (name == file) "file " + quote(file) |
|
586 |
else "path " + quote(name) + "\nfile " + quote(file) |
|
587 |
Some(info + (r0, true, XML.Text(text))) |
|
588 |
||
589 |
case (info, Text.Info(r0, XML.Elem(Markup.Doc(name), _))) => |
|
590 |
val text = "doc " + quote(name) |
|
591 |
Some(info + (r0, true, XML.Text(text))) |
|
592 |
||
593 |
case (info, Text.Info(r0, XML.Elem(Markup.Url(name), _))) => |
|
594 |
Some(info + (r0, true, XML.Text("URL " + quote(name)))) |
|
595 |
||
596 |
case (info, Text.Info(r0, XML.Elem(Markup(name, _), body))) |
|
597 |
if name == Markup.SORTING || name == Markup.TYPING => |
|
598 |
Some(info + (r0, true, Pretty.block(XML.Text("::") :: Pretty.brk(1) :: body))) |
|
599 |
||
600 |
case (info, Text.Info(r0, XML.Elem(Markup(Markup.CLASS_PARAMETER, _), body))) => |
|
601 |
Some(info + (r0, true, Pretty.block(0, body))) |
|
602 |
||
603 |
case (info, Text.Info(r0, XML.Elem(Markup(Markup.ML_TYPING, _), body))) => |
|
604 |
Some(info + (r0, false, Pretty.block(XML.Text("ML:") :: Pretty.brk(1) :: body))) |
|
605 |
||
606 |
case (info, Text.Info(r0, Protocol.ML_Breakpoint(breakpoint))) => |
|
65222
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65213
diff
changeset
|
607 |
val text = |
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65213
diff
changeset
|
608 |
if (session.debugger.breakpoint_state(breakpoint)) "breakpoint (enabled)" |
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65213
diff
changeset
|
609 |
else "breakpoint (disabled)" |
fb8253564483
more robust debugger initialization, e.g. required for GUI components before actual session startup;
wenzelm
parents:
65213
diff
changeset
|
610 |
Some(info + (r0, true, XML.Text(text))) |
65149 | 611 |
case (info, Text.Info(r0, XML.Elem(Markup.Language(language, _, _, _), _))) => |
612 |
val lang = Word.implode(Word.explode('_', language)) |
|
613 |
Some(info + (r0, true, XML.Text("language: " + lang))) |
|
614 |
||
615 |
case (info, Text.Info(r0, XML.Elem(Markup.Expression(kind), _))) => |
|
616 |
val descr = if (kind == "") "expression" else "expression: " + kind |
|
617 |
Some(info + (r0, true, XML.Text(descr))) |
|
618 |
||
619 |
case (info, Text.Info(r0, XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), _))) => |
|
620 |
Some(info + (r0, true, XML.Text("Markdown: paragraph"))) |
|
67323
d02208cefbdb
PIDE markup for Markdown items (which may consist of multiple paragraphs or lists);
wenzelm
parents:
67322
diff
changeset
|
621 |
case (info, Text.Info(r0, XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), _))) => |
d02208cefbdb
PIDE markup for Markdown items (which may consist of multiple paragraphs or lists);
wenzelm
parents:
67322
diff
changeset
|
622 |
Some(info + (r0, true, XML.Text("Markdown: item"))) |
65149 | 623 |
case (info, Text.Info(r0, XML.Elem(Markup.Markdown_List(kind), _))) => |
624 |
Some(info + (r0, true, XML.Text("Markdown: " + kind))) |
|
625 |
||
626 |
case (info, Text.Info(r0, XML.Elem(Markup(name, _), _))) => |
|
627 |
Rendering.tooltip_descriptions.get(name).map(desc => info + (r0, true, XML.Text(desc))) |
|
628 |
}).map(_.info) |
|
629 |
||
630 |
if (results.isEmpty) None |
|
631 |
else { |
|
632 |
val r = Text.Range(results.head.range.start, results.last.range.stop) |
|
633 |
val all_tips = |
|
634 |
Command.Results.make(results.flatMap(_.messages)).iterator.map(_._2).toList ::: |
|
635 |
results.flatMap(res => res.infos(true)) ::: |
|
636 |
results.flatMap(res => res.infos(false)).lastOption.toList |
|
637 |
if (all_tips.isEmpty) None else Some(Text.Info(r, all_tips)) |
|
638 |
} |
|
639 |
} |
|
65911 | 640 |
|
641 |
||
642 |
/* command status overview */ |
|
643 |
||
644 |
def overview_color(range: Text.Range): Option[Rendering.Color.Value] = |
|
645 |
{ |
|
646 |
if (snapshot.is_outdated) None |
|
647 |
else { |
|
648 |
val results = |
|
68758 | 649 |
snapshot.cumulate[List[Markup]](range, Nil, Document_Status.Command_Status.liberal_elements, |
650 |
_ => |
|
651 |
{ |
|
652 |
case (status, Text.Info(_, elem)) => Some(elem.markup :: status) |
|
653 |
}, status = true) |
|
65911 | 654 |
if (results.isEmpty) None |
655 |
else { |
|
68758 | 656 |
val status = Document_Status.Command_Status.make(results.iterator.flatMap(_.info)) |
65911 | 657 |
|
658 |
if (status.is_running) Some(Rendering.Color.running) |
|
659 |
else if (status.is_failed) Some(Rendering.Color.error) |
|
660 |
else if (status.is_warned) Some(Rendering.Color.warning) |
|
661 |
else if (status.is_unprocessed) Some(Rendering.Color.unprocessed) |
|
662 |
else None |
|
663 |
} |
|
664 |
} |
|
665 |
} |
|
67132 | 666 |
|
667 |
||
668 |
/* antiquoted text */ |
|
669 |
||
670 |
def antiquoted(range: Text.Range): Option[Text.Range] = |
|
671 |
snapshot.cumulate[Option[Text.Range]](range, None, Rendering.antiquoted_elements, _ => |
|
672 |
{ |
|
673 |
case (res, info) => if (res.isEmpty) Some(Some(info.range)) else None |
|
674 |
}).headOption.flatMap(_.info) |
|
64622
529bbb8977c7
more uniform rendering for Isabelle/jEdit and Isabelle/VSCode;
wenzelm
parents:
diff
changeset
|
675 |
} |