about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-10 21:44:06 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-10 21:44:06 -0800
commit378ffc9f2f5e4ecd585d16c085ced5ea307f224a (patch)
tree6b25c0503864227be785638800c443b327655748
parent0ad92f3b6ea199e9e0468144bf94023d130b3f5b (diff)
downloadmu-378ffc9f2f5e4ecd585d16c085ced5ea307f224a.tar.gz
738
-rw-r--r--trace.mu31
1 files changed, 19 insertions, 12 deletions
diff --git a/trace.mu b/trace.mu
index ca827564..51cf58ad 100644
--- a/trace.mu
+++ b/trace.mu
@@ -266,6 +266,24 @@
   (cursor-to-next-line screen:terminal-address)
 ])
 
+;; initial screen state
+(function print-traces-collapsed [
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (0:space-address/names:screen-state <- next-input)
+  (traces:instruction-trace-address-array-address <- next-input)
+  (len:integer <- length traces:instruction-trace-address-array-address/deref)
+  (i:integer <- copy 0:literal)
+  { begin
+    (done?:boolean <- greater-or-equal i:integer len:integer)
+    (break-if done?:boolean)
+    (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/deref i:integer)
+    (print-instruction-trace-collapsed nil:literal/terminal tr:instruction-trace-address 0:space-address/screen-state)
+    (i:integer <- add i:integer 1:literal)
+    (loop)
+  }
+])
+
+;; modify screen state in response to a single key
 (function process-key [
   (default-space:space-address <- new space:literal 30:literal/capacity)
   (0:space-address/names:screen-state <- next-input)
@@ -333,22 +351,11 @@ mem: ((3 integer)): 3 <= 4
 schedule:  done with routine")
   (s:stream-address <- init-stream x:string-address)
   (traces:instruction-trace-address-array-address <- parse-traces s:stream-address)
-  (len:integer <- length traces:instruction-trace-address-array-address/deref)
 ;?   ($print (("#traces: " literal))) ;? 1
 ;?   ($print len:integer) ;? 1
 ;?   ($print (("\n" literal))) ;? 1
   (cursor-mode)
-  ; print trace collapsed
-  (i:integer <- copy 0:literal)
-  { begin
-    (done?:boolean <- greater-or-equal i:integer len:integer)
-    (break-if done?:boolean)
-    (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/deref i:integer)
-    (print-instruction-trace-collapsed nil:literal/terminal tr:instruction-trace-address 0:space-address/screen-state)
-    (i:integer <- add i:integer 1:literal)
-    (loop)
-  }
-  ; handle key presses
+  (print-traces-collapsed 0:space-address/screen-state traces:instruction-trace-address-array-address)
   { begin
     (quit?:boolean <- process-key 0:space-address/screen-state nil:literal/keyboard nil:literal/terminal traces:instruction-trace-address-array-address)
     (break-if quit?:boolean)