about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-09 18:54:26 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-09 18:54:26 -0800
commit9ee879a3d0a4790fd5f75bf1814fab9a59503095 (patch)
tree45cfe011ce55c79a83f7f8ca0c6236d794a58070
parent2fc8f2a947e26d4d14cbbf1ff02dcdcb0825f951 (diff)
downloadmu-9ee879a3d0a4790fd5f75bf1814fab9a59503095.tar.gz
728 - move up/down and expand trace at cursor
Expand isn't anywhere near working, but already I like how the browser
returns to the commandline when exiting, without causing a mental
context switch. Little details like moving the cursor to the bottom
before quitting.
-rw-r--r--trace.mu44
1 files changed, 40 insertions, 4 deletions
diff --git a/trace.mu b/trace.mu
index 664f5354..2f72b850 100644
--- a/trace.mu
+++ b/trace.mu
@@ -222,14 +222,50 @@ schedule:  done with routine")
     (loop)
   }
   ; handle key presses
-  (i:integer <- copy 0:literal)
+  (cursor-row:integer <- copy len:integer)
   { begin
-    (c:character <- read-key nil:literal/keyboard)
+    next-key
+    (c:character <- read-key nil:literal/keyboard silent:literal/terminal)
     (loop-unless c:character)
     (quit?:boolean <- equal c:character ((#\q literal)))
     (break-if quit?:boolean)
-    ($print i:integer)
-    (i:integer <- add i:integer 1:literal)
+    ; up/down navigation
+    { begin
+      (up?:boolean <- equal c:character ((up literal)))
+      (break-unless up?:boolean)
+      (at-top?:boolean <- lesser-or-equal cursor-row:integer 0:literal)
+      (break-if at-top?:boolean)
+      (cursor-row:integer <- subtract cursor-row:integer 1:literal)
+      (cursor-up-on-host)
+      (jump next-key:offset)  ; loop
+    }
+    { begin
+      (down?:boolean <- equal c:character ((down literal)))
+      (break-unless down?:boolean)
+      (at-bottom?:boolean <- greater-or-equal cursor-row:integer len:integer)
+      (break-if at-bottom?:boolean)
+      (cursor-row:integer <- add cursor-row:integer 1:literal)
+      (cursor-down-on-host)
+      (jump next-key:offset)  ; loop
+    }
+    ; enter: expand current row
+    { begin
+      (toggle?:boolean <- equal c:character ((#\newline literal)))
+      (break-unless toggle?:boolean)
+      (tr:instruction-trace-address <- index arr:instruction-trace-address-array-address/deref cursor-row:integer)
+      (print-instruction-trace tr:instruction-trace-address)
+      (jump next-key:offset)  ; loop
+    }
+    ; debugging: print cursor-row
+    ($print cursor-row:integer)
+    (loop)
+  }
+  ; move cursor to bottom before exiting
+  { begin
+    (at-bottom?:boolean <- greater-or-equal cursor-row:integer len:integer)
+    (break-if at-bottom?:boolean)
+    (cursor-down-on-host)
+    (cursor-row:integer <- add cursor-row:integer 1:literal)
     (loop)
   }
 ])