From b93e71736c67c320d4ff8fac49e6bbd585c4e166 Mon Sep 17 00:00:00 2001 From: eknauel Date: Sat, 28 May 2005 12:08:23 +0000 Subject: [PATCH] A first step towards completion: Add completion for command plugins --- scheme/nuit-engine.scm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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