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