v0.8.0: integrate cl-tty text-input widget for buffer management
This commit is contained in:
@@ -311,6 +311,7 @@ Adds any missing keys with defaults to handle saved themes from older versions."
|
|||||||
(setf *state*
|
(setf *state*
|
||||||
(list :running t :mode :chat :connected nil :stream nil
|
(list :running t :mode :chat :connected nil :stream nil
|
||||||
:input-buffer nil :input-history nil :input-hpos 0
|
:input-buffer nil :input-history nil :input-hpos 0
|
||||||
|
:text-input (cl-tty.input:make-text-input)
|
||||||
:messages (make-array 16 :adjustable t :fill-pointer 0)
|
:messages (make-array 16 :adjustable t :fill-pointer 0)
|
||||||
:scroll-offset 0 :busy nil :cursor-pos 0
|
:scroll-offset 0 :busy nil :cursor-pos 0
|
||||||
:cursor-line 0 :cursor-col 0
|
:cursor-line 0 :cursor-col 0
|
||||||
@@ -342,26 +343,13 @@ Adds any missing keys with defaults to handle saved themes from older versions."
|
|||||||
(format nil "~2,'0d:~2,'0d" h m)))
|
(format nil "~2,'0d:~2,'0d" h m)))
|
||||||
|
|
||||||
(defun input-string ()
|
(defun input-string ()
|
||||||
(coerce (reverse (st :input-buffer)) 'string))
|
(cl-tty.input:text-input-value (st :text-input)))
|
||||||
|
|
||||||
(defun input-insert-char (ch)
|
(defun input-insert-char (ch)
|
||||||
"Insert character at cursor position into the input buffer."
|
(cl-tty.input::text-input-insert (st :text-input) ch))
|
||||||
(let* ((buf (st :input-buffer))
|
|
||||||
(pos (or (st :cursor-pos) 0))
|
|
||||||
(s (coerce (reverse buf) 'string))
|
|
||||||
(new (concatenate 'string (subseq s 0 pos) (string ch) (subseq s pos))))
|
|
||||||
(setf (st :input-buffer) (reverse (coerce new 'list)))
|
|
||||||
(setf (st :cursor-pos) (1+ pos))))
|
|
||||||
|
|
||||||
(defun input-delete-char ()
|
(defun input-delete-char ()
|
||||||
"Delete character before cursor position (standard backspace)."
|
(cl-tty.input::text-input-backspace (st :text-input)))
|
||||||
(let* ((buf (st :input-buffer))
|
|
||||||
(pos (or (st :cursor-pos) 0)))
|
|
||||||
(when (and buf (> pos 0))
|
|
||||||
(let* ((s (coerce (reverse buf) 'string))
|
|
||||||
(new (concatenate 'string (subseq s 0 (1- pos)) (subseq s pos))))
|
|
||||||
(setf (st :input-buffer) (reverse (coerce new 'list)))
|
|
||||||
(setf (st :cursor-pos) (1- pos))))))
|
|
||||||
|
|
||||||
(defun add-msg (role content &key gate-trace panel)
|
(defun add-msg (role content &key gate-trace panel)
|
||||||
(vector-push-extend (list :role role :content content :time (now) :gate-trace gate-trace :panel panel) (st :messages))
|
(vector-push-extend (list :role role :content content :time (now) :gate-trace gate-trace :panel panel) (st :messages))
|
||||||
|
|||||||
Reference in New Issue
Block a user