author | wenzelm |
Wed, 09 Jun 2004 18:52:42 +0200 | |
changeset 14898 | a25550451b51 |
parent 14880 | 7586233bd4bd |
child 14981 | e73f8140af78 |
permissions | -rw-r--r-- |
2697 | 1 |
(* Title: Pure/Syntax/token_trans.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
12785 | 4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
2697 | 5 |
|
6695
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
6 |
Token translations for xterm output. |
2697 | 7 |
*) |
8 |
||
6322 | 9 |
signature TOKEN_TRANS0 = |
10 |
sig |
|
11 |
val standard_token_classes: string list |
|
6695
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
12 |
val tokentrans_mode: string -> (string * (string -> string * real)) list -> |
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
13 |
(string * string * (string -> string * real)) list |
6322 | 14 |
end; |
15 |
||
2697 | 16 |
signature TOKEN_TRANS = |
17 |
sig |
|
6322 | 18 |
include TOKEN_TRANS0 |
11795 | 19 |
val standard_token_markers: string list |
2707 | 20 |
val normal: string |
21 |
val bold: string |
|
22 |
val underline: string |
|
23 |
val reverse: string |
|
24 |
val black: string |
|
25 |
val red: string |
|
26 |
val green: string |
|
27 |
val yellow: string |
|
28 |
val blue: string |
|
29 |
val purple: string |
|
30 |
val cyan: string |
|
31 |
val white: string |
|
2710 | 32 |
val xterm_class: string ref |
33 |
val xterm_tfree: string ref |
|
34 |
val xterm_tvar: string ref |
|
35 |
val xterm_free: string ref |
|
36 |
val xterm_bound: string ref |
|
37 |
val xterm_var: string ref |
|
38 |
val xterm_color_class: string ref |
|
39 |
val xterm_color_tfree: string ref |
|
40 |
val xterm_color_tvar: string ref |
|
41 |
val xterm_color_free: string ref |
|
42 |
val xterm_color_bound: string ref |
|
43 |
val xterm_color_var: string ref |
|
6322 | 44 |
val token_translation: (string * string * (string -> string * real)) list |
2697 | 45 |
end; |
46 |
||
47 |
structure TokenTrans: TOKEN_TRANS = |
|
48 |
struct |
|
49 |
||
5406 | 50 |
|
2697 | 51 |
(** misc utils **) |
52 |
||
6695
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
53 |
fun tokentrans_mode m trs = map (fn (s, f) => (m, s, f)) trs; |
2697 | 54 |
|
6322 | 55 |
val standard_token_classes = |
11697 | 56 |
["class", "tfree", "tvar", "free", "bound", "var", "num", "xnum", "xstr"]; |
2697 | 57 |
|
11795 | 58 |
val standard_token_markers = map (fn s => "_" ^ s) standard_token_classes; |
2697 | 59 |
|
60 |
||
61 |
(** xterm output **) |
|
62 |
||
63 |
(* styles *) |
|
64 |
||
65 |
val normal = "\^[[0m"; |
|
66 |
val bold = "\^[[1m"; |
|
67 |
val underline = "\^[[4m"; |
|
2707 | 68 |
val reverse = "\^[[7m"; |
69 |
||
2710 | 70 |
val black = "\^[[30m"; |
71 |
val red = "\^[[31m"; |
|
72 |
val green = "\^[[32m"; |
|
2707 | 73 |
val yellow = "\^[[33m"; |
2710 | 74 |
val blue = "\^[[34m"; |
75 |
val purple = "\^[[35m"; |
|
2707 | 76 |
val cyan = "\^[[36m"; |
77 |
val white = "\^[[37m"; |
|
2697 | 78 |
|
14880 | 79 |
fun style (ref s) x = Output.output_width x |> apfst (enclose s normal); |
2710 | 80 |
|
81 |
||
82 |
(* print modes "xterm" and "xterm_color" *) |
|
2707 | 83 |
|
2710 | 84 |
val xterm_class = ref normal; |
85 |
val xterm_tfree = ref bold; |
|
86 |
val xterm_tvar = ref bold; |
|
87 |
val xterm_free = ref bold; |
|
88 |
val xterm_bound = ref underline; |
|
89 |
val xterm_var = ref bold; |
|
2697 | 90 |
|
2710 | 91 |
val xterm_color_class = ref red; |
92 |
val xterm_color_tfree = ref purple; |
|
93 |
val xterm_color_tvar = ref purple; |
|
94 |
val xterm_color_free = ref blue; |
|
95 |
val xterm_color_bound = ref green; |
|
96 |
val xterm_color_var = ref blue; |
|
2697 | 97 |
|
98 |
val xterm_trans = |
|
6695
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
99 |
tokentrans_mode "xterm" |
2710 | 100 |
[("class", style xterm_class), |
101 |
("tfree", style xterm_tfree), |
|
102 |
("tvar", style xterm_tvar), |
|
103 |
("free", style xterm_free), |
|
104 |
("bound", style xterm_bound), |
|
105 |
("var", style xterm_var)] @ |
|
6695
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
106 |
tokentrans_mode "xterm_color" |
2710 | 107 |
[("class", style xterm_color_class), |
108 |
("tfree", style xterm_color_tfree), |
|
109 |
("tvar", style xterm_color_tvar), |
|
110 |
("free", style xterm_color_free), |
|
111 |
("bound", style xterm_color_bound), |
|
112 |
("var", style xterm_color_var)]; |
|
2697 | 113 |
|
114 |
||
5406 | 115 |
|
116 |
(** standard token translations **) |
|
2697 | 117 |
|
118 |
val token_translation = |
|
14880 | 119 |
map (fn s => ("", s, Output.output_width)) standard_token_classes @ |
6695
d3ba5427d562
Isamode and ProofGeneral configuration moved to Pure/Interface;
wenzelm
parents:
6322
diff
changeset
|
120 |
xterm_trans; |
2697 | 121 |
|
122 |
||
123 |
end; |