about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--mu.arc6
-rw-r--r--trace.arc.t32
-rw-r--r--trace.mu53
3 files changed, 70 insertions, 21 deletions
diff --git a/mu.arc b/mu.arc
index 9bee1eb1..dc2444a2 100644
--- a/mu.arc
+++ b/mu.arc
@@ -2689,6 +2689,9 @@
     (break-unless x:terminal-address)
 ;?     ($print ((#\% literal))) ;? 1
     (row:integer-address <- get-address x:terminal-address/deref cursor-row:offset)
+;?     ($print (("cursor down: " literal))) ;? 1
+;?     ($print row:integer-address/deref) ;? 1
+;?     ($print (("\n" literal))) ;? 1
     { begin
       (bottom?:boolean <- greater-or-equal row:integer-address/deref height:integer-address/deref)
       (break-if bottom?:boolean)
@@ -2707,6 +2710,9 @@
   { begin
     (break-unless x:terminal-address)
     (row:integer-address <- get-address x:terminal-address/deref cursor-row:offset)
+;?     ($print (("cursor up: " literal))) ;? 1
+;?     ($print row:integer-address/deref) ;? 1
+;?     ($print (("\n" literal))) ;? 1
     { begin
       (top?:boolean <- lesser-or-equal row:integer-address/deref 0:literal)
       (break-if top?:boolean)
diff --git a/trace.arc.t b/trace.arc.t
index 121d7db5..c023ec3e 100644
--- a/trace.arc.t
+++ b/trace.arc.t
@@ -1396,7 +1396,37 @@ run: main 7: n")
             "- main/ 4 : k    "
             "+ main/ 5 : l    "
             "                 "))
-  (prn "F - process-key expands trace segment on any page"))
+  (prn "F - process-key expands a trace index on any page"))
+(run-code main26
+  (replace-character 2:terminal-address/raw ((#\* literal)))
+)
+(when (~screen-contains memory*.4 17
+         (+ "+ main/ 3 : j    "
+            "* main/ 4 : k    "
+            "+ main/ 5 : l    "
+            "                 "))
+  (prn "F - process-key resets the cursor after expand"))
+(quit)
+
+(run-code main27
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state)
+  ; reset previous cursor
+  (replace-character 2:terminal-address/raw ((#\- literal)))
+  (s:string-address <- new "j\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)
+  )
+(each routine completed-routines*
+  (awhen rep.routine!error
+    (prn "error - " it)))
+(when (~screen-contains memory*.4 17
+         (+ "+ main/ 3 : j    "
+            "+ main/ 4 : k    "
+            "- main/ 5 : l    "
+            "                 "))
+  (prn "F - process-key expands a trace index on any page when there's an expanded trace index above it on the same page"))
 
 (reset2)
 ;? (print-times) ;? 3
diff --git a/trace.mu b/trace.mu
index 3cbf6020..9d13bb85 100644
--- a/trace.mu
+++ b/trace.mu
@@ -597,11 +597,17 @@
   { begin
     (above-expanded?:boolean <- lesser-or-equal last-index-on-page:integer/space:1 expanded-index:integer/space:1 )
     (break-unless above-expanded?:boolean)
+    ($print (("todo: need to handle partial expanded children at top of screen\n" literal)))
     (reply simple-result:integer)
   }
-  ; todo: partial expanded children on screen
-  (k:integer/index <- instruction-trace-num-children traces:instruction-trace-address-array-address/space:1 expanded-index:integer/space:1)
-  (result:integer/index <- subtract n:integer/screen k:integer/index)
+  (expanded-index-cursor-row:integer <- subtract expanded-index:integer/space:1 first-index-on-page:integer/space:1)
+  ; cursor is above expanded index? no munging needed
+  { begin
+    (above-expanded?:boolean <- lesser-or-equal cursor-row:integer/space:1 expanded-index-cursor-row:integer)
+    (break-unless above-expanded?:boolean)
+    (reply simple-result:integer)
+  }
+  (result:integer/index <- subtract simple-result:integer expanded-children:integer/space:1)
   (reply result:integer/index)
 ])
 
@@ -610,8 +616,15 @@
   (0:space-address/names:browser-state <- next-input)
   (screen:terminal-address <- next-input)
   (target-index:integer <- next-input)
+;?   ($print (("back-to-index: target " literal))) ;? 1
+;?   ($print target-index:integer) ;? 1
+;?   ($print (("\n" literal))) ;? 1
   { begin
     (index:integer <- cursor-row-to-trace-index 0:space-address/browser-state cursor-row:integer/space:1)
+;?     ($print cursor-row:integer/space:1) ;? 1
+;?     ($print ((" " literal))) ;? 1
+;?     ($print index:integer) ;? 1
+;?     ($print (("\n" literal))) ;? 1
     (done?:boolean <- lesser-or-equal index:integer target-index:integer)
     (break-if done?:boolean)
     (up 0:space-address screen:terminal-address)
@@ -875,13 +888,13 @@
     (toggle?:boolean <- equal c:character ((#\newline literal)))
     (break-unless toggle?:boolean)
     (original-cursor-row:integer <- copy cursor-row:integer/space:1)
-;?     ($print (("cursor starts at row " literal))) ;? 1
-;?     ($print original-cursor-row:integer) ;? 2
-;?     ($print (("\n" literal))) ;? 2
+;?     ($print (("cursor starts at row " literal))) ;? 2
+;?     ($print original-cursor-row:integer) ;? 3
+;?     ($print (("\n" literal))) ;? 3
     (original-trace-index:integer <- cursor-row-to-trace-index 0:space-address/browser-state original-cursor-row:integer)
-;?     ($print (("which maps to index " literal))) ;? 2
-;?     ($print original-trace-index:integer) ;? 4
-;?     ($print (("\n" literal))) ;? 4
+;?     ($print (("which maps to index " literal))) ;? 3
+;?     ($print original-trace-index:integer) ;? 5
+;?     ($print (("\n" literal))) ;? 5
     ; is expanded-index already set?
     { begin
       (expanded?:boolean <- greater-or-equal expanded-index:integer/space:1 0:literal)
@@ -891,12 +904,12 @@
       (too-late?:boolean <- greater-than expanded-index:integer/space:1 last-index-on-page:integer/space:1)
       (break-if too-late?:boolean)
       ; expanded-index is now on this page
-;?       ($print (("expanded index on this page\n" literal))) ;? 2
+;?       ($print (("expanded index on this page\n" literal))) ;? 3
       { begin
         ; are we at the expanded row?
         (at-expanded?:boolean <- equal cursor-row:integer/space:1 expanded-index:integer/space:1)
         (break-unless at-expanded?:boolean)
-;?         ($print (("at expanded index\n" literal))) ;? 1
+;?         ($print (("at expanded index\n" literal))) ;? 2
         ; print remaining lines collapsed and return
         (expanded-index:integer/space:1 <- copy -1:literal)
         (expanded-children:integer/space:1 <- copy -1:literal)
@@ -909,7 +922,7 @@
       { begin
         (below-expanded?:boolean <- greater-than cursor-row:integer/space:1 expanded-index:integer/space:1)
         (break-unless below-expanded?:boolean)
-;?         ($print (("below expanded index\n" literal))) ;? 1
+;?         ($print (("below expanded index\n" literal))) ;? 2
         ; scan up to expanded row
         { begin
           (at-expanded?:boolean <- equal cursor-row:integer/space:1 expanded-index:integer/space:1)
@@ -923,22 +936,22 @@
       }
     }
     ; expand original row and print traces below it
-;?     ($print (("done collapsing previously expanded index\n" literal))) ;? 2
+;?     ($print (("done collapsing previously expanded index\n" literal))) ;? 3
     (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 (("expanded\n" literal))) ;? 2
+;?     ($print (("expanded\n" literal))) ;? 3
     (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 (("printing collapsed lines from " literal))) ;? 3
-;?     ($print next-index:integer) ;? 4
-;?     ($print (("\n" literal))) ;? 4
+;?     ($print (("printing collapsed lines from " literal))) ;? 4
+;?     ($print next-index:integer) ;? 5
+;?     ($print (("\n" literal))) ;? 5
     (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address next-index:integer)
-;?     ($print (("clearing rest of page\n" literal))) ;? 2
+;?     ($print (("clearing rest of page\n" literal))) ;? 3
     (clear-rest-of-page 0:space-address/browser-state screen:terminal-address)
-;?     ($print (("moving cursor back up\n" literal))) ;? 2
+;?     ($print (("moving cursor back up\n" literal))) ;? 3
     (back-to-index 0:space-address/browser-state screen:terminal-address original-trace-index:integer)
-;?     ($print (("returning\n" literal))) ;? 2
+    ($print (("returning\n" literal))) ;? 2
     (reply nil:literal)
   }
   (reply nil:literal)