From 9a038dc356fd34b7e5574add4eb5778e8d921935 Mon Sep 17 00:00:00 2001 From: eknauel Date: Mon, 23 May 2005 13:22:16 +0000 Subject: [PATCH] make eval look whether the command is evaluated in command oder scheme mode --- scheme/nuit-engine.scm | 57 +++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index 9a6438d..75e5846 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -234,6 +234,32 @@ (move-cursor command-buffer) (refresh-command-window)) +(define (handle-return-key) + (let ((command (last (buffer-text command-buffer)))) + (cond + ((string=? command "") + (values)) + ((command-buffer-in-scheme-mode?) + (eval-command-in-scheme-mode command)) + ((command-buffer-in-command-mode?) + (eval-command-in-command-mode command))))) + +(define (eval-command-in-command-mode command) + (debug-message "eval-command-in-command-mode " command)) + +(define (eval-command-in-scheme-mode command) + (call-with-values + (lambda () + (execute-command command)) + (lambda (result plugin) + (let ((new-entry + (make-history-entry command '() + result plugin))) + ;; FIXME, use insert here + (append-to-history! new-entry) + (buffer-text-append-new-line! command-buffer) + (paint-result/command-buffer new-entry))))) + ;; handle input (define (run) @@ -303,26 +329,8 @@ (loop (wait-for-input) c-x-pressed?)) ((= ch 10) - (let ((command (last (buffer-text command-buffer)))) - (if (not (string=? command "")) - (call-with-values - (lambda () - (execute-command command)) - (lambda (result plugin) - (let ((new-entry - (make-history-entry command '() - result plugin))) - (append-to-history! new-entry) - (buffer-text-append-new-line! command-buffer) - (paint-result-window new-entry) - (paint-active-command-window) - (scroll-command-buffer) - (paint-command-window-contents) - (move-cursor command-buffer) - (refresh-result-window) - (refresh-command-window) - (loop (wait-for-input) c-x-pressed?)))) - (loop (wait-for-input) #f)))) + (handle-return-key) + (loop (wait-for-input) c-x-pressed?)) (else (cond @@ -457,6 +465,15 @@ (define (refresh-result-window) (wrefresh (app-window-curses-win result-window))) +(define (paint-result/command-buffer history-entry) + (paint-result-window history-entry) + (paint-active-command-window) + (scroll-command-buffer) + (paint-command-window-contents) + (move-cursor command-buffer) + (refresh-result-window) + (refresh-command-window)) + (define (paint) (debug-message "paint") (paint-bar-1)