author | wenzelm |
Mon, 28 Nov 2011 22:05:32 +0100 | |
changeset 45666 | d83797ef0d2d |
parent 45665 | 129db1416717 |
child 45672 | a497c5d4a523 |
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) |
44611 | 29 |
val running_color = new Color(97, 0, 97) |
30 |
val running1_color = new Color(97, 0, 97, 100) |
|
44866 | 31 |
val unprocessed_color = new Color(255, 160, 160) |
32 |
val unprocessed1_color = new Color(255, 160, 160, 50) |
|
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 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
57 |
/* command status */ |
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 status_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) |
44723 | 62 |
if (snapshot.is_outdated) Some(outdated_color) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
63 |
else |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
64 |
Isar_Document.command_status(state.status) match { |
44611 | 65 |
case Isar_Document.Forked(i) if i > 0 => Some(running1_color) |
44866 | 66 |
case Isar_Document.Unprocessed => Some(unprocessed1_color) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
67 |
case _ => None |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
68 |
} |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
69 |
} |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
70 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
71 |
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
|
72 |
{ |
44582 | 73 |
val state = snapshot.command_state(command) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
74 |
if (snapshot.is_outdated) None |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
75 |
else |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
76 |
Isar_Document.command_status(state.status) match { |
44611 | 77 |
case Isar_Document.Forked(i) => if (i > 0) Some(running_color) else None |
44866 | 78 |
case Isar_Document.Unprocessed => Some(unprocessed_color) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
79 |
case Isar_Document.Failed => Some(error_color) |
39512
31290f54be19
Isabelle_Markup.overview_color: indicate error / warning messages;
wenzelm
parents:
39244
diff
changeset
|
80 |
case Isar_Document.Finished => |
31290f54be19
Isabelle_Markup.overview_color: indicate error / warning messages;
wenzelm
parents:
39244
diff
changeset
|
81 |
if (state.results.exists(r => Isar_Document.is_error(r._2))) Some(error_color) |
31290f54be19
Isabelle_Markup.overview_color: indicate error / warning messages;
wenzelm
parents:
39244
diff
changeset
|
82 |
else if (state.results.exists(r => Isar_Document.is_warning(r._2))) Some(warning_color) |
31290f54be19
Isabelle_Markup.overview_color: indicate error / warning messages;
wenzelm
parents:
39244
diff
changeset
|
83 |
else None |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
84 |
} |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
85 |
} |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
86 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
87 |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
88 |
/* markup selectors */ |
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
89 |
|
45468 | 90 |
val message = |
91 |
Markup_Tree.Select[Color]( |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
92 |
{ |
45666 | 93 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.WRITELN, _), _)) => regular_color |
94 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.WARNING, _), _)) => warning_color |
|
95 |
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
|
96 |
}, |
45666 | 97 |
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
|
98 |
|
45467 | 99 |
val tooltip_message = |
100 |
Markup_Tree.Cumulate[SortedMap[Long, String]](SortedMap.empty, |
|
101 |
{ |
|
45666 | 102 |
case (msgs, Text.Info(_, msg @ XML.Elem(Markup(markup, Isabelle_Markup.Serial(serial)), _))) |
103 |
if markup == Isabelle_Markup.WRITELN || |
|
104 |
markup == Isabelle_Markup.WARNING || |
|
105 |
markup == Isabelle_Markup.ERROR => |
|
45467 | 106 |
msgs + (serial -> |
107 |
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
|
108 |
}, |
45666 | 109 |
Some(Set(Isabelle_Markup.WRITELN, Isabelle_Markup.WARNING, Isabelle_Markup.ERROR))) |
39740 | 110 |
|
45468 | 111 |
val gutter_message = |
112 |
Markup_Tree.Select[Icon]( |
|
113 |
{ |
|
45666 | 114 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.WARNING, _), body)) => |
45468 | 115 |
body match { |
45666 | 116 |
case List(XML.Elem(Markup(Isabelle_Markup.LEGACY, _), _)) => legacy_icon |
45468 | 117 |
case _ => warning_icon |
118 |
} |
|
45666 | 119 |
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
|
120 |
}, |
45666 | 121 |
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
|
122 |
|
45468 | 123 |
val background1 = |
124 |
Markup_Tree.Select[Color]( |
|
125 |
{ |
|
45666 | 126 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.BAD, _), _)) => bad_color |
127 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.HILITE, _), _)) => hilite_color |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
128 |
}, |
45666 | 129 |
Some(Set(Isabelle_Markup.BAD, Isabelle_Markup.HILITE))) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
130 |
|
45468 | 131 |
val background2 = |
132 |
Markup_Tree.Select[Color]( |
|
133 |
{ |
|
45666 | 134 |
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
|
135 |
}, |
45666 | 136 |
Some(Set(Isabelle_Markup.TOKEN_RANGE))) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
137 |
|
45468 | 138 |
val foreground = |
139 |
Markup_Tree.Select[Color]( |
|
140 |
{ |
|
45666 | 141 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.STRING, _), _)) => quoted_color |
142 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.ALTSTRING, _), _)) => quoted_color |
|
143 |
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
|
144 |
}, |
45666 | 145 |
Some(Set(Isabelle_Markup.STRING, Isabelle_Markup.ALTSTRING, Isabelle_Markup.VERBATIM))) |
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
146 |
|
43434 | 147 |
private val text_colors: Map[String, Color] = |
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
148 |
Map( |
45666 | 149 |
Isabelle_Markup.STRING -> get_color("black"), |
150 |
Isabelle_Markup.ALTSTRING -> get_color("black"), |
|
151 |
Isabelle_Markup.VERBATIM -> get_color("black"), |
|
152 |
Isabelle_Markup.LITERAL -> keyword1_color, |
|
153 |
Isabelle_Markup.DELIMITER -> get_color("black"), |
|
154 |
Isabelle_Markup.TFREE -> get_color("#A020F0"), |
|
155 |
Isabelle_Markup.TVAR -> get_color("#A020F0"), |
|
156 |
Isabelle_Markup.FREE -> get_color("blue"), |
|
157 |
Isabelle_Markup.SKOLEM -> get_color("#D2691E"), |
|
158 |
Isabelle_Markup.BOUND -> get_color("green"), |
|
159 |
Isabelle_Markup.VAR -> get_color("#00009B"), |
|
160 |
Isabelle_Markup.INNER_STRING -> get_color("#D2691E"), |
|
161 |
Isabelle_Markup.INNER_COMMENT -> get_color("#8B0000"), |
|
162 |
Isabelle_Markup.DYNAMIC_FACT -> get_color("#7BA428"), |
|
163 |
Isabelle_Markup.ML_KEYWORD -> keyword1_color, |
|
164 |
Isabelle_Markup.ML_DELIMITER -> get_color("black"), |
|
165 |
Isabelle_Markup.ML_NUMERAL -> get_color("red"), |
|
166 |
Isabelle_Markup.ML_CHAR -> get_color("#D2691E"), |
|
167 |
Isabelle_Markup.ML_STRING -> get_color("#D2691E"), |
|
168 |
Isabelle_Markup.ML_COMMENT -> get_color("#8B0000"), |
|
169 |
Isabelle_Markup.ML_MALFORMED -> get_color("#FF6A6A"), |
|
170 |
Isabelle_Markup.ANTIQ -> get_color("blue")) |
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
171 |
|
45468 | 172 |
val text_color = |
173 |
Markup_Tree.Select[Color]( |
|
174 |
{ |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
175 |
case Text.Info(_, XML.Elem(Markup(m, _), _)) |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
176 |
if text_colors.isDefinedAt(m) => text_colors(m) |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
177 |
}, |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
178 |
Some(Set() ++ text_colors.keys)) |
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43282
diff
changeset
|
179 |
|
43431 | 180 |
private val tooltips: Map[String, String] = |
181 |
Map( |
|
45666 | 182 |
Isabelle_Markup.SORT -> "sort", |
183 |
Isabelle_Markup.TYP -> "type", |
|
184 |
Isabelle_Markup.TERM -> "term", |
|
185 |
Isabelle_Markup.PROP -> "proposition", |
|
186 |
Isabelle_Markup.TOKEN_RANGE -> "inner syntax token", |
|
187 |
Isabelle_Markup.FREE -> "free variable", |
|
188 |
Isabelle_Markup.SKOLEM -> "skolem variable", |
|
189 |
Isabelle_Markup.BOUND -> "bound variable", |
|
190 |
Isabelle_Markup.VAR -> "schematic variable", |
|
191 |
Isabelle_Markup.TFREE -> "free type variable", |
|
192 |
Isabelle_Markup.TVAR -> "schematic type variable", |
|
193 |
Isabelle_Markup.ML_SOURCE -> "ML source", |
|
194 |
Isabelle_Markup.DOC_SOURCE -> "document source") |
|
43431 | 195 |
|
45445
41e641a870de
pass term positions into check phase, where resulting types are reported accordingly, and eventually shown as tooltips;
wenzelm
parents:
44866
diff
changeset
|
196 |
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
|
197 |
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
|
198 |
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
|
199 |
|
45468 | 200 |
val tooltip1 = |
201 |
Markup_Tree.Select[String]( |
|
202 |
{ |
|
45666 | 203 |
case Text.Info(_, XML.Elem(Isabelle_Markup.Entity(kind, name), _)) => kind + " " + quote(name) |
204 |
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
|
205 |
string_of_typing("ML:", body) |
45468 | 206 |
case Text.Info(_, XML.Elem(Markup(name, _), _)) |
207 |
if tooltips.isDefinedAt(name) => tooltips(name) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
208 |
}, |
45666 | 209 |
Some(Set(Isabelle_Markup.ENTITY, Isabelle_Markup.ML_TYPING) ++ tooltips.keys)) |
42302 | 210 |
|
45468 | 211 |
val tooltip2 = |
212 |
Markup_Tree.Select[String]( |
|
213 |
{ |
|
45666 | 214 |
case Text.Info(_, XML.Elem(Markup(Isabelle_Markup.TYPING, _), body)) => |
215 |
string_of_typing("::", body) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
216 |
}, |
45666 | 217 |
Some(Set(Isabelle_Markup.TYPING))) |
45460 | 218 |
|
42302 | 219 |
private val subexp_include = |
45666 | 220 |
Set(Isabelle_Markup.SORT, Isabelle_Markup.TYP, Isabelle_Markup.TERM, Isabelle_Markup.PROP, |
221 |
Isabelle_Markup.ML_TYPING, Isabelle_Markup.TOKEN_RANGE, Isabelle_Markup.ENTITY, |
|
222 |
Isabelle_Markup.TYPING, Isabelle_Markup.FREE, Isabelle_Markup.SKOLEM, Isabelle_Markup.BOUND, |
|
223 |
Isabelle_Markup.VAR, Isabelle_Markup.TFREE, Isabelle_Markup.TVAR, Isabelle_Markup.ML_SOURCE, |
|
224 |
Isabelle_Markup.DOC_SOURCE) |
|
42302 | 225 |
|
45468 | 226 |
val subexp = |
227 |
Markup_Tree.Select[(Text.Range, Color)]( |
|
228 |
{ |
|
229 |
case Text.Info(range, XML.Elem(Markup(name, _), _)) if subexp_include(name) => |
|
230 |
(range, subexp_color) |
|
45474
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
231 |
}, |
f793dd5d84b2
index markup elements for more efficient cumulate/select operations;
wenzelm
parents:
45468
diff
changeset
|
232 |
Some(subexp_include)) |
39179
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 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
235 |
/* token markup -- text styles */ |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
236 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
237 |
private val command_style: Map[String, Byte] = |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
238 |
{ |
43414 | 239 |
import JEditToken._ |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
240 |
Map[String, Byte]( |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
241 |
Keyword.THY_END -> KEYWORD2, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
242 |
Keyword.THY_SCRIPT -> LABEL, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
243 |
Keyword.PRF_SCRIPT -> LABEL, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
244 |
Keyword.PRF_ASM -> KEYWORD3, |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
245 |
Keyword.PRF_ASM_GOAL -> KEYWORD3 |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
246 |
).withDefaultValue(KEYWORD1) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
247 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
248 |
|
43414 | 249 |
private val token_style: Map[Token.Kind.Value, Byte] = |
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
250 |
{ |
43414 | 251 |
import JEditToken._ |
252 |
Map[Token.Kind.Value, Byte]( |
|
253 |
Token.Kind.KEYWORD -> KEYWORD2, |
|
254 |
Token.Kind.IDENT -> NULL, |
|
255 |
Token.Kind.LONG_IDENT -> NULL, |
|
256 |
Token.Kind.SYM_IDENT -> NULL, |
|
257 |
Token.Kind.VAR -> NULL, |
|
258 |
Token.Kind.TYPE_IDENT -> NULL, |
|
259 |
Token.Kind.TYPE_VAR -> NULL, |
|
260 |
Token.Kind.NAT -> NULL, |
|
261 |
Token.Kind.FLOAT -> NULL, |
|
43431 | 262 |
Token.Kind.STRING -> LITERAL1, |
263 |
Token.Kind.ALT_STRING -> LITERAL2, |
|
43414 | 264 |
Token.Kind.VERBATIM -> COMMENT3, |
265 |
Token.Kind.SPACE -> NULL, |
|
266 |
Token.Kind.COMMENT -> COMMENT1, |
|
267 |
Token.Kind.UNPARSED -> INVALID |
|
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
268 |
).withDefaultValue(NULL) |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
269 |
} |
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
270 |
|
43414 | 271 |
def token_markup(syntax: Outer_Syntax, token: Token): Byte = |
43430
1ed88ddf1268
more uniform treatment of "keyword" vs. "operator";
wenzelm
parents:
43418
diff
changeset
|
272 |
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
|
273 |
else if (token.is_operator) JEditToken.OPERATOR |
43414 | 274 |
else token_style(token.kind) |
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
275 |
} |