From 80abb231971d0d06622994f1bbd6eb94c8805c3b Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 12 May 2026 13:53:38 +0000 Subject: [PATCH] fix: query-terminal stream, enable-mouse/bracketed-paste methods, simple-backend draw-ellipsis position --- backend/detection.lisp | 8 ++++---- backend/modern.lisp | 10 ++++++++++ backend/simple.lisp | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/backend/detection.lisp b/backend/detection.lisp index d858350..2ece52a 100644 --- a/backend/detection.lisp +++ b/backend/detection.lisp @@ -28,13 +28,13 @@ Returns T if stdout is interactive, nil otherwise." (defun query-terminal (query &optional (timeout 0.1)) "Send QUERY string to terminal and return any response received within TIMEOUT seconds. Returns the response string, or nil if no response." - (write-string query *query-io*) - (force-output *query-io*) + (write-string query *standard-output*) + (force-output *standard-output*) (sleep timeout) (let ((response (make-array 0 :element-type 'character :fill-pointer 0 :adjustable t))) - (loop while (listen *query-io*) - do (vector-push-extend (read-char-no-hang *query-io*) response)) + (loop while (listen *standard-input*) + do (vector-push-extend (read-char-no-hang *standard-input*) response)) (when (plusp (length response)) response))) diff --git a/backend/modern.lisp b/backend/modern.lisp index 1cf7bc1..63d1091 100644 --- a/backend/modern.lisp +++ b/backend/modern.lisp @@ -289,6 +289,16 @@ as a fallback when a keyword is not in *named-colors*.") (defmethod cursor-style ((b modern-backend) shape &key 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)) (setf (in-sync-p b) t) (backend-write b (decicm-begin))) diff --git a/backend/simple.lisp b/backend/simple.lisp index b9b3a87..daafb5a 100644 --- a/backend/simple.lisp +++ b/backend/simple.lisp @@ -101,5 +101,8 @@ POS is :top-left, :top-right, :bottom-left, :bottom-right, (defmethod draw-ellipsis ((b simple-backend) x y width &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 "..."))