Minor code clean-up, fix more redrawing stuff

This commit is contained in:
eknauel 2005-05-17 09:00:33 +00:00
parent 88e805e52a
commit 03ffcf8280
1 changed files with 62 additions and 71 deletions

View File

@ -333,9 +333,9 @@
(make-key-pressed-message active-command (make-key-pressed-message active-command
current-result-object current-result-object
ch))) ch)))
(begin (set! current-result-object (switch key-message))
(set! current-result-object (switch key-message)) (paint-result-window)
(loop (wait-for-input)))) (loop (wait-for-input)))
(cond (cond
@ -344,25 +344,22 @@
(let ((restore-message (make-restore-message (let ((restore-message (make-restore-message
active-command active-command
current-result-object))) current-result-object)))
(begin (switch restore-message)
(switch restore-message) (execute-command)
(execute-command) (set-buffer-history-pos!
(set-buffer-history-pos! command-buffer
command-buffer (- (length (buffer-text command-buffer)) 1))
(- (length (buffer-text command-buffer)) 1)) (paint-result-window)
(paint-result-window) (paint-bar-2)
(paint-bar-2)
(paint-command-window-contents)
(move-cursor command-buffer)
(loop (wait-for-input)))))
(else
(begin
(set! command-buffer (input command-buffer ch))
(paint-command-window-contents) (paint-command-window-contents)
(set! command-buffer (move-cursor command-buffer)
(move-cursor command-buffer)) (loop (wait-for-input))))
(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) (define (window-init-curses-win! window)
(set-app-window-curses-win! (set-app-window-curses-win!
@ -452,47 +449,43 @@
;;If the user presses enter the last line is interpreted as a command ;;If the user presses enter the last line is interpreted as a command
;;which has to be executed. ;;which has to be executed.
(define execute-command (define (execute-command)
(lambda () (let* ((com (list-ref (buffer-text command-buffer)
(let* ((com (list-ref (buffer-text command-buffer) (- (length (buffer-text command-buffer)) 1)))
(- (length (buffer-text command-buffer)) 1))) (com-par (extract-com-and-par com))
(com-par (extract-com-and-par com)) (command (car com-par))
(command (car com-par)) (parameters (cdr com-par))
(parameters (cdr com-par)) ;;todo: parameters
;;todo: parameters (message (make-next-command-message
(message (make-next-command-message command parameters result-cols))
command parameters result-cols)) (model (switch message)))
(model (switch message))) (if (not (= history-pos 0))
(begin (let ((hist-entry (make-history-entry active-command
(if (not (= history-pos 0)) active-parameters
(let ((hist-entry (make-history-entry active-command current-result-object))
active-parameters (active (make-history-entry command
current-result-object)) (get-param-as-str parameters)
(active (make-history-entry command model)))
(get-param-as-str parameters) (if (< history-pos (length history))
model))) (set! history (append history (list hist-entry)))
(begin (set! history (append
(if (< history-pos (length history)) (sublist history 0
(set! history (append history (list hist-entry))) (- (length history) 1))
(set! history (append (list hist-entry) (list active))))
(sublist history 0 (set! history-pos (length history)))
(- (length history) 1)) (let ((hist-entry (make-history-entry
(list hist-entry) (list active)))) command
(set! history-pos (length history)))) (get-param-as-str parameters) model)))
(let ((hist-entry (make-history-entry (set! history (list hist-entry))
command (set! history-pos 1)))
(get-param-as-str parameters) model)))
(begin
(set! history (list hist-entry))
(set! history-pos 1))))
(set-buffer-text! command-buffer (set-buffer-text! command-buffer
(append (buffer-text command-buffer) (append (buffer-text command-buffer)
(list ""))) (list "")))
(set! active-command command) (set! active-command command)
(set! active-parameters (get-param-as-str parameters)) (set! active-parameters (get-param-as-str parameters))
(set! current-result-object model) (set! current-result-object model)
(scroll-command-buffer))))) (scroll-command-buffer)))
;;Extracts the name of the function and its parameters ;;Extracts the name of the function and its parameters
(define extract-com-and-par (define extract-com-and-par
@ -784,16 +777,14 @@
;;Cursor ;;Cursor
;;move cursor to the corrct position ;;move cursor to the corrct position
(define (move-cursor buffer) (define (move-cursor buffer)
(begin (if (focus-on-command-buffer?)
(if (focus-on-command-buffer?) (cursor-right-pos (app-window-curses-win command-window)
(cursor-right-pos (app-window-curses-win command-window) buffer)
buffer) (begin
(begin (compute-y-x)
(compute-y-x) (wmove (app-window-curses-win result-window)
(wmove (app-window-curses-win result-window) result-buffer-pos-y result-buffer-pos-x)
result-buffer-pos-y result-buffer-pos-x) (wrefresh (app-window-curses-win result-window)))))
(wrefresh (app-window-curses-win result-window))
buffer))))
;;compue pos-x and pos-y ;;compue pos-x and pos-y
(define compute-y-x (define compute-y-x