passepartout: v0.7.0 — Status bar fix, unicode width, Ctrl key bindings
This commit is contained in:
@@ -11,6 +11,29 @@
|
||||
(or name raw))
|
||||
raw)))
|
||||
(cond
|
||||
;; v0.7.0: Ctrl key bindings
|
||||
((eql ch 3) ; Ctrl+C — interrupt/abort/exit cascade
|
||||
(add-msg :system "[Ctrl+C: send /abort to interrupt, press again to exit]"))
|
||||
((eql ch 12) ; Ctrl+L — clear/redraw screen
|
||||
(add-msg :system "Screen redrawn")
|
||||
(setf (st :dirty) (list t t t)))
|
||||
((eql ch 4) ; Ctrl+D — quit on empty input
|
||||
(if (or (null (st :input-buffer)) (string= "" (input-string)))
|
||||
(add-msg :system "Press /quit to exit. Goodbye!")))
|
||||
((eql ch 21) ; Ctrl+U — clear line
|
||||
(setf (st :input-buffer) nil)
|
||||
(setf (st :dirty) (list nil nil t)))
|
||||
((eql ch 23) ; Ctrl+W — delete word backward
|
||||
(let ((buf (or (st :input-buffer) nil)))
|
||||
(when buf
|
||||
(loop while (and buf (char= (first buf) #\Space)) do (pop buf))
|
||||
(loop while (and buf (char/= (first buf) #\Space)) do (pop buf))
|
||||
(setf (st :input-buffer) buf)
|
||||
(setf (st :dirty) (list nil nil t)))))
|
||||
((eql ch 1) ; Ctrl+A — home
|
||||
(setf (st :cursor-pos) 0))
|
||||
((eql ch 5) ; Ctrl+E — end
|
||||
(setf (st :cursor-pos) (length (st :input-buffer))))
|
||||
;; Enter
|
||||
((or (eq ch :enter) (eql ch 13) (eql ch 10)
|
||||
(eql ch #\Newline) (eql ch #\Return))
|
||||
@@ -541,3 +564,45 @@
|
||||
(fiveam:is (eq :yellow (getf *tui-theme* :system)))
|
||||
(fiveam:is (eq :cyan (getf *tui-theme* :input)))
|
||||
(fiveam:is (eq :white (theme-color :unknown-role))))
|
||||
|
||||
(fiveam:test test-on-key-ctrl-d-empty-quits
|
||||
"Contract 1/v0.7.0: Ctrl+D on empty input adds quit system message."
|
||||
(init-state)
|
||||
(on-key 4) ; Ctrl+D
|
||||
(let ((msgs (st :messages)))
|
||||
(fiveam:is (> (length msgs) 0)) ; at least one message
|
||||
(fiveam:is (search "quit" (getf (elt msgs 0) :content) :test #'char-equal))))
|
||||
|
||||
(fiveam:test test-on-key-ctrl-u-clears-line
|
||||
"Contract 1/v0.7.0: Ctrl+U clears the input buffer."
|
||||
(init-state)
|
||||
(dolist (ch '(#\h #\e #\l #\l #\o))
|
||||
(on-key (char-code ch)))
|
||||
(on-key 21) ; Ctrl+U
|
||||
(fiveam:is (string= "" (input-string))))
|
||||
|
||||
(fiveam:test test-on-key-ctrl-a-moves-home
|
||||
"Contract 1/v0.7.0: Ctrl+A moves cursor to position 0."
|
||||
(init-state)
|
||||
(dolist (ch '(#\h #\i))
|
||||
(on-key (char-code ch)))
|
||||
(on-key 1) ; Ctrl+A
|
||||
(fiveam:is (= 0 (or (st :cursor-pos) 0))))
|
||||
|
||||
(fiveam:test test-on-key-ctrl-e-moves-end
|
||||
"Contract 1/v0.7.0: Ctrl+E moves cursor to end of input."
|
||||
(init-state)
|
||||
(dolist (ch '(#\h #\i))
|
||||
(on-key (char-code ch)))
|
||||
(on-key 5) ; Ctrl+E
|
||||
(fiveam:is (= 2 (or (st :cursor-pos) 0))))
|
||||
|
||||
(fiveam:test test-on-key-ctrl-l-redraws
|
||||
"Contract 1/v0.7.0: Ctrl+L sets all dirty flags for full redraw."
|
||||
(init-state)
|
||||
(setf (st :dirty) (list nil nil nil))
|
||||
(on-key 12) ; Ctrl+L
|
||||
(let ((d (st :dirty)))
|
||||
(fiveam:is (eq t (first d)))
|
||||
(fiveam:is (eq t (second d)))
|
||||
(fiveam:is (eq t (third d)))))
|
||||
|
||||
Reference in New Issue
Block a user