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