From eede03ee3f6e5685cb5c75173dcc3d85e521ee89 Mon Sep 17 00:00:00 2001 From: Hermes Date: Tue, 12 May 2026 01:49:48 +0000 Subject: [PATCH] =?UTF-8?q?Add=20demo.sh=20=E2=80=94=20shell=20wrapper=20f?= =?UTF-8?q?or=20raw=20terminal=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Raw terminal mode must be set by the parent process (the shell), not from inside SBCL. sb-ext:run-program subprocesses cannot reliably access the controlling terminal for stty operations. ./demo.sh sets raw mode via stty, runs sbcl --script demo.lisp, and restores terminal state on exit (EXIT, INT, TERM). demo.lisp no longer calls with-raw-terminal — it assumes the calling shell has already set raw mode. --- demo | 20 -------------------- demo.lisp | 10 ++-------- demo.sh | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 28 deletions(-) delete mode 100755 demo create mode 100755 demo.sh diff --git a/demo b/demo deleted file mode 100755 index 0e2542e..0000000 --- a/demo +++ /dev/null @@ -1,20 +0,0 @@ -#!/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" diff --git a/demo.lisp b/demo.lisp index fdb1d5c..3c90460 100644 --- a/demo.lisp +++ b/demo.lisp @@ -1,9 +1,5 @@ ;;; demo.lisp — cl-tty interactive demo ;;; Run: sbcl --script demo.lisp -;;; -;;; Demonstrates: backend detection, raw terminal mode, key/mouse input, -;;; layout engine, component rendering pipeline, framebuffer diff flush, -;;; text-input, textarea, select, dialog, scrollbox, tabbar. ;; Load cl-tty directly via ASDF (no Quicklisp dependency needed — ;; sb-posix is built into SBCL, no external libraries required). @@ -124,10 +120,8 @@ t))) (defun run-demo () - "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" + "Run the demo. Raw terminal mode should already be set by the +./demo.sh shell wrapper." (init-app-state) (let* ((backend (detect-backend)) (w 80) (h 24)) diff --git a/demo.sh b/demo.sh new file mode 100755 index 0000000..9d51d93 --- /dev/null +++ b/demo.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# cl-tty demo launcher +# Sets raw terminal mode before starting SBCL, restores on exit. +# Raw mode is needed so individual keystrokes are captured instead +# of being line-buffered and echoed by the terminal driver. + +SAVED=$(stty -g 2>/dev/null) +if [ -z "$SAVED" ]; then + echo "ERROR: Not running in a real terminal." >&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"