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, [
+    .                              .
+    .                              .
+  ]
+]
ss='alt'>
e25474154 ^





5b28d0820 ^
e25474154 ^




3e9dcc8be ^
e25474154 ^


3e9dcc8be ^
e25474154 ^

3e9dcc8be ^
e25474154 ^


c06569459 ^



e25474154 ^












c06569459 ^
e25474154 ^

































5b28d0820 ^

e25474154 ^































5b28d0820 ^
e25474154 ^














a489161b1 ^

e25474154 ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215