src/Pure/System/isabelle_system.scala
author wenzelm
Tue, 24 Apr 2012 15:23:12 +0200
changeset 47725 447b635bcea5
parent 47674 cdf95042e09c
child 48193 cab79d456044
permissions -rw-r--r--
cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30175
62ba490670e8 fixed headers;
wenzelm
parents: 30174
diff changeset
     1
/*  Title:      Pure/System/isabelle_system.scala
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
     3
43695
5130dfe1b7be simplified Symbol based on lazy Symbol.Interpretation -- reduced odd "functorial style";
wenzelm
parents: 43670
diff changeset
     4
Fundamental Isabelle system environment: quasi-static module with
5130dfe1b7be simplified Symbol based on lazy Symbol.Interpretation -- reduced odd "functorial style";
wenzelm
parents: 43670
diff changeset
     5
optional init operation.
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
     6
*/
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
     7
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
     8
package isabelle
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
     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
8199c9a42941 added isabelle_path;
wenzelm
parents: 31818
diff changeset
    12
import java.util.Locale
45027
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents: 44184
diff changeset
    13
import java.io.{InputStream, OutputStream, File, BufferedReader, InputStreamReader,
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents: 44184
diff changeset
    14
  BufferedWriter, OutputStreamWriter, IOException}
34024
0bae8702a7c5 basic support for IsabelleText fonts;
wenzelm
parents: 32450
diff changeset
    15
import java.awt.{GraphicsEnvironment, Font}
37367
8680677265c9 clarified font_family vs. font_family_default;
wenzelm
parents: 37132
diff changeset
    16
import java.awt.font.TextAttribute
28063
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents: 28057
diff changeset
    17
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents: 28057
diff changeset
    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
wenzelm
parents: 34162
diff changeset
    20
import scala.collection.mutable
27936
947cb8e3d313 added get_setting;
wenzelm
parents: 27919
diff changeset
    21
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
    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
43695
5130dfe1b7be simplified Symbol based on lazy Symbol.Interpretation -- reduced odd "functorial style";
wenzelm
parents: 43670
diff changeset
    27
  private case class State(standard_system: Standard_System, settings: Map[String, String])
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    28
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    29
  @volatile private var _state: Option[State] = None
43514
45cf8d5e109a lazy Isabelle_System.default supports implicit boot;
wenzelm
parents: 43484
diff changeset
    30
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    31
  private def check_state(): State =
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    32
  {
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    33
    if (_state.isEmpty) init()  // unsynchronized check
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    34
    _state.get
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    35
  }
37013
641923374eba Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents: 36991
diff changeset
    36
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    37
  def standard_system: Standard_System = check_state().standard_system
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    38
  def settings: Map[String, String] = check_state().settings
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
    39
37013
641923374eba Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents: 36991
diff changeset
    40
  /*
641923374eba Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents: 36991
diff changeset
    41
    isabelle_home precedence:
641923374eba Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents: 36991
diff changeset
    42
      (1) this_isabelle_home as explicit argument
641923374eba Isabelle_System: allow explicit isabelle_home argument;
wenzelm
parents: 36991
diff changeset
    43
      (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
    44
      (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
    45
  */
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    46
  def init(this_isabelle_home: String = null) = synchronized {
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    47
    if (_state.isEmpty) {
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    48
      import scala.collection.JavaConversions._
37013
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
      val standard_system = new Standard_System
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    51
      val settings =
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    52
      {
47725
447b635bcea5 cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
wenzelm
parents: 47674
diff changeset
    53
        val env0 = Map(System.getenv.toList: _*) +
47113
b5a5662528fb ISABELLE_JDK_HOME settings variable points to JDK with javac and jar (not just JRE);
wenzelm
parents: 45900
diff changeset
    54
          ("ISABELLE_JDK_HOME" -> standard_system.this_jdk_home())
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
    55
47725
447b635bcea5 cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
wenzelm
parents: 47674
diff changeset
    56
        val user_home = System.getProperty("user.home")
447b635bcea5 cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
wenzelm
parents: 47674
diff changeset
    57
        val env =
447b635bcea5 cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
wenzelm
parents: 47674
diff changeset
    58
          if (user_home == null || env0.isDefinedAt("HOME")) env0
447b635bcea5 cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
wenzelm
parents: 47674
diff changeset
    59
          else env0 + ("HOME" -> user_home)
447b635bcea5 cold-start HOME is user.home, in accordance with Cygwin-Terminal.bat;
wenzelm
parents: 47674
diff changeset
    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
0e88d33e8d19 maintain initial process environment;
wenzelm
parents: 29174
diff changeset
    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
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
    80
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    81
              val entries =
47674
cdf95042e09c more robust handling of PATH vs PATH_JVM -- required for cold start of Cygwin from Windows (e.g. Isabelle.exe);
wenzelm
parents: 47661
diff changeset
    82
                (for (entry <- Source.fromFile(dump).mkString split "\0" if entry != "") yield {
43661
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))
47674
cdf95042e09c more robust handling of PATH vs PATH_JVM -- required for cold start of Cygwin from Windows (e.g. Isabelle.exe);
wenzelm
parents: 47661
diff changeset
    86
                }).toMap
cdf95042e09c more robust handling of PATH vs PATH_JVM -- required for cold start of Cygwin from Windows (e.g. Isabelle.exe);
wenzelm
parents: 47661
diff changeset
    87
              entries + ("PATH" -> entries("PATH_JVM")) - "PATH_JVM"
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    88
            }
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents: 34200
diff changeset
    89
          }
