Fixes for the changes in nuit-engine
This commit is contained in:
parent
c405bc02c5
commit
246660a299
|
@ -1,26 +1,5 @@
|
||||||
(define-record-type inspector-state :inspector-state
|
|
||||||
(make-inspector-state val stack header num-cols num-lines selection-list)
|
|
||||||
inspector-state?
|
|
||||||
(val inspector-state-val)
|
|
||||||
(stack inspector-state-stack)
|
|
||||||
(header inspector-state-header)
|
|
||||||
(num-cols inspector-state-num-cols)
|
|
||||||
(num-lines inspector-state-num-lines)
|
|
||||||
(selection-list inspector-state-selection-list))
|
|
||||||
|
|
||||||
(define footer-length 0)
|
(define footer-length 0)
|
||||||
|
|
||||||
(define (make-initial-inspector-state focus-obj num-cols num-lines)
|
|
||||||
(let ((header (make-header focus-obj num-cols)))
|
|
||||||
(make-inspector-state focus-obj
|
|
||||||
'()
|
|
||||||
header
|
|
||||||
num-cols
|
|
||||||
num-lines
|
|
||||||
(make-inspector-selection-list num-cols
|
|
||||||
(- num-lines (length header))
|
|
||||||
focus-obj))))
|
|
||||||
|
|
||||||
(define (make-inspector-selection-list num-cols num-lines focus-obj)
|
(define (make-inspector-selection-list num-cols num-lines focus-obj)
|
||||||
(let ((menu (prepare-menu focus-obj)))
|
(let ((menu (prepare-menu focus-obj)))
|
||||||
(make-select-list
|
(make-select-list
|
||||||
|
@ -35,7 +14,6 @@
|
||||||
(if (exception-continuation? focus-obj)
|
(if (exception-continuation? focus-obj)
|
||||||
"Press cont-down key to see more"
|
"Press cont-down key to see more"
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
|
|
||||||
(define (layout-menu-entry num-cols entry)
|
(define (layout-menu-entry num-cols entry)
|
||||||
(let ((head (format #f "[~a]" (or (car entry) ""))))
|
(let ((head (format #f "[~a]" (or (car entry) ""))))
|
||||||
|
@ -51,58 +29,6 @@
|
||||||
(let ((str (get-output-string out)))
|
(let ((str (get-output-string out)))
|
||||||
(substring str 0 (min (string-length str) max-length)))))
|
(substring str 0 (min (string-length str) max-length)))))
|
||||||
|
|
||||||
(define (inspector-state-exchange-selection-list old-state sl)
|
|
||||||
(make-inspector-state (inspector-state-val old-state)
|
|
||||||
(inspector-state-stack old-state)
|
|
||||||
(inspector-state-header old-state)
|
|
||||||
(inspector-state-num-cols old-state)
|
|
||||||
(inspector-state-num-lines old-state)
|
|
||||||
sl))
|
|
||||||
|
|
||||||
(define (inspector-state-exchange-header-msg old-state msg)
|
|
||||||
(make-inspector-state (inspector-state-val old-state)
|
|
||||||
(inspector-state-stack old-state)
|
|
||||||
(cons (car (inspector-state-header old-state))
|
|
||||||
(list msg))
|
|
||||||
(inspector-state-num-cols old-state)
|
|
||||||
(inspector-state-num-lines old-state)
|
|
||||||
(inspector-state-selection-list old-state)))
|
|
||||||
|
|
||||||
|
|
||||||
(define (inspector-state-push-value state val)
|
|
||||||
(let* ((num-cols (inspector-state-num-cols state))
|
|
||||||
(num-lines (inspector-state-num-lines state))
|
|
||||||
(hdr (make-header val num-cols)))
|
|
||||||
(make-inspector-state val
|
|
||||||
(cons (inspector-state-val state)
|
|
||||||
(inspector-state-stack state))
|
|
||||||
hdr
|
|
||||||
num-cols
|
|
||||||
num-lines
|
|
||||||
(make-inspector-selection-list
|
|
||||||
num-cols
|
|
||||||
(- num-lines (length hdr))
|
|
||||||
val))))
|
|
||||||
|
|
||||||
(define (inspector-state-pop-value state)
|
|
||||||
(let ((stack (inspector-state-stack state))
|
|
||||||
(num-cols (inspector-state-num-cols state))
|
|
||||||
(num-lines (inspector-state-num-lines state)))
|
|
||||||
(if (null? stack)
|
|
||||||
(inspector-state-exchange-header-msg state
|
|
||||||
"Can't go up from here.")
|
|
||||||
(let ((hdr (make-header (car stack) num-cols)))
|
|
||||||
(make-inspector-state (car stack)
|
|
||||||
(cdr stack)
|
|
||||||
hdr
|
|
||||||
num-cols
|
|
||||||
num-lines
|
|
||||||
(make-inspector-selection-list
|
|
||||||
num-cols
|
|
||||||
(- num-lines (length hdr))
|
|
||||||
(car stack)))))))
|
|
||||||
|
|
||||||
|
|
||||||
(define (inspect-value val)
|
(define (inspect-value val)
|
||||||
(error "not yet"))
|
(error "not yet"))
|
||||||
|
|
||||||
|
@ -112,63 +38,66 @@
|
||||||
(define down-key key-d)
|
(define down-key key-d)
|
||||||
(define up-key key-u)
|
(define up-key key-u)
|
||||||
|
|
||||||
(define (inspector-receiver message)
|
(define (make-inspector focus-obj buffer)
|
||||||
(debug-message "inspector-receiver " message)
|
(let* ((num-cols (result-buffer-num-cols buffer))
|
||||||
(cond
|
(num-lines (result-buffer-num-lines buffer))
|
||||||
((init-with-result-message? message)
|
(val focus-obj)
|
||||||
(let* ((focus-obj (init-with-result-message-result message))
|
(stack '())
|
||||||
(buffer (init-with-result-message-buffer message))
|
(header (make-header focus-obj num-cols))
|
||||||
(num-cols (result-buffer-num-cols buffer))
|
(num-cols num-cols)
|
||||||
(num-lines (result-buffer-num-lines buffer)))
|
(num-lines num-lines)
|
||||||
(make-initial-inspector-state focus-obj
|
(selection-list
|
||||||
num-cols
|
(make-inspector-selection-list num-cols
|
||||||
num-lines)))
|
(- num-lines (length header))
|
||||||
((print-message? message)
|
focus-obj)))
|
||||||
(lambda (win result-buffer have-focus?)
|
|
||||||
(let* ((state (message-result-object message))
|
|
||||||
(hdr (inspector-state-header state))
|
|
||||||
(hdr-len (length hdr)))
|
|
||||||
(for-each (lambda (text y)
|
|
||||||
(mvwaddstr win y 0 text))
|
|
||||||
hdr
|
|
||||||
(iota hdr-len))
|
|
||||||
((paint-selection-list-at
|
|
||||||
(inspector-state-selection-list state)
|
|
||||||
0 hdr-len)
|
|
||||||
win result-buffer have-focus?))))
|
|
||||||
|
|
||||||
((key-pressed-message? message)
|
(define (inspect-next-continuation)
|
||||||
(let ((old-state (message-result-object message))
|
(if (continuation? val)
|
||||||
(key (key-pressed-message-key message)))
|
(set! stack (cons stack (continuation-parent val)))
|
||||||
(cond
|
(set! header
|
||||||
((= key down-key)
|
"Can't go down from a non-continuation.")))
|
||||||
(inspect-next-continuation old-state))
|
|
||||||
((= key up-key)
|
|
||||||
(inspector-state-pop-value old-state))
|
|
||||||
(else
|
|
||||||
(let ((old-state (message-result-object message)))
|
|
||||||
(inspector-state-exchange-selection-list
|
|
||||||
old-state
|
|
||||||
(select-list-handle-key-press
|
|
||||||
(inspector-state-selection-list old-state)
|
|
||||||
message)))))))
|
|
||||||
(else
|
|
||||||
(debug-message "did not handle message " message))))
|
|
||||||
|
|
||||||
(define (inspect-next-continuation state)
|
(define (inspector-state-pop-value)
|
||||||
(let ((val (inspector-state-val state)))
|
(if (null? stack)
|
||||||
(if (continuation? val)
|
(set! header "Can't go up from here.")
|
||||||
(inspector-state-push-value state (continuation-parent val))
|
(begin
|
||||||
(inspector-state-exchange-header-msg
|
(set! header (make-header (car stack) num-cols))
|
||||||
state
|
(set! val (car stack))
|
||||||
"Can't go down from a non-continuation."))))
|
(set! stack (cdr stack))
|
||||||
|
(set! selection-list
|
||||||
(define (error-receiver message)
|
(make-inspector-selection-list
|
||||||
(inspector-receiver message))
|
num-cols
|
||||||
|
(- num-lines (length header))
|
||||||
|
val)))))
|
||||||
|
|
||||||
|
(lambda (message)
|
||||||
|
(case message
|
||||||
|
((paint)
|
||||||
|
(lambda (self win result-buffer have-focus?)
|
||||||
|
(let ((hdr-len (length header)))
|
||||||
|
(for-each (lambda (text y)
|
||||||
|
(mvwaddstr win y 0 text))
|
||||||
|
header
|
||||||
|
(iota hdr-len))
|
||||||
|
(paint-selection-list-at
|
||||||
|
selection-list
|
||||||
|
0 hdr-len
|
||||||
|
win result-buffer have-focus?))))
|
||||||
|
|
||||||
|
((key-press)
|
||||||
|
(lambda (self key control-x-pressed?)
|
||||||
|
(cond
|
||||||
|
((= key down-key)
|
||||||
|
(inspect-next-continuation))
|
||||||
|
((= key up-key)
|
||||||
|
(inspector-state-pop-value))
|
||||||
|
(else
|
||||||
|
(set! selection-list
|
||||||
|
(select-list-handle-key-press
|
||||||
|
selection-list key))))
|
||||||
|
self))
|
||||||
|
(else
|
||||||
|
(error "did not handle message " message))))))
|
||||||
|
|
||||||
(register-plugin!
|
(register-plugin!
|
||||||
(make-view-plugin error-receiver exception-continuation?))
|
(make-view-plugin make-inspector exception-continuation?))
|
||||||
|
|
||||||
(register-plugin!
|
|
||||||
(make-view-plugin inspector-receiver inspector-state?))
|
|
||||||
|
|
|
@ -30,22 +30,15 @@
|
||||||
processes)
|
processes)
|
||||||
num-lines)))
|
num-lines)))
|
||||||
|
|
||||||
(define (make-pps-viewer)
|
(define (make-pps-viewer processes buffer)
|
||||||
(let ((processes #f)
|
(let ((processes processes)
|
||||||
(select-list #f))
|
(select-list
|
||||||
|
(make-process-selection-list
|
||||||
|
(result-buffer-num-cols buffer)
|
||||||
|
(result-buffer-num-lines buffer)
|
||||||
|
processes)))
|
||||||
(lambda (message)
|
(lambda (message)
|
||||||
(cond
|
(cond
|
||||||
|
|
||||||
((eq? message 'init)
|
|
||||||
(lambda (self process-list buffer)
|
|
||||||
(let ((num-cols (result-buffer-num-cols buffer))
|
|
||||||
(num-lines (result-buffer-num-lines buffer)))
|
|
||||||
(set! processes process-list)
|
|
||||||
(set! select-list
|
|
||||||
(make-process-selection-list
|
|
||||||
num-cols num-lines processes))
|
|
||||||
self)))
|
|
||||||
|
|
||||||
((eq? message 'paint)
|
((eq? message 'paint)
|
||||||
(lambda (self . args)
|
(lambda (self . args)
|
||||||
(apply paint-selection-list
|
(apply paint-selection-list
|
||||||
|
|
|
@ -1,21 +1,12 @@
|
||||||
(define (make-standard-viewer)
|
(define (make-standard-viewer value buffer)
|
||||||
(let ((x 1)
|
(let ((x 1)
|
||||||
(y 1)
|
(y 1)
|
||||||
(text "")
|
(value value)
|
||||||
(value #f))
|
(text (layout-result-standard
|
||||||
|
(exp->string value)
|
||||||
|
(result-buffer-num-cols buffer))))
|
||||||
(lambda (message)
|
(lambda (message)
|
||||||
(cond
|
(cond
|
||||||
|
|
||||||
((eq? message 'init)
|
|
||||||
(lambda (self new-value buffer)
|
|
||||||
(set! value new-value)
|
|
||||||
(set! text
|
|
||||||
(layout-result-standard
|
|
||||||
(exp->string value)
|
|
||||||
(result-buffer-num-cols buffer)))
|
|
||||||
self))
|
|
||||||
|
|
||||||
((eq? message 'paint)
|
((eq? message 'paint)
|
||||||
(lambda (self win buffer have-focus?)
|
(lambda (self win buffer have-focus?)
|
||||||
;; #### get rid of this cruft
|
;; #### get rid of this cruft
|
||||||
|
|
Loading…
Reference in New Issue