select the plug-in for viewing a result by it's type. Currently only

works with processes.
This commit is contained in:
eknauel 2005-05-22 09:20:44 +00:00
parent 783bad745a
commit 87f701f59d
3 changed files with 319 additions and 291 deletions

View File

@ -1,5 +1,11 @@
;; ,load /home/demattia/studium/studienarbeit/scsh-nuit/scheme/nuit-engine.scm ;; ,load /home/demattia/studium/studienarbeit/scsh-nuit/scheme/nuit-engine.scm
(define-syntax when
(syntax-rules ()
((_ ?test ?do-this ...)
(if ?test
(begin ?do-this ... (values))
(values)))))
;;This is the "heart" of NUIT. ;;This is the "heart" of NUIT.
;;In a central loop the program waits for input (with wgetch). ;;In a central loop the program waits for input (with wgetch).
@ -28,7 +34,7 @@
(w ,(app-window-width rec)) (h ,(app-window-height rec))))) (w ,(app-window-width rec)) (h ,(app-window-height rec)))))
(define bar-1 #f) (define bar-1 #f)
(define bar-2 #f) (define active-command-window #f)
(define command-frame-window #f) (define command-frame-window #f)
(define command-window #f) (define command-window #f)
@ -50,6 +56,9 @@
"Ctrl+e:End of Line" "Ctrl+e:End of Line"
"Ctrl+k:Delete Line")) "Ctrl+k:Delete Line"))
(define key-control-x 24)
(define key-o 111)
;;state of the upper window (Command-Window) ;;state of the upper window (Command-Window)
(define command-buffer (define command-buffer
(make-buffer '("Welcome to the scsh-ncurses-ui!" "") (make-buffer '("Welcome to the scsh-ncurses-ui!" "")
@ -106,30 +115,72 @@
(define (focus-result-buffer!) (define (focus-result-buffer!)
(set! *focus-buffer* 'result-buffer)) (set! *focus-buffer* 'result-buffer))
;;History ;; History
(define history '())
;;Position in the "elaborated" History
(define history-pos 0) (define history-pos 0)
(define the-history (make-empty-history))
;;data-type for history.entries (define (history) the-history)
(define-record-type history-entry history-entry
(make-history-entry command (define *current-history-item* #f)
parameters
result-object) (define (current-history-item)
*current-history-item*)
(define-record-type history-entry :history-entry
(make-history-entry command args result receiver)
history-entry? history-entry?
(command history-entry-command) (command history-entry-command)
(parameters history-entry-parameters) (args history-entry-args)
(result-object history-entry-result-object)) (result history-entry-result set-history-entry-result!)
(receiver history-entry-receiver))
;;active command (define (current-history-entry-selector-maker selector)
(define active-command "") (lambda ()
(cond
((current-history-item)
=> (lambda (entry)
(selector (entry-data entry))))
(else #f))))
;;sctive parameters (define active-command
(define active-parameters "") (current-history-entry-selector-maker history-entry-command))
;;active result-object (define active-command-arguments
(define current-result-object) (current-history-entry-selector-maker history-entry-args))
(define current-result
(current-history-entry-selector-maker history-entry-result))
(define (update-current-result! new-value)
(cond
((current-history-item)
=> (lambda (entry)
(set-history-entry-result! (entry-data) new-value)))
(else (values))))
(define (append-to-history! history-entry)
(append-history-item! the-history history-entry)
(set! *current-history-item*
(history-last-entry the-history)))
;; one step back in the history
(define (history-back!)
(cond
((and (current-history-item)
(history-prev-entry (current-history-item)))
=> (lambda (prev)
(set! *current-history-item* prev)))
(else (values))))
;; one step forward
(define (history-forward!)
(cond
((and *current-history-item*
(history-next-entry *current-history-item*))
=> (lambda (next)
(set! *current-history-item* next)))
(else (values))))
;;active keyboard-interrupt: ;;active keyboard-interrupt:
;;after each input this is set to #f. ;;after each input this is set to #f.
@ -159,11 +210,12 @@
(define-record-type key-pressed-message :key-pressed-message (define-record-type key-pressed-message :key-pressed-message
(make-key-pressed-message command-string (make-key-pressed-message command-string
result-object result-object
key) key prefix-key)
key-pressed-message? key-pressed-message?
(command-string key-pressed-command-string) (command-string key-pressed-command-string)
(result-object key-pressed-message-result-object) (result-object key-pressed-message-result-object)
(key key-pressed-message-key)) (key key-pressed-message-key)
(prefix-key key-pressed-message-prefix-key))
;;print ;;print
(define-record-type print-message :print-message (define-record-type print-message :print-message
@ -182,6 +234,7 @@
text text
highlighted-lines highlighted-lines
marked-lines) marked-lines)
print-object?
(pos-y print-object-pos-y) (pos-y print-object-pos-y)
(pos-x print-object-pos-x) (pos-x print-object-pos-x)
(text print-object-text) (text print-object-text)
@ -239,10 +292,17 @@
;;about which function is meant to be the receiver, when a certain ;;about which function is meant to be the receiver, when a certain
;;command is active ;;command is active
(define-record-type receiver :receiver (define-record-type receiver :receiver
(make-receiver command rec) (really-make-receiver command rec type-predicate)
receiver? receiver?
(command receiver-command) (command receiver-command)
(rec receiver-rec)) (rec receiver-rec)
(type-predicate receiver-type-predicate))
(define (make-receiver command rec . more)
(really-make-receiver command rec
(if (null? more)
(lambda (v) #f)
(car more))))
;;This list contains all the receivers that have been registered. ;;This list contains all the receivers that have been registered.
(define receivers '()) (define receivers '())
@ -270,7 +330,17 @@
#t))) #t)))
run)) run))
;;handle input (define (toggle-buffer-focus)
(cond
((focus-on-command-buffer?)
(focus-result-buffer!)
(refresh-result-window))
(else
(focus-command-buffer!)
(move-cursor command-buffer)
(refresh-command-window))))
;; handle input
(define (run) (define (run)
(init-windows!) (init-windows!)
@ -280,160 +350,88 @@
;;Loop ;;Loop
(paint) (paint)
(let loop ((ch (wait-for-input))) (let loop ((ch (wait-for-input)) (c-x-pressed? #f))
(cond (cond
;;The result of pressing these keys is independent of which
;;Buffer is active ;; Ctrl-x -> wait for next input
;;Finish ((= ch key-control-x)
(loop (wait-for-input) #t))
;; C-x o --- toggle buffer focus
((and c-x-pressed? (= ch key-o))
(toggle-buffer-focus)
(loop (wait-for-input) #f))
((and c-x-pressed? (focus-on-result-buffer?))
(let ((key-message
(make-key-pressed-message
(active-command) (current-result)
ch key-control-x)))
(update-current-result!
(post-message
(history-entry-receiver (entry-data (current-history-item)))
key-message))
(loop (wait-for-input) #f)))
;; C-x r --- redo
((and c-x-pressed? (focus-on-command-buffer?)
(= ch 114))
(debug-message "Eric should re-implement redo..."))
((= ch key-f1) ((= ch key-f1)
(begin (endwin))
(let ((restore-message (make-restore-message
active-command
current-result-object)))
(switch restore-message)
(restore-state))
(endwin)
(display "")))
((= ch key-f2) ((= ch key-f2)
(endwin)
(run))
;;Ctrl-x -> wait for next input
((= ch 24)
(begin
(set! c-x-pressed (not c-x-pressed))
(if (focus-on-result-buffer?)
(let ((key-message
(make-key-pressed-message active-command
current-result-object
ch)))
(set! current-result-object (switch key-message))))
(paint) (paint)
(loop (wait-for-input)))) (loop (wait-for-input) c-x-pressed?))
((= ch 35)
(error "Is this what you want?"))
;; forward in result history ;; forward in result history
((= ch key-npage) ((= ch key-npage)
(history-forward) (history-forward!)
(paint-result-window) (when (current-history-item)
(paint-active-command-window)
(paint-result-window (entry-data (current-history-item))))
(refresh-result-window) (refresh-result-window)
(loop (wait-for-input))) (loop (wait-for-input) c-x-pressed?))
;; back in result history ;; back in result history
((= ch key-ppage) ((= ch key-ppage)
(history-back) (history-back!)
(paint-result-window) (when (current-history-item)
(paint-active-command-window)
(paint-result-window (entry-data (current-history-item))))
(refresh-result-window) (refresh-result-window)
(loop (wait-for-input))) (loop (wait-for-input) c-x-pressed?))
;;if lower window is active a message is sent.
(else
(if c-x-pressed
(cond
;;Ctrl-x o ->switch buffer
((= ch 111)
(if (focus-on-command-buffer?)
(let ((key-message
(make-key-pressed-message active-command
current-result-object
97)))
(focus-result-buffer!)
(set! current-result-object (switch key-message))
(paint-result-window)
(refresh-result-window))
(begin
(focus-command-buffer!)
(paint-command-window-contents)
(move-cursor command-buffer)))
(set! c-x-pressed #f)
(loop (wait-for-input)))
;;C-x r -> redo
((= ch 114)
(if (or (> (length (buffer-text command-buffer)) 2)
(not (equal? active-command "")))
(let ((command-string (string-append active-command
active-parameters))
(text (sublist (buffer-text command-buffer) 0
(- (length (buffer-text command-buffer)) 1))))
(begin
;; is this correct?
(switch (make-restore-message
command-string
current-result-object))
(set-buffer-text! (append text (list command-string)))
(execute-command)
(set-buffer-history-pos! command-buffer
(- (length (buffer-text command-buffer)) 1))
(set! c-x-pressed #f)
(endwin)
(run)))
(begin
(set! c-x-pressed #f)
(loop (wait-for-input)))))
(else
(begin
(if (focus-on-result-buffer?)
(let ((key-message
(make-key-pressed-message active-command
current-result-object
ch)))
(set! current-result-object (switch key-message)))
(if (= ch 115)
(let* ((message
(make-selection-message
active-command current-result-object))
(marked-items (switch message)))
(add-string-to-command-buffer marked-items))))
(set! c-x-pressed #f)
(loop (wait-for-input)))))
(if (focus-on-result-buffer?)
(let ((key-message
(make-key-pressed-message active-command
current-result-object
ch)))
(set! current-result-object (switch key-message))
(paint-result-window)
(refresh-result-window)
(loop (wait-for-input)))
(cond
;;Enter
((= ch 10) ((= ch 10)
(let ((restore-message (make-restore-message (let ((command (last (buffer-text command-buffer))))
active-command (call-with-values
current-result-object))) (lambda ()
(switch restore-message) (execute-command command))
(execute-command) (lambda (result receiver)
(set-buffer-history-pos! (let ((new-entry
command-buffer (make-history-entry command '()
(- (length (buffer-text command-buffer)) 1)) result receiver)))
(paint-result-window) (append-to-history! new-entry)
(refresh-result-window) (buffer-text-append-new-line! command-buffer)
(paint-bar-2) (paint-result-window new-entry)
(paint-active-command-window)
(scroll-command-buffer)
(paint-command-window-contents) (paint-command-window-contents)
(move-cursor command-buffer) (move-cursor command-buffer)
(refresh-result-window)
(refresh-command-window) (refresh-command-window)
(loop (wait-for-input)))) (loop (wait-for-input) c-x-pressed?))))))
(else (else
(input command-buffer ch) (input command-buffer ch)
;(debug-message "loop after input " command-buffer)
(werase (app-window-curses-win command-window)) (werase (app-window-curses-win command-window))
(print-command-buffer (app-window-curses-win command-window) (print-command-buffer (app-window-curses-win command-window)
command-buffer) command-buffer)
;(debug-message "loop after print-command-buffer " command-buffer) ;;(debug-message "loop after print-command-buffer " command-buffer)
(move-cursor command-buffer) (move-cursor command-buffer)
(refresh-command-window) (refresh-command-window)
(loop (wait-for-input)))))))))) (loop (wait-for-input) c-x-pressed?)))))
(define (window-init-curses-win! window) (define (window-init-curses-win! window)
(set-app-window-curses-win! (set-app-window-curses-win!
@ -454,30 +452,31 @@
(make-app-window 1 1 (make-app-window 1 1
(- (COLS) 2) 2 (- (COLS) 2) 2
#f)) #f))
(set! bar-2 (set! active-command-window
(make-app-window 1 (+ (round (/ (LINES) 3)) 2) (make-app-window 1 (+ (round (/ (LINES) 3)) 2)
(- (COLS) 2) 3 (- (COLS) 2) 3
#f)) #f))
(set! command-frame-window (set! command-frame-window
(make-app-window 1 2 (make-app-window 1 2
(- (COLS) 2) (- (app-window-y bar-2) 2) (- (COLS) 2) (- (app-window-y active-command-window) 2)
#f)) #f))
(set! command-window (set! command-window
(make-inlying-app-window command-frame-window)) (make-inlying-app-window command-frame-window))
(set! result-frame-window (set! result-frame-window
(make-app-window 1 (+ (app-window-y bar-2) 3) (make-app-window 1 (+ (app-window-y active-command-window) 3)
(- (COLS) 2) (- (COLS) 2)
(- (- (LINES) 6) (app-window-height command-frame-window)) (- (- (LINES) 6) (app-window-height command-frame-window))
#f)) #f))
(set! result-window (set! result-window
(make-inlying-app-window result-frame-window)) (make-inlying-app-window result-frame-window))
(let ((all-windows (list bar-1 bar-2 (let ((all-windows (list bar-1 active-command-window
command-frame-window command-window command-frame-window command-window
result-frame-window result-window))) result-frame-window result-window)))
(for-each window-init-curses-win! all-windows) (for-each window-init-curses-win! all-windows)
(debug-message "init-windows!: bar-1 " bar-1 " bar-2 " bar-2 (debug-message "init-windows!: bar-1 " bar-1
" active-command-window " active-command-window
" command-frame-window " command-frame-window " command-frame-window " command-frame-window
" command-window " command-window " command-window " command-window
" result-frame-window " result-frame-window " result-frame-window " result-frame-window
@ -490,11 +489,6 @@
(mvwaddstr (app-window-curses-win bar-1) 0 1 "SCSH-NUIT") (mvwaddstr (app-window-curses-win bar-1) 0 1 "SCSH-NUIT")
(wrefresh (app-window-curses-win bar-1))) (wrefresh (app-window-curses-win bar-1)))
(define (paint-bar-2)
(box (app-window-curses-win bar-2) (ascii->char 0) (ascii->char 0))
(print-active-command-win (app-window-curses-win bar-2)
(app-window-width bar-2)))
(define (paint-command-frame-window) (define (paint-command-frame-window)
(box (app-window-curses-win command-frame-window) (box (app-window-curses-win command-frame-window)
(ascii->char 0) (ascii->char 0)) (ascii->char 0) (ascii->char 0))
@ -521,9 +515,15 @@
(set! result-cols (- (app-window-width result-window) 3)) (set! result-cols (- (app-window-width result-window) 3))
(wrefresh win))) (wrefresh win)))
(define (paint-result-window) (define (paint-result-window entry)
(wclear (app-window-curses-win result-window)) (wclear (app-window-curses-win result-window))
(print-result-buffer)) (paint-result-buffer
(post-message
(or (history-entry-receiver entry)
(determine-receiver-by-command (history-entry-command entry)))
(make-print-message (history-entry-command entry)
(history-entry-result entry)
(buffer-num-cols command-buffer)))))
(define (refresh-result-window) (define (refresh-result-window)
(wrefresh (app-window-curses-win result-window))) (wrefresh (app-window-curses-win result-window)))
@ -531,11 +531,11 @@
(define (paint) (define (paint)
(debug-message "paint") (debug-message "paint")
(paint-bar-1) (paint-bar-1)
(paint-bar-2)
(paint-command-frame-window) (paint-command-frame-window)
(paint-command-window-contents) (paint-command-window-contents)
(paint-active-command-window)
(paint-result-frame-window) (paint-result-frame-window)
(paint-result-window) ;(paint-result-window)
(move-cursor command-buffer) (move-cursor command-buffer)
(refresh-command-window) (refresh-command-window)
(refresh-result-window)) (refresh-result-window))
@ -548,9 +548,20 @@
(echo) (echo)
ch)) ch))
;;If the user presses enter the last line is interpreted as a command (define (execute-command command)
;;which has to be executed. (let ((result (evaluate command)))
(define (execute-command) (cond
((determine-receiver-by-type result)
=> (lambda (receiver)
(values result receiver)))
(else
(values
(post-message standard-receiver
(make-next-command-message
command '() (buffer-num-cols command-buffer)))
standard-receiver)))))
'(define (execute-command)
(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))
@ -559,14 +570,25 @@
;;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 (post-message
(determine-receiver-by-command command)
message)))
(debug-message 'execute-command
com " " com-par )
(if (not (= history-pos 0)) (if (not (= history-pos 0))
(let ((hist-entry (make-history-entry active-command (let ((hist-entry (make-history-entry (active-command)
active-parameters (active-command-arguments)
current-result-object)) (current-result)))
;; hack of year
(active (make-history-entry command (active (make-history-entry command
(get-param-as-str parameters) (get-param-as-str parameters)
model))) (if (standard-result-obj? model)
(standard-result-obj-result model)
model)
(and (standard-result-obj? model)
(determine-receiver-by-type
(standard-result-obj-result model))))))
(if (< history-pos (length history)) (if (< history-pos (length history))
(set! history (append history (list hist-entry))) (set! history (append history (list hist-entry)))
(set! history (append (set! history (append
@ -585,7 +607,7 @@
(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) 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
@ -651,32 +673,35 @@
(+ (buffer-pos-line command-buffer) 1)) (+ (buffer-pos-line command-buffer) 1))
(set-buffer-pos-col! command-buffer 2)) (set-buffer-pos-col! command-buffer 2))
;;evaluate an expression given as a string (define (init-evaluation-environment package)
(define (evaluate exp) (let ((structure (reify-structure package)))
(let* ((command-port (open-input-string exp)) (load-structure structure)
(handler (lambda (condition more) (rt-structure->environment structure)))
(cons 'Error: condition)))
(structure (reify-structure 'scheme-with-scsh))
(s (load-structure structure))
(env (rt-structure->environment structure))
(result (with-fatal-error-handler
handler
(eval (read command-port) env))))
result))
;;Message-Passing (define (read-sexp-from-string string)
;;switch manages that the messages are delivered in the correct way (let ((string-port (open-input-string string)))
(define (switch message) (read string-port)))
(cond
((get-receiver (message-command-string message))
=> (lambda (receiver)
((receiver-rec receiver) message)))
(else
(standard-receiver message))))
(define (get-receiver command) (define evaluate
(find (lambda (r) (let ((env (init-evaluation-environment 'nuit-eval-structure)))
(lambda (exp)
(with-fatal-error-handler
(lambda (condition more)
(cons 'error condition))
(eval (read-sexp-from-string exp) env)))))
(define (post-message receiver message)
((receiver-rec receiver) message))
(define (determine-receiver-by-command command)
(or (find (lambda (r)
(string=? (receiver-command r) command)) (string=? (receiver-command r) command))
receivers)
standard-receiver))
(define (determine-receiver-by-type result)
(find (lambda (r)
((receiver-type-predicate r) result))
receivers)) receivers))
;;Management of the upper buffer ;;Management of the upper buffer
@ -708,7 +733,6 @@
(add-to-command-buffer (char->ascii first-ch)) (add-to-command-buffer (char->ascii first-ch))
(loop (substring str 1 (string-length str))))))) (loop (substring str 1 (string-length str)))))))
;;selection of the visible area of the buffer ;;selection of the visible area of the buffer
(define (prepare-lines l height pos) (define (prepare-lines l height pos)
(if (< (length l) height) (if (< (length l) height)
@ -720,38 +744,40 @@
(sublist l 0 height) (sublist l 0 height)
(sublist l (- pos height) height)))) (sublist l (- pos height) height))))
;;print the active-command window: ;;; FIXME: I guess s48 knows a better way to do this (see ,inspect)
(define (print-active-command-win win width) (define (maybe-shorten-string string width)
(if (<= width 25) (if (> (string-length string) width)
(values) (string-append (substring string 0 (- width 3))
(let ((active-command (string-append active-command "...")
active-parameters))) string))
(if (> (string-length active-command) (- width 25))
(let* ((com-txt (substring active-command
0
(- width 25)))
(whole-text (string-append "Active Command: "
com-txt
"...")))
(mvwaddstr win 1 2 whole-text)
(wrefresh win))
(begin
(mvwaddstr win 1 2 (string-append "Active Command: "
active-command))
(wrefresh win))))))
;;print the lower window (define (paint-active-command-window)
(define (print-result-buffer) (let ((win (app-window-curses-win active-command-window))
(width (app-window-width active-command-window)))
(wclear win)
(box win (ascii->char 0) (ascii->char 0))
(cond
((current-history-item)
=> (lambda (entry)
(mvwaddstr win 1 2
(maybe-shorten-string
(history-entry-command (entry-data entry)) width)))))
(wrefresh win)))
(define (post-print-message command result-object)
(post-message
(determine-receiver-by-command command)
(make-print-message command result-object
(buffer-num-cols command-buffer))))
(define (paint-result-buffer print-object)
(debug-message "paint-result-buffer ")
(let* ((window (app-window-curses-win result-window)) (let* ((window (app-window-curses-win result-window))
(print-message (make-print-message active-command (text (print-object-text print-object))
current-result-object (pos-y (print-object-pos-y print-object))
(buffer-num-cols command-buffer))) (pos-x (print-object-pos-x print-object))
(model (switch print-message)) (highlighted-lns (print-object-highlighted-lines print-object))
(text (print-object-text model)) (marked-lns (print-object-marked-lines print-object)))
(pos-y (print-object-pos-y model))
(pos-x (print-object-pos-x model))
(highlighted-lns (print-object-highlighted-lines model))
(marked-lns (print-object-marked-lines model)))
(set! text-result text) (set! text-result text)
(set! pos-result pos-y) (set! pos-result pos-y)
(set! pos-result-col pos-x) (set! pos-result-col pos-x)
@ -765,7 +791,7 @@
(values) (values)
(let ((line (list-ref lines (- pos 1)))) (let ((line (list-ref lines (- pos 1))))
(begin (begin
(if (not (standard-result-obj? current-result-object)) (if (not (standard-result-obj? (current-result)))
(set! line (set! line
(if (> (string-length line) result-cols) (if (> (string-length line) result-cols)
(let ((start-line (let ((start-line
@ -902,35 +928,6 @@
; (mvwaddstr bar3 2 (+ used-width 1) last-string)) ; (mvwaddstr bar3 2 (+ used-width 1) last-string))
; (wrefresh bar3))))))))) ; (wrefresh bar3)))))))))
;; one step back in the history
(define (history-back)
(if (<= history-pos 0)
(values)
(let* ((hist-entry (list-ref history (- history-pos 1)))
(entry-com (history-entry-command hist-entry))
(entry-par (history-entry-parameters hist-entry))
(entry-res-obj (history-entry-result-object hist-entry)))
(set! active-command entry-com)
(set! active-parameters entry-par)
(set! current-result-object entry-res-obj)
(if (> history-pos 1)
(set! history-pos (- history-pos 1))))))
;;one step forward
(define (history-forward)
(if (> history-pos (- (length history) 1))
(values)
(let* ((hist-entry (list-ref history history-pos))
(entry-com (history-entry-command hist-entry))
(entry-par (history-entry-parameters hist-entry))
(entry-res-obj (history-entry-result-object hist-entry)))
(set! active-command entry-com)
(set! active-parameters entry-par)
(set! current-result-object entry-res-obj)
(set! history-pos (+ history-pos 1)))))
(define (sublist l pos k) (define (sublist l pos k)
(let ((tmp (list-tail l pos))) (let ((tmp (list-tail l pos)))
(reverse (list-tail (reverse tmp) (reverse (list-tail (reverse tmp)
@ -950,9 +947,6 @@
(set! marked-lines '()) (set! marked-lines '())
(set! history '()) (set! history '())
(set! history-pos 0) (set! history-pos 0)
(set! active-command "")
(set! active-parameters "")
(set! current-result-object init-std-res)
(set! active-keyboard-interrupt #f)) (set! active-keyboard-interrupt #f))
;;Shortcuts-receiver: ;;Shortcuts-receiver:
@ -1001,22 +995,16 @@
(define init-std-res (make-standard-result-obj 1 1 text-result (define init-std-res (make-standard-result-obj 1 1 text-result
(car text-result))) (car text-result)))
(set! current-result-object init-std-res)
;;Standard-Receiver: ;;Standard-Receiver:
(define (standard-receiver message) (define (standard-receiver-rec message)
(cond (cond
((next-command-message? message) ((next-command-message? message)
(let* ((command (next-command-string message)) (let* ((result (evaluate (message-command-string message)))
(result (evaluate command))
(result-string (exp->string result)) (result-string (exp->string result))
(width (next-command-message-width message))) (width (next-command-message-width message))
(let* ((text (text (layout-result-standard result-string result width))
(layout-result-standard result-string result width)) (std-obj (make-standard-result-obj 1 1 text result)))
(std-obj std-obj))
(make-standard-result-obj 1 1 text result)))
std-obj)))
((print-message? message) ((print-message? message)
(let* ((model (message-result-object message)) (let* ((model (message-result-object message))
(pos-y (standard-result-obj-cur-pos-y model)) (pos-y (standard-result-obj-cur-pos-y model))
@ -1033,6 +1021,9 @@
((selection-message? message) ((selection-message? message)
""))) "")))
(define standard-receiver
(make-receiver #f standard-receiver-rec))
;;the result is the "answer" of scsh ;;the result is the "answer" of scsh
(define (layout-result-standard result-str result width) (define (layout-result-standard result-str result width)
(reverse (seperate-line result-str width))) (reverse (seperate-line result-str width)))

View File

@ -1,3 +1,33 @@
;;; history data structure
(define-interface history-interface
(export make-empty-history
history?
entry?
entry-data
append-history-item!
insert-history-item!
history-next-entry
history-prev-entry
history-first-entry
history-last-entry))
(define-structure history history-interface
(open scheme
define-record-types)
(files history))
;;; nuit evaluates the expressions entered into command buffer in this
;;; package
(define-structure nuit-eval-structure (export)
(open scheme-with-scsh
srfi-1
pps)
(begin))
;;; nuit
(define-interface nuit-interface (define-interface nuit-interface
(export nuit)) (export nuit))
@ -16,7 +46,8 @@
inspect-exception inspect-exception
rt-modules rt-modules
tty-debug tty-debug
pps) pps
history)
(files nuit-engine (files nuit-engine
handle-fatal-error handle-fatal-error
directory-files directory-files
@ -26,3 +57,6 @@
browse-list browse-list
process)) process))

View File

@ -1,3 +1,7 @@
(define (list-of-processes? thing)
(and (proper-list? thing)
(every process-info? thing)))
(define (print-processes processes) (define (print-processes processes)
(map (lambda (pi) (map (lambda (pi)
(apply format (apply format
@ -14,6 +18,7 @@
processes)) processes))
(define (pps-receiver message) (define (pps-receiver message)
(debug-message "pps-receiver " message)
(cond (cond
((next-command-message? message) ((next-command-message? message)
(pps)) (pps))
@ -28,9 +33,7 @@
((selection-message? message) ((selection-message? message)
"'()"))) "'()")))
(set! receivers (cons (make-receiver "ps" pps-receiver) (set! receivers (cons (make-receiver "ps" pps-receiver
list-of-processes?)
receivers)) receivers))