fix: Reader error loop from (= nil 27), Swank *standard-output* redirect
- Remove 'code' variable binding (redundant with b). esc-seq now starts with (and b (= b 27) ...) so when b is nil (timeout), the and short-circuits before (= b 27) can error with 'NIL is not of the type NUMBER'. - Swank prints to *standard-output*, not *error-output*. Bind both to string output streams to prevent ';; Swank started' leak.
This commit is contained in:
@@ -968,8 +968,7 @@ Returns T on success, nil on failure. Does NOT wait or retry."
|
|||||||
;; Keyboard reader via read-raw-byte (proven CSI detection)
|
;; Keyboard reader via read-raw-byte (proven CSI detection)
|
||||||
(handler-case
|
(handler-case
|
||||||
(let* ((b (cl-tty.input::read-raw-byte :timeout 0.1))
|
(let* ((b (cl-tty.input::read-raw-byte :timeout 0.1))
|
||||||
(code b)
|
(esc-seq (and b (= b 27)
|
||||||
(esc-seq (and (= code 27)
|
|
||||||
(let ((b2 (cl-tty.input::read-raw-byte :timeout 0.15)))
|
(let ((b2 (cl-tty.input::read-raw-byte :timeout 0.15)))
|
||||||
(when (and b2 (= b2 91))
|
(when (and b2 (= b2 91))
|
||||||
(let ((t2 (cl-tty.input::read-raw-byte :timeout 0.15)))
|
(let ((t2 (cl-tty.input::read-raw-byte :timeout 0.15)))
|
||||||
@@ -981,21 +980,21 @@ Returns T on success, nil on failure. Does NOT wait or retry."
|
|||||||
(when b
|
(when b
|
||||||
(queue-event
|
(queue-event
|
||||||
(list :type :key
|
(list :type :key
|
||||||
:payload (list :code (or code 0)
|
:payload (list :code b
|
||||||
:ch (or esc-seq
|
:ch (or esc-seq
|
||||||
(cond
|
(cond
|
||||||
((= code 13) :enter)
|
((= b 13) :enter)
|
||||||
((= code 10) :enter)
|
((= b 10) :enter)
|
||||||
((= code 27) :escape)
|
((= b 27) :escape)
|
||||||
((= code 9) :tab)
|
((= b 9) :tab)
|
||||||
((or (= code 127) (= code 8)) :backspace)
|
((or (= b 127) (= b 8)) :backspace)
|
||||||
((and (>= code 1) (<= code 26))
|
((and (>= b 1) (<= b 26))
|
||||||
(intern
|
(intern
|
||||||
(string-upcase
|
(string-upcase
|
||||||
(format nil "CTRL-~a"
|
(format nil "CTRL-~a"
|
||||||
(code-char (+ #x60 code))))
|
(code-char (+ #x60 b))))
|
||||||
:keyword))
|
:keyword))
|
||||||
(t code))))))))
|
(t b))))))))
|
||||||
(error (c)
|
(error (c)
|
||||||
(add-msg :system (format nil "* Reader error: ~a *" c))))
|
(add-msg :system (format nil "* Reader error: ~a *" c))))
|
||||||
;; Check for terminal resize (SIGWINCH sets this flag)
|
;; Check for terminal resize (SIGWINCH sets this flag)
|
||||||
|
|||||||
Reference in New Issue
Block a user