43695
5130dfe1b7be simplified Symbol based on lazy Symbol.Interpretation -- reduced odd "functorial style";
wenzelm
parents: 43670
diff changeset
    90
      _state = Some(State(standard_system, settings))
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
    91
    }
27953
b2003c98897c added getenv;
wenzelm
parents: 27936
diff changeset
    92
  }
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
    93
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
    94
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
    95
  /* getenv */
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
    96
47661
012a887997f3 USER_HOME settings variable points to cross-platform user home directory;
wenzelm
parents: 47113
diff changeset
    97
  def getenv(name: String): String = settings.getOrElse(name, "")
31498
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
    98
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
    99
  def getenv_strict(name: String): String =
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
   100
  {
31234
6ce6801129de getenv_strict needs to be based on getenv (accidentally broken in 0e88d33e8d19);
wenzelm
parents: 30175
diff changeset
   101
    val value = getenv(name)
27993
6dd90ef9f927 simplified exceptions: use plain error function / RuntimeException;
wenzelm
parents: 27974
diff changeset
   102
    if (value != "") value else error("Undefined environment variable: " + name)
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
   103
  }
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
   104
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
   105
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   106
  /** file-system operations **/
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
   107
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   108
  /* path specifications */
36136
89b1a136edef more precise treatment of UNC server prefix, e.g. //foo;
wenzelm
parents: 36012
diff changeset
   109
43664
wenzelm
parents: 43661
diff changeset
   110
  def standard_path(path: Path): String = path.expand.implode
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
   111
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
   112
  def platform_path(path: Path): String = standard_system.jvm_path(standard_path(path))
45027
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents: 44184
diff changeset
   113
  def platform_file(path: Path): File = new File(platform_path(path))
29152
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   114
45100
0971c3ee3cdf proper platform_file_url;
wenzelm
parents: 45027
diff changeset
   115
  def platform_file_url(raw_path: Path): String =
0971c3ee3cdf proper platform_file_url;
wenzelm
parents: 45027
diff changeset
   116
  {
0971c3ee3cdf proper platform_file_url;
wenzelm
parents: 45027
diff changeset
   117
    val path = raw_path.expand
0971c3ee3cdf proper platform_file_url;
wenzelm
parents: 45027
diff changeset
   118
    require(path.is_absolute)
45101
6317e969fb30 proper platform_file_url for Windows UNC paths (server shares);
wenzelm
parents: 45100
diff changeset
   119
    val s = platform_path(path).replaceAll(" ", "%20")
6317e969fb30 proper platform_file_url for Windows UNC paths (server shares);
wenzelm
parents: 45100
diff changeset
   120
    if (!Platform.is_windows) "file://" + s
6317e969fb30 proper platform_file_url for Windows UNC paths (server shares);
wenzelm
parents: 45100
diff changeset
   121
    else if (s.startsWith("\\\\")) "file:" + s.replace('\\', '/')
6317e969fb30 proper platform_file_url for Windows UNC paths (server shares);
wenzelm
parents: 45100
diff changeset
   122
    else "file:///" + s.replace('\\', '/')
45100
0971c3ee3cdf proper platform_file_url;
wenzelm
parents: 45027
diff changeset
   123
  }
