fix: wrap CSI terminal query in with-timeout 0.3s
The blocking read-char in %query-terminal-size could hang if the terminal doesn't respond to CSI 18 t. Wrapped in sb-ext:with-timeout 0.3 to abort if no response.
This commit is contained in:
@@ -9,15 +9,14 @@ Returns (values cols rows) or nil."
|
|||||||
:fill-pointer 0 :adjustable t)))
|
:fill-pointer 0 :adjustable t)))
|
||||||
(format t "~C[18t" #\Esc)
|
(format t "~C[18t" #\Esc)
|
||||||
(force-output)
|
(force-output)
|
||||||
;; Blocking read-char loop — the response arrives immediately
|
(handler-case
|
||||||
(loop with deadline = (+ (get-internal-real-time)
|
(sb-ext:with-timeout 0.3
|
||||||
(* internal-time-units-per-second 0.5))
|
(loop do (let ((ch (read-char saved nil nil)))
|
||||||
while (< (get-internal-real-time) deadline)
|
(when ch
|
||||||
do (let ((ch (read-char saved nil nil)))
|
(vector-push-extend ch response)
|
||||||
(when ch
|
(when (char= ch #\t) (return))))))
|
||||||
(vector-push-extend ch response)
|
(sb-ext:timeout ()))
|
||||||
(when (char= ch #\t) (return)))))
|
(when (>= (length response) 5)
|
||||||
(when (>= (length response) 8)
|
|
||||||
(let* ((str (subseq response 1))
|
(let* ((str (subseq response 1))
|
||||||
(start (or (position #\[ str) 0))
|
(start (or (position #\[ str) 0))
|
||||||
(after (subseq str (1+ start)))
|
(after (subseq str (1+ start)))
|
||||||
|
|||||||
Reference in New Issue
Block a user