Present completions in modal window
part of darcs patch Fri Sep 23 12:32:41 EEST 2005 Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de>
This commit is contained in:
parent
c9bd3f8209
commit
de78de0050
|
@ -412,7 +412,8 @@
|
||||||
(cond
|
(cond
|
||||||
(maybe-modal-window
|
(maybe-modal-window
|
||||||
(if (maybe-modal-window ch)
|
(if (maybe-modal-window ch)
|
||||||
(begin
|
(begin
|
||||||
|
(close-modal-window!)
|
||||||
(paint)
|
(paint)
|
||||||
(when (current-history-item)
|
(when (current-history-item)
|
||||||
(paint-result-window (entry-data (current-history-item)))
|
(paint-result-window (entry-data (current-history-item)))
|
||||||
|
@ -422,10 +423,6 @@
|
||||||
((= ch key-control-x)
|
((= ch key-control-x)
|
||||||
(loop (wait-for-input) #t completion-selector))
|
(loop (wait-for-input) #t completion-selector))
|
||||||
|
|
||||||
((and (focus-on-result-buffer?) completion-selector)
|
|
||||||
(let ((new-selector (completion-selector ch)))
|
|
||||||
(loop (wait-for-input) c-x-pressed? new-selector)))
|
|
||||||
|
|
||||||
;; tab pressed twice, select completion using select-list
|
;; tab pressed twice, select completion using select-list
|
||||||
((and (focus-on-command-buffer?)
|
((and (focus-on-command-buffer?)
|
||||||
completion-selector
|
completion-selector
|
||||||
|
@ -437,9 +434,8 @@
|
||||||
((and (focus-on-command-buffer?)
|
((and (focus-on-command-buffer?)
|
||||||
(command-buffer-in-command-mode?)
|
(command-buffer-in-command-mode?)
|
||||||
(= ch key-tab))
|
(= ch key-tab))
|
||||||
(let ((maybe-selector
|
(offer-completions (last (buffer-text (command-buffer))))
|
||||||
(offer-completions (last (buffer-text (command-buffer))))))
|
(loop (wait-for-input) #f #f))
|
||||||
(loop (wait-for-input) #f maybe-selector)))
|
|
||||||
|
|
||||||
((and (focus-on-command-buffer?)
|
((and (focus-on-command-buffer?)
|
||||||
(command-buffer-in-command-mode?)
|
(command-buffer-in-command-mode?)
|
||||||
|
@ -803,17 +799,15 @@
|
||||||
(move-cursor (command-buffer) (result-buffer))
|
(move-cursor (command-buffer) (result-buffer))
|
||||||
(refresh-command-window))
|
(refresh-command-window))
|
||||||
|
|
||||||
(define (paint-completion-select-list select-list command)
|
(define (paint-completion-select-list win width select-list command)
|
||||||
(let ((win (app-window-curses-win (result-window))))
|
(wclear win)
|
||||||
(wclear win)
|
(wattron win (A-BOLD))
|
||||||
(wattron win (A-BOLD))
|
(mvwaddstr win 0 0
|
||||||
(mvwaddstr win 0 0
|
(string-append "Possible completions for " command))
|
||||||
(string-append "Possible completions for " command))
|
(wattrset win (A-NORMAL))
|
||||||
(wattrset win (A-NORMAL))
|
(paint-selection-list-at select-list 0 2
|
||||||
(paint-selection-list-at select-list 0 2
|
win width #t)
|
||||||
win (result-buffer-num-cols (result-buffer))
|
(wrefresh win))
|
||||||
(focus-on-result-buffer?))
|
|
||||||
(refresh-result-window)))
|
|
||||||
|
|
||||||
(define (current-cursor-index)
|
(define (current-cursor-index)
|
||||||
;; #### No, I will not comment on this.
|
;; #### No, I will not comment on this.
|
||||||
|
@ -838,48 +832,66 @@
|
||||||
((null? completions)
|
((null? completions)
|
||||||
#f)
|
#f)
|
||||||
((list? completions)
|
((list? completions)
|
||||||
(let* ((select-list
|
(set-modal-window!
|
||||||
(completions->select-list
|
(make-completions-window command completions cmdln to-complete)))
|
||||||
completions
|
|
||||||
(- (result-buffer-num-lines (result-buffer)) 3)))
|
|
||||||
(selector
|
|
||||||
(make-completion-selector select-list completions
|
|
||||||
cmdln to-complete)))
|
|
||||||
(paint-completion-select-list select-list command)
|
|
||||||
(move-cursor (command-buffer) (result-buffer))
|
|
||||||
(refresh-command-window)
|
|
||||||
selector))
|
|
||||||
(else
|
(else
|
||||||
(error "COMPLETE returned an unexpected value"
|
(error "COMPLETE returned an unexpected value"
|
||||||
completions)))))))
|
completions)))))))
|
||||||
|
|
||||||
(define (make-completion-selector select-list completions
|
(define (make-completions-window command completions
|
||||||
cmdln to-complete)
|
cmdln to-complete)
|
||||||
(lambda (key)
|
(define header-line "Select completion")
|
||||||
(cond
|
(define header-length (string-length header-line))
|
||||||
((= key 10)
|
|
||||||
(let ((completion
|
(let* ((lines 10)
|
||||||
(select-list-selected-entry select-list)))
|
(inner-width
|
||||||
(focus-command-buffer!)
|
(min (apply max header-length
|
||||||
;; #### No, I will not comment on this.
|
(map string-length completions))
|
||||||
(call-with-values
|
(COLS)))
|
||||||
(lambda ()
|
(dialog (make-app-window (- (quotient (COLS) 2)
|
||||||
(unparse-command-line cmdln
|
(quotient inner-width 2))
|
||||||
(lambda (to-complete)
|
5
|
||||||
(display completion))))
|
(+ 4 inner-width)
|
||||||
(lambda (completed-line new-cursor-pos)
|
lines)))
|
||||||
(display-completed-line completed-line
|
(app-window-init-curses-win! dialog)
|
||||||
(+ 2 new-cursor-pos))))
|
(let* ((dialog-win (app-window-curses-win dialog))
|
||||||
#f))
|
(select-list
|
||||||
((select-list-key? key)
|
(completions->select-list
|
||||||
(let ((new-select-list
|
completions
|
||||||
(select-list-handle-key-press select-list key)))
|
(- lines 3))))
|
||||||
(paint-completion-select-list
|
|
||||||
new-select-list (last (buffer-text (command-buffer))))
|
(define (paint)
|
||||||
(make-completion-selector
|
(werase dialog-win)
|
||||||
new-select-list completions cmdln to-complete)))
|
(box dialog-win
|
||||||
(else
|
(ascii->char 0) (ascii->char 0))
|
||||||
;; #### FIXME we loose a character this way
|
(mvwaddstr dialog-win
|
||||||
(focus-command-buffer!)
|
0
|
||||||
#f))))
|
(+ 1 (quotient (- inner-width header-length) 2))
|
||||||
|
header-line)
|
||||||
|
(paint-completion-select-list dialog-win inner-width select-list command)
|
||||||
|
(wrefresh dialog-win))
|
||||||
|
(paint)
|
||||||
|
(lambda (key)
|
||||||
|
(cond
|
||||||
|
((= key 10)
|
||||||
|
(let ((completion
|
||||||
|
(select-list-selected-entry select-list)))
|
||||||
|
;; #### No, I will not comment on this.
|
||||||
|
(call-with-values
|
||||||
|
(lambda ()
|
||||||
|
(unparse-command-line cmdln
|
||||||
|
(lambda (to-complete)
|
||||||
|
(display completion))))
|
||||||
|
(lambda (completed-line new-cursor-pos)
|
||||||
|
(display-completed-line completed-line
|
||||||
|
(+ 2 new-cursor-pos))))
|
||||||
|
(delete-app-window! dialog)
|
||||||
|
#t))
|
||||||
|
((select-list-key? key)
|
||||||
|
(set! select-list
|
||||||
|
(select-list-handle-key-press select-list key))
|
||||||
|
(paint)
|
||||||
|
#f)
|
||||||
|
(else
|
||||||
|
#f))))))
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,6 @@
|
||||||
val)) entries)))
|
val)) entries)))
|
||||||
(send list-viewer 'set-entries! new-entries))
|
(send list-viewer 'set-entries! new-entries))
|
||||||
(delete-app-window! dialog)
|
(delete-app-window! dialog)
|
||||||
(close-modal-window!)
|
|
||||||
#t)
|
#t)
|
||||||
(else #f))))))
|
(else #f))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue