author | wenzelm |
Thu, 31 Jan 2019 16:44:04 +0100 | |
changeset 69771 | a8ee66876a1a |
parent 69770 | efb0e5332441 |
child 69804 | 9efccbad7d42 |
permissions | -rw-r--r-- |
50687 | 1 |
/* Title: Pure/Tools/main.scala |
47663
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
3 |
|
53419
1c87e79bb838
main application entry point involves implicit Cygwin init, depending on "uninitialized" file indicator;
wenzelm
parents:
52675
diff
changeset
|
4 |
Main Isabelle application entry point. |
47663
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
6 |
|
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
8 |
|
53419
1c87e79bb838
main application entry point involves implicit Cygwin init, depending on "uninitialized" file indicator;
wenzelm
parents:
52675
diff
changeset
|
9 |
|
55618 | 10 |
import java.lang.{Class, ClassLoader} |
47663
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
11 |
|
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
12 |
|
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
13 |
object Main |
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
14 |
{ |
61282 | 15 |
/* main entry point */ |
53461 | 16 |
|
53456 | 17 |
def main(args: Array[String]) |
53449 | 18 |
{ |
61282 | 19 |
val start = |
61277 | 20 |
{ |
21 |
try { |
|
61282 | 22 |
Isabelle_System.init() |
69368
6f360600eabc
clarified signature: fonts are not dependent on GUI;
wenzelm
parents:
69188
diff
changeset
|
23 |
Isabelle_Fonts.init() |
61282 | 24 |
|
25 |
||
66577 | 26 |
/* ROOTS template */ |
27 |
||
28 |
{ |
|
29 |
val roots = Path.explode("$ISABELLE_HOME_USER/ROOTS") |
|
30 |
if (!roots.is_file) File.write(roots, """# Additional session root directories |
|
31 |
# |
|
32 |
# * each line contains one directory entry in Isabelle path notation |
|
33 |
# * lines starting with "#" are stripped |
|
34 |
# * changes require application restart |
|
35 |
# |
|
36 |
#:mode=text:encoding=UTF-8: |
|
37 |
""") |
|
38 |
} |
|
39 |
||
40 |
||
61277 | 41 |
/* settings directory */ |
42 |
||
43 |
val settings_dir = Path.explode("$JEDIT_SETTINGS") |
|
66463 | 44 |
|
45 |
val properties = settings_dir + Path.explode("properties") |
|
46 |
if (properties.is_file) { |
|
47 |
val props1 = split_lines(File.read(properties)) |
|
48 |
val props2 = props1.filterNot(_.startsWith("plugin-blacklist.Isabelle-jEdit")) |
|
49 |
if (props1 != props2) File.write(properties, cat_lines(props2)) |
|
50 |
} |
|
51 |
||
61277 | 52 |
Isabelle_System.mkdirs(settings_dir + Path.explode("DockableWindowManager")) |
53 |
||
54 |
if (!(settings_dir + Path.explode("perspective.xml")).is_file) { |
|
55 |
File.write(settings_dir + Path.explode("DockableWindowManager/perspective-view0.xml"), |
|
69770
efb0e5332441
clarified default layout: global overview left, local document information right;
wenzelm
parents:
69644
diff
changeset
|
56 |
"""<DOCKING LEFT="isabelle-documentation" TOP="" RIGHT="isabelle-theories" BOTTOM="" LEFT_POS="250" TOP_POS="0" RIGHT_POS="250" BOTTOM_POS="250" />""") |
61277 | 57 |
File.write(settings_dir + Path.explode("perspective.xml"), |
58 |
"""<?xml version="1.0" encoding="UTF-8" ?> |
|
59 |
<!DOCTYPE PERSPECTIVE SYSTEM "perspective.dtd"> |
|
60 |
<PERSPECTIVE> |
|
61 |
<VIEW PLAIN="FALSE"> |
|
69771 | 62 |
<GEOMETRY X="0" Y="35" WIDTH="1200" HEIGHT="850" EXT_STATE="0" /> |
61277 | 63 |
</VIEW> |
64 |
</PERSPECTIVE>""") |
|
65 |
} |
|
66 |
||
67 |
||
68 |
/* args */ |
|
69 |
||
62036 | 70 |
val jedit_settings = |
71 |
"-settings=" + File.platform_path(Path.explode("$JEDIT_SETTINGS")) |
|
72 |
||
73 |
val jedit_server = |
|
74 |
System.getProperty("isabelle.jedit_server") match { |
|
75 |
case null | "" => "-noserver" |
|
76 |
case name => "-server=" + name |
|
77 |
} |
|
78 |
||
61277 | 79 |
val jedit_options = |
80 |
Isabelle_System.getenv_strict("JEDIT_OPTIONS").split(" +") |
|
81 |
||
82 |
val more_args = |
|
61512
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
83 |
{ |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
84 |
args.toList.dropWhile(arg => arg.startsWith("-") && arg != "--") match { |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
85 |
case Nil | List("--") => |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
86 |
args ++ Array(File.platform_path(Path.explode("$USER_HOME/Scratch.thy"))) |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
87 |
case List(":") => args.slice(0, args.size - 1) |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
88 |
case _ => args |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
89 |
} |
933463440449
more uniform command-line for "isabelle jedit" and the isabelle.Main app wrapper;
wenzelm
parents:
61307
diff
changeset
|
90 |
} |
61277 | 91 |
|
92 |
||
69188
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
93 |
/* environment */ |
61277 | 94 |
|
69188
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
95 |
def putenv(name: String, value: String) |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
96 |
{ |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
97 |
val misc = |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
98 |
Class.forName("org.gjt.sp.jedit.MiscUtilities", true, ClassLoader.getSystemClassLoader) |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
99 |
val putenv = misc.getMethod("putenv", classOf[String], classOf[String]) |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
100 |
putenv.invoke(null, name, value) |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
101 |
} |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
102 |
|
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
103 |
for (name <- List("ISABELLE_HOME", "ISABELLE_HOME_USER", "JEDIT_HOME", "JEDIT_SETTINGS")) { |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
104 |
putenv(name, File.platform_path(Isabelle_System.getenv(name))) |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
105 |
} |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
106 |
putenv("ISABELLE_ROOT", null) |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
107 |
|
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
108 |
|
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
109 |
/* properties */ |
61277 | 110 |
|
111 |
System.setProperty("jedit.home", File.platform_path(Path.explode("$JEDIT_HOME/dist"))) |
|
112 |
System.setProperty("scala.home", File.platform_path(Path.explode("$SCALA_HOME"))) |
|
65875
12c90c0c4b32
suppress ANSI control sequences in Scala console;
wenzelm
parents:
63749
diff
changeset
|
113 |
System.setProperty("scala.color", "false") |
61277 | 114 |
|
69188
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
115 |
|
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
116 |
/* main startup */ |
2fd73a1a0937
updated to jedit_build-20181025 according to patches/macos (Java 11), patches/putenv;
wenzelm
parents:
66577
diff
changeset
|
117 |
|
61277 | 118 |
val jedit = |
119 |
Class.forName("org.gjt.sp.jedit.jEdit", true, ClassLoader.getSystemClassLoader) |
|
120 |
val jedit_main = jedit.getMethod("main", classOf[Array[String]]) |
|
121 |
||
62036 | 122 |
() => jedit_main.invoke( |
123 |
null, Array(jedit_settings, jedit_server) ++ jedit_options ++ more_args) |
|
61277 | 124 |
} |
61282 | 125 |
catch { |
126 |
case exn: Throwable => |
|
127 |
GUI.init_laf() |
|
128 |
GUI.dialog(null, "Isabelle", GUI.scrollable_text(Exn.message(exn))) |
|
129 |
sys.exit(2) |
|
130 |
} |
|
61277 | 131 |
} |
61282 | 132 |
start() |
53445
811db2b751ed
warm start of Isabelle/jEdit from Isabelle/Scala;
wenzelm
parents:
53423
diff
changeset
|
133 |
} |
47663
20e0865ae9e7
default Isabelle application wrapper -- JVM entry point for Isabelle.exe;
wenzelm
parents:
diff
changeset
|
134 |
} |