diff --git a/org/channel-tui-state.org b/org/channel-tui-state.org index 5642452..1cdb9a6 100644 --- a/org/channel-tui-state.org +++ b/org/channel-tui-state.org @@ -312,7 +312,8 @@ Adds any missing keys with defaults to handle saved themes from older versions." (list :running t :mode :chat :connected nil :stream nil :input-buffer nil :input-history nil :input-hpos 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 :pending-ctrl-x nil :scroll-at-bottom t :scroll-notify nil :streaming-text nil :url-buffer nil ; v0.7.1 diff --git a/org/channel-tui-view.org b/org/channel-tui-view.org index 1b0cd36..cede7ab 100644 --- a/org/channel-tui-view.org +++ b/org/channel-tui-view.org @@ -219,7 +219,7 @@ and current sidebar mode (:auto/:visible/:hidden)." (dotimes (r panel-rows) (cl-tty.backend:draw-text fb hpad (+ panel-top r) "│" (theme-color :input-prompt) nil)) ;; Draw each wrapped input line - (let ((accum 0) (cursor-line 0) (cursor-col 0)) + (let ((accum 0) (cl 0) (cc 0)) (dotimes (i n-lines) (let* ((line (nth i lines)) (row (+ panel-top 1 i)) @@ -227,9 +227,9 @@ and current sidebar mode (:auto/:visible/:hidden)." (when (>= row (- h 4)) (return)) (cl-tty.backend:draw-text fb (+ hpad 2) row line input-fg nil) (when (and (>= pos accum) (<= pos (+ accum len))) - (setf cursor-line i - cursor-col (- pos accum))) + (setf cl i cc (- pos accum))) (incf accum (1+ len)))) + (setf (st :cursor-line) cl (st :cursor-col) cc)) ;; Hint bar at h-2: F:/MCP: on left, token gauge + keybindings on right (let* ((focal (or (st :foveal-id) "-")) (focal-str (format nil "F:~a" focal)) @@ -351,13 +351,19 @@ and current sidebar mode (:auto/:visible/:hidden)." (let* ((sw (if (sidebar-visible-p w) (or (st :sidebar-width) 42) 0)) (cw (- w sw)) (hpad 2) + (chat-w (- w sw)) (text (input-string)) (text-len (length text)) (pos (or (st :cursor-pos) 0)) (prompt-w (- cw (* 2 hpad) 2)) - (display-start (max 0 (- pos (1- prompt-w)))) - (cx (+ hpad 2 (- pos display-start))) - (cy (- h 6)) + (cl (or (st :cursor-line) 0)) + (cc (or (st :cursor-col) 0)) + (lines (cl-tty.box:word-wrap text prompt-w)) + (n-lines (max 1 (length lines))) + (panel-rows (max 4 (+ n-lines 2))) + (panel-top (- h 4 panel-rows -1)) + (cx (+ hpad 2 cc)) + (cy (+ panel-top 1 cl)) (bg-i (theme-color :bg-input)) (input-fg (theme-color :input-fg))) (if (< pos text-len)