diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-16 01:09:00 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-16 01:09:00 -0800 |
commit | 2590658547c0a391e15943c054eb588af3ba4356 (patch) | |
tree | e0455e09ce69eb0fb949c34d740b5a9e7eb8a6e7 /trace.arc.t | |
parent | 76911c57d1fb69467b5e9ad7fb717cea947c9bd0 (diff) | |
download | mu-2590658547c0a391e15943c054eb588af3ba4356.tar.gz |
755 - cursor can only lie on top-level lines
This allows the initial model of a trace to have just one new number: the currently expanded row. We'll make it more flexible later if we feel the need. Still no collapsing lines, though. But we're getting there.
Diffstat (limited to 'trace.arc.t')
-rw-r--r-- | trace.arc.t | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/trace.arc.t b/trace.arc.t index 1ae0ed39..2614e722 100644 --- a/trace.arc.t +++ b/trace.arc.t @@ -395,3 +395,89 @@ schedule: done with routine") (prn "F - process-key: expanding a line continues to print lines after it")) (reset) +(new-trace "process-key-skip-expanded") +(add-code:readfile "trace.mu") +(add-code + '((function! main [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"schedule: main +run: main 0: (((1 integer)) <- ((copy)) ((1 literal))) +run: main 0: 1 => ((1 integer)) +mem: ((1 integer)): 1 <= 1 +run: main 1: (((2 integer)) <- ((copy)) ((3 literal))) +run: main 1: 3 => ((2 integer)) +mem: ((2 integer)): 2 <= 3 +run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) +mem: ((1 integer)) => 1 +mem: ((2 integer)) => 3 +run: main 2: 4 => ((3 integer)) +mem: ((3 integer)): 3 <= 4 +schedule: done with routine") + (s:stream-address <- init-stream x:string-address) + (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address) + (len:integer <- length 1:instruction-trace-address-array-address/raw/deref) + (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal) + ; position the cursor away from top of screen + (cursor-down 2:terminal-address/raw) + (cursor-down 2:terminal-address/raw) + (3:space-address/raw <- screen-state 1:instruction-trace-address-array-address/raw) + ; draw trace + (print-traces-collapsed 3:space-address/raw/screen-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + ; expand penultimate line, then move one line down and draw cursor + (s:string-address <- new "kk\nj") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + (replace-character 2:terminal-address/raw ((#\* literal))) + (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset) + ]))) +;? (set dump-trace*) ;? 1 +(run 'main) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +; cursor should be at next top-level 'run' line +(when (~screen-contains memory*.4 70 + (+ " " + " " + "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) " + "+ main/ 0 : 1 => ((1 integer)) " + "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) " + "+ main/ 1 : 3 => ((2 integer)) " + "- main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) " + " mem : ((1 integer)) => 1 " + " mem : ((2 integer)) => 3 " + "* main/ 2 : 4 => ((3 integer)) ")) + (prn "F - process-key: navigation moves between top-level lines only")) +(run-code main2 + (default-space:space-address <- new space:literal 30:literal/capacity) + ; reset previous cursor + (replace-character 2:terminal-address/raw ((#\+ literal))) + ; move cursor back up one line + (s:string-address <- new "k") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + ; show cursor + (replace-character 2:terminal-address/raw ((#\* literal))) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +; cursor should be back at the top of the expanded line +(when (~screen-contains memory*.4 70 + (+ " " + " " + "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) " + "+ main/ 0 : 1 => ((1 integer)) " + "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) " + "+ main/ 1 : 3 => ((2 integer)) " + "* main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) " + " mem : ((1 integer)) => 1 " + " mem : ((2 integer)) => 3 " + "+ main/ 2 : 4 => ((3 integer)) ")) + (prn "F - process-key: navigation moves between top-level lines only")) + +(reset) |