author | wenzelm |
Tue, 05 Jul 2011 10:54:05 +0200 | |
changeset 43664 | 47af50b0c8c5 |
parent 43661 | 39fdbd814c7f |
child 43669 | 9d34288e9351 |
permissions | -rw-r--r-- |
30175 | 1 |
/* Title: Pure/System/isabelle_system.scala |
27919 | 2 |
Author: Makarius |
3 |
||
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
4 |
Fundamental Isabelle system environment: settings, symbols etc. |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
5 |
Quasi-static module with optional init operation. |
27919 | 6 |
*/ |
7 |
||
8 |
package isabelle |
|
9 |
||
43520
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
wenzelm
parents:
43514
diff
changeset
|
10 |
import java.lang.System |
31520
0a99c8716312
simplified IsabelleSystem.platform_path for cygwin;
wenzelm
parents:
31500
diff
changeset
|
11 |
import java.util.regex.Pattern |
31820 | 12 |
import java.util.Locale |
39576
48baf61cb888
refined ML/Scala bash wrapper, based on more general lib/scripts/process;
wenzelm
parents:
39574
diff
changeset
|
13 |
import java.io.{InputStream, FileInputStream, OutputStream, FileOutputStream, File, |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
14 |
BufferedReader, InputStreamReader, BufferedWriter, OutputStreamWriter, IOException} |
34024 | 15 |
import java.awt.{GraphicsEnvironment, Font} |
37367 | 16 |
import java.awt.font.TextAttribute |
28063 | 17 |
|
18 |
import scala.io.Source |
|
31520
0a99c8716312
simplified IsabelleSystem.platform_path for cygwin;
wenzelm
parents:
31500
diff
changeset
|
19 |
import scala.util.matching.Regex |
34163 | 20 |
import scala.collection.mutable |
27936 | 21 |
|
27919 | 22 |
|
43514
45cf8d5e109a
lazy Isabelle_System.default supports implicit boot;
wenzelm
parents:
43484
diff
changeset
|
23 |
object Isabelle_System |
45cf8d5e109a
lazy Isabelle_System.default supports implicit boot;
wenzelm
parents:
43484
diff
changeset
|
24 |
{ |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
25 |
/** implicit state **/ |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
26 |
|
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
27 |
private case class State( |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
28 |
standard_system: Standard_System, |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
29 |
settings: Map[String, String], |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
30 |
symbols: Symbol.Interpretation) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
31 |
|
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
32 |
@volatile private var _state: Option[State] = None |
43514
45cf8d5e109a
lazy Isabelle_System.default supports implicit boot;
wenzelm
parents:
43484
diff
changeset
|
33 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
34 |
private def check_state(): State = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
35 |
{ |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
36 |
if (_state.isEmpty) init() // unsynchronized check |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
37 |
_state.get |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
38 |
} |
37013
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
39 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
40 |
def standard_system: Standard_System = check_state().standard_system |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
41 |
def settings: Map[String, String] = check_state().settings |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
42 |
def symbols: Symbol.Interpretation = check_state().symbols |
31796 | 43 |
|
37013
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
44 |
/* |
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
45 |
isabelle_home precedence: |
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
46 |
(1) this_isabelle_home as explicit argument |
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
47 |
(2) ISABELLE_HOME process environment variable (e.g. inherited from running isabelle tool) |
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
48 |
(3) isabelle.home system property (e.g. via JVM application boot process) |
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
49 |
*/ |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
50 |
def init(this_isabelle_home: String = null) = synchronized { |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
51 |
if (_state.isEmpty) { |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
52 |
import scala.collection.JavaConversions._ |
37013
641923374eba
Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents:
36991
diff
changeset
|
53 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
54 |
val standard_system = new Standard_System |
31498 | 55 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
56 |
val settings = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
57 |
{ |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
58 |
val env = Map(System.getenv.toList: _*) + |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
59 |
("THIS_JAVA" -> standard_system.this_java()) |
27919 | 60 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
61 |
val isabelle_home = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
62 |
if (this_isabelle_home != null) this_isabelle_home |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
63 |
else |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
64 |
env.get("ISABELLE_HOME") match { |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
65 |
case None | Some("") => |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
66 |
val path = System.getProperty("isabelle.home") |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
67 |
if (path == null || path == "") error("Unknown Isabelle home directory") |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
68 |
else path |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
69 |
case Some(path) => path |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
70 |
} |
29177 | 71 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
72 |
Standard_System.with_tmp_file("settings") { dump => |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
73 |
val shell_prefix = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
74 |
if (Platform.is_windows) List(standard_system.platform_root + "\\bin\\bash", "-l") |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
75 |
else Nil |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
76 |
val cmdline = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
77 |
shell_prefix ::: List(isabelle_home + "/bin/isabelle", "getenv", "-d", dump.toString) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
78 |
val (output, rc) = Standard_System.raw_exec(null, env, true, cmdline: _*) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
79 |
if (rc != 0) error(output) |
31498 | 80 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
81 |
val entries = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
82 |
for (entry <- Source.fromFile(dump).mkString split "\0" if entry != "") yield { |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
83 |
val i = entry.indexOf('=') |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
84 |
if (i <= 0) (entry -> "") |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
85 |
else (entry.substring(0, i) -> entry.substring(i + 1)) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
86 |
} |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
87 |
Map(entries: _*) + |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
88 |
("HOME" -> System.getenv("HOME")) + |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
89 |
("PATH" -> System.getenv("PATH")) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
90 |
} |
34201
c95dcd12f48a
separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
34200
diff
changeset
|
91 |
} |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
92 |
|
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
93 |
val symbols = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
94 |
{ |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
95 |
val isabelle_symbols = settings.getOrElse("ISABELLE_SYMBOLS", "") |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
96 |
if (isabelle_symbols == "") error("Undefined environment variable: ISABELLE_SYMBOLS") |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
97 |
val files = |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
98 |
isabelle_symbols.split(":").toList.map(s => new File(standard_system.jvm_path(s))) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
99 |
new Symbol.Interpretation(Standard_System.try_read(files).split("\n").toList) |
34201
c95dcd12f48a
separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
34200
diff
changeset
|
100 |
} |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
101 |
|
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
102 |
_state = Some(State(standard_system, settings, symbols)) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
103 |
} |
27953 | 104 |
} |
27919 | 105 |
|
31796 | 106 |
|
107 |
/* getenv */ |
|
108 |
||
31498 | 109 |
def getenv(name: String): String = |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
110 |
settings.getOrElse(if (name == "HOME") "HOME_JVM" else name, "") |
31498 | 111 |
|
112 |
def getenv_strict(name: String): String = |
|
113 |
{ |
|
31234
6ce6801129de
getenv_strict needs to be based on getenv (accidentally broken in 0e88d33e8d19);
wenzelm
parents:
30175
diff
changeset
|
114 |
val value = getenv(name) |
27993
6dd90ef9f927
simplified exceptions: use plain error function / RuntimeException;
wenzelm
parents:
27974
diff
changeset
|
115 |
if (value != "") value else error("Undefined environment variable: " + name) |
27919 | 116 |
} |
117 |
||
31796 | 118 |
|
43606 | 119 |
/** file-system operations **/ |
31796 | 120 |
|
43606 | 121 |
/* path specifications */ |
36136
89b1a136edef
more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents:
36012
diff
changeset
|
122 |
|
43664 | 123 |
def standard_path(path: Path): String = path.expand.implode |
31796 | 124 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
125 |
def platform_path(path: Path): String = standard_system.jvm_path(standard_path(path)) |
43606 | 126 |
def platform_file(path: Path) = new File(platform_path(path)) |
29152 | 127 |
|
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
128 |
def posix_path(jvm_path: String): String = standard_system.posix_path(jvm_path) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
129 |
|
27953 | 130 |
|
36991 | 131 |
/* try_read */ |
132 |
||
43606 | 133 |
def try_read(paths: Seq[Path]): String = |
36991 | 134 |
{ |
37058
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
135 |
val buf = new StringBuilder |
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
136 |
for { |
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
137 |
path <- paths |
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
138 |
file = platform_file(path) if file.isFile |
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
139 |
c <- (Source.fromFile(file) ++ Iterator.single('\n')) |
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
140 |
} buf.append(c) |
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
141 |
buf.toString |
36991 | 142 |
} |
143 |
||
144 |
||
31436 | 145 |
/* source files */ |
146 |
||
147 |
private def try_file(file: File) = if (file.isFile) Some(file) else None |
|
148 |
||
43606 | 149 |
def source_file(path: Path): Option[File] = |
31498 | 150 |
{ |
43606 | 151 |
if (path.is_absolute || path.is_current) |
31436 | 152 |
try_file(platform_file(path)) |
153 |
else { |
|
43606 | 154 |
val pure_file = platform_file(Path.explode("~~/src/Pure") + path) |
31436 | 155 |
if (pure_file.isFile) Some(pure_file) |
156 |
else if (getenv("ML_SOURCES") != "") |
|
43606 | 157 |
try_file(platform_file(Path.explode("$ML_SOURCES") + path)) |
31436 | 158 |
else None |
159 |
} |
|
160 |
} |
|
161 |
||
162 |
||
32450 | 163 |
|
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
164 |
/** external processes **/ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
165 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
166 |
/* plain execute */ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
167 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
168 |
def execute(redirect: Boolean, args: String*): Process = |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
169 |
{ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
170 |
val cmdline = |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
171 |
if (Platform.is_windows) List(standard_system.platform_root + "\\bin\\env.exe") ++ args |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
172 |
else args |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
173 |
Standard_System.raw_execute(null, settings, redirect, cmdline: _*) |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
174 |
} |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
175 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
176 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
177 |
/* managed process */ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
178 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
179 |
class Managed_Process(redirect: Boolean, args: String*) |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
180 |
{ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
181 |
private val params = |
43606 | 182 |
List(standard_path(Path.explode("~~/lib/scripts/process")), "group", "-", "no_script") |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
183 |
private val proc = execute(redirect, (params ++ args):_*) |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
184 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
185 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
186 |
// channels |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
187 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
188 |
val stdin: BufferedWriter = |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
189 |
new BufferedWriter(new OutputStreamWriter(proc.getOutputStream, Standard_System.charset)) |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
190 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
191 |
val stdout: BufferedReader = |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
192 |
new BufferedReader(new InputStreamReader(proc.getInputStream, Standard_System.charset)) |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
193 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
194 |
val stderr: BufferedReader = |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
195 |
new BufferedReader(new InputStreamReader(proc.getErrorStream, Standard_System.charset)) |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
196 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
197 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
198 |
// signals |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
199 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
200 |
private val pid = stdout.readLine |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
201 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
202 |
private def kill(signal: String): Boolean = |
39584
f2a10986e85a
more robust Managed_Process.kill: check after sending signal;
wenzelm
parents:
39583
diff
changeset
|
203 |
{ |
f2a10986e85a
more robust Managed_Process.kill: check after sending signal;
wenzelm
parents:
39583
diff
changeset
|
204 |
execute(true, "kill", "-" + signal, "-" + pid).waitFor |
f2a10986e85a
more robust Managed_Process.kill: check after sending signal;
wenzelm
parents:
39583
diff
changeset
|
205 |
execute(true, "kill", "-0", "-" + pid).waitFor == 0 |
f2a10986e85a
more robust Managed_Process.kill: check after sending signal;
wenzelm
parents:
39583
diff
changeset
|
206 |
} |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
207 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
208 |
private def multi_kill(signal: String): Boolean = |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
209 |
{ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
210 |
var running = true |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
211 |
var count = 10 |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
212 |
while (running && count > 0) { |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
213 |
if (kill(signal)) { |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
214 |
Thread.sleep(100) |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
215 |
count -= 1 |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
216 |
} |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
217 |
else running = false |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
218 |
} |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
219 |
running |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
220 |
} |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
221 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
222 |
def interrupt() { multi_kill("INT") } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
223 |
def terminate() { multi_kill("INT") && multi_kill("TERM") && kill("KILL"); proc.destroy } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
224 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
225 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
226 |
// JVM shutdown hook |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
227 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
228 |
private val shutdown_hook = new Thread { override def run = terminate() } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
229 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
230 |
try { Runtime.getRuntime.addShutdownHook(shutdown_hook) } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
231 |
catch { case _: IllegalStateException => } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
232 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
233 |
private def cleanup() = |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
234 |
try { Runtime.getRuntime.removeShutdownHook(shutdown_hook) } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
235 |
catch { case _: IllegalStateException => } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
236 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
237 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
238 |
/* result */ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
239 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
240 |
def join: Int = { val rc = proc.waitFor; cleanup(); rc } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
241 |
} |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
242 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
243 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
244 |
/* bash */ |
31796 | 245 |
|
39581
430ff865089b
refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents:
39576
diff
changeset
|
246 |
def bash(script: String): (String, String, Int) = |
34198
ff5486262cd6
moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents:
34196
diff
changeset
|
247 |
{ |
34201
c95dcd12f48a
separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents:
34200
diff
changeset
|
248 |
Standard_System.with_tmp_file("isabelle_script") { script_file => |
39581
430ff865089b
refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents:
39576
diff
changeset
|
249 |
Standard_System.write_file(script_file, script) |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
250 |
val proc = new Managed_Process(false, "bash", posix_path(script_file.getPath)) |
39581
430ff865089b
refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents:
39576
diff
changeset
|
251 |
|
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
252 |
proc.stdin.close |
39586
ea8f3ea13a95
eliminated Simple_Thread shorthands that can overlap with full version;
wenzelm
parents:
39584
diff
changeset
|
253 |
val stdout = Simple_Thread.future("bash_stdout") { Standard_System.slurp(proc.stdout) } |
ea8f3ea13a95
eliminated Simple_Thread shorthands that can overlap with full version;
wenzelm
parents:
39584
diff
changeset
|
254 |
val stderr = Simple_Thread.future("bash_stderr") { Standard_System.slurp(proc.stderr) } |
34198
ff5486262cd6
moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents:
34196
diff
changeset
|
255 |
|
39581
430ff865089b
refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents:
39576
diff
changeset
|
256 |
val rc = |
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
257 |
try { proc.join } |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
258 |
catch { case e: InterruptedException => Thread.interrupted; proc.terminate; 130 } |
39581
430ff865089b
refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents:
39576
diff
changeset
|
259 |
(stdout.join, stderr.join, rc) |
34198
ff5486262cd6
moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents:
34196
diff
changeset
|
260 |
} |
ff5486262cd6
moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents:
34196
diff
changeset
|
261 |
} |
ff5486262cd6
moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents:
34196
diff
changeset
|
262 |
|
39583
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
263 |
|
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
264 |
/* system tools */ |
c1e9c6dfeff8
more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents:
39581
diff
changeset
|
265 |
|
31818
f698f76a3713
builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents:
31803
diff
changeset
|
266 |
def isabelle_tool(name: String, args: String*): (String, Int) = |
31498 | 267 |
{ |
34200 | 268 |
getenv_strict("ISABELLE_TOOLS").split(":").find { dir => |
43606 | 269 |
val file = platform_file(Path.explode(dir) + Path.basic(name)) |
42124 | 270 |
try { |
271 |
file.isFile && file.canRead && file.canExecute && |
|
272 |
!name.endsWith("~") && !name.endsWith(".orig") |
|
273 |
} |
|
31818
f698f76a3713
builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents:
31803
diff
changeset
|
274 |
catch { case _: SecurityException => false } |
34200 | 275 |
} match { |
31818
f698f76a3713
builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents:
31803
diff
changeset
|
276 |
case Some(dir) => |
43606 | 277 |
val file = standard_path(Path.explode(dir) + Path.basic(name)) |
278 |
Standard_System.process_output(execute(true, (List(file) ++ args): _*)) |
|
31818
f698f76a3713
builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents:
31803
diff
changeset
|
279 |
case None => ("Unknown Isabelle tool: " + name, 2) |
f698f76a3713
builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents:
31803
diff
changeset
|
280 |
} |
28063 | 281 |
} |
282 |
||
283 |
||
284 |
/* named pipes */ |
|
285 |
||
43660 | 286 |
private val next_fifo = new Counter |
39520
bad14b7d0520
Isabelle_System.mk_fifo: more robust enumeration of unique names, based on persisting JVM pid (parent of shell process);
wenzelm
parents:
38371
diff
changeset
|
287 |
|
31498 | 288 |
def mk_fifo(): String = |
289 |
{ |
|
39529
4e466a5f67f3
simplified Isabelle_System.mk_fifo: inlined script, append PPID and PID uniformly;
wenzelm
parents:
39523
diff
changeset
|
290 |
val i = next_fifo() |
4e466a5f67f3
simplified Isabelle_System.mk_fifo: inlined script, append PPID and PID uniformly;
wenzelm
parents:
39523
diff
changeset
|
291 |
val script = |
43660 | 292 |
"FIFO=\"/tmp/isabelle-fifo-${PPID}-$$" + i + "\"\n" + |
39699 | 293 |
"echo -n \"$FIFO\"\n" + |
294 |
"mkfifo -m 600 \"$FIFO\"\n" |
|
39581
430ff865089b
refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents:
39576
diff
changeset
|
295 |
val (out, err, rc) = bash(script) |
39699 | 296 |
if (rc == 0) out else error(err.trim) |
28063 | 297 |
} |
298 |
||
39574
91b23d141dbf
more robust Isabelle_System.rm_fifo: avoid external bash invocation, which might not work in JVM shutdown phase (due to Runtime.addShutdownHook);
wenzelm
parents:
39529
diff
changeset
|
299 |
def rm_fifo(fifo: String): Boolean = |
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43660
diff
changeset
|
300 |
(new File(standard_system.jvm_path(if (Platform.is_windows) fifo + ".lnk" else fifo))).delete |
28063 | 301 |
|
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
302 |
def fifo_input_stream(fifo: String): InputStream = |
31498 | 303 |
{ |
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
304 |
if (Platform.is_windows) { // Cygwin fifo as Windows/Java input stream |
43606 | 305 |
val proc = execute(false, standard_path(Path.explode("~~/lib/scripts/raw_dump")), fifo, "-") |
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
306 |
proc.getOutputStream.close |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
307 |
proc.getErrorStream.close |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
308 |
proc.getInputStream |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
309 |
} |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
310 |
else new FileInputStream(fifo) |
29177 | 311 |
} |
28063 | 312 |
|
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
313 |
def fifo_output_stream(fifo: String): OutputStream = |
38253
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents:
37367
diff
changeset
|
314 |
{ |
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
315 |
if (Platform.is_windows) { // Cygwin fifo as Windows/Java output stream |
43606 | 316 |
val proc = execute(false, standard_path(Path.explode("~~/lib/scripts/raw_dump")), "-", fifo) |
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
317 |
proc.getInputStream.close |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
318 |
proc.getErrorStream.close |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
319 |
val out = proc.getOutputStream |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
320 |
new OutputStream { |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
321 |
override def close() { out.close(); proc.waitFor() } |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
322 |
override def flush() { out.flush() } |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
323 |
override def write(b: Array[Byte]) { out.write(b) } |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
324 |
override def write(b: Array[Byte], off: Int, len: Int) { out.write(b, off, len) } |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
325 |
override def write(b: Int) { out.write(b) } |
38253
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents:
37367
diff
changeset
|
326 |
} |
38371
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
327 |
} |
5b615a4a3a68
do not buffer fifo streams here -- done in Isabelle_Process;
wenzelm
parents:
38255
diff
changeset
|
328 |
else new FileOutputStream(fifo) |
38253
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents:
37367
diff
changeset
|
329 |
} |
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
wenzelm
parents:
37367
diff
changeset
|
330 |
|
29152 | 331 |
|
32450 | 332 |
|
31796 | 333 |
/** Isabelle resources **/ |
334 |
||
32328 | 335 |
/* components */ |
336 |
||
337 |
def components(): List[String] = |
|
37058
c47653f3ec14
rendering information and style sheets via settings;
wenzelm
parents:
37013
diff
changeset
|
338 |
getenv_strict("ISABELLE_COMPONENTS").split(":").toList |
32328 | 339 |
|
340 |
||
29152 | 341 |
/* find logics */ |
342 |
||
31498 | 343 |
def find_logics(): List[String] = |
344 |
{ |
|
29152 | 345 |
val ml_ident = getenv_strict("ML_IDENTIFIER") |
34163 | 346 |
val logics = new mutable.ListBuffer[String] |
29152 | 347 |
for (dir <- getenv_strict("ISABELLE_PATH").split(":")) { |
43606 | 348 |
val files = platform_file(Path.explode(dir) + Path.explode(ml_ident)).listFiles() |
29152 | 349 |
if (files != null) { |
350 |
for (file <- files if file.isFile) logics += file.getName |
|
351 |
} |
|
352 |
} |
|
36012 | 353 |
logics.toList.sortWith(_ < _) |
29152 | 354 |
} |
29570 | 355 |
|
356 |
||
34024 | 357 |
/* fonts */ |
358 |
||
43484 | 359 |
def get_font(family: String = "IsabelleText", size: Int = 1, bold: Boolean = false): Font = |
360 |
new Font(family, if (bold) Font.BOLD else Font.PLAIN, size) |
|
37367 | 361 |
|
34044
09afb1d49fe7
slightly more robust and less ambitious version of install_fonts;
wenzelm
parents:
34027
diff
changeset
|
362 |
def install_fonts() |
09afb1d49fe7
slightly more robust and less ambitious version of install_fonts;
wenzelm
parents:
34027
diff
changeset
|
363 |
{ |
37367 | 364 |
val ge = GraphicsEnvironment.getLocalGraphicsEnvironment() |
43484 | 365 |
for (font <- getenv_strict("ISABELLE_FONTS").split(":")) |
43606 | 366 |
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, platform_file(Path.explode(font)))) |
34024 | 367 |
} |
27919 | 368 |
} |