From 4594d40a9cad7e943acf5f371548a13a3575919c Mon Sep 17 00:00:00 2001 From: Hermes Date: Tue, 12 May 2026 01:30:09 +0000 Subject: [PATCH] Fix termios-cc API for SBCL 2.5.x, demo exits cleanly if raw mode fails make-raw-termios (input.lisp:66-67): termios-cc accessor in SBCL 2.5.x takes one arg (the struct) and returns the cc array. Use (aref ...) to set individual control characters. Old code used 3-arg setf form that no longer works and produced style warnings. demo.lisp: Now exits with a clear error message when raw mode can't be established, rather than running in broken pipe-safe mode where escape sequences are echoed and input is line-buffered. --- demo.lisp | 5 ++++- src/components/input.lisp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/demo.lisp b/demo.lisp index bc61f90..d7eb880 100644 --- a/demo.lisp +++ b/demo.lisp @@ -126,7 +126,10 @@ (defun run-demo () (let ((saved (ignore-errors (set-raw-mode)))) (unless saved - (format *error-output* "Failed to set raw mode, trying pipe-safe mode~%")) + (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 (init-app-state) diff --git a/src/components/input.lisp b/src/components/input.lisp index eae07e8..6f3c0db 100644 --- a/src/components/input.lisp +++ b/src/components/input.lisp @@ -63,8 +63,9 @@ (clear-flag (sb-posix:termios-lflag termios) (logior sb-posix:icanon sb-posix:echo sb-posix:isig sb-posix:iexten))) - (setf (sb-posix:termios-cc termios sb-posix:vmin) 1) - (setf (sb-posix:termios-cc termios sb-posix:vtime) 0) + (let ((cc-array (sb-posix:termios-cc termios))) + (setf (aref cc-array sb-posix:vmin) 1) + (setf (aref cc-array sb-posix:vtime) 0)) termios)) (defun set-raw-mode ()