diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-28 13:13:39 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-28 13:13:39 -0800 |
commit | 9a04619261302b24c15e96e3150a6157f3408c5e (patch) | |
tree | e885fdec9d445bc33887d646de6fc91782fb3ac7 | |
parent | 0272c9715237834c0f8b9e8505693c08be8bf956 (diff) | |
download | mu-9a04619261302b24c15e96e3150a6157f3408c5e.tar.gz |
852 - page-down stitches expanded lines properly
-rw-r--r-- | mu.arc | 1 | ||||
-rw-r--r-- | trace.arc.t | 35 | ||||
-rw-r--r-- | trace.mu | 117 |
3 files changed, 143 insertions, 10 deletions
diff --git a/mu.arc b/mu.arc index 7f435a6f..01f2586f 100644 --- a/mu.arc +++ b/mu.arc @@ -1116,6 +1116,7 @@ operand))) (def lookup-space (operand base space) +;? (prn operand " " base) ;? 1 (if (is 0 space) ; base case (if (< v.operand memory*.base) diff --git a/trace.arc.t b/trace.arc.t index a8d23792..4615c68d 100644 --- a/trace.arc.t +++ b/trace.arc.t @@ -683,6 +683,41 @@ run: main 7: n") "+ main/ 5 : l " " ")) (prn "F - 'page-up' on partial page behaves as if page was full")) +;; back to page 1, expand a line +(run-code main9 + (default-space:space-address <- new space:literal 30:literal/capacity) + (s:string-address <- new "Kkk\n") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) +;? (print-character 2:terminal-address/raw ((#\* literal))) ;? 1 + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +; now we have an expanded line +(when (~screen-contains memory*.4 17 + (+ "+ main/ 0 : a b c" + "- main/ 1 : d e f" + " mem : 1 a " + " " + " ")) + (prn "F - intermediate state after expanding a line")) +; next page +(run-code main10 + (default-space:space-address <- new space:literal 30:literal/capacity) + (s:string-address <- new "J") + (k:keyboard-address <- init-keyboard s:string-address) +;? ($start-tracing) ;? 1 + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +; no lines skipped +(when (~screen-contains memory*.4 17 + (+ " mem : 1 b " + " mem : 1 c " + "+ main/ 2 : g hi " + " " + " ")) + (prn "F - page down continues existing expanded line")) ; todo ; expanded trace straddles page boundary diff --git a/trace.mu b/trace.mu index cff7c865..05ee4ad5 100644 --- a/trace.mu +++ b/trace.mu @@ -163,6 +163,9 @@ (len:integer <- length ch:trace-address-array-address/deref) (expanded-children:integer/space:1 <- copy len:integer) { begin +;? ($print (("i: " literal))) ;? 1 +;? ($print i:integer) ;? 1 +;? ($print (("\n" literal))) ;? 1 ; until done with trace (done?:boolean <- greater-or-equal i:integer len:integer) (break-if done?:boolean) @@ -175,6 +178,10 @@ (print-character screen:terminal-address ((#\space literal))) (print-trace screen:terminal-address t:trace-address) (add-line 0:space-address/browser-state screen:terminal-address) + (last-subindex-on-page:integer/space:1 <- copy i:integer) +;? ($print (("subindex: " literal))) ;? 1 +;? ($print last-subindex-on-page:integer/space:1) ;? 1 +;? ($print (("\n" literal))) ;? 1 (i:integer <- add i:integer 1:literal) (loop) } @@ -234,9 +241,9 @@ (expanded-index:integer <- copy -1:literal) ; currently trace browser only ever shows one item expanded (expanded-children:integer <- copy -1:literal) (first-index-on-page:integer <- copy 0:literal) ; 'outer' line with label 'run' - (first-subindex-on-page:integer <- copy 0:literal) ; 'inner' line with other labels + (first-subindex-on-page:integer <- copy -1:literal) ; 'inner' line with other labels (last-index-on-page:integer <- copy 0:literal) - (last-subindex-on-page:integer <- copy 0:literal) + (last-subindex-on-page:integer <- copy -1:literal) ; screen state (screen-height:integer <- next-input) ; 'hardware' limitation (app-height:integer <- copy 0:literal) ; area of the screen we're responsible for; can't be larger than screen-height @@ -405,6 +412,10 @@ ; continue printing trace lines (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref trace-index:integer) (last-index-on-page:integer/space:1 <- copy trace-index:integer) +;? ($print (("setting last index: " literal))) ;? 1 +;? ($print last-index-on-page:integer/space:1) ;? 1 +;? ($print (("\n" literal))) ;? 1 + (last-subindex-on-page:integer/space:1 <- copy -1:literal) (print-instruction-trace-collapsed screen:terminal-address tr:instruction-trace-address 0:space-address/browser-state) (trace-index:integer <- add trace-index:integer 1:literal) (loop) @@ -422,6 +433,42 @@ } ]) +(function print-page [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- next-input) + (screen:terminal-address <- next-input) + (first-full-index:integer <- copy first-index-on-page:integer/space:1) + ; finish printing the last trace from the previous page + { begin + (partial-trace?:boolean <- equal first-index-on-page:integer/space:1 expanded-index:integer/space:1) + (break-unless partial-trace?:boolean) + (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref first-index-on-page:integer/space:1) + (ch:trace-address-array-address <- get tr:instruction-trace-address/deref children:offset) + (i:integer <- copy first-subindex-on-page:integer/space:1) + ; print any remaining data in the currently expanded trace + { begin + ; until done with trace + (done?:boolean <- greater-or-equal i:integer expanded-children:integer/space:1) + (break-if done?:boolean) + ; or screen ends + (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1) + (break-if screen-done?:boolean) + (t:trace-address <- index ch:trace-address-array-address/deref i:integer) + (print-character screen:terminal-address ((#\space literal))) + (print-character screen:terminal-address ((#\space literal))) + (print-character screen:terminal-address ((#\space literal))) + (print-trace screen:terminal-address t:trace-address) + (add-line 0:space-address/browser-state screen:terminal-address) + (last-subindex-on-page:integer/space:1 <- copy i:integer) + (i:integer <- add i:integer 1:literal) + (loop) + } + (first-full-index:integer <- add first-full-index:integer 1:literal) + } + ; more new lines + (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer) +]) + (function cursor-row-to-trace-index [ (default-space:space-address <- new space:literal 30:literal/capacity) (0:space-address/names:browser-state <- next-input) @@ -495,7 +542,7 @@ ; switch browser state (previous-page 0:space-address/browser-state) ; redraw - (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-index-on-page:integer/space:1) + (print-page 0:space-address/browser-state screen:terminal-address) (reply nil:literal) } { begin @@ -509,10 +556,16 @@ (break-if final-page?:boolean) ; move cursor to top of screen (to-top 0:space-address/browser-state screen:terminal-address) +;? ($print (("before: " literal))) ;? 1 +;? ($print first-index-on-page:integer/space:1) ;? 1 +;? ($print (("\n" literal))) ;? 1 ; switch browser state (next-page 0:space-address/browser-state) +;? ($print (("after: " literal))) ;? 1 +;? ($print first-index-on-page:integer/space:1) ;? 1 +;? ($print (("\n" literal))) ;? 1 ; redraw - (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-index-on-page:integer/space:1) + (print-page 0:space-address/browser-state screen:terminal-address) ; move cursor back to top of screen (to-top 0:space-address/browser-state screen:terminal-address) (reply nil:literal) @@ -531,6 +584,7 @@ { begin (expanded?:boolean <- greater-or-equal expanded-index:integer/space:1 0:literal) (break-unless expanded?:boolean) +;? ($print (("already expanded\n" literal))) ;? 1 { begin ; are we at the expanded row? (at-expanded?:boolean <- equal cursor-row:integer/space:1 expanded-index:integer/space:1) @@ -566,11 +620,13 @@ } ; expand original row and print traces below it (expanded-index:integer/space:1 <- copy original-trace-index:integer) + (last-index-on-page:integer/space:1 <- copy original-trace-index:integer) (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref original-trace-index:integer) (print-instruction-trace screen:terminal-address tr:instruction-trace-address 0:space-address/browser-state) (next-index:integer <- add original-trace-index:integer 1:literal) -;? ($print next-index:integer) ;? 1 -;? ($print (("\n" literal))) ;? 1 +;? ($print (("printing collapsed lines from " literal))) ;? 1 +;? ($print next-index:integer) ;? 2 +;? ($print (("\n" literal))) ;? 2 (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address next-index:integer) (back-to 0:space-address/browser-state screen:terminal-address original-trace-index:integer) (reply nil:literal) @@ -583,6 +639,17 @@ (default-space:space-address <- new space:literal 30:literal/capacity) (0:space-address/names:browser-state <- next-input) ; read-only (result:boolean <- lesser-or-equal first-index-on-page:integer/space:1 0:literal) + { begin + (break-if result:boolean) + (reply nil:literal) + } + (expanded?:boolean <- equal expanded-index:integer/space:1 0:literal) + { begin + (break-if expanded?:boolean) + (reply t:literal) + } + ; if first subindex is 0, the top-level line is on a previous page + (result:boolean <- less-than first-subindex-on-page:integer/space:1 0:literal) (reply result:boolean) ]) @@ -590,16 +657,46 @@ (default-space:space-address <- new space:literal 30:literal/capacity) (0:space-address/names:browser-state <- next-input) ; read-only (len:integer <- length traces:instruction-trace-address-array-address/space:1/deref) - (next-page-start:integer <- add last-index-on-page:integer/space:1 1:literal) - (result:boolean <- greater-or-equal next-page-start:integer len:integer) + (final-index:integer <- subtract len:integer 1:literal) + (result:boolean <- greater-or-equal last-index-on-page:integer/space:1 final-index:integer) + { begin + (break-if result:boolean) + (reply nil:literal) + } + (last-trace-expanded?:boolean <- equal expanded-index:integer/space:1 len:integer) + { begin + (break-if last-trace-expanded?:boolean) + (reply t:literal) + } + (result:boolean <- greater-or-equal last-subindex-on-page:integer/space:1 expanded-children:integer/space:1) (reply result:boolean) ]) (function next-page [ (default-space:space-address <- new space:literal 30:literal/capacity) (0:space-address/names:browser-state <- next-input) - (next-page-start:integer <- add last-index-on-page:integer/space:1 1:literal) - (first-index-on-page:integer/space:1 <- copy next-page-start:integer) + { begin +;? ($print (("expanded: " literal))) ;? 1 +;? ($print expanded-index:integer/space:1) ;? 1 +;? ($print ((" last index: " literal))) ;? 1 +;? ($print last-index-on-page:integer/space:1) ;? 1 +;? ($print (("\n" literal))) ;? 1 + (last-index-expanded?:boolean <- equal expanded-index:integer/space:1 last-index-on-page:integer/space:1) + (break-unless last-index-expanded?:boolean) + ; expanded +;? ($print (("last expanded\n" literal))) ;? 1 + { begin + (expanded-index-done?:boolean <- equal expanded-children:integer/space:1 last-subindex-on-page:integer/space:1) + (break-if expanded-index-done?:boolean 2:blocks) +;? ($print (("children left\n" literal))) ;? 1 + ; children left to open + (first-index-on-page:integer/space:1 <- copy last-index-on-page:integer/space:1) + (first-subindex-on-page:integer/space:1 <- add last-subindex-on-page:integer/space:1 1:literal) + (reply) + } + } + (first-index-on-page:integer/space:1 <- add last-index-on-page:integer/space:1 1:literal) + (first-subindex-on-page:integer/space:1 <- copy -1:integer) ]) (function previous-page [ |