0971c3ee3cdf proper platform_file_url;
wenzelm
parents: 45027
diff changeset
   124
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
   125
  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
   126
27953
b2003c98897c added getenv;
wenzelm
parents: 27936
diff changeset
   127
36991
ccb8da7f76e6 general Isabelle_System.try_read;
wenzelm
parents: 36788
diff changeset
   128
  /* try_read */
ccb8da7f76e6 general Isabelle_System.try_read;
wenzelm
parents: 36788
diff changeset
   129
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   130
  def try_read(paths: Seq[Path]): String =
36991
ccb8da7f76e6 general Isabelle_System.try_read;
wenzelm
parents: 36788
diff changeset
   131
  {
37058
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   132
    val buf = new StringBuilder
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   133
    for {
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   134
      path <- paths
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   135
      file = platform_file(path) if file.isFile
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   136
      c <- (Source.fromFile(file) ++ Iterator.single('\n'))
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   137
    } buf.append(c)
c47653f3ec14 rendering information and style sheets via settings;
wenzelm
parents: 37013
diff changeset
   138
    buf.toString
36991
ccb8da7f76e6 general Isabelle_System.try_read;
wenzelm
parents: 36788
diff changeset
   139
  }
ccb8da7f76e6 general Isabelle_System.try_read;
wenzelm
parents: 36788
diff changeset
   140
ccb8da7f76e6 general Isabelle_System.try_read;
wenzelm
parents: 36788
diff changeset
   141
31436
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   142
  /* source files */
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   143
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   144
  private def try_file(file: File) = if (file.isFile) Some(file) else None
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   145
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   146
  def source_file(path: Path): Option[File] =
31498
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
   147
  {
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   148
    if (path.is_absolute || path.is_current)
31436
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   149
      try_file(platform_file(path))
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   150
    else {
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   151
      val pure_file = platform_file(Path.explode("~~/src/Pure") + path)
31436
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   152
      if (pure_file.isFile) Some(pure_file)
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   153
      else if (getenv("ML_SOURCES") != "")
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   154
        try_file(platform_file(Path.explode("$ML_SOURCES") + path))
31436
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   155
      else None
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   156
    }
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   157
  }
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   158
dde1b4d1c95b retrieve ML source files;
wenzelm
parents: 31234
diff changeset
   159
32450
375db037f4d2 misc tuning;
wenzelm
parents: 32328
diff changeset
   160
