about summary refs log tree commit diff stats
path: root/color-repl.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-01 01:59:52 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-01 01:59:52 -0800
commit589e58a3a5bae5c38741a60ce3bb26425b267edd (patch)
tree6d53940bfccfe16131fa58b1c9e4e165a767cb72 /color-repl.mu
parent339dfd55df8a85f65a95d2a88b9b177a4112b069 (diff)
downloadmu-589e58a3a5bae5c38741a60ce3bb26425b267edd.tar.gz
696 - hacky solution, but I think <up> works now
Diffstat (limited to 'color-repl.mu')
-rw-r--r--color-repl.mu14
1 files changed, 9 insertions, 5 deletions
diff --git a/color-repl.mu b/color-repl.mu
index efbe0035..b886c139 100644
--- a/color-repl.mu
+++ b/color-repl.mu
@@ -133,6 +133,11 @@
     (open-parens:integer <- copy 0:literal)
     (escapes:buffer-address <- init-buffer 5:literal)
     (not-empty?:boolean <- copy nil:literal)
+    ; save old keyboard
+    ; beware: recursive calls to process-key below can clobber locals used
+    ; outside the up/down cases. So we need to save copies that are only used
+    ; in this part of the function. This is all a giant hack.
+    (old-keyboard:keyboard-address <- copy k:keyboard-address)
     ; identify the history item
     (current-history-index:integer <- subtract current-history-index:integer 1:literal)
     (curr-history:string-address <- buffer-index history:buffer-address current-history-index:integer)
@@ -141,19 +146,18 @@
     (hist:keyboard-address <- init-keyboard curr-history:string-address)
     (hist-index:integer-address <- get-address hist:keyboard-address/deref index:offset)
     { begin
-      ($print hist-index:integer-address/deref)
-      ($print curr-history-len:integer)
-      ($print (("\n" literal)))
+;?       ($print hist-index:integer-address/deref) ;? 1
+;?       ($print curr-history-len:integer) ;? 1
+;?       ($print (("\n" literal))) ;? 1
       (done?:boolean <- greater-or-equal hist-index:integer-address/deref curr-history-len:integer)
       (break-if done?:boolean)
-      ; beware: recursive calls to process-key can clobber locals used outside
-      ; the up/down cases
       (sub-return:boolean <- process-key default-space:space-address hist:keyboard-address screen:terminal-address)
       (assert-false sub-return:boolean (("recursive call to process keys thought it was done" literal)))
       (loop)
     }
     ; <enter> is trimmed in the history expression, so wait for the human to
     ; hit <enter> again or backspace to make edits
+    (k:keyboard-address <- copy old-keyboard:keyboard-address)
     (reply nil:literal)
   }
   ; if it's a newline, decide whether to return