cleanup — remove dead markdown code, migrate theme to cl-tty, fix dialog navigation
Phases 1-3 of library/application boundary cleanup: Phase 1: Remove dead code (150 lines) - Delete local word-wrap (all callers already used cl-tty.box:word-wrap) - Delete parse-markdown-spans, render-styled, parse-markdown-blocks, syntax-highlight (all unused — view uses cl-tty.markdown directly) - Replace tests with cl-tty.markdown equivalents Phase 2: Migrate theme to cl-tty.theme (250 lines removed) - Replace *tui-theme*/*tui-theme-presets* with *theme* + define-preset - theme-switch/theme-save/theme-load delegate to cl-tty.theme - theme-color is now a 3-line wrapper - Added save-theme/load-theme to cl-tty.theme (38 lines added there) Phase 3: Fix dialog arrow navigation with select-handle-key - Replace broken manual key dispatch with cl-tty.dialog:select-handle-key - The old code had a dead (and ch (graphic-char-p ch)) — the and result was discarded, so every unhandled key ran (code-char key-code) against the filter unconditionally, inserting garbage on arrow keys
This commit is contained in:
@@ -373,12 +373,11 @@ Event handlers + daemon I/O + main loop.
|
||||
(add-msg :system "Ctrl+G Toggle gate trace"))
|
||||
;; /theme command
|
||||
((string-equal text "/theme")
|
||||
(add-msg :system (format nil "Theme: ~a — user-fg=~a agent-fg=~a system=~a input-fg=~a"
|
||||
*tui-theme-current-name*
|
||||
(getf *tui-theme* :user-fg)
|
||||
(getf *tui-theme* :agent-fg)
|
||||
(getf *tui-theme* :system)
|
||||
(getf *tui-theme* :input-fg)))
|
||||
(add-msg :system (format nil "Theme — user-fg=~a agent-fg=~a system=~a input-fg=~a"
|
||||
(theme-color :user-fg)
|
||||
(theme-color :agent-fg)
|
||||
(theme-color :system)
|
||||
(theme-color :input-fg)))
|
||||
(add-msg :system "Presets: /theme amber | gold | terracotta | sepia | nord-warm | monokai-warm | gruvbox-warm | light-amber | catppuccin | tokyonight | dracula | gemini | mono"))
|
||||
((and (>= (length text) 7)
|
||||
(string-equal (subseq text 0 7) "/theme "))
|
||||
@@ -765,37 +764,26 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
|
||||
((st :dialog-stack)
|
||||
(let* ((dlg (car (st :dialog-stack)))
|
||||
(sel (cl-tty.dialog:dialog-content dlg)))
|
||||
(cond
|
||||
((eq k :escape)
|
||||
(pop (st :dialog-stack))
|
||||
(setf (st :dirty) (list t t nil)))
|
||||
((member k '(:up :down))
|
||||
(if (eq k :up)
|
||||
(cl-tty.dialog:select-prev sel)
|
||||
(cl-tty.dialog:select-next sel))
|
||||
(setf (st :dirty) (list t t nil)))
|
||||
((eq k :enter)
|
||||
(let* ((filtered (cl-tty.dialog:select-filtered-options sel))
|
||||
(idx (cl-tty.dialog:select-selected-index sel))
|
||||
(item (when (< idx (length filtered))
|
||||
(third (nth idx filtered)))))
|
||||
(when item
|
||||
(let ((cb (cl-tty.dialog:select-on-select sel)))
|
||||
(when cb (funcall cb item))))
|
||||
(pop (st :dialog-stack))
|
||||
(setf (st :dirty) (list t t nil))))
|
||||
((let ((ch (code-char (cl-tty.input:key-event-code event))))
|
||||
(and ch (graphic-char-p ch))
|
||||
(setf (cl-tty.dialog:select-filter sel)
|
||||
(concatenate 'string
|
||||
(or (cl-tty.dialog:select-filter sel) "")
|
||||
(string ch)))))
|
||||
((eq k :backspace)
|
||||
(let* ((f (cl-tty.dialog:select-filter sel))
|
||||
(len (length (or f ""))))
|
||||
(when (> len 0)
|
||||
(setf (cl-tty.dialog:select-filter sel)
|
||||
(subseq f 0 (1- len)))))))))
|
||||
(if (cl-tty.dialog:select-handle-key sel event)
|
||||
;; select-handle-key handled nav or enter + fired callback
|
||||
(when (eql k :enter)
|
||||
(pop (st :dialog-stack)))
|
||||
;; not handled: escape, char input, backspace
|
||||
(cond
|
||||
((eql k :escape)
|
||||
(pop (st :dialog-stack)))
|
||||
((let ((ch (code-char (cl-tty.input:key-event-code event))))
|
||||
(and ch (graphic-char-p ch)
|
||||
(setf (cl-tty.dialog:select-filter sel)
|
||||
(concatenate 'string
|
||||
(or (cl-tty.dialog:select-filter sel) "")
|
||||
(string ch))))))
|
||||
((eql k :backspace)
|
||||
(let ((f (cl-tty.dialog:select-filter sel)))
|
||||
(when (> (length (or f "")) 0)
|
||||
(setf (cl-tty.dialog:select-filter sel)
|
||||
(subseq f 0 (1- (length f)))))))))
|
||||
(setf (st :dirty) (list t t nil))))
|
||||
((cl-tty.input:dispatch-key-event event)
|
||||
(setf (st :dirty) (list t t nil)))
|
||||
((member k '(:enter :tab :escape :up :down))
|
||||
@@ -1273,11 +1261,11 @@ Returns T on success, nil on failure. Does NOT wait or retry."
|
||||
(fiveam:is (eq nil (st :busy))))
|
||||
|
||||
(fiveam:test test-theme
|
||||
"Contract view: *tui-theme* provides color mappings."
|
||||
(fiveam:is (string= "#fab283" (getf *tui-theme* :user-fg)))
|
||||
(fiveam:is (string= "#e8e8e8" (getf *tui-theme* :agent-fg)))
|
||||
(fiveam:is (string= "#808080" (getf *tui-theme* :system)))
|
||||
(fiveam:is (string= "#e8e8e8" (getf *tui-theme* :input-fg)))
|
||||
"Contract view: *theme* provides color mappings via theme-color."
|
||||
(fiveam:is (string= "#fab283" (theme-color :user-fg)))
|
||||
(fiveam:is (string= "#e8e8e8" (theme-color :agent-fg)))
|
||||
(fiveam:is (string= "#808080" (theme-color :system)))
|
||||
(fiveam:is (string= "#e8e8e8" (theme-color :input-fg)))
|
||||
(fiveam:is (string= "#FFFFFF" (theme-color :unknown-role))))
|
||||
|
||||
(fiveam:test test-on-key-ctrl-u-clears
|
||||
|
||||
Reference in New Issue
Block a user