1
0
mirror of synced 2026-01-13 23:47:27 +00:00
Interlisp.medley/run-medley
Nick Briggs 14415e197f
Fix run-medley -dimensions processing to make sensible choices (#217)
Given a "-dimension WxH" argument, round up the W to a multiple of 32 for the
Lisp window width and use an X window geometry with an additional
22 pixels for both W and H to account for the current scrollbar size so that
the resulting X window will not require scrolling.
2021-02-28 01:59:06 +00:00

168 lines
4.4 KiB
Bash
Executable File

#!/bin/sh
# Run Medley
#
# Syntax: run-medley [--dimensions WIDTHxHEIGHT] \ sets both -g -sc
# [-g WIDTHxHEIGHT] \
# [-sc WIDTHxHEIGHT] \
# [--display X_DISPLAY] \
# [--vmem | --vmfile FILE] \
# [--nogreet | --greet FILE] \
# [URL_OR_FILE]
# Directory variables are accessible from Lisp via UNIX-GETENV
# LDESRCESYSOUT SYSOUT full-file name you want to run
# LDEDESTSYSOUT name for destination of SaveVM/LOGOUT
# MEDLEYDIR used by init file to set other path variables
inferred_medleydir=false
if [ -z "$MEDLEYDIR" ] ; then
export MEDLEYDIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
inferred_medleydir=true
fi
if [ ! -d "$MEDLEYDIR/loadups" ] ; then
echo "MEDLEYDIR has no loadups: $MEDLEYDIR"
if [ inferred_medleydir = true ] ; then
echo "I tried to infer it based on your working directory, but that didn't work."
echo "Try cd there or setting the MEDLEYDIR environment variable to its location."
fi
exit 1
fi
# set defaults, overridden if suppplied explicitly
prog="lde"
passthrough_args=""
if [ -z "$LDEDESTSYSOUT" ] ; then
if [ -z "$LOGINDIR" ] ; then
export LDEDESTSYSOUT="${HOME}/lisp.virtualmem"
else
export LDEDESTSYSOUT="${LOGINDIR}/lisp.virtualmem"
fi
fi
if [ -z "$LDEINIT" ] ; then
export LDEINIT="$MEDLEYDIR/greetfiles/SIMPLE-INIT"
fi
export LDEKBDTYPE=x
while [ "$#" -ne 0 ]; do
case "$1" in
"-nogreet" | "--nogreet")
export LDEINIT=""
;;
"-greet" | "--greet")
export LDEINIT="$2"
shift
;;
"--dimensions" | "-dimensions")
sw=`expr "$2" : "\([0-9]*\)x[0-9]*$"`
sh=`expr "$2" : "[0-9]*x\([0-9]*\)$"`
if [ -n "$sw" -a -n "$sh" ] ; then
sw=$(( (31+$sw)/32*32 ))
gw=$(( 22+$sw ))
gh=$(( 22+$sh ))
geometry="-g ${gw}x${gh}"
screensize="-sc ${sw}x${sh}"
fi
shift
;;
"--geometry" | "-geometry" | "-g")
geometry="-g $2"
shift
;;
"--screensize" | "-screensize" | "-sc")
screensize="-sc $2"
shift
;;
"--display" | "-d")
export DISPLAY="$2"
shift
;;
"-vmem" | "--vmem" | "-vmfile" )
export LDEDESTSYSOUT="$2"
shift
;;
"-full")
export LDESRCESYSOUT="$MEDLEYDIR/loadups/xfull35.sysout"
;;
"-lisp")
export LDESRCESYSOUT="$MEDLEYDIR/loadups/xlisp.sysout"
;;
"-*")
passthrough_args="$passthrough_args $1 $2"
echo passing through unrecognized option: "$1" "$2"
shift
;;
*)
export LDESRCESYSOUT="$1"
;;
esac
shift
done
# not set on command line
if [ -z "$LDESRCESYSOUT" ] ; then
if [ -f "$LDEDESTSYSOUT" ] ; then
export LDESRCESYSOUT="$LDEDESTSYSOUT"
else
export LDESRCESYSOUT="$MEDLEYDIR/loadups/xfull35.sysout"
fi
fi
if [ -z "$geometry" ] ; then
# maiko guesses wrong
geometry="-g 1440x900"
screensize="-sc 1440x900"
fi
case "$LDESRCSYSOUT" in
"http:*" | "https:*")
echo URL not supported yet
exit 1
esac
inferred_maikodir=false
if [ -z "$MAIKODIR" ] ; then
# here we try two options relative to MEDLEYDIR: ./maiko and ../maiko
# this is highly imperfect, but the user can always set the env variables
export MAIKODIR="$MEDLEYDIR/../maiko"
if [ ! -d "$MAIKODIR" ] ; then
export MAIKODIR="$MEDLEYDIR/maiko"
fi
inferred_maikodir=true
fi
if [ ! -d "$MAIKODIR/bin" ] ; then
echo "MAIKODIR has no bin: $MAIKODIR"
if [ inferred_maikodir = true ] ; then
echo "I tried to infer it based on your working directory, but that didn't work."
echo "Try setting the MAIKODIR environment variable to the right location."
fi
exit 1
fi
oldpath="$PATH"
export PATH=.:"$PATH"
cd "$MAIKODIR"/bin
export PATH="$MAIKODIR"/`osversion`.`machinetype`:"$oldpath"
cd "$OLDPWD"
echo "sysout is $LDESRCESYSOUT"
echo "running `which $prog` $geometry $screensize"
echo "start $LDEINIT"
export INMEDLEY=1
$prog $geometry $screensize -t "Medley Interlisp" $passthrough_args "$LDESRCESYSOUT"