about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-29 10:56:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-29 10:56:54 -0800
commit15a113ed434eeda5e5b2ea85f29b82318bbdca39 (patch)
treecd3f7d73b3f086fdd0da675d7a8530cfee4f5896
parent877d0a44b7be2ca0d9b30900526fc6f4b07a5389 (diff)
downloadmu-15a113ed434eeda5e5b2ea85f29b82318bbdca39.tar.gz
671 - starting to add history support
-rw-r--r--color-repl.mu10
1 files changed, 8 insertions, 2 deletions
diff --git a/color-repl.mu b/color-repl.mu
index c83a56ba..85e2c05d 100644
--- a/color-repl.mu
+++ b/color-repl.mu
@@ -9,7 +9,8 @@
 (function read-sexp [
   (default-space:space-address <- new space:literal 30:literal)
   (abort:continuation <- next-input)
-  (result:buffer-address <- init-buffer 3:literal)
+  (history:buffer-address <- next-input)  ; buffer of strings
+  (result:buffer-address <- init-buffer 3:literal)  ; string to maybe add to
   (open-parens:integer <- copy 0:literal)  ; for balancing parens and tracking nesting depth
   ; we can change color when backspacing over parens or comments or strings,
   ; but we need to know that they aren't escaped
@@ -337,9 +338,14 @@
   (print-primitive-to-host (("connected to anarki! type in an expression, then hit enter. ctrl-d exits. ctrl-g clears the current expression." literal)))
   (print-character nil:literal/terminal ((#\newline literal)))
   (abort:continuation <- current-continuation)
+  (history:buffer-address <- init-buffer 5:literal)
   { begin
-    (s:string-address <- read-sexp abort:continuation)
+    (s:string-address <- read-sexp abort:continuation history:buffer-address)
     (break-unless s:string-address)
+    (history:buffer-address <- append history:buffer-address s:string-address)
+    (len:integer <- get history:buffer-address/deref length:offset)
+    (print-primitive-to-host len:integer)
+    (print-primitive-to-host ((#\newline literal)))
     (retro-mode)  ; print errors cleanly
       (t:string-address <- $eval s:string-address)
     (cursor-mode)