1
0
Fork 0

- changed the way the input is completed, complete with current selected item in suggestion window.

This commit is contained in:
cage 2021-07-23 18:46:13 +02:00
parent e28ae6ff1a
commit 3ba5b83015
3 changed files with 18 additions and 19 deletions

View File

@ -434,8 +434,7 @@ be either `:keybinding' or `:string'. the former for key command the latter for
(column (elt columns selected-item-column-index))
(suggestion (trim-blanks (elt column selected-item-row-index))))
(setf command-line suggestion)
(move-point-to-end win command-line)
(win-hide suggestions-win))))))
(move-point-to-end win command-line))))))
(defun fire-user-input-event (win)
"Generates an event to notify that the user inserted an input on the
@ -478,12 +477,6 @@ command line."
(move-suggestion-page-left command-window))
((eq :alt-right event)
(move-suggestion-page-right command-window))
((eq :alt-up event)
(select-suggestion-next command-window))
((eq :alt-down event)
(select-suggestion-previous command-window))
((eq :alt-i event)
(insert-selected-suggestion command-window))
((eq :backspace event)
(setf command-line (delete-at-point command-window command-line :direction :left))
(show-candidate-completion command-window))
@ -499,13 +492,17 @@ command line."
((eq :home event)
(move-point-to-start command-window))
((eq :up event)
(multiple-value-bind (new-id new-input)
(db:previous-in-history history-position prompt)
(set-history new-id new-input)))
(if (win-shown-p suggestions-win)
(select-suggestion-next command-window)
(multiple-value-bind (new-id new-input)
(db:previous-in-history history-position prompt)
(set-history new-id new-input))))
((eq :down event)
(multiple-value-bind (new-id new-input)
(db:next-in-history history-position prompt)
(set-history new-id new-input)))
(if (win-shown-p suggestions-win)
(select-suggestion-previous command-window)
(multiple-value-bind (new-id new-input)
(db:next-in-history history-position prompt)
(set-history new-id new-input))))
((characterp event)
(cond
((char= #\Newline event)
@ -515,7 +512,7 @@ command line."
(move-point-to-start command-window)
(set-keybinding-mode command-window))
((char= #\Tab event)
(complete-at-point command-window))
(insert-selected-suggestion command-window))
(t
(when (null suggestions-win)
(setf suggestions-win (complete-window:init)))

View File

@ -199,13 +199,13 @@ list af all possible candidtae for completion."
(let ((strings '())
(indices '())
(ordering ()))
(loop for candidate in bag when (< (length template)
(length candidate))
(loop for candidate in bag when (<= (length template)
(length candidate))
do
(when-let ((indices-matched (cl-i18n-utils:fuzzy-match template candidate
:similarity-match 5
:similarity-mismatch -5
:penalty-weight 1 )))
:penalty-weight 1)))
(push candidate strings)
(push indices-matched indices)))
(setf ordering (loop for i from 0 below (length strings) collect i))

View File

@ -128,7 +128,9 @@
(advance-res)
(%advance))))
(%advance)
res))))
(if (= prefix-count 0)
nil
res)))))
(defgeneric join-with-strings (object junction))