v0.8.0: TUI simplification — process-key-event, with-frame, inline reader
Replace queue-based key dispatch with process-key-event (inline in reader, zero latency between keypress and render). Add with-frame to cl-tty.backend (error-safe begin-sync/end-sync wrapper). Use with-frame in redraw instead of manual begin-sync/end-sync. Add initial render before main loop (UI appears before first read-event). Remove position-cursor (replaced by inline block cursor in view-input). Remove input-string/input-insert-char/input-delete-char wrappers. Remove :input-buffer/:cursor-pos from state (managed by text-input widget). passepartout script: set *debugger-hook* nil and failure-behaviour :warn before quickload to survive compile warnings; remove cache-clear line.
This commit is contained in:
@@ -20,10 +20,9 @@ All state mutation flows through event handlers in the controller.
|
||||
#+BEGIN_SRC lisp :tangle /home/user/.local/share/passepartout/lisp/channel-tui-state.lisp
|
||||
(defpackage :passepartout.channel-tui
|
||||
(:use :cl :passepartout :usocket :bordeaux-threads)
|
||||
(:export :tui-main :st :add-msg :now :input-string
|
||||
(:export :tui-main :st :add-msg :now
|
||||
:queue-event :drain-queue :init-state
|
||||
:view-status :view-chat :view-input :redraw
|
||||
:position-cursor
|
||||
:input-panel-top
|
||||
:on-key :on-daemon-msg :send-daemon
|
||||
:connect-daemon :disconnect-daemon
|
||||
@@ -310,11 +309,10 @@ Adds any missing keys with defaults to handle saved themes from older versions."
|
||||
(defun init-state ()
|
||||
(setf *state*
|
||||
(list :running t :mode :chat :connected nil :stream nil
|
||||
:input-buffer nil :input-history nil :input-hpos 0
|
||||
:input-history nil :input-hpos 0
|
||||
:text-input (cl-tty.input:make-text-input)
|
||||
:messages (make-array 16 :adjustable t :fill-pointer 0)
|
||||
:scroll-offset 0 :busy nil :cursor-pos 0
|
||||
:cursor-line 0 :cursor-col 0
|
||||
:scroll-offset 0 :busy nil
|
||||
:pending-ctrl-x nil
|
||||
:scroll-at-bottom t :scroll-notify nil
|
||||
:streaming-text nil :url-buffer nil ; v0.7.1
|
||||
@@ -342,15 +340,6 @@ Adds any missing keys with defaults to handle saved themes from older versions."
|
||||
(declare (ignore s))
|
||||
(format nil "~2,'0d:~2,'0d" h m)))
|
||||
|
||||
(defun input-string ()
|
||||
(cl-tty.input:text-input-value (st :text-input)))
|
||||
|
||||
(defun input-insert-char (ch)
|
||||
(cl-tty.input:text-input-insert (st :text-input) ch))
|
||||
|
||||
(defun input-delete-char ()
|
||||
(cl-tty.input:text-input-backspace (st :text-input)))
|
||||
|
||||
(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))
|
||||
;; v0.7.0: notify when scrolled up and new msg arrives
|
||||
|
||||
Reference in New Issue
Block a user