fix: query-terminal stream, enable-mouse/bracketed-paste methods, simple-backend draw-ellipsis position

This commit is contained in:
Hermes Agent
2026-05-12 13:53:38 +00:00
parent e198e8b5da
commit 80abb23197
3 changed files with 18 additions and 5 deletions

View File

@@ -28,13 +28,13 @@ Returns T if stdout is interactive, nil otherwise."
(defun query-terminal (query &optional (timeout 0.1)) (defun query-terminal (query &optional (timeout 0.1))
"Send QUERY string to terminal and return any response received within "Send QUERY string to terminal and return any response received within
TIMEOUT seconds. Returns the response string, or nil if no response." TIMEOUT seconds. Returns the response string, or nil if no response."
(write-string query *query-io*) (write-string query *standard-output*)
(force-output *query-io*) (force-output *standard-output*)
(sleep timeout) (sleep timeout)
(let ((response (make-array 0 :element-type 'character (let ((response (make-array 0 :element-type 'character
:fill-pointer 0 :adjustable t))) :fill-pointer 0 :adjustable t)))
(loop while (listen *query-io*) (loop while (listen *standard-input*)
do (vector-push-extend (read-char-no-hang *query-io*) response)) do (vector-push-extend (read-char-no-hang *standard-input*) response))
(when (plusp (length response)) (when (plusp (length response))
response))) response)))

View File

@@ -289,6 +289,16 @@ as a fallback when a keyword is not in *named-colors*.")
(defmethod cursor-style ((b modern-backend) shape &key blink) (defmethod cursor-style ((b modern-backend) shape &key blink)
(backend-write b (cursor-style-escape shape blink))) (backend-write b (cursor-style-escape shape blink)))
(defmethod enable-mouse ((b modern-backend))
(backend-write b (format nil "~C[?1000h" #\Esc)) ; basic
(backend-write b (format nil "~C[?1002h" #\Esc)) ; drag
(backend-write b (format nil "~C[?1006h" #\Esc)) ; SGR
(finish-output (backend-output-stream b)))
(defmethod enable-bracketed-paste ((b modern-backend))
(backend-write b (format nil "~C[?2004h" #\Esc)) ; bracketed paste
(finish-output (backend-output-stream b)))
(defmethod begin-sync ((b modern-backend)) (defmethod begin-sync ((b modern-backend))
(setf (in-sync-p b) t) (setf (in-sync-p b) t)
(backend-write b (decicm-begin))) (backend-write b (decicm-begin)))

View File

@@ -101,5 +101,8 @@ POS is :top-left, :top-right, :bottom-left, :bottom-right,
(defmethod draw-ellipsis ((b simple-backend) x y width (defmethod draw-ellipsis ((b simple-backend) x y width
&key fg bg) &key fg bg)
(declare (ignore x y width fg bg)) (declare (ignore width fg bg))
;; Position using newlines+spaces (simple-backend pattern)
(dotimes (row y) (backend-write b (string #\Newline)))
(backend-write b (make-string x :initial-element #\Space))
(backend-write b "...")) (backend-write b "..."))