39583
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   161
  /** external processes **/
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   162
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   163
  /* plain execute */
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   164
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   165
  def execute(redirect: Boolean, args: String*): Process =
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   166
  {
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   167
    val cmdline =
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
   168
      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
   169
      else args
43661
39fdbd814c7f quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents: 43660
diff changeset
   170
    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
   171
  }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   172
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   173
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   174
  /* managed process */
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
  class Managed_Process(redirect: Boolean, args: String*)
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   177
  {
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   178
    private val params =
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   179
      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
   180
    private val proc = execute(redirect, (params ++ args):_*)
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   181
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   182
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   183
    // channels
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
    val stdin: BufferedWriter =
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   186
      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
   187
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   188
    val stdout: BufferedReader =
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   189
      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
   190
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   191
    val stderr: BufferedReader =
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   192
      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
   193
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   194
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   195
    // signals
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
    private val pid = stdout.readLine
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   198
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   199
    private def kill(signal: String): Boolean =
39584
f2a10986e85a more robust Managed_Process.kill: check after sending signal;
wenzelm
parents: 39583
diff changeset
   200
    {
f2a10986e85a more robust Managed_Process.kill: check after sending signal;
wenzelm
parents: 39583
diff changeset
   201
      execute(true, "kill", "-" + signal, "-" + pid).waitFor
f2a10986e85a more robust Managed_Process.kill: check after sending signal;
wenzelm
parents: 39583
diff changeset
   202
      execute(true, "kill", "-0", "-" + pid).waitFor == 0
f2a10986e85a more robust Managed_Process.kill: check after sending signal;
wenzelm
parents: 39583
diff changeset
   203
    }
39583
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   204
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   205
    private def multi_kill(signal: String): Boolean =
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   206
    {
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   207
      var running = true
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   208
      var count = 10
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   209
      while (running && count > 0) {
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   210
        if (kill(signal)) {
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   211
          Thread.sleep(100)
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   212
          count -= 1
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   213
        }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   214
        else running = false
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   215
      }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   216
      running
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   217
    }
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
    def interrupt() { multi_kill("INT") }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   220
    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
   221
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   222
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   223
    // JVM shutdown hook
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
    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
   226
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   227
    try { Runtime.getRuntime.addShutdownHook(shutdown_hook) }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   228
    catch { case _: IllegalStateException => }
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
    private def cleanup() =
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   231
      try { Runtime.getRuntime.removeShutdownHook(shutdown_hook) }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   232
      catch { case _: IllegalStateException => }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   233
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   234
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   235
    /* result */
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
    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
   238
  }
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
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   241
  /* bash */
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
   242
39581
430ff865089b refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents: 39576
diff changeset
   243
  def bash(script: String): (String, String, Int) =
34198
ff5486262cd6 moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents: 34196
diff changeset
   244
  {
34201
c95dcd12f48a separate Standard_System (Cygwin/Posix compatibility) vs. Isabelle_System (settings environment etc.);
wenzelm
parents: 34200
diff changeset
   245
    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
   246
      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
   247
      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
   248
39583
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   249
      proc.stdin.close
39586
ea8f3ea13a95 eliminated Simple_Thread shorthands that can overlap with full version;
wenzelm
parents: 39584
diff changeset
   250
      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
   251
      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
   252
39581
430ff865089b refined Isabelle_System.bash_output: pass pid via stdout, separate stdout/stderr;
wenzelm
parents: 39576
diff changeset
   253
      val rc =
39583
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   254
        try { proc.join }
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   255
        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
   256
      (stdout.join, stderr.join, rc)
34198
ff5486262cd6 moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents: 34196
diff changeset
   257
    }
ff5486262cd6 moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents: 34196
diff changeset
   258
  }
ff5486262cd6 moved Library.decode_permissive_utf8 to Isabelle_System;
wenzelm
parents: 34196
diff changeset
   259
39583
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   260
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   261
  /* system tools */
c1e9c6dfeff8 more robust lib/scripts/process, with explicit script/no_script mode;
wenzelm
parents: 39581
diff changeset
   262
31818
f698f76a3713 builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents: 31803
diff changeset
   263
  def isabelle_tool(name: String, args: String*): (String, Int) =
31498
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
   264
  {
43669
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   265
    Path.split(getenv_strict("ISABELLE_TOOLS")).find { dir =>
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   266
      val file = platform_file(dir + Path.basic(name))
42124
7519c7c33017 suppress Mercurial backup files;
wenzelm
parents: 39699
diff changeset
   267
      try {
7519c7c33017 suppress Mercurial backup files;
wenzelm
parents: 39699
diff changeset
   268
        file.isFile && file.canRead && file.canExecute &&
7519c7c33017 suppress Mercurial backup files;
wenzelm
parents: 39699
diff changeset
   269
          !name.endsWith("~") && !name.endsWith(".orig")
7519c7c33017 suppress Mercurial backup files;
wenzelm
parents: 39699
diff changeset
   270
      }
31818
f698f76a3713 builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents: 31803
diff changeset
   271
      catch { case _: SecurityException => false }
34200
wenzelm
parents: 34199
diff changeset
   272
    } match {
31818
f698f76a3713 builtin isabelle_tool for ML and Scala -- avoids excessive shell script (especially important for Cygwin);
wenzelm
parents: 31803
diff changeset
   273
      case Some(dir) =>
43669
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   274
        val file = standard_path(dir + Path.basic(name))
43606
e1a09c2a6248 prefer Isabelle path algebra;
wenzelm
parents: 43520
diff changeset
   275
        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
   276
      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
   277
    }
28063
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents: 28057
diff changeset
   278
  }
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents: 28057
diff changeset
   279
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents: 28057
diff changeset
   280
