author | wenzelm |
Mon, 09 Jan 2012 23:11:28 +0100 | |
changeset 46166 | 4beb2f41ed93 |
parent 45709 | 87017fcbad83 |
child 46178 | 1c5c88f6feb5 |
permissions | -rw-r--r-- |
45665
129db1416717
renamed Isabelle_Markup to Isabelle_Rendering to emphasize its meaning and make room for Pure Isabelle_Markup module;
wenzelm
parents:
45489
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/isabelle_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 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
4 |
Isabelle specific physical rendering and markup selection. |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
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 |
package isabelle.jedit |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
8 |
|
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 |
import isabelle._ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
11 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
12 |
import java.awt.Color |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
13 |
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
14 |
import org.lobobrowser.util.gui.ColorFactory |
43414 | 15 |
import org.gjt.sp.jedit.syntax.{Token => JEditToken} |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
16 |
|
45460 | 17 |
import scala.collection.immutable.SortedMap |
18 |
||
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
19 |
|
45665
129db1416717
renamed Isabelle_Markup to Isabelle_Rendering to emphasize its meaning and make room for Pure Isabelle_Markup module;
wenzelm
parents:
45489
diff
changeset
|
20 |
object Isabelle_Rendering |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
21 |
{ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
22 |
/* physical rendering */ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
23 |
|
43377 | 24 |
// see http://www.w3schools.com/css/css_colornames.asp |
25 |
||
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
26 |
def get_color(s: String): Color = ColorFactory.getInstance.getColor(s) |
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
27 |
|
44579
a9cf2380377d
tuned colors -- more distance between outdated_color and quoted_color;
wenzelm
parents:
44549
diff
changeset
|
28 |
val outdated_color = new Color(238, 227, 227) |
46166 | 29 |
val unprocessed_color = new Color(255, 160, 160) |
30 |
val unprocessed1_color = new Color(255, 160, 160, 50) |
|
44611 | 31 |
val running_color = new Color(97, 0, 97) |
32 |
val running1_color = new Color(97, 0, 97, 100) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
33 |
|
39690
6c6164b37fef
some attempts to improve visual appearance of bad text;
wenzelm
parents:
39512
diff
changeset
|
34 |
val light_color = new Color(240, 240, 240) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
35 |
val regular_color = new Color(192, 192, 192) |
39692 | 36 |
val warning_color = new Color(255, 140, 0) |
39691 | 37 |
val error_color = new Color(178, 34, 34) |
44866 | 38 |
val error1_color = new Color(178, 34, 34, 50) |
39690
6c6164b37fef
some attempts to improve visual appearance of bad text;
wenzelm
parents:
39512
diff
changeset
|
39 |
val bad_color = new Color(255, 106, 106, 100) |
42171 | 40 |
val hilite_color = new Color(255, 204, 102, 100) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
41 |
|
44546 | 42 |
val quoted_color = new Color(139, 139, 139, 25) |
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
43 |
val subexp_color = new Color(80, 80, 80, 50) |
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
44 |
|
43388 | 45 |
val keyword1_color = get_color("#006699") |
46 |
val keyword2_color = get_color("#009966") |
|
47 |
||
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
48 |
class Icon(val priority: Int, val icon: javax.swing.Icon) |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
49 |
{ |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
50 |
def >= (that: Icon): Boolean = this.priority >= that.priority |
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
51 |
} |
44547 | 52 |
val warning_icon = new Icon(1, Isabelle.load_icon("16x16/status/dialog-information.png")) |
44549 | 53 |
val legacy_icon = new Icon(2, Isabelle.load_icon("16x16/status/dialog-warning.png")) |
54 |
val error_icon = new Icon(3, Isabelle.load_icon("16x16/status/dialog-error.png")) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
55 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
56 |
|
46166 | 57 |
/* command overview */ |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
58 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
59 |
def overview_color(snapshot: Document.Snapshot, command: Command): Option[Color] = |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
60 |
{ |
44582 | 61 |
val state = snapshot.command_state(command) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
62 |
if (snapshot.is_outdated) None |
46166 | 63 |
else { |
64 |
val status = Protocol.command_status(state.status) |
|
65 |
||
66 |
if (status.is_unprocessed) Some(unprocessed_color) |
|
67 |
else if (status.is_running) Some(running_color) |
|
68 |
else if (status.is_finished) { |
|
69 |
if (state.results.exists(r => Protocol.is_error(r._2))) Some(error_color) |
|
70 |
else if (state.results.exists(r => Protocol.is_warning(r._2))) Some(warning_color) |
|
71 |
else None |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
72 |
} |
46166 | 73 |
else if (status.is_failed) Some(error_color) |
74 |
else None |
|
75 |
} |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
76 |
} |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
77 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
78 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
79 |
/* markup selectors */ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
80 |
|
45468 | 81 |
val message = |
82 |
Markup_Tree.Select[Color]( |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
83 |
{ |
45666 | 84 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.WRITELN, _), _)) => regular_color |
85 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.WARNING, _), _)) => warning_color |
|
86 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.ERROR, _), _)) => error_color |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
87 |
}, |
45666 | 88 |
Some(Set(Isabelle_Markup.WRITELN, Isabelle_Markup.WARNING, Isabelle_Markup.ERROR))) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
89 |
|
45467 | 90 |
val tooltip_message = |
91 |
Markup_Tree.Cumulate[SortedMap[Long, String]](SortedMap.empty, |
|
92 |
{ |
|
45666 | 93 |
case (msgs, Text.Info(_, msg @ XML.Elem(Markup(markup, Isabelle_Markup.Serial(serial)), _))) |
94 |
if markup == Isabelle_Markup.WRITELN || |
|
95 |
markup == Isabelle_Markup.WARNING || |
|
96 |
markup == Isabelle_Markup.ERROR => |
|
45467 | 97 |
msgs + (serial -> |
98 |
Pretty.string_of(List(msg), margin = Isabelle.Int_Property("tooltip-margin"))) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
99 |
}, |
45666 | 100 |
Some(Set(Isabelle_Markup.WRITELN, Isabelle_Markup.WARNING, Isabelle_Markup.ERROR))) |
39740 | 101 |
|
45468 | 102 |
val gutter_message = |
103 |
Markup_Tree.Select[Icon]( |
|
104 |
{ |
|
45666 | 105 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.WARNING, _), body)) => |
45468 | 106 |
body match { |
45666 | 107 |
case List(XML.Elem(Markup(Isabelle_Markup.LEGACY, _), _)) => legacy_icon |
45468 | 108 |
case _ => warning_icon |
109 |
} |
|
45666 | 110 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.ERROR, _), _)) => error_icon |
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
111 |
}, |
45666 | 112 |
Some(Set(Isabelle_Markup.WARNING, Isabelle_Markup.ERROR))) |
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
113 |
|
45468 | 114 |
val background1 = |
46166 | 115 |
Markup_Tree.Cumulate[(Option[Protocol.Status], Option[Color])]( |
116 |
(Some(Protocol.Status()), None), |
|
45468 | 117 |
{ |
46166 | 118 |
case (((Some(status), color), Text.Info(_, XML.Elem(markup, _)))) |
119 |
if (Protocol.command_status_markup(markup.name)) => |
|
120 |
(Some(Protocol.command_status(status, markup)), color) |
|
121 |
case (_, Text.Info(_, XML.Elem(Markup(Isabelle_Markup.BAD, _), _))) => |
|
122 |
(None, Some(bad_color)) |
|
123 |
case (_, Text.Info(_, XML.Elem(Markup(Isabelle_Markup.HILITE, _), _))) => |
|
124 |
(None, Some(hilite_color)) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
125 |
}, |
46166 | 126 |
Some(Protocol.command_status_markup + Isabelle_Markup.BAD + Isabelle_Markup.HILITE)) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
127 |
|
45468 | 128 |
val background2 = |
129 |
Markup_Tree.Select[Color]( |
|
130 |
{ |
|
45666 | 131 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.TOKEN_RANGE, _), _)) => light_color |
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
132 |
}, |
45666 | 133 |
Some(Set(Isabelle_Markup.TOKEN_RANGE))) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
134 |
|
45468 | 135 |
val foreground = |
136 |
Markup_Tree.Select[Color]( |
|
137 |
{ |
|
45666 | 138 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.STRING, _), _)) => quoted_color |
139 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.ALTSTRING, _), _)) => quoted_color |
|
140 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.VERBATIM, _), _)) => quoted_color |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
141 |
}, |
45666 | 142 |
Some(Set(Isabelle_Markup.STRING, Isabelle_Markup.ALTSTRING, Isabelle_Markup.VERBATIM))) |
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
143 |
|
43434 | 144 |
private val text_colors: Map[String, Color] = |
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
145 |
Map( |
45666 | 146 |
Isabelle_Markup.STRING -> get_color("black"), |
147 |
Isabelle_Markup.ALTSTRING -> get_color("black"), |
|
148 |
Isabelle_Markup.VERBATIM -> get_color("black"), |
|
149 |
Isabelle_Markup.LITERAL -> keyword1_color, |
|
150 |
Isabelle_Markup.DELIMITER -> get_color("black"), |
|
151 |
Isabelle_Markup.TFREE -> get_color("#A020F0"), |
|
152 |
Isabelle_Markup.TVAR -> get_color("#A020F0"), |
|
153 |
Isabelle_Markup.FREE -> get_color("blue"), |
|
154 |
Isabelle_Markup.SKOLEM -> get_color("#D2691E"), |
|
155 |
Isabelle_Markup.BOUND -> get_color("green"), |
|
156 |
Isabelle_Markup.VAR -> get_color("#00009B"), |
|
157 |
Isabelle_Markup.INNER_STRING -> get_color("#D2691E"), |
|
158 |
Isabelle_Markup.INNER_COMMENT -> get_color("#8B0000"), |
|
159 |
Isabelle_Markup.DYNAMIC_FACT -> get_color("#7BA428"), |
|
160 |
Isabelle_Markup.ML_KEYWORD -> keyword1_color, |
|
161 |
Isabelle_Markup.ML_DELIMITER -> get_color("black"), |
|
162 |
Isabelle_Markup.ML_NUMERAL -> get_color("red"), |
|
163 |
Isabelle_Markup.ML_CHAR -> get_color("#D2691E"), |
|
164 |
Isabelle_Markup.ML_STRING -> get_color("#D2691E"), |
|
165 |
Isabelle_Markup.ML_COMMENT -> get_color("#8B0000"), |
|
166 |
Isabelle_Markup.ML_MALFORMED -> get_color("#FF6A6A"), |
|
167 |
Isabelle_Markup.ANTIQ -> get_color("blue")) |
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
168 |
|
45468 | 169 |
val text_color = |
170 |
Markup_Tree.Select[Color]( |
|
171 |
{ |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
172 |
case Text.Info(_, XML.Elem(Markup(m, _), _)) |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
173 |
if text_colors.isDefinedAt(m) => text_colors(m) |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
174 |
}, |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
175 |
Some(Set() ++ text_colors.keys)) |
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43282
diff
changeset
|
176 |
|
43431 | 177 |
private val tooltips: Map[String, String] = |
178 |
Map( |
|
45666 | 179 |
Isabelle_Markup.SORT -> "sort", |
180 |
Isabelle_Markup.TYP -> "type", |
|
181 |
Isabelle_Markup.TERM -> "term", |
|
182 |
Isabelle_Markup.PROP -> "proposition", |
|
183 |
Isabelle_Markup.TOKEN_RANGE -> "inner syntax token", |
|
184 |
Isabelle_Markup.FREE -> "free variable", |
|
185 |
Isabelle_Markup.SKOLEM -> "skolem variable", |
|
186 |
Isabelle_Markup.BOUND -> "bound variable", |
|
187 |
Isabelle_Markup.VAR -> "schematic variable", |
|
188 |
Isabelle_Markup.TFREE -> "free type variable", |
|
189 |
Isabelle_Markup.TVAR -> "schematic type variable", |
|
190 |
Isabelle_Markup.ML_SOURCE -> "ML source", |
|
191 |
Isabelle_Markup.DOC_SOURCE -> "document source") |
|
43431 | 192 |
|
45445
41e641a870de
pass term positions into check phase, where resulting types are reported accordingly, and eventually shown as tooltips;
wenzelm
parents:
44866
diff
changeset
|
193 |
private def string_of_typing(kind: String, body: XML.Body): String = |
41e641a870de
pass term positions into check phase, where resulting types are reported accordingly, and eventually shown as tooltips;
wenzelm
parents:
44866
diff
changeset
|
194 |
Pretty.string_of(List(Pretty.block(XML.Text(kind) :: Pretty.Break(1) :: body)), |
41e641a870de
pass term positions into check phase, where resulting types are reported accordingly, and eventually shown as tooltips;
wenzelm
parents:
44866
diff
changeset
|
195 |
margin = Isabelle.Int_Property("tooltip-margin")) |
41e641a870de
pass term positions into check phase, where resulting types are reported accordingly, and eventually shown as tooltips;
wenzelm
parents:
44866
diff
changeset
|
196 |
|
45468 | 197 |
val tooltip1 = |
198 |
Markup_Tree.Select[String]( |
|
199 |
{ |
|
45666 | 200 |
case Text.Info(_, XML.Elem(Isabelle_Markup.Entity(kind, name), _)) => kind + " " + quote(name) |
201 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.ML_TYPING, _), body)) => |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
202 |
string_of_typing("ML:", body) |
45468 | 203 |
case Text.Info(_, XML.Elem(Markup(name, _), _)) |
204 |
if tooltips.isDefinedAt(name) => tooltips(name) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
205 |
}, |
45666 | 206 |
Some(Set(Isabelle_Markup.ENTITY, Isabelle_Markup.ML_TYPING) ++ tooltips.keys)) |
42302 | 207 |
|
45468 | 208 |
val tooltip2 = |
209 |
Markup_Tree.Select[String]( |
|
210 |
{ |
|
45666 | 211 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.TYPING, _), body)) => |
212 |
string_of_typing("::", body) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
213 |
}, |
45666 | 214 |
Some(Set(Isabelle_Markup.TYPING))) |
45460 | 215 |
|
42302 | 216 |
private val subexp_include = |
45666 | 217 |
Set(Isabelle_Markup.SORT, Isabelle_Markup.TYP, Isabelle_Markup.TERM, Isabelle_Markup.PROP, |
218 |
Isabelle_Markup.ML_TYPING, Isabelle_Markup.TOKEN_RANGE, Isabelle_Markup.ENTITY, |
|
219 |
Isabelle_Markup.TYPING, Isabelle_Markup.FREE, Isabelle_Markup.SKOLEM, Isabelle_Markup.BOUND, |
|
220 |
Isabelle_Markup.VAR, Isabelle_Markup.TFREE, Isabelle_Markup.TVAR, Isabelle_Markup.ML_SOURCE, |
|
221 |
Isabelle_Markup.DOC_SOURCE) |
|
42302 | 222 |
|
45468 | 223 |
val subexp = |
224 |
Markup_Tree.Select[(Text.Range, Color)]( |
|
225 |
{ |
|
226 |
case Text.Info(range, XML.Elem(Markup(name, _), _)) if subexp_include(name) => |
|
227 |
(range, subexp_color) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
228 |
}, |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
229 |
Some(subexp_include)) |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
230 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
231 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
232 |
/* token markup -- text styles */ |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
233 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
234 |
private val command_style: Map[String, Byte] = |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
235 |
{ |
43414 | 236 |
import JEditToken._ |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
237 |
Map[String, Byte]( |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
238 |
Keyword.THY_END -> KEYWORD2, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
239 |
Keyword.THY_SCRIPT -> LABEL, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
240 |
Keyword.PRF_SCRIPT -> LABEL, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
241 |
Keyword.PRF_ASM -> KEYWORD3, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
242 |
Keyword.PRF_ASM_GOAL -> KEYWORD3 |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
243 |
).withDefaultValue(KEYWORD1) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
244 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
245 |
|
43414 | 246 |
private val token_style: Map[Token.Kind.Value, Byte] = |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
247 |
{ |
43414 | 248 |
import JEditToken._ |
249 |
Map[Token.Kind.Value, Byte]( |
|
250 |
Token.Kind.KEYWORD -> KEYWORD2, |
|
251 |
Token.Kind.IDENT -> NULL, |
|
252 |
Token.Kind.LONG_IDENT -> NULL, |
|
253 |
Token.Kind.SYM_IDENT -> NULL, |
|
254 |
Token.Kind.VAR -> NULL, |
|
255 |
Token.Kind.TYPE_IDENT -> NULL, |
|
256 |
Token.Kind.TYPE_VAR -> NULL, |
|
257 |
Token.Kind.NAT -> NULL, |
|
258 |
Token.Kind.FLOAT -> NULL, |
|
43431 | 259 |
Token.Kind.STRING -> LITERAL1, |
260 |
Token.Kind.ALT_STRING -> LITERAL2, |
|
43414 | 261 |
Token.Kind.VERBATIM -> COMMENT3, |
262 |
Token.Kind.SPACE -> NULL, |
|
263 |
Token.Kind.COMMENT -> COMMENT1, |
|
264 |
Token.Kind.UNPARSED -> INVALID |
|
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
265 |
).withDefaultValue(NULL) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
266 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
267 |
|
43414 | 268 |
def token_markup(syntax: Outer_Syntax, token: Token): Byte = |
43430
1ed88ddf1268
more uniform treatment of "keyword" vs. "operator";
wenzelm
parents:
43418
diff
changeset
|
269 |
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
|
270 |
else if (token.is_operator) JEditToken.OPERATOR |
43414 | 271 |
else token_style(token.kind) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
272 |
} |