author | wenzelm |
Tue, 12 Jan 2010 16:51:51 +0100 | |
changeset 34880 | f88fc4fcab86 |
parent 34843 | eb8806a2e348 |
child 34881 | d5b901fc63e7 |
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 |
|
34790
643c48774b17
actually use JEDIT_JAVA_OPTIONS from settings, not ..._ARGS;
wenzelm
parents:
34780
diff
changeset
|
79 |
declare -a JAVA_ARGS; eval "JAVA_ARGS=($JEDIT_JAVA_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 |
|
34780 | 82 |
declare -a ARGS; eval "ARGS=($JEDIT_OPTIONS)" |
34333 | 83 |
|
34780 | 84 |
declare -a OPTIONS; eval "OPTIONS=($ISABELLE_JEDIT_OPTIONS)" |
85 |
getoptions "${OPTIONS[@]}" |
|
86 |
||
87 |
getoptions "$@" |
|
34333 | 88 |
shift $(($OPTIND - 1)) |
89 |
||
90 |
||
91 |
# args |
|
92 |
||
93 |
if [ "$#" -eq 0 ]; then |
|
34780 | 94 |
ARGS["${#ARGS[@]}"]="Scratch.thy" |
34333 | 95 |
else |
96 |
while [ "$#" -gt 0 ]; do |
|
34780 | 97 |
ARGS["${#ARGS[@]}"]="$(jvmpath "$1")" |
34333 | 98 |
shift |
99 |
done |
|
100 |
fi |
|
101 |
||
102 |
||
34880 | 103 |
## default perspective |
104 |
||
105 |
mkdir -p "$JEDIT_SETTINGS/DockableWindowManager" |
|
106 |
||
107 |
if [ ! -e "$JEDIT_SETTINGS/perspective.xml" ]; then |
|
108 |
cat > "$JEDIT_SETTINGS/DockableWindowManager/perspective-view0.xml" <<EOF |
|
109 |
<DOCKING LEFT="" TOP="" RIGHT="" BOTTOM="" LEFT_POS="0" TOP_POS="0" RIGHT_POS="172" BOTTOM_POS="183" /> |
|
110 |
EOF |
|
111 |
cat > "$JEDIT_SETTINGS/perspective.xml" <<EOF |
|
112 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
113 |
<!DOCTYPE PERSPECTIVE SYSTEM "perspective.dtd"> |
|
114 |
<PERSPECTIVE> |
|
115 |
<VIEW PLAIN="FALSE"> |
|
116 |
<GEOMETRY X="0" Y="35" WIDTH="1072" HEIGHT="787" EXT_STATE="0" /> |
|
117 |
</VIEW> |
|
118 |
</PERSPECTIVE> |
|
119 |
EOF |
|
120 |
fi |
|
121 |
||
122 |
||
34333 | 123 |
## main |
124 |
||
125 |
case "$JEDIT_LOGIC" in |
|
126 |
/*) |
|
127 |
;; |
|
128 |
*/*) |
|
129 |
JEDIT_LOGIC="$(pwd -P)/$JEDIT_LOGIC" |
|
130 |
;; |
|
131 |
esac |
|
132 |
||
133 |
export JEDIT_LOGIC JEDIT_PRINT_MODE |
|
134 |
||
34780 | 135 |
exec "$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" \ |
34339 | 136 |
-jar "$(jvmpath "$JEDIT_HOME/jedit.jar")" \ |
34880 | 137 |
"-settings=$(jvmpath "$JEDIT_SETTINGS")" "${ARGS[@]}" |