32450
375db037f4d2 misc tuning;
wenzelm
parents: 32328
diff changeset
   281
31796
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
   282
  /** Isabelle resources **/
117300d72398 renamed IsabelleSystem to Isabelle_System;
wenzelm
parents: 31704
diff changeset
   283
32328
f2fd9da84bac added Isabelle_System.components;
wenzelm
parents: 31927
diff changeset
   284
  /* components */
f2fd9da84bac added Isabelle_System.components;
wenzelm
parents: 31927
diff changeset
   285
43669
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   286
  def components(): List[Path] =
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   287
    Path.split(getenv_strict("ISABELLE_COMPONENTS"))
32328
f2fd9da84bac added Isabelle_System.components;
wenzelm
parents: 31927
diff changeset
   288
f2fd9da84bac added Isabelle_System.components;
wenzelm
parents: 31927
diff changeset
   289
29152
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   290
  /* find logics */
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   291
31498
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
   292
  def find_logics(): List[String] =
be0f7f4f9e12 static IsabelleSystem.charset;
wenzelm
parents: 31443
diff changeset
   293
  {
29152
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   294
    val ml_ident = getenv_strict("ML_IDENTIFIER")
34163
wenzelm
parents: 34162
diff changeset
   295
    val logics = new mutable.ListBuffer[String]
43669
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   296
    for (dir <- Path.split(getenv_strict("ISABELLE_PATH"))) {
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   297
      val files = platform_file(dir + Path.explode(ml_ident)).listFiles()
29152
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   298
      if (files != null) {
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   299
        for (file <- files if file.isFile) logics += file.getName
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   300
      }
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   301
    }
45900
793bf5fa5fbf prefer sorting from Scala library;
wenzelm
parents: 45101
diff changeset
   302
    logics.toList.sorted
29152
89b0803404d7 added platform_file;
wenzelm
parents: 29140
diff changeset
   303
  }
29570
10fca82e688a IsabelleSystem: provide Symbol.Interpretation;
wenzelm
parents: 29180
diff changeset
   304
10fca82e688a IsabelleSystem: provide Symbol.Interpretation;
wenzelm
parents: 29180
diff changeset
   305
34024
0bae8702a7c5 basic support for IsabelleText fonts;
wenzelm
parents: 32450
diff changeset
   306
  /* fonts */
0bae8702a7c5 basic support for IsabelleText fonts;
wenzelm
parents: 32450
diff changeset
   307
43484
51b8043a8cf5 simplified/generalized ISABELLE_FONTS handling;
wenzelm
parents: 42124
diff changeset
   308
  def get_font(family: String = "IsabelleText", size: Int = 1, bold: Boolean = false): Font =
51b8043a8cf5 simplified/generalized ISABELLE_FONTS handling;
wenzelm
parents: 42124
diff changeset
   309
    new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
37367
8680677265c9 clarified font_family vs. font_family_default;
wenzelm
parents: 37132
diff changeset
   310
34044
09afb1d49fe7 slightly more robust and less ambitious version of install_fonts;
wenzelm
parents: 34027
diff changeset
   311
  def install_fonts()
09afb1d49fe7 slightly more robust and less ambitious version of install_fonts;
wenzelm
parents: 34027
diff changeset
   312
  {
37367
8680677265c9 clarified font_family vs. font_family_default;
wenzelm
parents: 37132
diff changeset
   313
    val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
43669
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   314
    for (font <- Path.split(getenv_strict("ISABELLE_FONTS")))
9d34288e9351 Path.split convenience;
wenzelm
parents: 43664
diff changeset
   315
      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, platform_file(font)))
34024
0bae8702a7c5 basic support for IsabelleText fonts;
wenzelm
parents: 32450
diff changeset
   316
  }
27919
1eb8a3902d49 Isabelle system support.
wenzelm
parents:
diff changeset
   317
}