make eval look whether the command is evaluated in command oder scheme

mode
This commit is contained in:
eknauel 2005-05-23 13:22:16 +00:00
parent 75500100b3
commit 9a038dc356
1 changed files with 37 additions and 20 deletions

View File

@ -234,6 +234,32 @@
(move-cursor command-buffer) (move-cursor command-buffer)
(refresh-command-window)) (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 ;; handle input
(define (run) (define (run)
@ -303,26 +329,8 @@
(loop (wait-for-input) c-x-pressed?)) (loop (wait-for-input) c-x-pressed?))
((= ch 10) ((= ch 10)
(let ((command (last (buffer-text command-buffer)))) (handle-return-key)
(if (not (string=? command "")) (loop (wait-for-input) c-x-pressed?))
(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))))
(else (else
(cond (cond
@ -457,6 +465,15 @@
(define (refresh-result-window) (define (refresh-result-window)
(wrefresh (app-window-curses-win 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) (define (paint)
(debug-message "paint") (debug-message "paint")
(paint-bar-1) (paint-bar-1)