v0.15.0: Critical input/rendering fixes, subagent-reviewed #7
20
demo
Executable file
20
demo
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# cl-tty demo launcher
|
||||
# Sets raw terminal mode, runs the demo, restores terminal on exit.
|
||||
# This is needed because SBCL's --script mode + run-program combo
|
||||
# can't reliably set raw mode from inside the Lisp process.
|
||||
|
||||
SAVED=$(stty -g 2>/dev/null)
|
||||
if [ -z "$SAVED" ]; then
|
||||
echo "ERROR: Not running in a real terminal." >&2
|
||||
echo " Try: sbcl --script demo.lisp" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup() {
|
||||
stty "$SAVED" 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
stty raw -echo -isig -icanon min 1 time 0 2>/dev/null
|
||||
sbcl --script "$(dirname "$0")/demo.lisp"
|
||||
15
demo.lisp
15
demo.lisp
@@ -124,17 +124,14 @@
|
||||
t)))
|
||||
|
||||
(defun run-demo ()
|
||||
(let ((saved (ignore-errors (set-raw-mode))))
|
||||
(unless saved
|
||||
(format *error-output* "~&ERROR: Cannot set terminal to raw mode.~%")
|
||||
(format *error-output* " Make sure you are in a real terminal (not a pipe/redirect).~%")
|
||||
(format *error-output* " Try: sbcl --script demo.lisp~%")
|
||||
(return-from run-demo))
|
||||
(unwind-protect
|
||||
(progn
|
||||
"Run the demo. Assumes raw terminal mode is already set by the
|
||||
shell wrapper (./demo) or by running:
|
||||
stty raw -echo -isig -icanon min 1 time 0
|
||||
sbcl --script demo.lisp"
|
||||
(init-app-state)
|
||||
(let* ((backend (detect-backend))
|
||||
(w 80) (h 24))
|
||||
(declare (ignore h))
|
||||
(initialize-backend backend)
|
||||
(unwind-protect
|
||||
(loop while (getf *app* :running)
|
||||
@@ -176,8 +173,6 @@
|
||||
(when event
|
||||
(handle-event event))))
|
||||
(shutdown-backend backend))))
|
||||
(when saved
|
||||
(restore-terminal-state saved)))))
|
||||
|
||||
(run-demo)
|
||||
(uiop:quit 0)
|
||||
|
||||
Reference in New Issue
Block a user