about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-28 12:22:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-28 12:22:24 -0700
commit68c0b583ca09ff8f958c2c2738571a03d5e036d3 (patch)
treeb3c94bae7d9cebf9a4eae8762d40e760312f0ca3
parent6aae42ba95a81e4abbfd9512ed948619c2d67141 (diff)
downloadmu-68c0b583ca09ff8f958c2c2738571a03d5e036d3.tar.gz
1499 - now repl supports backspacing over strings
-rw-r--r--repl.mu54
1 files changed, 54 insertions, 0 deletions
diff --git a/repl.mu b/repl.mu
index bea5c643..35bc6f93 100644
--- a/repl.mu
+++ b/repl.mu
@@ -173,6 +173,7 @@ recipe slurp-string [
       print-character x:address:screen, c:character, 6:literal/cyan
       result:address:buffer <- buffer-append result:address:buffer, c:character
       result:address:buffer, tmp:number, k:address:keyboard, x:address:screen <- slurp-string result:address:buffer, k:address:keyboard, x:address:screen
+      characters-slurped:number <- add characters-slurped:number, tmp:number, 1:literal  # for the leading '['
       loop +next-character:label
     }
     # print
@@ -435,3 +436,56 @@ scenario read-instruction-color-string-inside-string [
     .                              .
   ]
 ]
+
+scenario read-instruction-cancel-string-on-backspace [
+  assume-screen 30:literal/width, 5:literal/height
+  # need to escape the '[' once for 'scenario' and once for 'assume-keyboard'
+  assume-keyboard [\\\[a<<z
+]
+  # setup: replace '<'s with backspace key since we can't represent backspace in strings
+  run [
+    buf:address:array:character <- get keyboard:address:keyboard/deref, data:offset
+    first-backspace:address:character <- index-address buf:address:array:character/deref, 2:literal
+    first-backspace:address:character/deref <- copy 8:literal/backspace
+    second-backspace:address:character <- index-address buf:address:array:character/deref, 3:literal
+    second-backspace:address:character/deref <- copy 8:literal/backspace
+  ]
+  run [
+    read-instruction keyboard:address, screen:address
+  ]
+  screen-should-contain-in-color 6:literal/cyan, [
+    .                              .
+    .                              .
+  ]
+  screen-should-contain-in-color 7:literal/white, [
+    .z                             .
+    .                              .
+  ]
+]
+
+scenario read-instruction-cancel-string-inside-string-on-backspace [
+  assume-screen 30:literal/width, 5:literal/height
+  assume-keyboard [\[a\[b\]<<<b\]
+]
+  # setup: replace '<'s with backspace key since we can't represent backspace in strings
+  run [
+    buf:address:array:character <- get keyboard:address:keyboard/deref, data:offset
+    first-backspace:address:character <- index-address buf:address:array:character/deref, 5:literal
+    first-backspace:address:character/deref <- copy 8:literal/backspace
+    second-backspace:address:character <- index-address buf:address:array:character/deref, 6:literal
+    second-backspace:address:character/deref <- copy 8:literal/backspace
+    third-backspace:address:character <- index-address buf:address:array:character/deref, 7:literal
+    third-backspace:address:character/deref <- copy 8:literal/backspace
+  ]
+  run [
+    read-instruction keyboard:address, screen:address
+  ]
+  screen-should-contain-in-color 6:literal/cyan, [
+    .[ab]                          .
+    .                              .
+  ]
+  screen-should-contain-in-color 7:literal/white, [
+    .                              .
+    .                              .
+  ]
+]