diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index 7bb2b6a..37aad26 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -288,12 +288,13 @@ ((= ch key-control-x) (loop (wait-for-input) #t)) - ((= ch key-tab) - (debug-message "Should do completion now") + ((and (focus-on-command-buffer?) + (= ch key-tab)) + (offer-completions (last (buffer-text command-buffer))) (loop (wait-for-input) #f)) ;; F7 toggle scheme-mode / command-mode (FIXME: find a better key) - ((= ch key-home) + ((= ch key-f7) (toggle-command/scheme-mode) (loop (wait-for-input) #f)) @@ -740,6 +741,22 @@ (loop (cdr lst) (string-append str " " (car lst)))))) +(define (completions->select-list completions) + (debug-message "possible completions " completions) + (make-select-list + (map (lambda (s) (make-unmarked-element s #f s)) + completions) + (result-buffer-num-lines result-buffer))) + +(define (offer-completions command) + (debug-message "offer-completions " command) + (let ((select-list + (completions->select-list + (completions-for (command-completions) command)))) + (wclear (app-window-curses-win result-window)) + (paint-result-buffer (paint-selection-list select-list)) + (refresh-result-window))) + (define-record-type standard-result-obj standard-result-obj (make-standard-result-obj cursor-pos-y cursor-pos-x