fix: restore :key event handler with Ctrl+P/B/Q/L and dialog routing
The key event dispatch was lost during git restores, causing all :key events (Ctrl+P, Ctrl+B, Enter, etc.) to fall through to on-key which only handles :enter, :escape, and character insertion. Added back the case ch with :CTRL-Q/:CTRL-P/:CTRL-B/:CTRL-L branches and full dialog key routing.
This commit is contained in:
@@ -945,10 +945,51 @@ Event handlers + daemon I/O + main loop.
|
|||||||
(cond
|
(cond
|
||||||
((eq (getf ev :type) :daemon)
|
((eq (getf ev :type) :daemon)
|
||||||
(on-daemon-msg (getf ev :payload)))
|
(on-daemon-msg (getf ev :payload)))
|
||||||
((eq (getf ev :type) :disconnected)
|
((eq (getf ev :type) :disconnected)
|
||||||
(setf (st :connected) nil
|
(setf (st :connected) nil
|
||||||
(st :busy) nil)
|
(st :busy) nil)
|
||||||
(add-msg :system "* Connection lost — type /reconnect to retry *"))))
|
(add-msg :system "* Connection lost — type /reconnect to retry *"))
|
||||||
|
((eq (getf ev :type) :key)
|
||||||
|
(let* ((payload (getf ev :payload))
|
||||||
|
(ch (getf payload :ch)))
|
||||||
|
(case ch
|
||||||
|
(:CTRL-Q (setf (st :running) nil))
|
||||||
|
(:CTRL-P (command-palette-show-commands))
|
||||||
|
(:CTRL-B (setf (st :sidebar-visible) (not (st :sidebar-visible)))
|
||||||
|
(setf (st :dirty) (list t t nil)))
|
||||||
|
(:CTRL-L (setf (st :dirty) (list t t t)))
|
||||||
|
(t (if (st :dialog-stack)
|
||||||
|
(let* ((dlg (car (st :dialog-stack)))
|
||||||
|
(sel (cl-tty.dialog:dialog-content dlg)))
|
||||||
|
(cond
|
||||||
|
((eql ch :escape)
|
||||||
|
(pop (st :dialog-stack))
|
||||||
|
(setf (st :minibuffer-active) nil)
|
||||||
|
(setf (st :command-palette-active) nil)
|
||||||
|
(setf (st :dirty) (list t t nil)))
|
||||||
|
((member ch '(:up :down))
|
||||||
|
(if (eql ch :up)
|
||||||
|
(cl-tty.select:select-prev sel)
|
||||||
|
(cl-tty.select:select-next sel)))
|
||||||
|
((member ch '(:enter 13 10))
|
||||||
|
(let* ((filtered (cl-tty.select:select-filtered-options sel))
|
||||||
|
(idx (cl-tty.select:select-selected-index sel))
|
||||||
|
(item (when (< idx (length filtered))
|
||||||
|
(third (nth idx filtered)))))
|
||||||
|
(when item
|
||||||
|
(let ((cb (cl-tty.select:select-on-select sel)))
|
||||||
|
(when cb (funcall cb item))))))
|
||||||
|
((and (characterp ch) (graphic-char-p ch))
|
||||||
|
(setf (cl-tty.select:select-filter sel)
|
||||||
|
(concatenate 'string
|
||||||
|
(or (cl-tty.select:select-filter sel) "")
|
||||||
|
(string ch))))
|
||||||
|
((member ch '(:backspace 127 8))
|
||||||
|
(let ((f (cl-tty.select:select-filter sel)))
|
||||||
|
(when (> (length f) 0)
|
||||||
|
(setf (cl-tty.select:select-filter sel)
|
||||||
|
(subseq f 0 (1- f))))))))
|
||||||
|
(on-key ch))))))))
|
||||||
;; Check for terminal resize (SIGWINCH sets this flag)
|
;; Check for terminal resize (SIGWINCH sets this flag)
|
||||||
;; Keyboard reader: block on cat pipe with 0.1s timeout.
|
;; Keyboard reader: block on cat pipe with 0.1s timeout.
|
||||||
(handler-case
|
(handler-case
|
||||||
|
|||||||
Reference in New Issue
Block a user