author | wenzelm |
Tue, 16 Nov 2010 15:23:26 +0100 | |
changeset 40565 | 40cefa372680 |
parent 40155 | 0b57e3d9bc62 |
child 40574 | 226563829580 |
permissions | -rwxr-xr-x |
34333 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
34664 | 3 |
# Author: Makarius |
4 |
# |
|
5 |
# DESCRIPTION: Isabelle/jEdit interface wrapper |
|
6 |
||
34333 | 7 |
|
8 |
## diagnostics |
|
9 |
||
34664 | 10 |
PRG="$(basename "$0")" |
11 |
||
34333 | 12 |
usage() |
13 |
{ |
|
14 |
echo |
|
34664 | 15 |
echo "Usage: isabelle $PRG [OPTIONS] [FILES ...]" |
34333 | 16 |
echo |
17 |
echo " Options are:" |
|
18 |
echo " -J OPTION add JVM runtime option" |
|
34409 | 19 |
echo " (default JEDIT_JAVA_OPTIONS=$JEDIT_JAVA_OPTIONS)" |
34691 | 20 |
echo " -d enable debugger" |
34333 | 21 |
echo " -j OPTION add jEdit runtime option" |
22 |
echo " (default JEDIT_OPTIONS=$JEDIT_OPTIONS)" |
|
23 |
echo " -l NAME logic image name (default ISABELLE_LOGIC=$ISABELLE_LOGIC)" |
|
24 |
echo " -m MODE add print mode for output" |
|
25 |
echo |
|
34664 | 26 |
echo "Start jEdit with Isabelle plugin setup and opens theory FILES" |
34336
c9a96ddfceab
explicit home path for default file -- more robust;
wenzelm
parents:
34335
diff
changeset
|
27 |
echo "(default ~/Scratch.thy)." |
34333 | 28 |
echo |
29 |
exit 1 |
|
30 |
} |
|
31 |
||
32 |
fail() |
|
33 |
{ |
|
34 |
echo "$1" >&2 |
|
35 |
exit 2 |
|
36 |
} |
|
37 |
||
38 |
||
39 |
## process command line |
|
40 |
||
41 |
# options |
|
42 |
||
43 |
JEDIT_LOGIC="$ISABELLE_LOGIC" |
|
44 |
JEDIT_PRINT_MODE="" |
|
45 |
||
34780 | 46 |
getoptions() |
47 |
{ |
|
48 |
OPTIND=1 |
|
49 |
while getopts "J:dj:l:m:" OPT |
|
50 |
do |
|
51 |
case "$OPT" in |
|
52 |
J) |
|
53 |
JAVA_ARGS["${#JAVA_ARGS[@]}"]="$OPTARG" |
|
54 |
;; |
|
55 |
d) |
|
56 |
JAVA_ARGS["${#JAVA_ARGS[@]}"]="-Xdebug" |
|
57 |
JAVA_ARGS["${#JAVA_ARGS[@]}"]="-Xrunjdwp:transport=dt_socket,server=y,suspend=n" |
|
58 |
;; |
|
59 |
j) |
|
60 |
ARGS["${#ARGS[@]}"]="$OPTARG" |
|
61 |
;; |
|
62 |
l) |
|
63 |
JEDIT_LOGIC="$OPTARG" |
|
64 |
;; |
|
65 |
m) |
|
66 |
if [ -z "$JEDIT_PRINT_MODE" ]; then |
|
67 |
JEDIT_PRINT_MODE="$OPTARG" |
|
68 |
else |
|
69 |
JEDIT_PRINT_MODE="$JEDIT_PRINT_MODE,$OPTARG" |
|
70 |
fi |
|
71 |
;; |
|
72 |
\?) |
|
73 |
usage |
|
74 |
;; |
|
75 |
esac |
|
76 |
done |
|
77 |
} |
|
34581
abab3a577e10
slightly more robust treatment of options via arrays;
wenzelm
parents:
34412
diff
changeset
|
78 |
|
38257
f0fd14a9c11f
clarified JEDIT_JAVA_OPTIONS vs. JEDIT_SYSTEM_OPTIONS -- discontinued JEDIT_APPLE_PROPERTIES;
wenzelm
parents:
34881
diff
changeset
|
79 |
declare -a JAVA_ARGS; eval "JAVA_ARGS=($JEDIT_JAVA_OPTIONS $JEDIT_SYSTEM_OPTIONS)" |
34843
eb8806a2e348
define scala.home, for more robust startup of Scala tools, notably the compiler;
wenzelm
parents:
34790
diff
changeset
|
80 |
[ -n "$SCALA_HOME" ] && JAVA_ARGS["${#JAVA_ARGS[@]}"]="-Dscala.home=$SCALA_HOME" |
eb8806a2e348
define scala.home, for more robust startup of Scala tools, notably the compiler;
wenzelm
parents:
34790
diff
changeset
|
81 |
|
40565
40cefa372680
more reasonably defaults for typical laptops (2 GB RAM, 2 cores);
wenzelm
parents:
40155
diff
changeset
|
82 |
"$ISABELLE_TOOL" java -server >/dev/null 2>/dev/null && \ |
40cefa372680
more reasonably defaults for typical laptops (2 GB RAM, 2 cores);
wenzelm
parents:
40155
diff
changeset
|
83 |
JAVA_ARGS["${#JAVA_ARGS[@]}"]="-server" |
40cefa372680
more reasonably defaults for typical laptops (2 GB RAM, 2 cores);
wenzelm
parents:
40155
diff
changeset
|
84 |
|
34780 | 85 |
declare -a ARGS; eval "ARGS=($JEDIT_OPTIONS)" |
34333 | 86 |
|
34780 | 87 |
declare -a OPTIONS; eval "OPTIONS=($ISABELLE_JEDIT_OPTIONS)" |
88 |
getoptions "${OPTIONS[@]}" |
|
89 |
||
90 |
getoptions "$@" |
|
34333 | 91 |
shift $(($OPTIND - 1)) |
92 |
||
93 |
||
94 |
# args |
|
95 |
||
96 |
if [ "$#" -eq 0 ]; then |
|
34780 | 97 |
ARGS["${#ARGS[@]}"]="Scratch.thy" |
34333 | 98 |
else |
99 |
while [ "$#" -gt 0 ]; do |
|
34780 | 100 |
ARGS["${#ARGS[@]}"]="$(jvmpath "$1")" |
34333 | 101 |
shift |
102 |
done |
|
103 |
fi |
|
104 |
||
105 |
||
34880 | 106 |
## default perspective |
107 |
||
108 |
mkdir -p "$JEDIT_SETTINGS/DockableWindowManager" |
|
109 |
||
110 |
if [ ! -e "$JEDIT_SETTINGS/perspective.xml" ]; then |
|
111 |
cat > "$JEDIT_SETTINGS/DockableWindowManager/perspective-view0.xml" <<EOF |
|
40155
0b57e3d9bc62
dock isabelle-session at bottom (again, cf. 37bdc2220cf8) to ensure that controls are fully visible;
wenzelm
parents:
39815
diff
changeset
|
112 |
<DOCKING LEFT="" TOP="" RIGHT="" BOTTOM="isabelle-session" LEFT_POS="0" TOP_POS="0" RIGHT_POS="250" BOTTOM_POS="250" /> |
34880 | 113 |
EOF |
114 |
cat > "$JEDIT_SETTINGS/perspective.xml" <<EOF |
|
115 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
116 |
<!DOCTYPE PERSPECTIVE SYSTEM "perspective.dtd"> |
|
117 |
<PERSPECTIVE> |
|
118 |
<VIEW PLAIN="FALSE"> |
|
119 |
<GEOMETRY X="0" Y="35" WIDTH="1072" HEIGHT="787" EXT_STATE="0" /> |
|
120 |
</VIEW> |
|
121 |
</PERSPECTIVE> |
|
122 |
EOF |
|
123 |
fi |
|
124 |
||
125 |
||
34333 | 126 |
## main |
127 |
||
128 |
case "$JEDIT_LOGIC" in |
|
129 |
/*) |
|
130 |
;; |
|
131 |
*/*) |
|
132 |
JEDIT_LOGIC="$(pwd -P)/$JEDIT_LOGIC" |
|
133 |
;; |
|
134 |
esac |
|
135 |
||
136 |
export JEDIT_LOGIC JEDIT_PRINT_MODE |
|
137 |
||
34780 | 138 |
exec "$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" \ |
34339 | 139 |
-jar "$(jvmpath "$JEDIT_HOME/jedit.jar")" \ |
34880 | 140 |
"-settings=$(jvmpath "$JEDIT_SETTINGS")" "${ARGS[@]}" |