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