data tape inspector works like cli (only shows end state)
This commit is contained in:
parent
16394ebd9e
commit
38823db6da
2 changed files with 18 additions and 17 deletions
34
gui.rkt
34
gui.rkt
|
@ -64,6 +64,8 @@
|
||||||
(execute-content
|
(execute-content
|
||||||
(lambda (ps)
|
(lambda (ps)
|
||||||
(define out (prog-state-output ps))
|
(define out (prog-state-output ps))
|
||||||
|
; update data tape inspector
|
||||||
|
(make-tape-cells ps)
|
||||||
; set output and change color to ended
|
; set output and change color to ended
|
||||||
(send RUN-OUTPUT set-value out)
|
(send RUN-OUTPUT set-value out)
|
||||||
(send RUN-OUTPUT set-field-background end-col))))
|
(send RUN-OUTPUT set-field-background end-col))))
|
||||||
|
@ -168,34 +170,32 @@
|
||||||
[style (list 'auto-hscroll)]
|
[style (list 'auto-hscroll)]
|
||||||
[stretchable-height #f]))
|
[stretchable-height #f]))
|
||||||
|
|
||||||
; make-cell: Number String Boolean -> Canvas
|
; make-cell: Nat Byte Boolean -> Canvas
|
||||||
|
; Given a cell index, the cell contents, and a boolean set to #t when the cell
|
||||||
|
; is pointed by the data pointer, returns the rendered cell as a Canvas.
|
||||||
(define (make-cell index content hl)
|
(define (make-cell index content hl)
|
||||||
(new canvas%
|
(new canvas%
|
||||||
[parent tape-panel]
|
[parent tape-panel]
|
||||||
[min-height 50]
|
[min-height 50]
|
||||||
[min-width 50]
|
[min-width 50]
|
||||||
|
[stretchable-width #f]
|
||||||
[stretchable-height #f]
|
[stretchable-height #f]
|
||||||
[label (string-append (number->string index) ":")]
|
[label (string-append (number->string index) ":")]
|
||||||
[paint-callback
|
[paint-callback
|
||||||
(lambda (c dc)
|
(lambda (c dc)
|
||||||
(send c set-canvas-background (if hl end-col run-col))
|
(send c set-canvas-background (if hl end-col run-col))
|
||||||
(send dc draw-text (send c get-label) 12.5 5)
|
(send dc draw-text (send c get-label) 12.5 10)
|
||||||
(send dc draw-text content 12.5 25))]))
|
(send dc draw-text content 12.5 30))]))
|
||||||
|
|
||||||
(make-cell 0 "000" #f)
|
; make-tape-cells: ProgState -> _
|
||||||
(make-cell 1 "255" #t)
|
; Given a ProgState, empties the data tape inspector and creates the
|
||||||
(make-cell 2 "100" #f)
|
; corresponding cells as canvasas in the tape inspector.
|
||||||
(make-cell 300000000 "100" #f)
|
(define (make-tape-cells ps)
|
||||||
(make-cell 4 "100" #f)
|
(define dt (prog-state-tape ps))
|
||||||
(make-cell 5 "100" #f)
|
(send tape-panel change-children (lambda (_) '()))
|
||||||
(make-cell 6 "100" #f)
|
(for ([i (in-range 0 (prog-state-tape-len ps))]
|
||||||
(make-cell 7 "100" #f)
|
[tp dt])
|
||||||
(make-cell 8 "100" #f)
|
(make-cell i (number->string tp) (= i (prog-state-dp ps)))))
|
||||||
(make-cell 9 "100" #f)
|
|
||||||
(make-cell 10 "100" #f)
|
|
||||||
(make-cell 11 "100" #f)
|
|
||||||
(make-cell 12 "100" #f)
|
|
||||||
(make-cell 13 "100" #f)
|
|
||||||
|
|
||||||
; The input horizontal panel
|
; The input horizontal panel
|
||||||
(define input-panel
|
(define input-panel
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
(provide prog-state
|
(provide prog-state
|
||||||
prog-state?
|
prog-state?
|
||||||
prog-state-tape
|
prog-state-tape
|
||||||
|
prog-state-tape-len
|
||||||
prog-state-dp
|
prog-state-dp
|
||||||
prog-state-output
|
prog-state-output
|
||||||
prog-state-program
|
prog-state-program
|
||||||
|
|
Loading…
Reference in a new issue