1
0
Fork 0

- tracked incompatible changes from croatoan;

An event  is no  more a character  or symbol but  is an  instabce of
  class 'event'.
This commit is contained in:
cage 2021-12-26 13:03:47 +01:00
parent 50bf7a8716
commit a29c6aa058
3 changed files with 75 additions and 70 deletions

View File

@ -43,7 +43,7 @@ CROATOAN_GIT_URL=https://github.com/McParen/croatoan.git
CROATOAN_DIR="$QUICKLISP_INSTALL_DIR"/local-projects/croatoan/;
CROATOAN_COMMIT=cf875137a23ed4efbfde63e52691f1b544d55d17
CROATOAN_COMMIT=000c60428fe73d796d4ee032cfa5901eb57b4703
echo_bold () {
echo -e "${BOLD_TEXT}${1}${NORMAL_TEXT}";

View File

@ -492,68 +492,71 @@ command line."
(insert-in-history (prompt command-line)
(db:insert-in-history prompt command-line)
(set-history-most-recent command-window prompt)))
(remove-messages command-window)
(cond
((string= (decode-key-event event) "^K")
(setf command-line (safe-subseq command-line 0 (no-prompt-point-pos command-window))))
((eq :alt-left event)
(move-suggestion-page-left command-window))
((eq :alt-right event)
(move-suggestion-page-right command-window))
((eq :backspace 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))
(show-candidate-completion command-window))
((eq :dc event)
(setf command-line (delete-at-point command-window command-line :direction :right))
(when 'hooks:*after-char-to-command-window*
(hooks:run-hook 'hooks:*after-delete-char-from-command-window* command-window))
(show-candidate-completion command-window))
((eq :left event)
(move-point-left command-window))
((eq :right event)
(move-point-right command-window (length command-line)))
((eq :end event)
(move-point-to-end command-window command-line))
((eq :home event)
(move-point-to-start command-window))
((eq :up event)
(if (win-shown-p suggestions-win)
(select-suggestion-previous 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)
(if (win-shown-p suggestions-win)
(select-suggestion-next 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)
(when 'hooks:*before-fire-string-event-command-window*
(hooks:run-hook 'hooks:*before-fire-string-event-command-window*
command-window))
(insert-in-history prompt command-line)
(fire-user-input-event command-window)
(setf command-line nil)
(move-point-to-start command-window)
(set-keybinding-mode command-window))
((char= #\Tab event)
(complete-at-point command-window))
(t
(if (null suggestions-win)
(setf suggestions-win (complete-window:init))
(complete-window:reset-selected-item suggestions-win))
(win-show suggestions-win)
(setf command-line
(insert-at-point command-window event command-line))
(when 'hooks:*after-char-to-command-window*
(hooks:run-hook 'hooks:*after-char-to-command-window*
command-window))
(show-candidate-completion command-window)))))))
(multiple-value-bind (decoded-event original-key-event)
(decode-key-event event)
(cond
((string= decoded-event "^K")
(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 :backspace original-key-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))
(show-candidate-completion command-window))
((eq :dc original-key-event)
(setf command-line (delete-at-point command-window command-line :direction :right))
(when 'hooks:*after-char-to-command-window*
(hooks:run-hook 'hooks:*after-delete-char-from-command-window* command-window))
(show-candidate-completion command-window))
((eq :left original-key-event)
(move-point-left command-window))
((eq :right original-key-event)
(move-point-right command-window (length command-line)))
((eq :end original-key-event)
(move-point-to-end command-window command-line))
((eq :home original-key-event)
(move-point-to-start command-window))
((eq :up original-key-event)
(if (win-shown-p suggestions-win)
(select-suggestion-previous command-window)
(multiple-value-bind (new-id new-input)
(db:previous-in-history history-position prompt)
(set-history new-id new-input))))
((eq :down original-key-event)
(if (win-shown-p suggestions-win)
(select-suggestion-next command-window)
(multiple-value-bind (new-id new-input)
(db:next-in-history history-position prompt)
(set-history new-id new-input))))
((characterp original-key-event)
(cond
((char= #\Newline original-key-event)
(when 'hooks:*before-fire-string-event-command-window*
(hooks:run-hook 'hooks:*before-fire-string-event-command-window*
command-window))
(insert-in-history prompt command-line)
(fire-user-input-event command-window)
(setf command-line nil)
(move-point-to-start command-window)
(set-keybinding-mode command-window))
((char= #\Tab original-key-event)
(complete-at-point command-window))
(t
(if (null suggestions-win)
(setf suggestions-win (complete-window:init))
(complete-window:reset-selected-item suggestions-win))
(win-show suggestions-win)
(setf command-line
(insert-at-point command-window original-key-event command-line))
(when 'hooks:*after-char-to-command-window*
(hooks:run-hook 'hooks:*after-char-to-command-window*
command-window))
(show-candidate-completion command-window))))
(t
(misc:dbg "unknow ~s ~a" decoded-event (type-of decoded-event)))))))
command-window)
(defun set-input-mode (win mode suggestions-cached-win)

View File

@ -96,13 +96,15 @@ as argument `complex-string'."
(length (complex-char-array complex-string)))
(defun decode-key-event (event)
(cond
((characterp event)
(key-to-string event))
((symbolp event)
(symbol-name event))
(t
(error (_ "Unknown event ~a") event))))
(let* ((key (croatoan:event-key event))
(decoded-event (cond
((characterp key)
(key-to-string key))
((symbolp key)
(symbol-name key))
(t
(error (_ "Unknown key event ~a") key)))))
(values decoded-event key)))
(defun colorize-tree-element (color-map annotated-element)
"Colormap is an alist like: