| author | wenzelm |
| Tue, 27 Sep 2011 20:45:15 +0200 | |
| changeset 45097 | d0f851903e55 |
| parent 44866 | 0eb8284a64bd |
| child 45445 | 41e641a870de |
| permissions | -rw-r--r-- |
|
43282
5d294220ca43
moved sources -- eliminated Netbeans artifact of jedit package directory;
wenzelm
parents:
42492
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/isabelle_markup.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 |
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
17 |
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
18 |
object Isabelle_Markup |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
19 |
{
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
20 |
/* physical rendering */ |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
21 |
|
| 43377 | 22 |
// see http://www.w3schools.com/css/css_colornames.asp |
23 |
||
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
24 |
def get_color(s: String): Color = ColorFactory.getInstance.getColor(s) |
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
25 |
|
|
44579
a9cf2380377d
tuned colors -- more distance between outdated_color and quoted_color;
wenzelm
parents:
44549
diff
changeset
|
26 |
val outdated_color = new Color(238, 227, 227) |
| 44611 | 27 |
val running_color = new Color(97, 0, 97) |
28 |
val running1_color = new Color(97, 0, 97, 100) |
|
| 44866 | 29 |
val unprocessed_color = new Color(255, 160, 160) |
30 |
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
|
31 |
|
|
39690
6c6164b37fef
some attempts to improve visual appearance of bad text;
wenzelm
parents:
39512
diff
changeset
|
32 |
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
|
33 |
val regular_color = new Color(192, 192, 192) |
| 39692 | 34 |
val warning_color = new Color(255, 140, 0) |
| 39691 | 35 |
val error_color = new Color(178, 34, 34) |
| 44866 | 36 |
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
|
37 |
val bad_color = new Color(255, 106, 106, 100) |
| 42171 | 38 |
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
|
39 |
|
| 44546 | 40 |
val quoted_color = new Color(139, 139, 139, 25) |
|
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
41 |
val subexp_color = new Color(80, 80, 80, 50) |
|
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
42 |
|
| 43388 | 43 |
val keyword1_color = get_color("#006699")
|
44 |
val keyword2_color = get_color("#009966")
|
|
45 |
||
|
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
46 |
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
|
47 |
{
|
|
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
48 |
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
|
49 |
} |
| 44547 | 50 |
val warning_icon = new Icon(1, Isabelle.load_icon("16x16/status/dialog-information.png"))
|
| 44549 | 51 |
val legacy_icon = new Icon(2, Isabelle.load_icon("16x16/status/dialog-warning.png"))
|
52 |
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
|
53 |
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
54 |
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
55 |
/* command status */ |
|
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 |
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
|
58 |
{
|
| 44582 | 59 |
val state = snapshot.command_state(command) |
| 44723 | 60 |
if (snapshot.is_outdated) Some(outdated_color) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
61 |
else |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
62 |
Isar_Document.command_status(state.status) match {
|
| 44611 | 63 |
case Isar_Document.Forked(i) if i > 0 => Some(running1_color) |
| 44866 | 64 |
case Isar_Document.Unprocessed => Some(unprocessed1_color) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
65 |
case _ => None |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
66 |
} |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
67 |
} |
|
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 |
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
|
70 |
{
|
| 44582 | 71 |
val state = snapshot.command_state(command) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
72 |
if (snapshot.is_outdated) None |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
73 |
else |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
74 |
Isar_Document.command_status(state.status) match {
|
| 44611 | 75 |
case Isar_Document.Forked(i) => if (i > 0) Some(running_color) else None |
| 44866 | 76 |
case Isar_Document.Unprocessed => Some(unprocessed_color) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
77 |
case Isar_Document.Failed => Some(error_color) |
|
39512
31290f54be19
Isabelle_Markup.overview_color: indicate error / warning messages;
wenzelm
parents:
39244
diff
changeset
|
78 |
case Isar_Document.Finished => |
|
31290f54be19
Isabelle_Markup.overview_color: indicate error / warning messages;
wenzelm
parents:
39244
diff
changeset
|
79 |
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
|
80 |
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
|
81 |
else None |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
82 |
} |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
83 |
} |
|
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 |
/* markup selectors */ |
|
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 |
val message: Markup_Tree.Select[Color] = |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
89 |
{
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
90 |
case Text.Info(_, XML.Elem(Markup(Markup.WRITELN, _), _)) => regular_color |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
91 |
case Text.Info(_, XML.Elem(Markup(Markup.WARNING, _), _)) => warning_color |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
92 |
case Text.Info(_, XML.Elem(Markup(Markup.ERROR, _), _)) => error_color |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
93 |
} |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
94 |
|
|
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
39740
diff
changeset
|
95 |
val popup: Markup_Tree.Select[String] = |
| 39740 | 96 |
{
|
97 |
case Text.Info(_, msg @ XML.Elem(Markup(markup, _), _)) |
|
|
40338
e2f03de2b3c7
clarified tooltips: message output by default, extra info via control/command;
wenzelm
parents:
39740
diff
changeset
|
98 |
if markup == Markup.WRITELN || markup == Markup.WARNING || markup == Markup.ERROR => |
| 40339 | 99 |
Pretty.string_of(List(msg), margin = Isabelle.Int_Property("tooltip-margin"))
|
| 39740 | 100 |
} |
101 |
||
|
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
102 |
val gutter_message: Markup_Tree.Select[Icon] = |
|
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
103 |
{
|
| 44549 | 104 |
case Text.Info(_, XML.Elem(Markup(Markup.WARNING, _), body)) => |
105 |
body match {
|
|
106 |
case List(XML.Elem(Markup(Markup.LEGACY, _), _)) => legacy_icon |
|
107 |
case _ => warning_icon |
|
108 |
} |
|
|
39181
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
109 |
case Text.Info(_, XML.Elem(Markup(Markup.ERROR, _), _)) => error_icon |
|
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
110 |
} |
|
2257eded8323
Document_View: select gutter message icons from markup over line range, not full range results;
wenzelm
parents:
39179
diff
changeset
|
111 |
|
|
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39692
diff
changeset
|
112 |
val background1: Markup_Tree.Select[Color] = |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
113 |
{
|
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
114 |
case Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _)) => bad_color |
| 42171 | 115 |
case Text.Info(_, XML.Elem(Markup(Markup.HILITE, _), _)) => hilite_color |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
116 |
} |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
117 |
|
|
39700
fa55cf2c1ae4
more precise treatment of backgrounds vs. rectangles;
wenzelm
parents:
39692
diff
changeset
|
118 |
val background2: Markup_Tree.Select[Color] = |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
119 |
{
|
|
39690
6c6164b37fef
some attempts to improve visual appearance of bad text;
wenzelm
parents:
39512
diff
changeset
|
120 |
case Text.Info(_, XML.Elem(Markup(Markup.TOKEN_RANGE, _), _)) => light_color |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
121 |
} |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
122 |
|
|
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
123 |
val foreground: Markup_Tree.Select[Color] = |
|
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
124 |
{
|
| 44546 | 125 |
case Text.Info(_, XML.Elem(Markup(Markup.STRING, _), _)) => quoted_color |
126 |
case Text.Info(_, XML.Elem(Markup(Markup.ALTSTRING, _), _)) => quoted_color |
|
127 |
case Text.Info(_, XML.Elem(Markup(Markup.VERBATIM, _), _)) => quoted_color |
|
|
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
128 |
} |
|
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
129 |
|
|
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43453
diff
changeset
|
130 |
private val text_entity_colors: Map[String, Color] = |
|
44706
fe319b45315c
eliminated markup for plain identifiers (frequent but insignificant);
wenzelm
parents:
44611
diff
changeset
|
131 |
Map(Markup.CLASS -> get_color("red"))
|
|
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43453
diff
changeset
|
132 |
|
| 43434 | 133 |
private val text_colors: Map[String, Color] = |
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
134 |
Map( |
|
44545
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
135 |
Markup.STRING -> get_color("black"),
|
|
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
136 |
Markup.ALTSTRING -> get_color("black"),
|
|
3c40007aa031
transparent foreground color for quoted entities;
wenzelm
parents:
44181
diff
changeset
|
137 |
Markup.VERBATIM -> get_color("black"),
|
| 43436 | 138 |
Markup.LITERAL -> keyword1_color, |
139 |
Markup.DELIMITER -> get_color("black"),
|
|
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
140 |
Markup.TFREE -> get_color("#A020F0"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
141 |
Markup.TVAR -> get_color("#A020F0"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
142 |
Markup.FREE -> get_color("blue"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
143 |
Markup.SKOLEM -> get_color("#D2691E"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
144 |
Markup.BOUND -> get_color("green"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
145 |
Markup.VAR -> get_color("#00009B"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
146 |
Markup.INNER_STRING -> get_color("#D2691E"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
147 |
Markup.INNER_COMMENT -> get_color("#8B0000"),
|
|
44602
795978192588
tuned color for Mac OS X (very light color profile?);
wenzelm
parents:
44582
diff
changeset
|
148 |
Markup.DYNAMIC_FACT -> get_color("#7BA428"),
|
| 43388 | 149 |
Markup.ML_KEYWORD -> keyword1_color, |
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
150 |
Markup.ML_DELIMITER -> get_color("black"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
151 |
Markup.ML_NUMERAL -> get_color("red"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
152 |
Markup.ML_CHAR -> get_color("#D2691E"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
153 |
Markup.ML_STRING -> get_color("#D2691E"),
|
|
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
154 |
Markup.ML_COMMENT -> get_color("#8B0000"),
|
| 43431 | 155 |
Markup.ML_MALFORMED -> get_color("#FF6A6A"),
|
156 |
Markup.ANTIQ -> get_color("blue"))
|
|
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
157 |
|
| 43434 | 158 |
val text_color: Markup_Tree.Select[Color] = |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43282
diff
changeset
|
159 |
{
|
|
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43453
diff
changeset
|
160 |
case Text.Info(_, XML.Elem(Markup.Entity(kind, _), _)) |
|
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43453
diff
changeset
|
161 |
if text_entity_colors.isDefinedAt(kind) => text_entity_colors(kind) |
|
43386
4e78dd88c64f
more foreground markup, using actual CSS color names;
wenzelm
parents:
43377
diff
changeset
|
162 |
case Text.Info(_, XML.Elem(Markup(m, _), _)) |
| 43434 | 163 |
if text_colors.isDefinedAt(m) => text_colors(m) |
|
43376
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43282
diff
changeset
|
164 |
} |
|
0f6880c1c759
some direct text foreground painting, instead of token marking;
wenzelm
parents:
43282
diff
changeset
|
165 |
|
| 43431 | 166 |
private val tooltips: Map[String, String] = |
167 |
Map( |
|
168 |
Markup.SORT -> "sort", |
|
169 |
Markup.TYP -> "type", |
|
170 |
Markup.TERM -> "term", |
|
171 |
Markup.PROP -> "proposition", |
|
172 |
Markup.TOKEN_RANGE -> "inner syntax token", |
|
173 |
Markup.FREE -> "free variable (globally fixed)", |
|
174 |
Markup.SKOLEM -> "skolem variable (locally fixed)", |
|
175 |
Markup.BOUND -> "bound variable (internally fixed)", |
|
176 |
Markup.VAR -> "schematic variable", |
|
177 |
Markup.TFREE -> "free type variable", |
|
178 |
Markup.TVAR -> "schematic type variable", |
|
179 |
Markup.ML_SOURCE -> "ML source", |
|
180 |
Markup.DOC_SOURCE -> "document source") |
|
181 |
||
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
182 |
val tooltip: Markup_Tree.Select[String] = |
|
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
183 |
{
|
| 44181 | 184 |
case Text.Info(_, XML.Elem(Markup.Entity(kind, name), _)) => kind + " " + quote(name) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
185 |
case Text.Info(_, XML.Elem(Markup(Markup.ML_TYPING, _), body)) => |
| 40339 | 186 |
Pretty.string_of(List(Pretty.block(XML.Text("ML:") :: Pretty.Break(1) :: body)),
|
187 |
margin = Isabelle.Int_Property("tooltip-margin"))
|
|
| 43431 | 188 |
case Text.Info(_, XML.Elem(Markup(name, _), _)) |
189 |
if tooltips.isDefinedAt(name) => tooltips(name) |
|
| 42302 | 190 |
} |
191 |
||
192 |
private val subexp_include = |
|
193 |
Set(Markup.SORT, Markup.TYP, Markup.TERM, Markup.PROP, Markup.ML_TYPING, Markup.TOKEN_RANGE, |
|
194 |
Markup.ENTITY, Markup.FREE, Markup.SKOLEM, Markup.BOUND, Markup.VAR, |
|
| 43431 | 195 |
Markup.TFREE, Markup.TVAR, Markup.ML_SOURCE, Markup.DOC_SOURCE) |
| 42302 | 196 |
|
197 |
val subexp: Markup_Tree.Select[(Text.Range, Color)] = |
|
198 |
{
|
|
199 |
case Text.Info(range, XML.Elem(Markup(name, _), _)) if subexp_include(name) => |
|
|
43435
ae6b0c3e58a8
highlight via foreground painter, using alpha channel;
wenzelm
parents:
43434
diff
changeset
|
200 |
(range, subexp_color) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
201 |
} |
|
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
202 |
|
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
203 |
|
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
204 |
/* token markup -- text styles */ |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
205 |
|
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
206 |
private val command_style: Map[String, Byte] = |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
207 |
{
|
| 43414 | 208 |
import JEditToken._ |
|
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
209 |
Map[String, Byte]( |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
210 |
Keyword.THY_END -> KEYWORD2, |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
211 |
Keyword.THY_SCRIPT -> LABEL, |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
212 |
Keyword.PRF_SCRIPT -> LABEL, |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
213 |
Keyword.PRF_ASM -> KEYWORD3, |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
214 |
Keyword.PRF_ASM_GOAL -> KEYWORD3 |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
215 |
).withDefaultValue(KEYWORD1) |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
216 |
} |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
217 |
|
| 43414 | 218 |
private val token_style: Map[Token.Kind.Value, Byte] = |
|
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
219 |
{
|
| 43414 | 220 |
import JEditToken._ |
221 |
Map[Token.Kind.Value, Byte]( |
|
222 |
Token.Kind.KEYWORD -> KEYWORD2, |
|
223 |
Token.Kind.IDENT -> NULL, |
|
224 |
Token.Kind.LONG_IDENT -> NULL, |
|
225 |
Token.Kind.SYM_IDENT -> NULL, |
|
226 |
Token.Kind.VAR -> NULL, |
|
227 |
Token.Kind.TYPE_IDENT -> NULL, |
|
228 |
Token.Kind.TYPE_VAR -> NULL, |
|
229 |
Token.Kind.NAT -> NULL, |
|
230 |
Token.Kind.FLOAT -> NULL, |
|
| 43431 | 231 |
Token.Kind.STRING -> LITERAL1, |
232 |
Token.Kind.ALT_STRING -> LITERAL2, |
|
| 43414 | 233 |
Token.Kind.VERBATIM -> COMMENT3, |
234 |
Token.Kind.SPACE -> NULL, |
|
235 |
Token.Kind.COMMENT -> COMMENT1, |
|
236 |
Token.Kind.UNPARSED -> INVALID |
|
|
39179
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
237 |
).withDefaultValue(NULL) |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
238 |
} |
|
591bbab9ef59
moved token markup tables to isabelle_markup.scala;
wenzelm
parents:
39178
diff
changeset
|
239 |
|
| 43414 | 240 |
def token_markup(syntax: Outer_Syntax, token: Token): Byte = |
|
43430
1ed88ddf1268
more uniform treatment of "keyword" vs. "operator";
wenzelm
parents:
43418
diff
changeset
|
241 |
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
|
242 |
else if (token.is_operator) JEditToken.OPERATOR |
| 43414 | 243 |
else token_style(token.kind) |
|
39178
83e9f3ccea9f
concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff
changeset
|
244 |
} |