1 #!/usr/bin/env bash |
|
2 # |
|
3 # Author: Makarius |
|
4 # |
|
5 # Isabelle application wrapper |
|
6 |
|
7 THIS="$(cd "$(dirname "$0")"; pwd)" |
|
8 THIS_APP="$(cd "$THIS/../.."; pwd)" |
|
9 SUPER_APP="$(cd "$THIS/../../.."; pwd)" |
|
10 |
|
11 |
|
12 # global defaults |
|
13 |
|
14 ISABELLE_TOOL="$THIS/Isabelle/bin/isabelle" |
|
15 PROOFGENERAL_EMACS="$THIS/Aquamacs.app/Contents/MacOS/Aquamacs" |
|
16 |
|
17 |
|
18 # environment |
|
19 |
|
20 cd "$HOME" |
|
21 if [ -x /usr/libexec/path_helper ]; then |
|
22 eval $(/usr/libexec/path_helper -s) |
|
23 fi |
|
24 |
|
25 [ -z "$LANG" ] && export LANG=en_US.UTF-8 |
|
26 |
|
27 |
|
28 # run interface with error feedback |
|
29 |
|
30 ISABELLE_INTERFACE_CHOICE="$("$ISABELLE_TOOL" getenv -b ISABELLE_INTERFACE_CHOICE)" |
|
31 if [ "$ISABELLE_INTERFACE_CHOICE" != emacs -a "$ISABELLE_INTERFACE_CHOICE" != jedit ] |
|
32 then |
|
33 declare -a CHOICE |
|
34 CHOICE=($("$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" dropdown \ |
|
35 --title Isabelle \ |
|
36 --text "Which Isabelle interface?" \ |
|
37 --items "Isabelle/jEdit PIDE" "Emacs / Proof General" \ |
|
38 --button2 "OK, do not ask again" --button1 "OK")) |
|
39 if [ "${CHOICE[1]}" = 0 ]; then |
|
40 ISABELLE_INTERFACE_CHOICE=jedit |
|
41 else |
|
42 ISABELLE_INTERFACE_CHOICE=emacs |
|
43 fi |
|
44 if [ "${CHOICE[0]}" = 2 ]; then |
|
45 ISABELLE_HOME_USER="$("$ISABELLE_TOOL" getenv -b ISABELLE_HOME_USER)" |
|
46 mkdir -p "$ISABELLE_HOME_USER/etc" |
|
47 ( echo; echo "ISABELLE_INTERFACE_CHOICE=$ISABELLE_INTERFACE_CHOICE"; ) \ |
|
48 >> "$ISABELLE_HOME_USER/etc/settings" |
|
49 "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" ok-msgbox \ |
|
50 --title Isabelle \ |
|
51 --text Note \ |
|
52 --informative-text "ISABELLE_INTERFACE_CHOICE stored in $ISABELLE_HOME_USER/etc/settings" \ |
|
53 --no-cancel |
|
54 fi |
|
55 fi |
|
56 |
|
57 OUTPUT="/tmp/isabelle$$.out" |
|
58 |
|
59 if [ "$ISABELLE_INTERFACE_CHOICE" = emacs ]; then |
|
60 ( "$ISABELLE_TOOL" emacs -p "$PROOFGENERAL_EMACS" "$@" ) > "$OUTPUT" 2>&1 |
|
61 RC=$? |
|
62 else |
|
63 ( "$ISABELLE_TOOL" jedit -s "$@" ) > "$OUTPUT" 2>&1 |
|
64 RC=$? |
|
65 fi |
|
66 |
|
67 if [ "$RC" != 0 ]; then |
|
68 echo >> "$OUTPUT" |
|
69 echo "Return code: $RC" >> "$OUTPUT" |
|
70 fi |
|
71 |
|
72 if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then |
|
73 "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \ |
|
74 --title "Isabelle" \ |
|
75 --informative-text "Isabelle output" \ |
|
76 --text-from-file "$OUTPUT" \ |
|
77 --button1 "OK" |
|
78 fi |
|
79 |
|
80 rm -f "$OUTPUT" |
|
81 |
|
82 exit "$RC" |
|