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
|
||||
(lambda (ps)
|
||||
(define out (prog-state-output ps))
|
||||
; update data tape inspector
|
||||
(make-tape-cells ps)
|
||||
; set output and change color to ended
|
||||
(send RUN-OUTPUT set-value out)
|
||||
(send RUN-OUTPUT set-field-background end-col))))
|
||||
|
@ -168,34 +170,32 @@
|
|||
[style (list 'auto-hscroll)]
|
||||
[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)
|
||||
(new canvas%
|
||||
[parent tape-panel]
|
||||
[min-height 50]
|
||||
[min-width 50]
|
||||
[stretchable-width #f]
|
||||
[stretchable-height #f]
|
||||
[label (string-append (number->string index) ":")]
|
||||
[paint-callback
|
||||
(lambda (c dc)
|
||||
(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 content 12.5 25))]))
|
||||
(send dc draw-text (send c get-label) 12.5 10)
|
||||
(send dc draw-text content 12.5 30))]))
|
||||
|
||||
(make-cell 0 "000" #f)
|
||||
(make-cell 1 "255" #t)
|
||||
(make-cell 2 "100" #f)
|
||||
(make-cell 300000000 "100" #f)
|
||||
(make-cell 4 "100" #f)
|
||||
(make-cell 5 "100" #f)
|
||||
(make-cell 6 "100" #f)
|
||||
(make-cell 7 "100" #f)
|
||||
(make-cell 8 "100" #f)
|
||||
(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)
|
||||
; make-tape-cells: ProgState -> _
|
||||
; Given a ProgState, empties the data tape inspector and creates the
|
||||
; corresponding cells as canvasas in the tape inspector.
|
||||
(define (make-tape-cells ps)
|
||||
(define dt (prog-state-tape ps))
|
||||
(send tape-panel change-children (lambda (_) '()))
|
||||
(for ([i (in-range 0 (prog-state-tape-len ps))]
|
||||
[tp dt])
|
||||
(make-cell i (number->string tp) (= i (prog-state-dp ps)))))
|
||||
|
||||
; The input horizontal panel
|
||||
(define input-panel
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
(provide prog-state
|
||||
prog-state?
|
||||
prog-state-tape
|
||||
prog-state-tape-len
|
||||
prog-state-dp
|
||||
prog-state-output
|
||||
prog-state-program
|
||||
|
|
Loading…
Reference in a new issue