Fix painting of completions window, remove loop parameter

part of darcs patch Fri Sep 23 22:15:31 EEST 2005  Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de>
This commit is contained in:
eknauel 2005-09-27 16:37:12 +00:00
parent de78de0050
commit 96973d961c
1 changed files with 28 additions and 40 deletions

View File

@ -404,10 +404,9 @@
(release-lock paint-lock) (release-lock paint-lock)
(lp (cml-receive statistics-channel)))))) (lp (cml-receive statistics-channel))))))
;;Loop
(paint) (paint)
(let loop ((ch (wait-for-input)) (c-x-pressed? #f) (let loop ((ch (wait-for-input))
(completion-selector #f)) (c-x-pressed? #f))
(cond (cond
(maybe-modal-window (maybe-modal-window
@ -418,75 +417,69 @@
(when (current-history-item) (when (current-history-item)
(paint-result-window (entry-data (current-history-item))) (paint-result-window (entry-data (current-history-item)))
(refresh-result-window)))) (refresh-result-window))))
(loop (wait-for-input) c-x-pressed? completion-selector)) (loop (wait-for-input) c-x-pressed?))
;; Ctrl-x -> wait for next input ;; Ctrl-x -> wait for next input
((= ch key-control-x) ((= ch key-control-x)
(loop (wait-for-input) #t completion-selector)) (loop (wait-for-input) #t))
;; tab pressed twice, select completion using select-list ;; tab is pressed, offer completions
((and (focus-on-command-buffer?)
completion-selector
(= ch key-tab))
(focus-result-buffer!)
(loop (wait-for-input) #f completion-selector))
;; tab is pressed in the first place, offer completions
((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))
(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))
((and (focus-on-command-buffer?) ((and (focus-on-command-buffer?)
(command-buffer-in-command-mode?) (command-buffer-in-command-mode?)
c-x-pressed? c-x-pressed?
(= ch (config 'main 'switch-command-buffer-mode-key))) (= ch (config 'main 'switch-command-buffer-mode-key)))
(toggle-command/scheme-mode-with-conversion) (toggle-command/scheme-mode-with-conversion)
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
((= ch (config 'main 'switch-command-buffer-mode-key)) ((= ch (config 'main 'switch-command-buffer-mode-key))
(toggle-command/scheme-mode) (toggle-command/scheme-mode)
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
((= ch key-end) ((= ch key-end)
(show-shell-screen) (show-shell-screen)
(paint) (paint)
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
;; C-x o --- toggle buffer focus ;; C-x o --- toggle buffer focus
((and c-x-pressed? (= ch key-o)) ((and c-x-pressed? (= ch key-o))
(toggle-buffer-focus) (toggle-buffer-focus)
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
;; C-x p --- insert selection ;; C-x p --- insert selection
((and c-x-pressed? (current-history-item) ((and c-x-pressed? (current-history-item)
(= ch 112)) (= ch 112))
(paste-selection/refresh (current-viewer)) (paste-selection/refresh (current-viewer))
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
;; C-x P --- insert focus object(s) ;; C-x P --- insert focus object(s)
((and c-x-pressed? (current-history-item) ((and c-x-pressed? (current-history-item)
(= ch 80)) (= ch 80))
(paste-focus-object/refresh (current-viewer)) (paste-focus-object/refresh (current-viewer))
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
((and c-x-pressed? (focus-on-result-buffer?)) ((and c-x-pressed? (focus-on-result-buffer?))
(update-current-viewer! (update-current-viewer!
(send (current-viewer) (send (current-viewer)
'key-press ch key-control-x)) 'key-press ch key-control-x))
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
;; C-x r --- redo ;; C-x r --- redo
((and c-x-pressed? (focus-on-command-buffer?) ((and c-x-pressed? (focus-on-command-buffer?)
(= ch 114)) (= ch 114))
(debug-message "Eric should re-implement redo...")) (debug-message "Eric should re-implement redo...")
(loop (wait-for-input) #f))
((= ch key-f1) ((= ch key-f1)
(endwin)) (endwin))
((= ch key-f2) ((= ch key-f2)
(paint) (paint)
(loop (wait-for-input) c-x-pressed? #f)) (loop (wait-for-input) c-x-pressed?))
;; forward in result history ;; forward in result history
((= ch key-npage) ((= ch key-npage)
@ -498,7 +491,7 @@
(paint-result-window (entry-data (current-history-item)))) (paint-result-window (entry-data (current-history-item))))
(refresh-result-window) (refresh-result-window)
(release-lock paint-lock) (release-lock paint-lock)
(loop (wait-for-input) c-x-pressed? #f)) (loop (wait-for-input) c-x-pressed?))
;; back in result history ;; back in result history
((= ch key-ppage) ((= ch key-ppage)
@ -510,7 +503,7 @@
(paint-result-window (entry-data (current-history-item)))) (paint-result-window (entry-data (current-history-item))))
(refresh-result-window) (refresh-result-window)
(release-lock paint-lock) (release-lock paint-lock)
(loop (wait-for-input) c-x-pressed? #f)) (loop (wait-for-input) c-x-pressed?))
((and (focus-on-command-buffer?) (= ch 10)) ((and (focus-on-command-buffer?) (= ch 10))
(input (command-buffer) ch) (input (command-buffer) ch)
@ -522,7 +515,7 @@
(refresh-command-window) (refresh-command-window)
(release-lock paint-lock) (release-lock paint-lock)
(handle-return-key) (handle-return-key)
(loop (wait-for-input) c-x-pressed? #f)) (loop (wait-for-input) c-x-pressed?))
(else (else
(cond (cond
@ -536,7 +529,7 @@
(move-cursor (command-buffer) (result-buffer)) (move-cursor (command-buffer) (result-buffer))
(refresh-result-window) (refresh-result-window)
(release-lock paint-lock)) (release-lock paint-lock))
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f))
(else (else
(input (command-buffer) ch) (input (command-buffer) ch)
(obtain-lock paint-lock) (obtain-lock paint-lock)
@ -546,7 +539,7 @@
(move-cursor (command-buffer) (result-buffer)) (move-cursor (command-buffer) (result-buffer))
(refresh-command-window) (refresh-command-window)
(release-lock paint-lock) (release-lock paint-lock)
(loop (wait-for-input) c-x-pressed? #f))))))) (loop (wait-for-input) c-x-pressed?)))))))
(define (paint-bar-1) (define (paint-bar-1)
(mvwaddstr (app-window-curses-win (bar-1)) 0 1 "Commander S") (mvwaddstr (app-window-curses-win (bar-1)) 0 1 "Commander S")
@ -799,16 +792,6 @@
(move-cursor (command-buffer) (result-buffer)) (move-cursor (command-buffer) (result-buffer))
(refresh-command-window)) (refresh-command-window))
(define (paint-completion-select-list win width select-list command)
(wclear win)
(wattron win (A-BOLD))
(mvwaddstr win 0 0
(string-append "Possible completions for " command))
(wattrset win (A-NORMAL))
(paint-selection-list-at select-list 0 2
win width #t)
(wrefresh win))
(define (current-cursor-index) (define (current-cursor-index)
;; #### No, I will not comment on this. ;; #### No, I will not comment on this.
(- (buffer-pos-col (command-buffer)) 2)) (- (buffer-pos-col (command-buffer)) 2))
@ -868,11 +851,16 @@
0 0
(+ 1 (quotient (- inner-width header-length) 2)) (+ 1 (quotient (- inner-width header-length) 2))
header-line) header-line)
(paint-completion-select-list dialog-win inner-width select-list command) (paint-selection-list-at select-list 1 1
dialog-win inner-width #t)
(wrefresh dialog-win)) (wrefresh dialog-win))
(paint) (paint)
(lambda (key) (lambda (key)
(cond (cond
((= key 27)
(delete-app-window! dialog)
(close-modal-window!)
#t)
((= key 10) ((= key 10)
(let ((completion (let ((completion
(select-list-selected-entry select-list))) (select-list-selected-entry select-list)))