author | wenzelm |
Mon, 02 Sep 2013 16:10:26 +0200 | |
changeset 53371 | 47b23c582127 |
parent 53272 | 0dfd78ff7696 |
child 53571 | e58ca0311c0f |
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 |
||
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
70 |
/* token markup -- text styles */ |
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, |
50643 | 78 |
Keyword.PRF_SCRIPT -> DIGIT, |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
79 |
Keyword.PRF_ASM -> KEYWORD3, |
53371
47b23c582127
more explicit indication of 'guess' as improper Isar (aka "script") element;
wenzelm
parents:
53272
diff
changeset
|
80 |
Keyword.PRF_ASM_GOAL -> KEYWORD3, |
47b23c582127
more explicit indication of 'guess' as improper Isar (aka "script") element;
wenzelm
parents:
53272
diff
changeset
|
81 |
Keyword.PRF_ASM_GOAL_SCRIPT -> DIGIT |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
82 |
).withDefaultValue(KEYWORD1) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
83 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
84 |
|
43414 | 85 |
private val token_style: Map[Token.Kind.Value, Byte] = |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
86 |
{ |
43414 | 87 |
import JEditToken._ |
88 |
Map[Token.Kind.Value, Byte]( |
|
89 |
Token.Kind.KEYWORD -> KEYWORD2, |
|
90 |
Token.Kind.IDENT -> NULL, |
|
91 |
Token.Kind.LONG_IDENT -> NULL, |
|
92 |
Token.Kind.SYM_IDENT -> NULL, |
|
93 |
Token.Kind.VAR -> NULL, |
|
94 |
Token.Kind.TYPE_IDENT -> NULL, |
|
95 |
Token.Kind.TYPE_VAR -> NULL, |
|
96 |
Token.Kind.NAT -> NULL, |
|
97 |
Token.Kind.FLOAT -> NULL, |
|
43431 | 98 |
Token.Kind.STRING -> LITERAL1, |
99 |
Token.Kind.ALT_STRING -> LITERAL2, |
|
43414 | 100 |
Token.Kind.VERBATIM -> COMMENT3, |
101 |
Token.Kind.SPACE -> NULL, |
|
102 |
Token.Kind.COMMENT -> COMMENT1, |
|
48754
c2c1e5944536
clarified undefined, unparsed, unfinished command spans;
wenzelm
parents:
48751
diff
changeset
|
103 |
Token.Kind.ERROR -> INVALID |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
104 |
).withDefaultValue(NULL) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
105 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
106 |
|
43414 | 107 |
def token_markup(syntax: Outer_Syntax, token: Token): Byte = |
43430
1ed88ddf1268
more uniform treatment of "keyword" vs. "operator";
wenzelm
parents:
43418
diff
changeset
|
108 |
if (token.is_command) command_style(syntax.keyword_kind(token.content).getOrElse("")) |
1ed88ddf1268
more uniform treatment of "keyword" vs. "operator";
wenzelm
parents:
43418
diff
changeset
|
109 |
else if (token.is_operator) JEditToken.OPERATOR |
43414 | 110 |
else token_style(token.kind) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
111 |
} |
49356 | 112 |
|
113 |
||
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
114 |
class Rendering private(val snapshot: Document.Snapshot, val options: Options) |
49356 | 115 |
{ |
116 |
/* colors */ |
|
117 |
||
118 |
def color_value(s: String): Color = Color_Value(options.string(s)) |
|
119 |
||
120 |
val outdated_color = color_value("outdated_color") |
|
121 |
val unprocessed_color = color_value("unprocessed_color") |
|
122 |
val unprocessed1_color = color_value("unprocessed1_color") |
|
123 |
val running_color = color_value("running_color") |
|
124 |
val running1_color = color_value("running1_color") |
|
125 |
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
|
126 |
val bullet_color = color_value("bullet_color") |
49706 | 127 |
val tooltip_color = color_value("tooltip_color") |
49356 | 128 |
val writeln_color = color_value("writeln_color") |
52650 | 129 |
val information_color = color_value("information_color") |
49356 | 130 |
val warning_color = color_value("warning_color") |
131 |
val error_color = color_value("error_color") |
|
132 |
val error1_color = color_value("error1_color") |
|
49418 | 133 |
val writeln_message_color = color_value("writeln_message_color") |
52650 | 134 |
val information_message_color = color_value("information_message_color") |
49418 | 135 |
val tracing_message_color = color_value("tracing_message_color") |
136 |
val warning_message_color = color_value("warning_message_color") |
|
137 |
val error_message_color = color_value("error_message_color") |
|
49356 | 138 |
val bad_color = color_value("bad_color") |
49358 | 139 |
val intensify_color = color_value("intensify_color") |
49356 | 140 |
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
|
141 |
val antiquoted_color = color_value("antiquoted_color") |
49358 | 142 |
val highlight_color = color_value("highlight_color") |
49356 | 143 |
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
|
144 |
val active_color = color_value("active_color") |
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
145 |
val active_hover_color = color_value("active_hover_color") |
50498 | 146 |
val active_result_color = color_value("active_result_color") |
49356 | 147 |
val keyword1_color = color_value("keyword1_color") |
148 |
val keyword2_color = color_value("keyword2_color") |
|
149 |
||
150 |
val tfree_color = color_value("tfree_color") |
|
151 |
val tvar_color = color_value("tvar_color") |
|
152 |
val free_color = color_value("free_color") |
|
153 |
val skolem_color = color_value("skolem_color") |
|
154 |
val bound_color = color_value("bound_color") |
|
155 |
val var_color = color_value("var_color") |
|
156 |
val inner_numeral_color = color_value("inner_numeral_color") |
|
157 |
val inner_quoted_color = color_value("inner_quoted_color") |
|
158 |
val inner_comment_color = color_value("inner_comment_color") |
|
159 |
val dynamic_color = color_value("dynamic_color") |
|
160 |
||
161 |
||
162 |
/* command overview */ |
|
163 |
||
49969
72216713733a
further attempts to cope with large files via option jedit_text_overview_limit;
wenzelm
parents:
49827
diff
changeset
|
164 |
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
|
165 |
|
50547 | 166 |
private val overview_include = Protocol.command_status_markup + Markup.WARNING + Markup.ERROR |
167 |
||
49356 | 168 |
def overview_color(range: Text.Range): Option[Color] = |
169 |
{ |
|
170 |
if (snapshot.is_outdated) None |
|
171 |
else { |
|
172 |
val results = |
|
173 |
snapshot.cumulate_markup[(Protocol.Status, Int)]( |
|
50547 | 174 |
range, (Protocol.Status.init, 0), Some(overview_include), _ => |
49356 | 175 |
{ |
52890 | 176 |
case ((status, pri), Text.Info(_, elem)) => |
177 |
if (elem.name == Markup.WARNING || elem.name == Markup.ERROR) |
|
178 |
Some((status, pri max Rendering.message_pri(elem.name))) |
|
179 |
else if (overview_include(elem.name)) |
|
180 |
Some((Protocol.command_status(status, elem.markup), pri)) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
181 |
else None |
49356 | 182 |
}) |
183 |
if (results.isEmpty) None |
|
184 |
else { |
|
185 |
val (status, pri) = |
|
186 |
((Protocol.Status.init, 0) /: results) { |
|
187 |
case ((s1, p1), Text.Info(_, (s2, p2))) => (s1 + s2, p1 max p2) } |
|
188 |
||
50895 | 189 |
if (status.is_running) Some(running_color) |
190 |
else if (pri == Rendering.warning_pri) Some(warning_color) |
|
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
191 |
else if (pri == Rendering.error_pri) Some(error_color) |
49356 | 192 |
else if (status.is_unprocessed) Some(unprocessed_color) |
193 |
else if (status.is_failed) Some(error_color) |
|
194 |
else None |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
||
200 |
/* markup selectors */ |
|
201 |
||
49358 | 202 |
private val highlight_include = |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
203 |
Set(Markup.SORT, Markup.TYP, Markup.TERM, Markup.PROP, Markup.ML_TYPING, Markup.TOKEN_RANGE, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
204 |
Markup.ENTITY, Markup.PATH, Markup.SORTING, Markup.TYPING, Markup.FREE, Markup.SKOLEM, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
205 |
Markup.BOUND, Markup.VAR, Markup.TFREE, Markup.TVAR, Markup.ML_SOURCE, Markup.DOCUMENT_SOURCE) |
49356 | 206 |
|
49358 | 207 |
def highlight(range: Text.Range): Option[Text.Info[Color]] = |
49356 | 208 |
{ |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
209 |
snapshot.select_markup(range, Some(highlight_include), _ => |
49356 | 210 |
{ |
52890 | 211 |
case Text.Info(info_range, elem) => |
212 |
if (highlight_include(elem.name)) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
213 |
Some(Text.Info(snapshot.convert(info_range), highlight_color)) |
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
214 |
else None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
215 |
}) match { case Text.Info(_, info) :: _ => Some(info) case _ => None } |
49356 | 216 |
} |
217 |
||
218 |
||
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
219 |
private val hyperlink_include = Set(Markup.ENTITY, Markup.PATH) |
49356 | 220 |
|
52980 | 221 |
def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] = |
49356 | 222 |
{ |
52980 | 223 |
snapshot.cumulate_markup[List[Text.Info[PIDE.editor.Hyperlink]]]( |
224 |
range, Nil, Some(hyperlink_include), _ => |
|
49356 | 225 |
{ |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
226 |
case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) |
49356 | 227 |
if Path.is_ok(name) => |
50205 | 228 |
val jedit_file = PIDE.thy_load.append(snapshot.node_name.dir, Path.explode(name)) |
52980 | 229 |
val link = PIDE.editor.hyperlink_file(jedit_file) |
230 |
Some(Text.Info(snapshot.convert(info_range), link) :: links) |
|
49356 | 231 |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
232 |
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _))) |
49815 | 233 |
if !props.exists( |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
234 |
{ 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
|
235 |
case (Markup.KIND, Markup.ML_STRUCT) => true |
49815 | 236 |
case _ => false }) => |
49356 | 237 |
|
238 |
props match { |
|
49419
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49418
diff
changeset
|
239 |
case Position.Def_Line_File(line, name) if Path.is_ok(name) => |
49356 | 240 |
Isabelle_System.source_file(Path.explode(name)) match { |
241 |
case Some(path) => |
|
242 |
val jedit_file = Isabelle_System.platform_path(path) |
|
52980 | 243 |
val link = PIDE.editor.hyperlink_file(jedit_file, line) |
244 |
Some(Text.Info(snapshot.convert(info_range), link) :: links) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
245 |
case None => None |
49356 | 246 |
} |
247 |
||
49419
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49418
diff
changeset
|
248 |
case Position.Def_Id_Offset(id, offset) => |
49356 | 249 |
snapshot.state.find_command(snapshot.version, id) match { |
250 |
case Some((node, command)) => |
|
52980 | 251 |
PIDE.editor.hyperlink_command(snapshot, command, offset) |
252 |
.map(link => (Text.Info(snapshot.convert(info_range), link) :: links)) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
253 |
case None => None |
49356 | 254 |
} |
255 |
||
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
256 |
case _ => None |
49356 | 257 |
} |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
258 |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
259 |
case _ => None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
260 |
}) match { case Text.Info(_, info :: _) :: _ => Some(info) case _ => None } |
49356 | 261 |
} |
262 |
||
263 |
||
50715
8cfd585b9162
prefer old graph browser in Isabelle/jEdit, which still produces better layout;
wenzelm
parents:
50643
diff
changeset
|
264 |
private val active_include = |
8cfd585b9162
prefer old graph browser in Isabelle/jEdit, which still produces better layout;
wenzelm
parents:
50643
diff
changeset
|
265 |
Set(Markup.BROWSER, Markup.GRAPHVIEW, Markup.SENDBACK, Markup.DIALOG) |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
266 |
|
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50215
diff
changeset
|
267 |
def active(range: Text.Range): Option[Text.Info[XML.Elem]] = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
268 |
snapshot.select_markup(range, Some(active_include), command_state => |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
269 |
{ |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
270 |
case Text.Info(info_range, elem @ Protocol.Dialog(_, serial, _)) |
50507 | 271 |
if !command_state.results.defined(serial) => |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
272 |
Some(Text.Info(snapshot.convert(info_range), elem)) |
52890 | 273 |
case Text.Info(info_range, elem) => |
274 |
if (elem.name == Markup.BROWSER || |
|
275 |
elem.name == Markup.GRAPHVIEW || |
|
276 |
elem.name == Markup.SENDBACK) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
277 |
Some(Text.Info(snapshot.convert(info_range), elem)) |
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
278 |
else None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
279 |
}) match { case Text.Info(_, info) :: _ => Some(info) case _ => None } |
49492 | 280 |
|
281 |
||
50502 | 282 |
def command_results(range: Text.Range): Command.Results = |
283 |
{ |
|
284 |
val results = |
|
285 |
snapshot.select_markup[Command.Results](range, None, 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
|
286 |
{ case _ => Some(command_state.results) }).map(_.info) |
50507 | 287 |
(Command.Results.empty /: results)(_ ++ _) |
50502 | 288 |
} |
289 |
||
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
|
290 |
def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 291 |
{ |
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
|
292 |
val results = |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
293 |
snapshot.cumulate_markup[List[Text.Info[Command.Results.Entry]]](range, Nil, |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
294 |
Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR, Markup.BAD)), _ => |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
295 |
{ |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
296 |
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
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
(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
|
301 |
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
|
302 |
|
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
303 |
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
|
304 |
if !body.isEmpty => |
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52472
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
308 |
case _ => None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
309 |
}).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
|
310 |
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
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
|
315 |
} |
49356 | 316 |
} |
317 |
||
318 |
||
319 |
private val tooltips: Map[String, String] = |
|
320 |
Map( |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
321 |
Markup.SORT -> "sort", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
322 |
Markup.TYP -> "type", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
323 |
Markup.TERM -> "term", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
324 |
Markup.PROP -> "proposition", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
325 |
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
|
326 |
Markup.FREE -> "free variable", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
327 |
Markup.SKOLEM -> "skolem variable", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
328 |
Markup.BOUND -> "bound variable", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
329 |
Markup.VAR -> "schematic variable", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
330 |
Markup.TFREE -> "free type variable", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
331 |
Markup.TVAR -> "schematic type variable", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
332 |
Markup.ML_SOURCE -> "ML source", |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
333 |
Markup.DOCUMENT_SOURCE -> "document source") |
49356 | 334 |
|
335 |
private val tooltip_elements = |
|
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
336 |
Set(Markup.TIMING, Markup.ENTITY, Markup.SORTING, Markup.TYPING, |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
337 |
Markup.ML_TYPING, Markup.PATH) ++ tooltips.keys |
49356 | 338 |
|
49700
2d1cbdf6a68b
Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents:
49674
diff
changeset
|
339 |
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
|
340 |
Pretty.block(XML.Text(kind) :: Pretty.Break(1) :: body) |
49356 | 341 |
|
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
342 |
private val timing_threshold: Double = options.real("jedit_timing_threshold") |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
343 |
|
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
|
344 |
def tooltip(range: Text.Range): Option[Text.Info[XML.Body]] = |
49356 | 345 |
{ |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
346 |
def add(prev: Text.Info[(Timing, List[(Boolean, XML.Tree)])], |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
347 |
r0: Text.Range, p: (Boolean, XML.Tree)): Text.Info[(Timing, List[(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
|
348 |
{ |
cb677987b7e3
retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents:
50895
diff
changeset
|
349 |
val r = snapshot.convert(r0) |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
350 |
val (t, info) = prev.info |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
351 |
if (prev.range == r) Text.Info(r, (t, p :: info)) else Text.Info(r, (t, List(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
|
352 |
} |
49356 | 353 |
|
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
|
354 |
val results = |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
355 |
snapshot.cumulate_markup[Text.Info[(Timing, List[(Boolean, XML.Tree)])]]( |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
356 |
range, Text.Info(range, (Timing.zero, Nil)), Some(tooltip_elements), _ => |
49356 | 357 |
{ |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
358 |
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
|
359 |
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
|
360 |
case (prev, Text.Info(r, XML.Elem(Markup.Entity(kind, name), _))) => |
49356 | 361 |
val kind1 = space_explode('_', kind).mkString(" ") |
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
362 |
val txt1 = kind1 + " " + quote(name) |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
363 |
val t = prev.info._1 |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
364 |
val txt2 = |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
365 |
if (kind == Markup.COMMAND && t.elapsed.seconds >= timing_threshold) |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
366 |
"\n" + t.message |
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
367 |
else "" |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
368 |
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
|
369 |
case (prev, Text.Info(r, XML.Elem(Markup.Path(name), _))) |
49356 | 370 |
if Path.is_ok(name) => |
50205 | 371 |
val jedit_file = PIDE.thy_load.append(snapshot.node_name.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
|
372 |
Some(add(prev, r, (true, XML.Text("file " + quote(jedit_file))))) |
49674
dbadb4d03cbc
report sort assignment of visible type variables;
wenzelm
parents:
49554
diff
changeset
|
373 |
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
|
374 |
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
|
375 |
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
|
376 |
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
|
377 |
Some(add(prev, r, (false, pretty_typing("ML:", body)))) |
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
378 |
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
|
379 |
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
|
380 |
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
|
381 |
else None |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
382 |
}).map(_.info) |
49356 | 383 |
|
51588
167e2d64327a
tooltip of command keyword includes timing information;
wenzelm
parents:
51574
diff
changeset
|
384 |
results.map(_.info).flatMap(_._2) 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
|
385 |
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
|
386 |
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
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
} |
49356 | 391 |
} |
392 |
||
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
|
393 |
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
|
394 |
|
52873 | 395 |
lazy val tooltip_close_icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon")) |
396 |
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
|
397 |
|
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
398 |
|
3a43a8b1ecb0
load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents:
52471
diff
changeset
|
399 |
private lazy val gutter_icons = Map( |
52873 | 400 |
Rendering.information_pri -> JEdit_Lib.load_icon(options.string("gutter_information_icon")), |
401 |
Rendering.warning_pri -> JEdit_Lib.load_icon(options.string("gutter_warning_icon")), |
|
402 |
Rendering.legacy_pri -> JEdit_Lib.load_icon(options.string("gutter_legacy_icon")), |
|
403 |
Rendering.error_pri -> JEdit_Lib.load_icon(options.string("gutter_error_icon"))) |
|
49356 | 404 |
|
52644 | 405 |
private val gutter_elements = Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR) |
406 |
||
49356 | 407 |
def gutter_message(range: Text.Range): Option[Icon] = |
408 |
{ |
|
409 |
val results = |
|
52644 | 410 |
snapshot.cumulate_markup[Int](range, 0, Some(gutter_elements), _ => |
49356 | 411 |
{ |
52644 | 412 |
case (pri, Text.Info(_, XML.Elem(Markup(Markup.WRITELN, _), |
413 |
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
|
414 |
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
|
415 |
case (pri, Text.Info(_, XML.Elem(Markup(Markup.WARNING, _), body))) => |
49356 | 416 |
body match { |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
417 |
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
|
418 |
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
|
419 |
case _ => |
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
420 |
Some(pri max Rendering.warning_pri) |
49356 | 421 |
} |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
422 |
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
|
423 |
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
|
424 |
case _ => None |
49356 | 425 |
}) |
426 |
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
|
427 |
gutter_icons.get(pri) |
49356 | 428 |
} |
429 |
||
430 |
||
431 |
private val squiggly_colors = Map( |
|
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
432 |
Rendering.writeln_pri -> writeln_color, |
52650 | 433 |
Rendering.information_pri -> information_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
434 |
Rendering.warning_pri -> warning_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
435 |
Rendering.error_pri -> error_color) |
49356 | 436 |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
437 |
private val squiggly_include = Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR) |
52644 | 438 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
439 |
def squiggly_underline(range: Text.Range): List[Text.Info[Color]] = |
49356 | 440 |
{ |
441 |
val results = |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
442 |
snapshot.cumulate_markup[Int](range, 0, Some(squiggly_include), _ => |
49356 | 443 |
{ |
52890 | 444 |
case (pri, Text.Info(_, elem)) => |
445 |
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
|
446 |
Some(pri max Rendering.information_pri) |
52890 | 447 |
else if (squiggly_include.contains(elem.name)) |
448 |
Some(pri max Rendering.message_pri(elem.name)) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
449 |
else None |
49356 | 450 |
}) |
451 |
for { |
|
452 |
Text.Info(r, pri) <- results |
|
453 |
color <- squiggly_colors.get(pri) |
|
454 |
} yield Text.Info(r, color) |
|
455 |
} |
|
456 |
||
49474 | 457 |
|
458 |
private val message_colors = Map( |
|
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
459 |
Rendering.writeln_pri -> writeln_message_color, |
52650 | 460 |
Rendering.information_pri -> information_message_color, |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
461 |
Rendering.tracing_pri -> tracing_message_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
462 |
Rendering.warning_pri -> warning_message_color, |
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50196
diff
changeset
|
463 |
Rendering.error_pri -> error_message_color) |
49474 | 464 |
|
52650 | 465 |
private val line_background_elements = |
466 |
Set(Markup.WRITELN_MESSAGE, Markup.TRACING_MESSAGE, Markup.WARNING_MESSAGE, |
|
467 |
Markup.ERROR_MESSAGE, Markup.INFORMATION) |
|
468 |
||
49473 | 469 |
def line_background(range: Text.Range): Option[(Color, Boolean)] = |
470 |
{ |
|
49474 | 471 |
val results = |
52650 | 472 |
snapshot.cumulate_markup[Int](range, 0, Some(line_background_elements), _ => |
49473 | 473 |
{ |
52890 | 474 |
case (pri, Text.Info(_, elem)) => |
475 |
val name = elem.name |
|
476 |
if (name == Markup.INFORMATION) |
|
477 |
Some(pri max Rendering.information_pri) |
|
478 |
else if (name == Markup.WRITELN_MESSAGE || name == Markup.TRACING_MESSAGE || |
|
479 |
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
|
480 |
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
|
481 |
else None |
49474 | 482 |
}) |
483 |
val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
|
484 |
||
485 |
val is_separator = pri > 0 && |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
486 |
snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)), _ => |
49473 | 487 |
{ |
52890 | 488 |
case (_, Text.Info(_, elem)) => |
489 |
if (elem.name == Markup.SEPARATOR) Some(true) else None |
|
49473 | 490 |
}).exists(_.info) |
491 |
||
49474 | 492 |
message_colors.get(pri).map((_, is_separator)) |
49473 | 493 |
} |
49356 | 494 |
|
49492 | 495 |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
496 |
def output_messages(st: Command.State): List[XML.Tree] = |
50507 | 497 |
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
|
498 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
499 |
|
49492 | 500 |
private val background1_include = |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
501 |
Protocol.command_status_markup + Markup.WRITELN_MESSAGE + Markup.TRACING_MESSAGE + |
52650 | 502 |
Markup.WARNING_MESSAGE + Markup.ERROR_MESSAGE + Markup.BAD + Markup.INTENSIFY ++ |
503 |
active_include |
|
49492 | 504 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
505 |
def background1(range: Text.Range): List[Text.Info[Color]] = |
49356 | 506 |
{ |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
507 |
if (snapshot.is_outdated) List(Text.Info(range, outdated_color)) |
49356 | 508 |
else |
509 |
for { |
|
510 |
Text.Info(r, result) <- |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
511 |
snapshot.cumulate_markup[(Option[Protocol.Status], Option[Color])]( |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
512 |
range, (Some(Protocol.Status.init), None), Some(background1_include), command_state => |
49356 | 513 |
{ |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
514 |
case (((Some(status), color), Text.Info(_, XML.Elem(markup, _)))) |
49356 | 515 |
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
|
516 |
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
|
517 |
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
|
518 |
Some((None, Some(bad_color))) |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
519 |
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
|
520 |
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
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
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
|
525 |
case _ => |
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52873
diff
changeset
|
526 |
Some((None, Some(active_color))) |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
527 |
} |
52890 | 528 |
case (_, Text.Info(_, elem)) => |
529 |
if (active_include(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
|
530 |
else None |
49356 | 531 |
}) |
532 |
color <- |
|
533 |
(result match { |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
534 |
case (Some(status), opt_color) => |
49356 | 535 |
if (status.is_unprocessed) Some(unprocessed1_color) |
536 |
else if (status.is_running) Some(running1_color) |
|
537 |
else opt_color |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
538 |
case (_, opt_color) => opt_color |
49356 | 539 |
}) |
540 |
} yield Text.Info(r, color) |
|
541 |
} |
|
542 |
||
543 |
||
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
544 |
def background2(range: Text.Range): List[Text.Info[Color]] = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
545 |
snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)), _ => |
49356 | 546 |
{ |
52890 | 547 |
case Text.Info(_, elem) => |
548 |
if (elem.name == Markup.TOKEN_RANGE) Some(light_color) else None |
|
49356 | 549 |
}) |
550 |
||
551 |
||
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
552 |
def bullet(range: Text.Range): List[Text.Info[Color]] = |
51574
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
553 |
snapshot.select_markup(range, Some(Set(Markup.BULLET)), _ => |
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
554 |
{ |
52890 | 555 |
case Text.Info(_, elem) => |
556 |
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
|
557 |
}) |
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
558 |
|
2b58d7b139d6
ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents:
51496
diff
changeset
|
559 |
|
52890 | 560 |
private val foreground_include = |
52101
7679178b0aa5
less intrusive rendering of antiquoted text -- avoid visual clash with "blue variables" in particular;
wenzelm
parents:
52081
diff
changeset
|
561 |
Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM, Markup.ANTIQ) |
7679178b0aa5
less intrusive rendering of antiquoted text -- avoid visual clash with "blue variables" in particular;
wenzelm
parents:
52081
diff
changeset
|
562 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
563 |
def foreground(range: Text.Range): List[Text.Info[Color]] = |
52890 | 564 |
snapshot.select_markup(range, Some(foreground_include), _ => |
49356 | 565 |
{ |
52890 | 566 |
case Text.Info(_, elem) => |
567 |
if (elem.name == Markup.ANTIQ) Some(antiquoted_color) |
|
568 |
else if (foreground_include.contains(elem.name)) Some(quoted_color) |
|
569 |
else None |
|
49356 | 570 |
}) |
571 |
||
572 |
||
573 |
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
|
574 |
Markup.KEYWORD1 -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
575 |
Markup.KEYWORD2 -> keyword2_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
576 |
Markup.STRING -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
577 |
Markup.ALTSTRING -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
578 |
Markup.VERBATIM -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
579 |
Markup.LITERAL -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
580 |
Markup.DELIMITER -> Color.BLACK, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
581 |
Markup.TFREE -> tfree_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
582 |
Markup.TVAR -> tvar_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
583 |
Markup.FREE -> free_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
584 |
Markup.SKOLEM -> skolem_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
585 |
Markup.BOUND -> bound_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
586 |
Markup.VAR -> var_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
587 |
Markup.INNER_STRING -> inner_quoted_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
588 |
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
|
589 |
Markup.DYNAMIC_FACT -> dynamic_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
590 |
Markup.ML_KEYWORD -> keyword1_color, |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50200
diff
changeset
|
591 |
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
|
592 |
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
|
593 |
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
|
594 |
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
|
595 |
Markup.ML_COMMENT -> inner_comment_color) |
49356 | 596 |
|
52102 | 597 |
private val text_color_elements = text_colors.keySet |
49356 | 598 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
599 |
def text_color(range: Text.Range, color: Color): List[Text.Info[Color]] = |
49356 | 600 |
{ |
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
601 |
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
|
602 |
else |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50499
diff
changeset
|
603 |
snapshot.cumulate_markup(range, color, Some(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
|
604 |
{ |
52890 | 605 |
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
|
606 |
}) |
49356 | 607 |
} |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
608 |
|
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
609 |
|
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
610 |
/* 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
|
611 |
|
50545
00bdc48c5f71
explicit text_fold markup, which is used by default in Pretty.chunks/chunks2;
wenzelm
parents:
50543
diff
changeset
|
612 |
private val fold_depth_include = 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
|
613 |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52890
diff
changeset
|
614 |
def fold_depth(range: Text.Range): List[Text.Info[Int]] = |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
615 |
snapshot.cumulate_markup[Int](range, 0, Some(fold_depth_include), _ => |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
616 |
{ |
52890 | 617 |
case (depth, Text.Info(_, elem)) => |
618 |
if (fold_depth_include(elem.name)) Some(depth + 1) else None |
|
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50507
diff
changeset
|
619 |
}) |
49356 | 620 |
} |