docs: sync .org with implementation for backend-size, read-raw-byte, SIGWINCH
backend-protocol.org / simple.lisp: - Replace hard-coded 80x24 prose with full 5-step fallback chain (MY_TERM env vars → ioctl fd 0 → ioctl stdout → /dev/tty → 80x24) - Document return-from pattern (or discards secondary values) modern-backend.org / modern.lisp: - Replace simple ioctl-only prose with 4-step fallback chain - Document env-var pre-check and /dev/tty fallback text-input.org / input.lisp: - Update read-raw-byte prose: with-pinned-objects/vector-sap instead of alien buffer (code was already correct, prose stale) - Add missing (require :sb-posix) to SIGWINCH handler code block - Document :sb-posix requirement in prose
This commit is contained in:
@@ -434,9 +434,11 @@ The ~timeout~ keyword uses ~sb-unix:unix-simple-poll~ to implement
|
||||
non-blocking reads with a configurable deadline. This is critical for
|
||||
the 50ms escape sequence ambiguity resolution in ~%read-escape-sequence~.
|
||||
|
||||
Memory management: we allocate a 1-byte alien buffer, read into it, then
|
||||
~free-alien~ in an ~unwind-protect~ to prevent leaks even if the read
|
||||
is interrupted by a signal.
|
||||
Memory management: we use ~sb-sys:with-pinned-objects~ to pin a 1-byte
|
||||
~make-array~ vector in memory, obtain its SAP via ~sb-sys:vector-sap~,
|
||||
and read directly into the backing storage. This avoids alien allocation
|
||||
and manual ~free-alien~ while keeping the GC from moving the buffer
|
||||
during the ~unix-read~ syscall.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/input.lisp
|
||||
(defun read-raw-byte (&key timeout)
|
||||
@@ -744,7 +746,8 @@ connection. The 500ms gives the terminal ample time to deliver all bytes.
|
||||
When the terminal emulator window is resized, the kernel sends SIGWINCH
|
||||
to the foreground process group. SBCL's signal handling facility
|
||||
(~sb-sys:enable-interrupt~) lets us install a handler that sets this
|
||||
flag.
|
||||
flag. The ~:sb-posix~ module must be ~require~d first so that the
|
||||
~sb-posix:sigwinch~ constant is available.
|
||||
|
||||
The main event loop should check this flag after each ~%read-event~
|
||||
call and, if set, query the new terminal dimensions and redraw. The
|
||||
@@ -758,6 +761,7 @@ after handling the resize.
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/input.lisp
|
||||
#+sbcl
|
||||
(eval-when (:load-toplevel :execute)
|
||||
(require :sb-posix)
|
||||
(sb-sys:enable-interrupt sb-posix:sigwinch
|
||||
(lambda (signal info context)
|
||||
(declare (ignore signal info context))
|
||||
|
||||
Reference in New Issue
Block a user