Admin/MacOS/App1/script
author wenzelm
Sun, 11 Sep 2011 19:52:09 +0200
changeset 44880 9fb612890ad9
parent 41644 a6c45c8d52fc
child 44881 ca2f585d1ebe
permissions -rw-r--r--
explicit choice of interface;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     1
#!/bin/bash
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     2
#
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     4
#
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     5
# Isabelle application wrapper
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     6
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     7
THIS="$(cd "$(dirname "$0")"; pwd)"
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
     8
THIS_APP="$(cd "$THIS/../.."; pwd)"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
     9
SUPER_APP="$(cd "$THIS/../../.."; pwd)"
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    10
29173
c14c9a41f1ac PATH: /opt/local/bin is back again (required for latex etc.);
wenzelm
parents: 29149
diff changeset
    11
c14c9a41f1ac PATH: /opt/local/bin is back again (required for latex etc.);
wenzelm
parents: 29149
diff changeset
    12
# sane environment defaults
41643
10b0d338d99e default UTF-8 locale, to work with funny base directory (e.g. Chinese);
wenzelm
parents: 41642
diff changeset
    13
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    14
cd "$HOME"
29173
c14c9a41f1ac PATH: /opt/local/bin is back again (required for latex etc.);
wenzelm
parents: 29149
diff changeset
    15
PATH="$PATH:/opt/local/bin"
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    16
41643
10b0d338d99e default UTF-8 locale, to work with funny base directory (e.g. Chinese);
wenzelm
parents: 41642
diff changeset
    17
[ -z "$LANG" ] && export LANG=en_US.UTF-8
10b0d338d99e default UTF-8 locale, to work with funny base directory (e.g. Chinese);
wenzelm
parents: 41642
diff changeset
    18
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    19
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    20
# settings support
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    21
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    22
function choosefrom ()
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    23
{
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    24
  local RESULT=""
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    25
  local FILE=""
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    26
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    27
  for FILE in "$@"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    28
  do
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    29
    [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    30
  done
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    31
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    32
  [ -z "$RESULT" ] && RESULT="$FILE"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    33
  echo "$RESULT"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    34
}
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    35
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    36
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    37
# Isabelle
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    38
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    39
ISABELLE_TOOL="$(choosefrom \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    40
  "$THIS/Isabelle/bin/isabelle" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    41
  "$SUPER_APP/Isabelle/bin/isabelle" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    42
  "$HOME/bin/isabelle" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    43
  isabelle)"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    44
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    45
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    46
# Proof General / Emacs
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    47
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    48
PROOFGENERAL_EMACS="$(choosefrom \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    49
  "$THIS/Emacs.app/Contents/MacOS/Emacs" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    50
  "$SUPER_APP/Emacs.app/Contents/MacOS/Emacs" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    51
  /Applications/Emacs.app/Contents/MacOS/Emacs \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    52
  "")"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    53
33912
a5e6e849a0d8 allow spaces within PROOFGENERAL_EMACS;
wenzelm
parents: 31924
diff changeset
    54
declare -a EMACS_OPTIONS=()
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    55
if [ -n "$PROOFGENERAL_EMACS" ]; then
33912
a5e6e849a0d8 allow spaces within PROOFGENERAL_EMACS;
wenzelm
parents: 31924
diff changeset
    56
  EMACS_OPTIONS=(-p "$PROOFGENERAL_EMACS")
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    57
fi
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    58
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    59
41642
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    60
# enforce fonts
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    61
41644
a6c45c8d52fc enforce STIXGeneral, which is preferred by PG 4.1;
wenzelm
parents: 41643
diff changeset
    62
if [ ! -f "$HOME/Library/Fonts/STIXGeneral.ttf" -a ! -f "$HOME/Library/Fonts/STIXGeneral.otf" ]
41642
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    63
then
41644
a6c45c8d52fc enforce STIXGeneral, which is preferred by PG 4.1;
wenzelm
parents: 41643
diff changeset
    64
  cp -f "$THIS/STIXv1.0.0/Fonts"/STIXGeneral* "$HOME/Library/Fonts/"
41642
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    65
  sleep 3
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    66
fi
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    67
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    68
EMACS_OPTIONS["${#EMACS_OPTIONS[@]}"]="-x"
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    69
EMACS_OPTIONS["${#EMACS_OPTIONS[@]}"]="true"
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    70
b9442d9ce7f5 enforce fonts;
wenzelm
parents: 41610
diff changeset
    71
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    72
# run interface with error feedback
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    73
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    74
OUTPUT="/tmp/isabelle$$.out"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    75
44880
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    76
declare -a CHOICE
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    77
CHOICE=($("$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" dropdown \
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    78
  --title Isabelle \
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    79
  --text "Which Isabelle interface?" \
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    80
  --items "Emacs / Proof General" "Isabelle/jEdit PIDE" \
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    81
  --button1 "OK"))
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    82
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    83
if [ "${CHOICE[1]}" = 0 ]; then
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    84
  ( "$ISABELLE_TOOL" emacs "${EMACS_OPTIONS[@]}" "$@" ) > "$OUTPUT" 2>&1
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    85
  RC=$?
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    86
else
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    87
  ( "$ISABELLE_TOOL" jedit "$@" ) > "$OUTPUT" 2>&1
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    88
  RC=$?
9fb612890ad9 explicit choice of interface;
wenzelm
parents: 41644
diff changeset
    89
fi
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    90
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    91
if [ "$RC" != 0 ]; then
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    92
  echo >> "$OUTPUT"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    93
  echo "Return code: $RC" >> "$OUTPUT"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    94
fi
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    95
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    96
if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    97
  "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    98
    --title "Isabelle" \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    99
    --informative-text "Isabelle output" \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   100
    --text-from-file "$OUTPUT" \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   101
    --button1 "OK"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   102
fi
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   103
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   104
rm -f "$OUTPUT"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   105
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
   106
exit "$RC"