From 03ffcf82808a2a7bb2630ee9ddb13d597f665057 Mon Sep 17 00:00:00 2001 From: eknauel Date: Tue, 17 May 2005 09:00:33 +0000 Subject: [PATCH] Minor code clean-up, fix more redrawing stuff --- scheme/nuit-engine.scm | 133 +++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 71 deletions(-) diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index b58c5ce..babc551 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -333,9 +333,9 @@ (make-key-pressed-message active-command current-result-object ch))) - (begin - (set! current-result-object (switch key-message)) - (loop (wait-for-input)))) + (set! current-result-object (switch key-message)) + (paint-result-window) + (loop (wait-for-input))) (cond @@ -344,25 +344,22 @@ (let ((restore-message (make-restore-message active-command current-result-object))) - (begin - (switch restore-message) - (execute-command) - (set-buffer-history-pos! - command-buffer - (- (length (buffer-text command-buffer)) 1)) - (paint-result-window) - (paint-bar-2) - (paint-command-window-contents) - (move-cursor command-buffer) - (loop (wait-for-input))))) - - (else - (begin - (set! command-buffer (input command-buffer ch)) + (switch restore-message) + (execute-command) + (set-buffer-history-pos! + command-buffer + (- (length (buffer-text command-buffer)) 1)) + (paint-result-window) + (paint-bar-2) (paint-command-window-contents) - (set! command-buffer - (move-cursor command-buffer)) - (loop (wait-for-input))))))))))) + (move-cursor command-buffer) + (loop (wait-for-input)))) + + (else + (set! command-buffer (input command-buffer ch)) + (paint-command-window-contents) + (move-cursor command-buffer) + (loop (wait-for-input)))))))))) (define (window-init-curses-win! window) (set-app-window-curses-win! @@ -452,47 +449,43 @@ ;;If the user presses enter the last line is interpreted as a command ;;which has to be executed. -(define execute-command - (lambda () - (let* ((com (list-ref (buffer-text command-buffer) - (- (length (buffer-text command-buffer)) 1))) - (com-par (extract-com-and-par com)) - (command (car com-par)) - (parameters (cdr com-par)) - ;;todo: parameters - (message (make-next-command-message - command parameters result-cols)) - (model (switch message))) - (begin - (if (not (= history-pos 0)) - (let ((hist-entry (make-history-entry active-command - active-parameters - current-result-object)) - (active (make-history-entry command - (get-param-as-str parameters) - model))) - (begin - (if (< history-pos (length history)) - (set! history (append history (list hist-entry))) - (set! history (append - (sublist history 0 - (- (length history) 1)) - (list hist-entry) (list active)))) - (set! history-pos (length history)))) - (let ((hist-entry (make-history-entry - command - (get-param-as-str parameters) model))) - (begin - (set! history (list hist-entry)) - (set! history-pos 1)))) +(define (execute-command) + (let* ((com (list-ref (buffer-text command-buffer) + (- (length (buffer-text command-buffer)) 1))) + (com-par (extract-com-and-par com)) + (command (car com-par)) + (parameters (cdr com-par)) + ;;todo: parameters + (message (make-next-command-message + command parameters result-cols)) + (model (switch message))) + (if (not (= history-pos 0)) + (let ((hist-entry (make-history-entry active-command + active-parameters + current-result-object)) + (active (make-history-entry command + (get-param-as-str parameters) + model))) + (if (< history-pos (length history)) + (set! history (append history (list hist-entry))) + (set! history (append + (sublist history 0 + (- (length history) 1)) + (list hist-entry) (list active)))) + (set! history-pos (length history))) + (let ((hist-entry (make-history-entry + command + (get-param-as-str parameters) model))) + (set! history (list hist-entry)) + (set! history-pos 1))) - (set-buffer-text! command-buffer - (append (buffer-text command-buffer) - (list ""))) - (set! active-command command) - (set! active-parameters (get-param-as-str parameters)) - (set! current-result-object model) - (scroll-command-buffer))))) + (set-buffer-text! command-buffer + (append (buffer-text command-buffer) + (list ""))) + (set! active-command command) + (set! active-parameters (get-param-as-str parameters)) + (set! current-result-object model) + (scroll-command-buffer))) ;;Extracts the name of the function and its parameters (define extract-com-and-par @@ -784,16 +777,14 @@ ;;Cursor ;;move cursor to the corrct position (define (move-cursor buffer) - (begin - (if (focus-on-command-buffer?) - (cursor-right-pos (app-window-curses-win command-window) - buffer) - (begin - (compute-y-x) - (wmove (app-window-curses-win result-window) - result-buffer-pos-y result-buffer-pos-x) - (wrefresh (app-window-curses-win result-window)) - buffer)))) + (if (focus-on-command-buffer?) + (cursor-right-pos (app-window-curses-win command-window) + buffer) + (begin + (compute-y-x) + (wmove (app-window-curses-win result-window) + result-buffer-pos-y result-buffer-pos-x) + (wrefresh (app-window-curses-win result-window))))) ;;compue pos-x and pos-y (define compute-y-x