1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2024-12-22 23:47:56 +01:00

- [TUI] allowed the backspace key to send rubout char (ASCII 177).

This commit is contained in:
cage 2024-02-28 15:49:28 +01:00
parent 4c44c94c0d
commit 3053183a68

View File

@ -246,6 +246,10 @@ be either `:keybinding' or `:string'. the former for key command the latter for
(defgeneric remove-messages (object))
(defun event-wants-delete-last-element-p (decoded-event)
(or (eq decoded-event :key-backspace)
(string= decoded-event "^?")))
(defun manage-command-event (command-window event)
"Intercept UI events in keybinding mode"
(with-accessors ((command-line command-line)
@ -257,7 +261,7 @@ be either `:keybinding' or `:string'. the former for key command the latter for
(move-suggestion-page-left command-window))
((eq :control-right decoded-event) ; suggestion win pagination
(move-suggestion-page-right command-window))
((eq :key-backspace decoded-event) ; delete last command or char
((event-wants-delete-last-element-p decoded-event) ; delete last command or char
(let ((command-before-last (safe-all-but-last-elt command-line)))
(setf command-line nil)
(cond
@ -479,6 +483,8 @@ command line."
command-line)
(program-events:push-event input-done-event))))
(define-constant +event-cut-line+ "^K" :test #'string=)
(defun manage-string-event (command-window event)
"Manage UI events when `command-window` is in string mode"
(with-accessors ((command-line command-line)
@ -498,15 +504,15 @@ command line."
(db:insert-in-history prompt command-line)
(set-history-most-recent command-window prompt)))
(multiple-value-bind (decoded-event original-key-event)
(decode-key-event event)
(decode-key-event event :convert-symbol-to-string nil)
(cond
((string= decoded-event "^K")
((string= decoded-event +event-cut-line+)
(setf command-line (safe-subseq command-line 0 (no-prompt-point-pos command-window))))
((eq :alt-left original-key-event)
(move-suggestion-page-left command-window))
((eq :alt-right original-key-event)
(move-suggestion-page-right command-window))
((eq :key-backspace original-key-event)
((event-wants-delete-last-element-p decoded-event)
(setf command-line (delete-at-point command-window command-line :direction :left))
(when 'hooks:*after-char-to-command-window*
(hooks:run-hook 'hooks:*after-delete-char-from-command-window* command-window))