about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-06 01:15:11 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-03-06 01:15:11 -0800
commit52b9c5ea2feab6eb218f8bac0f41817e719cd1ed (patch)
tree5c9faeabb2423847992153f265d8c3b257d2676b
parent42eabf184bf178f6bb47af7ea8f78e9bdb49172c (diff)
downloadmu-52b9c5ea2feab6eb218f8bac0f41817e719cd1ed.tar.gz
864
-rw-r--r--trace.arc.t39
-rw-r--r--trace.mu69
2 files changed, 80 insertions, 28 deletions
diff --git a/trace.arc.t b/trace.arc.t
index cf886c4f..b075f848 100644
--- a/trace.arc.t
+++ b/trace.arc.t
@@ -635,6 +635,7 @@ run: main 7: n")
             "+ main/ 5 : l    "
             "                 "))
   (prn "F - 'page-down' skips to next page after this one"))
+;? (quit) ;? 1
 ; move cursor down, then page-down
 (run-code main6
   (default-space:space-address <- new space:literal 30:literal/capacity)
@@ -744,6 +745,7 @@ run: main 7: n")
             "                 "
             "                 "))
   (prn "F - page down shows collapsed lines after continued expanded line at top of page"))
+;? (quit) ;? 1
 ; page-up through an expanded line
 (run-code main12
   (default-space:space-address <- new space:literal 30:literal/capacity)
@@ -823,11 +825,7 @@ run: main 7: n")
 (run-code main14pre
   (default-space:space-address <- new space:literal 30:literal/capacity)
   (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
-;?   ($print first-index-on-page:integer/space:1) ;? 2
-;?   ($print (("\n" literal))) ;? 2
   (first-index-on-page:integer/space:1 <- copy 1:literal)
-;?   ($print first-index-on-page:integer/space:1) ;? 2
-;?   ($print (("\n" literal))) ;? 2
   (first-subindex-on-page:integer/space:1 <- copy -1:literal)
   (last-index-on-page:integer/space:1 <- copy 1:literal)
   (last-subindex-on-page:integer/space:1 <- copy 1:literal)
@@ -846,14 +844,33 @@ run: main 7: n")
             "                 "
             "                 "))
   (prn "F - page-up 3: initial print-page state"))
+(run-code main14post
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
+  (first-index-on-page:integer/space:1 <- copy 0:literal)
+  (first-subindex-on-page:integer/space:1 <- copy -2:literal)
+  (last-index-on-page:integer/space:1 <- copy 1:literal)
+  (last-subindex-on-page:integer/space:1 <- copy 0:literal)
+  (expanded-index:integer/space:1 <- copy 1:literal)
+  (expanded-children:integer/space:1 <- copy 5:literal)
+  (to-top 0:space-address/browser-state 2:terminal-address/raw)
+  (print-page 0:space-address/browser-state 2:terminal-address/raw)
+  )
+(each routine completed-routines*
+  (awhen rep.routine!error
+    (prn "error - " it)))
+(when (~screen-contains memory*.4 17
+         (+ "+ main/ 0 : a b c"
+            "- main/ 1 : d e f"
+            "   mem : 1 a     "
+            "                 "
+            "                 "))
+  (prn "F - page-up 3: expected post page-up state"))
+;? (quit) ;? 1
 (run-code main14
   (default-space:space-address <- new space:literal 30:literal/capacity)
   (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
-;?   ($print first-index-on-page:integer/space:1) ;? 2
-;?   ($print (("\n" literal))) ;? 2
   (first-index-on-page:integer/space:1 <- copy 1:literal)
-;?   ($print first-index-on-page:integer/space:1) ;? 2
-;?   ($print (("\n" literal))) ;? 2
   (first-subindex-on-page:integer/space:1 <- copy -1:literal)
   (last-index-on-page:integer/space:1 <- copy 1:literal)
   (last-subindex-on-page:integer/space:1 <- copy 1:literal)
@@ -874,6 +891,7 @@ run: main 7: n")
             "                 "
             "                 "))
   (prn "F - page-up 3"))
+;? (quit) ;? 1
 ; page-up scenario 4
 ; + run: main 0: a b c
 ;   mem: 0 a
