From 75500100b326e6a14f6cd20a285e60759d767e1e Mon Sep 17 00:00:00 2001 From: eknauel Date: Mon, 23 May 2005 13:03:45 +0000 Subject: [PATCH] add a command buffer mode indicator --- scheme/nuit-engine.scm | 51 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index 61160c6..9a6438d 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -81,9 +81,6 @@ ;;lines to be marked (define marked-lines '()) - - - ;;miscelaneous state ;;------------------- @@ -101,6 +98,21 @@ (define (focus-result-buffer!) (set! *focus-buffer* 'result-buffer)) +;; mode of the command buffer +(define *command-buffer-mode* 'scheme) + +(define (command-buffer-in-scheme-mode?) + (eq? *command-buffer-mode* 'scheme)) + +(define (command-buffer-in-command-mode?) + (eq? *command-buffer-mode* 'command)) + +(define (enter-scheme-mode!) + (set! *command-buffer-mode* 'scheme)) + +(define (enter-command-mode!) + (set! *command-buffer-mode* 'command)) + ;; History (define history-pos 0) @@ -211,6 +223,17 @@ (move-cursor command-buffer) (refresh-command-window)))) +(define (toggle-command/scheme-mode) + (cond + ((command-buffer-in-command-mode?) + (enter-scheme-mode!)) + ((command-buffer-in-scheme-mode?) + (enter-command-mode!))) + (paint-command-frame-window) + (paint-command-window-contents) + (move-cursor command-buffer) + (refresh-command-window)) + ;; handle input (define (run) @@ -228,6 +251,11 @@ ((= ch key-control-x) (loop (wait-for-input) #t)) + ;; F7 toggle scheme-mode / command-mode (FIXME: find a better key) + ((= ch key-f7) + (toggle-command/scheme-mode) + (loop (wait-for-input) #f)) + ;; C-x o --- toggle buffer focus ((and c-x-pressed? (= ch key-o)) (toggle-buffer-focus) @@ -374,9 +402,26 @@ (mvwaddstr (app-window-curses-win bar-1) 0 1 "SCSH-NUIT") (wrefresh (app-window-curses-win bar-1))) +(define (paint-command-buffer-mode-indicator) + (let ((mode-string + (string-append + "[ " + (if (command-buffer-in-command-mode?) + "Command" + "Scheme") + " ]"))) + (mvwaddstr + (app-window-curses-win command-frame-window) + 0 + (- (- (app-window-width command-frame-window) + (string-length mode-string)) + 2) + mode-string))) + (define (paint-command-frame-window) (box (app-window-curses-win command-frame-window) (ascii->char 0) (ascii->char 0)) + (paint-command-buffer-mode-indicator) (wrefresh (app-window-curses-win command-frame-window))) (define (paint-command-window-contents)