src/Tools/jEdit/dist-template/lib/Tools/jedit
author wenzelm
Fri, 01 Oct 2010 15:11:15 +0200
changeset 39815 37bdc2220cf8
parent 39739 c7f0fa0593f0
child 40155 0b57e3d9bc62
permissions -rwxr-xr-x
tuned default "Prover Session" perspective;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     2
#
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     3
# Author: Makarius
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     4
#
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     5
# DESCRIPTION: Isabelle/jEdit interface wrapper
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     6
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     7
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     8
## diagnostics
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     9
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    10
PRG="$(basename "$0")"
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    11
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    12
usage()
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    13
{
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    14
  echo
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    15
  echo "Usage: isabelle $PRG [OPTIONS] [FILES ...]"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    16
  echo
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    17
  echo "  Options are:"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    18
  echo "    -J OPTION    add JVM runtime option"
34409
e61e2ab1f6f7 proper spelling of JEDIT_JAVA_OPTIONS;
wenzelm
parents: 34339
diff changeset
    19
  echo "                 (default JEDIT_JAVA_OPTIONS=$JEDIT_JAVA_OPTIONS)"
34691
f28c014bcbe3 option -d: enable debugger;
wenzelm
parents: 34664
diff changeset
    20
  echo "    -d           enable debugger"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    21
  echo "    -j OPTION    add jEdit runtime option"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    22
  echo "                 (default JEDIT_OPTIONS=$JEDIT_OPTIONS)"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    23
  echo "    -l NAME      logic image name (default ISABELLE_LOGIC=$ISABELLE_LOGIC)"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    24
  echo "    -m MODE      add print mode for output"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    25
  echo
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    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
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    28
  echo
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    29
  exit 1
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    30
}
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    31
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    32
fail()
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    33
{
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    34
  echo "$1" >&2
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    35
  exit 2
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    36
}
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    37
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    38
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    39
## process command line
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    40
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    41
# options
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    42
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    43
JEDIT_LOGIC="$ISABELLE_LOGIC"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    44
JEDIT_PRINT_MODE=""
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    45
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    46
getoptions()
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    47
{
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    48
  OPTIND=1
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    49
  while getopts "J:dj:l:m:" OPT
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    50
  do
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    51
    case "$OPT" in
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    52
      J)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    53
        JAVA_ARGS["${#JAVA_ARGS[@]}"]="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    54
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    55
      d)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    56
        JAVA_ARGS["${#JAVA_ARGS[@]}"]="-Xdebug"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    57
        JAVA_ARGS["${#JAVA_ARGS[@]}"]="-Xrunjdwp:transport=dt_socket,server=y,suspend=n"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    58
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    59
      j)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    60
        ARGS["${#ARGS[@]}"]="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    61
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    62
      l)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    63
        JEDIT_LOGIC="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    64
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    65
      m)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    66
        if [ -z "$JEDIT_PRINT_MODE" ]; then
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    67
          JEDIT_PRINT_MODE="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    68
        else
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    69
          JEDIT_PRINT_MODE="$JEDIT_PRINT_MODE,$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    70
        fi
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    71
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    72
      \?)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    73
        usage
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    74
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    75
    esac
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    76
  done
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    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
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    82
declare -a ARGS; eval "ARGS=($JEDIT_OPTIONS)"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    83
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    84
declare -a OPTIONS; eval "OPTIONS=($ISABELLE_JEDIT_OPTIONS)"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    85
getoptions "${OPTIONS[@]}"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    86
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    87
getoptions "$@"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    88
shift $(($OPTIND - 1))
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    89
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    90
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    91
# args
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    92
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    93
if [ "$#" -eq 0 ]; then
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    94
  ARGS["${#ARGS[@]}"]="Scratch.thy"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    95
else
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    96
  while [ "$#" -gt 0 ]; do
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
    97
    ARGS["${#ARGS[@]}"]="$(jvmpath "$1")"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    98
    shift
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    99
  done
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   100
fi
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   101
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   102
34880
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   103
## default perspective
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   104
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   105
mkdir -p "$JEDIT_SETTINGS/DockableWindowManager"
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   106
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   107
if [ ! -e "$JEDIT_SETTINGS/perspective.xml" ]; then
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   108
  cat > "$JEDIT_SETTINGS/DockableWindowManager/perspective-view0.xml" <<EOF
39815
37bdc2220cf8 tuned default "Prover Session" perspective;
wenzelm
parents: 39739
diff changeset
   109
<DOCKING LEFT="" TOP="" RIGHT="isabelle-session" BOTTOM="" LEFT_POS="0" TOP_POS="0" RIGHT_POS="250" BOTTOM_POS="250" />
34880
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   110
EOF
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   111
  cat > "$JEDIT_SETTINGS/perspective.xml" <<EOF
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   112
<?xml version="1.0" encoding="UTF-8" ?>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   113
<!DOCTYPE PERSPECTIVE SYSTEM "perspective.dtd">
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   114
<PERSPECTIVE>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   115
<VIEW PLAIN="FALSE">
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   116
<GEOMETRY X="0" Y="35" WIDTH="1072" HEIGHT="787" EXT_STATE="0" />
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   117
</VIEW>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   118
</PERSPECTIVE>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   119
EOF
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   120
fi
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   121
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   122
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   123
## main
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   124
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   125
case "$JEDIT_LOGIC" in
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   126
  /*)
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   127
    ;;
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   128
  */*)
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   129
    JEDIT_LOGIC="$(pwd -P)/$JEDIT_LOGIC"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   130
    ;;
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   131
esac
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   132
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   133
export JEDIT_LOGIC JEDIT_PRINT_MODE
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   134
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   135
exec "$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" \
34339
8c70469bc83a added jvmpath conversion for Cygwin;
wenzelm
parents: 34336
diff changeset
   136
  -jar "$(jvmpath "$JEDIT_HOME/jedit.jar")" \
34880
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   137
  "-settings=$(jvmpath "$JEDIT_SETTINGS")" "${ARGS[@]}"