From 54230412f85d8713e514b249ed6fcfd702e19d8e Mon Sep 17 00:00:00 2001 From: eknauel Date: Mon, 30 May 2005 15:38:13 +0000 Subject: [PATCH] make it easier to abort the process of choosing a completion via the select-list --- scheme/nuit-engine.scm | 31 +++++++++++++++++++------------ scheme/nuit-packages.scm | 5 ++++- scheme/select-list.scm | 7 +++++++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index 12213a0..12a3e3d 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -295,6 +295,7 @@ (let loop ((ch (wait-for-input)) (c-x-pressed? #f) (completion-selector #f)) + (debug-message "loop: " ch "|" c-x-pressed? "|" completion-selector) (cond ;; Ctrl-x -> wait for next input @@ -487,7 +488,8 @@ (with-lock executable-completions-lock (lambda() (set! executable-completions - (make-completion-set-for-executables (get-path-list)))))))) + (make-completion-set-for-executables (get-path-list))) + (debug-message "finished scanning executable-completions-set")))))) (define (paint-bar-1) (mvwaddstr (app-window-curses-win bar-1) 0 1 "SCSH-NUIT") @@ -955,17 +957,22 @@ (select-list-selected-entry select-list))) display-completed-line) #f) - (else - (let ((new-select-list - (select-list-handle-key-press - select-list - (make-key-pressed-message - (active-command) (current-result) - result-buffer key #f)))) - (paint-completion-select-list - new-select-list (last (buffer-text command-buffer))) - (make-completion-selector - new-select-list completions command arg arg-pos)))))) + ((or (select-list-navigation-key? key) + (select-list-marking-key? key)) + (let ((new-select-list + (select-list-handle-key-press + select-list + (make-key-pressed-message + (active-command) (current-result) + result-buffer key #f)))) + (paint-completion-select-list + new-select-list (last (buffer-text command-buffer))) + (make-completion-selector + new-select-list completions command arg arg-pos))) + (else + ;; #### FIXME we loose a character this way + (focus-command-buffer!) + #f)))) (define (find-token-with-cursor tokens/cursor-list) (debug-message "find-token-with-cursor " tokens/cursor-list) diff --git a/scheme/nuit-packages.scm b/scheme/nuit-packages.scm index e2d8e66..f90daca 100644 --- a/scheme/nuit-packages.scm +++ b/scheme/nuit-packages.scm @@ -156,7 +156,10 @@ paint-selection-list paint-selection-list-at select-list-get-selection - select-list-selected-entry)) + select-list-selected-entry + + select-list-navigation-key? + select-list-marking-key?)) (define-structure select-list select-list-interface (open scheme diff --git a/scheme/select-list.scm b/scheme/select-list.scm index 0974079..e26918f 100644 --- a/scheme/select-list.scm +++ b/scheme/select-list.scm @@ -40,6 +40,7 @@ (define (select-list-handle-key-press select-list key-message) (let ((key (key-pressed-message-key key-message)) (result-buffer (key-pressed-message-result-buffer key-message))) + (debug-message "select-list-handle-key-press " select-list " " key) (cond ((= key key-m) (mark-current-line select-list)) @@ -52,6 +53,12 @@ (else select-list)))) +(define (select-list-navigation-key? key) + (or (= key key-up) (= key key-down))) + +(define (select-list-marking-key? key) + (or (= key key-m) (= key key-u))) + (define (mark/unmark-current-line-maker mark) (lambda (select-list) (let* ((index (select-list-cursor-index select-list))