fix: query-terminal stream, enable-mouse/bracketed-paste methods, simple-backend draw-ellipsis position
This commit is contained in:
@@ -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)))
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -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 "..."))
|
||||
|
||||
Reference in New Issue
Block a user