added isabelle jedit_client;
authorwenzelm
Mon Sep 14 16:06:32 2015 +0200 (2015-09-14)
changeset 61170dee0aec271b7
parent 61169 4de9ff3ea29a
child 61171 2a56a53d78f9
added isabelle jedit_client;
NEWS
src/Tools/jEdit/lib/Tools/jedit_client
     1.1 --- a/NEWS	Sun Sep 13 22:56:52 2015 +0200
     1.2 +++ b/NEWS	Mon Sep 14 16:06:32 2015 +0200
     1.3 @@ -21,6 +21,10 @@
     1.4  At least one Debugger view needs to be active to have any effect on the
     1.5  running ML program.
     1.6  
     1.7 +* Command-line tool "isabelle jedit_client" allows to connect to already
     1.8 +running Isabelle/jEdit process. This achieves the effect of
     1.9 +single-instance applications seen on common GUI desktops.
    1.10 +
    1.11  
    1.12  *** Isar ***
    1.13  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/Tools/jEdit/lib/Tools/jedit_client	Mon Sep 14 16:06:32 2015 +0200
     2.3 @@ -0,0 +1,115 @@
     2.4 +#!/usr/bin/env bash
     2.5 +#
     2.6 +# Author: Makarius
     2.7 +#
     2.8 +# DESCRIPTION: Isabelle/jEdit client for already running application
     2.9 +
    2.10 +## settings
    2.11 +
    2.12 +SERVER_NAME="${ISABELLE_IDENTIFIER:-Isabelle}"
    2.13 +
    2.14 +case "$ISABELLE_JAVA_PLATFORM" in
    2.15 +  x86_64-*)
    2.16 +    JEDIT_JAVA_OPTIONS="$JEDIT_JAVA_OPTIONS64"
    2.17 +    ;;
    2.18 +  *)
    2.19 +    JEDIT_JAVA_OPTIONS="$JEDIT_JAVA_OPTIONS32"
    2.20 +    ;;
    2.21 +esac
    2.22 +
    2.23 +declare -a JAVA_ARGS; eval "JAVA_ARGS=($JEDIT_JAVA_SYSTEM_OPTIONS $JEDIT_JAVA_OPTIONS)"
    2.24 +
    2.25 +
    2.26 +## diagnostics
    2.27 +
    2.28 +PRG="$(basename "$0")"
    2.29 +
    2.30 +function usage()
    2.31 +{
    2.32 +  echo
    2.33 +  echo "Usage: isabelle $PRG [OPTIONS] [FILES ...]"
    2.34 +  echo
    2.35 +  echo "  Options are:"
    2.36 +  echo "    -c           only check presence of server"
    2.37 +  echo "    -n           only report server name"
    2.38 +  echo "    -s NAME      server name (default $SERVER_NAME)"
    2.39 +  echo
    2.40 +  echo "  Connect to already running Isabelle/jEdit instance and open FILES"
    2.41 +  echo
    2.42 +  exit 1
    2.43 +}
    2.44 +
    2.45 +function fail()
    2.46 +{
    2.47 +  echo "$1" >&2
    2.48 +  exit 2
    2.49 +}
    2.50 +
    2.51 +function failed()
    2.52 +{
    2.53 +  fail "Failed!"
    2.54 +}
    2.55 +
    2.56 +
    2.57 +## process command line
    2.58 +
    2.59 +# options
    2.60 +
    2.61 +CHECK_ONLY="false"
    2.62 +NAME_ONLY="false"
    2.63 +
    2.64 +while getopts "cns:" OPT
    2.65 +do
    2.66 +  case "$OPT" in
    2.67 +    c)
    2.68 +      CHECK_ONLY="true"
    2.69 +      ;;
    2.70 +    n)
    2.71 +      NAME_ONLY="true"
    2.72 +      ;;
    2.73 +    s)
    2.74 +      SERVER_NAME="$OPTARG"
    2.75 +      ;;
    2.76 +    \?)
    2.77 +      usage
    2.78 +      ;;
    2.79 +  esac
    2.80 +done
    2.81 +
    2.82 +shift $(($OPTIND - 1))
    2.83 +
    2.84 +
    2.85 +# args
    2.86 +
    2.87 +declare -a ARGS=()
    2.88 +
    2.89 +while [ "$#" -gt 0 ]
    2.90 +do
    2.91 +  ARGS["${#ARGS[@]}"]="$(jvmpath "$1")"
    2.92 +  shift
    2.93 +done
    2.94 +
    2.95 +
    2.96 +## main
    2.97 +
    2.98 +if [ "$CHECK_ONLY" = true ]
    2.99 +then
   2.100 +  [ -f "$JEDIT_SETTINGS/$SERVER_NAME" ]
   2.101 +  exit $?
   2.102 +fi
   2.103 +
   2.104 +if [ "$NAME_ONLY" = true ]
   2.105 +then
   2.106 +  echo "$SERVER_NAME"
   2.107 +  exit
   2.108 +fi
   2.109 +
   2.110 +"$ISABELLE_TOOL" jedit -b || exit $?
   2.111 +
   2.112 +if [ -f "$JEDIT_SETTINGS/$SERVER_NAME" ]
   2.113 +then
   2.114 +  exec "$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" -jar "$JEDIT_HOME/dist/jedit.jar" \
   2.115 +    "-settings=$(jvmpath "$JEDIT_SETTINGS")" -server="$SERVER_NAME" -reuseview "${ARGS[@]}"
   2.116 +else
   2.117 +  fail "Isabelle/jEdit server \"$SERVER_NAME\" not active"
   2.118 +fi