@@ -893,11 +911,7 @@ run: main 7: n")
 (run-code main15
   (default-space:space-address <- new space:literal 30:literal/capacity)
   (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
-;?   ($print first-index-on-page:integer/space:1) ;? 2
-;?   ($print (("\n" literal))) ;? 2
   (first-index-on-page:integer/space:1 <- copy 1:literal)
-;?   ($print first-index-on-page:integer/space:1) ;? 2
-;?   ($print (("\n" literal))) ;? 2
   (first-subindex-on-page:integer/space:1 <- copy 2:literal)
   (last-index-on-page:integer/space:1 <- copy 1:literal)
   (last-subindex-on-page:integer/space:1 <- copy 4:literal)
@@ -905,7 +919,6 @@ run: main 7: n")
   (expanded-children:integer/space:1 <- copy 5:literal)
   (s:string-address <- new "K")
   (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)
   )
 (each routine completed-routines*
diff --git a/trace.mu b/trace.mu
index 9b6cbd3b..9ce574d6 100644
--- a/trace.mu
+++ b/trace.mu
@@ -432,11 +432,17 @@
   (0:space-address/names:browser-state <- next-input)
   (screen:terminal-address <- next-input)
   (trace-index:integer <- next-input)
-  (len:integer <- length traces:instruction-trace-address-array-address/space:1/deref)
+  (limit-index:integer <- next-input)  ; print until this index (exclusive)
+  ; compute bound
+  (max:integer <- length traces:instruction-trace-address-array-address/space:1/deref)
+  { begin
+    (break-unless limit-index:integer)
+    (max:integer <- min max:integer limit-index:integer)
+  }
   ; print remaining traces collapsed
   { begin
     ; until trace ends
-    (trace-done?:boolean <- greater-or-equal trace-index:integer len:integer)
+    (trace-done?:boolean <- greater-or-equal trace-index:integer max:integer)
     (break-if trace-done?:boolean)
     ; or screen ends
     (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1)
@@ -477,13 +483,22 @@
 ;?   ($print first-subindex-on-page:integer/space:1) ;? 1
 ;?   ($print (("\n" literal))) ;? 1
   (screen:terminal-address <- next-input)
+;?   ($dump-browser-state 0:space-address/browser-state) ;? 1
+  ; if top inside expanded index, complete existing trace
   (first-full-index:integer <- copy first-index-on-page:integer/space:1)
-  ; finish printing the last trace from the previous page
+;?   ($print first-full-index:integer) ;? 1
+;?   ($print cursor-row:integer/space:1) ;? 1
   { begin
     (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1)
-    (break-if screen-done?:boolean)
+    (break-unless screen-done?:boolean)
+    (reply)
+  }
+;?   ($print (("\nAAA\n" literal))) ;? 1
+  { begin
     (partial-trace?:boolean <- equal first-index-on-page:integer/space:1 expanded-index:integer/space:1)
     (break-unless partial-trace?:boolean)
+;?   ($print (("AAA: partial\n" literal))) ;? 1
+    (first-full-index:integer <- add first-full-index:integer 1:literal)
     (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref first-index-on-page:integer/space:1)
     { begin
       (print-parent?:boolean <- equal first-subindex-on-page:integer/space:1 -1:literal)
@@ -510,16 +525,39 @@
       (i:integer <- add i:integer 1:literal)
       (loop)
     }
-    (first-full-index:integer <- add first-full-index:integer 1:literal)
   }
-  ; more new lines
-;?   ($print (("AAA " literal))) ;? 2
-;?   ($print first-full-index:integer) ;? 1
+;?   ($print (("AAA 3: " literal))) ;? 2
 ;?   ($print cursor-row:integer/space:1) ;? 1
-;?   ($print ((" " literal))) ;? 1
-;?   ($print screen-height:integer/space:1) ;? 1
-;?   ($print (("\n" literal))) ;? 2
-  (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer)
+;?   ($print (("\n" literal))) ;? 1
+  { begin
+    (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1)
+    (break-unless screen-done?:boolean)
+    (reply)
+  }
+;?   ($print (("AAA 4\n" literal))) ;? 2
+  { begin
+    (has-expanded?:boolean <- greater-or-equal expanded-index:integer/space:1 0:literal)
+    (break-if has-expanded?:boolean)
+;?     ($print (("AAA 5a\n" literal))) ;? 1
+    (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer)
+    (clear-rest-of-page 0:space-address/browser-state screen:terminal-address)
+    (reply)
+  }
+  { begin
+    (below-expanded?:boolean <- greater-than first-full-index:integer expanded-index:integer/space:1)
+    (break-unless below-expanded?:boolean)
+;?     ($print (("AAA 5b\n" literal))) ;? 1
+    (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer)
+    (clear-rest-of-page 0:space-address/browser-state screen:terminal-address)
+    (reply)
+  }
+  ; trace has an expanded index and it's below first-full-index
+  ; print traces collapsed until expanded index
+;?   ($print (("AAA 5c\n" literal))) ;? 1
+  (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer expanded-index:integer/space:1/until)
+  ; if room, start printing expanded index
+  (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref expanded-index:integer/space:1)
+  (print-instruction-trace screen:terminal-address tr:instruction-trace-address 0:space-address/browser-state)
   (clear-rest-of-page 0:space-address/browser-state screen:terminal-address)
 ])
 
@@ -595,6 +633,7 @@
     (to-top 0:space-address/browser-state screen:terminal-address)
     ; switch browser state
     (previous-page 0:space-address/browser-state)
+;?     ($dump-browser-state 0:space-address) ;? 1
     ; redraw
     (print-page 0:space-address/browser-state screen:terminal-address)
     (reply nil:literal)
@@ -773,13 +812,13 @@
   (x:boolean <- greater-than expanded-index:integer/space:1 first-index-on-page:integer/space:1)
   (jump-if x:boolean easy-case:offset)
   ; easy case: expanded-index *starts* at top of current page
-;?   ($print (("d\n" literal))) ;? 2
+;?   ($print (("d\n" literal))) ;? 3
   (top-of-screen-inside-expanded:boolean <- equal expanded-index:integer/space:1 first-index-on-page:integer/space:1)
-  (y:boolean <- less-than first-subindex-on-page:integer/space:1 -1:literal)
+  (y:boolean <- lesser-or-equal first-subindex-on-page:integer/space:1 -1:literal)
   (y:boolean <- and top-of-screen-inside-expanded:boolean y:boolean)
   (jump-if y:boolean easy-case:offset)
   ; easy case: expanded-index too far up for previous page
-;?   ($print (("e\n" literal))) ;? 2
+;?   ($print (("e\n" literal))) ;? 3
   (delta-to-expanded:integer <- subtract first-index-on-page:integer/space:1 expanded-index:integer/space:1)
 ;?   ($print (("e2\n" literal))) ;? 2
   (x:boolean <- greater-than delta-to-expanded:integer expanded-index:integer/space:1)