1
0
Fork 0

- added keybinding to cancel inputing of the string command.

This commit is contained in:
cage 2024-03-01 14:57:36 +01:00
parent 8c8b5555f7
commit 84d2d7a5e0
5 changed files with 22 additions and 6 deletions

View File

@ -172,6 +172,8 @@ the \fBnew line\fP (often called \fBenter\fP key) send the input to the program;
.IP \(em 4
\fBC-k\fP (that is: "press 'control' and while pressed press 'k') \fIkills\fP (deletes) the text from the cursor position to the end of the input previously typed;
.IP \(em 4
\fBC-g\fP will cancel the prompt and quit the command;
.IP \(em 4
press \fBM-left\fP and \fBM-right\fP (\fBleft alt\fP and \fBleft\fP or \fBright\fP arrow together) to browse pages of the suggestion window; the suggestion window is a window that holds a previously inputted data that are compatible with the string the user is typing into the command window;
.IP \(em 4
if suggestions are gemini URI press \fBTAB\fP to input the current selected suggestion;

View File

@ -116,6 +116,7 @@
- *canc* and *backspace* delete the next and previous character respectively;
- the *new line* (often called *enter* key) send the input to the program;
- *C-k* (that is: "press 'control' and while pressed press 'k') /kills/ (deletes) the text from the cursor position to the end of the input previously typed;
- *C-g* will cancel the prompt and quit the command;
- press *M-left* and *M-right* (*left alt* and *left* or *right* arrow together) to browse pages of the suggestion window; the suggestion window is a window that holds a previously inputted data that are compatible with the string the user is typing into the command window;
- if suggestions are gemini URI press *TAB* to input the current selected suggestion;
- if suggestion window is *not* rendered, pressing *up* and *down* arrow keys will cycle through input history, if there is not a suggestion window rendered pressing *up* and *down* will scroll on suggestions.

View File

@ -464,7 +464,7 @@ be either `:keybinding' or `:string'. the former for key command the latter for
(move-point-to-end win command-line)))))
win)
(defun fire-user-input-event (win)
(defun fire-user-input-event (win &key (canceled nil))
"Generates an event to notify that the user inserted an input on the
command line."
(with-accessors ((event-to-answer event-to-answer)
@ -480,11 +480,15 @@ command line."
:condition-variable
(program-events:condition-variable event-to-answer))))
(setf (box:dunbox (program-events:payload input-done-event))
command-line)
(if canceled
:canceled
command-line))
(program-events:push-event input-done-event))))
(define-constant +event-cut-line+ "^K" :test #'string=)
(define-constant +event-cancel-command-line+ "^G" :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)
@ -508,6 +512,11 @@ command line."
(cond
((string= decoded-event +event-cut-line+)
(setf command-line (safe-subseq command-line 0 (no-prompt-point-pos command-window))))
((string= decoded-event +event-cancel-command-line+)
(setf command-line nil)
(move-point-to-start command-window)
(set-keybinding-mode command-window)
(fire-user-input-event command-window :canceled t))
((eq :alt-left original-key-event)
(move-suggestion-page-left command-window))
((eq :alt-right original-key-event)

View File

@ -297,9 +297,10 @@
:accessor complete-fn))
(:documentation "This events, when processed, will prepare the
command-window `specials:*command-window*' to ask for user
input. The most importatn thing is that the process-event will set
input. The most important thing is that the process-event will bind
the slot `command-window:event-to-answer' with this events and will
set the payload of this events with the user provided string."))
bind the slot `payload' of this events with the user provided
string."))
(defmethod initialize-instance :after ((object ask-user-input-string-event)
&key (forced-priority nil) &allow-other-keys)

View File

@ -248,8 +248,11 @@
do
(condition-wait condition-variable lock))
(setf (command-window:echo-character *command-window*) nil)
(funcall on-input-complete-fn (box:dunbox (payload event))))))))
(make-thread #'thread-fn)))
(let ((input-string (box:dunbox (payload event))))
(if (stringp input-string)
(funcall on-input-complete-fn input-string)
(info-message (_ "Command cancelled")))))))))
(make-thread #'thread-fn)))
(defun thread-go-up ()
(thread-window:go-message-up *thread-window*))