diff options
Diffstat (limited to 'html/060string.mu.html')
-rw-r--r-- | html/060string.mu.html | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/html/060string.mu.html b/html/060string.mu.html index ee17699c..18869d3c 100644 --- a/html/060string.mu.html +++ b/html/060string.mu.html @@ -10,8 +10,8 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } -body { font-family: monospace; color: #d0d0d0; background-color: #080808; } +pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1em; } .CommentedCode { color: #6c6c6c; } .Delimiter { color: #c000c0; } @@ -190,13 +190,22 @@ container buffer [ <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> in:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> c:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + len:address:number<span class="Special"> <- </span>get-address in:address:buffer/deref, length:offset + <span class="Delimiter">{</span> + <span class="Comment"># backspace? just drop last character if it exists and return</span> + backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal/backspace</span> + <span class="Identifier">break-unless</span> backspace?:boolean + empty?:boolean<span class="Special"> <- </span>lesser-or-equal len:address:number/deref, <span class="Constant">0:literal</span> + <span class="Identifier">reply-if</span> empty?:boolean, in:address:buffer/same-as-ingredient:0 + len:address:number/deref<span class="Special"> <- </span>subtract len:address:number/deref, <span class="Constant">1:literal</span> + <span class="Identifier">reply</span> in:address:buffer/same-as-ingredient:0 + <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># grow buffer if necessary</span> full?:boolean<span class="Special"> <- </span>buffer-full? in:address:buffer <span class="Identifier">break-unless</span> full?:boolean in:address:buffer<span class="Special"> <- </span>grow-buffer in:address:buffer <span class="Delimiter">}</span> - len:address:number<span class="Special"> <- </span>get-address in:address:buffer/deref, length:offset s:address:array:character<span class="Special"> <- </span>get in:address:buffer/deref, data:offset dest:address:character<span class="Special"> <- </span>index-address s:address:array:character/deref, len:address:number/deref dest:address:character/deref<span class="Special"> <- </span>copy c:character @@ -256,6 +265,23 @@ container buffer [ ] ] +<span class="muScenario">scenario</span> buffer-append-handles-backspace [ + run [ + <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + x:address:buffer<span class="Special"> <- </span>init-buffer <span class="Constant">3:literal</span> + x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> + x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">98:literal</span> <span class="Comment"># 'b'</span> + x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">8:literal/backspace</span> + s:address:array:character<span class="Special"> <- </span>buffer-to-array x:address:buffer + 1:array:character/<span class="Special">raw <- </span>copy s:address:array:character/deref + ] + memory-should-contain [ + 1<span class="Special"> <- </span>1 <span class="Comment"># length</span> + 2<span class="Special"> <- </span>97 <span class="Comment"># contents</span> + 3<span class="Special"> <- </span>0 + ] +] + <span class="Comment"># result:address:array:character <- integer-to-decimal-string n:number</span> <span class="muRecipe">recipe</span> integer-to-decimal-string [ <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> @@ -316,15 +342,15 @@ container buffer [ <span class="muRecipe">recipe</span> buffer-to-array [ <span class="Identifier">default-space</span>:address:array:character<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> in:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - len:number<span class="Special"> <- </span>get in:address:buffer/deref, length:offset -<span class="CommentedCode">#? $print [size ], len:number, [ </span> -<span class="CommentedCode">#? ] #? 1</span> - s:address:array:character<span class="Special"> <- </span>get in:address:buffer/deref, data:offset <span class="Delimiter">{</span> <span class="Comment"># propagate null buffer</span> - <span class="Identifier">break-if</span> s:address:array:character + <span class="Identifier">break-if</span> in:address:buffer <span class="Identifier">reply</span> <span class="Constant">0:literal</span> <span class="Delimiter">}</span> + len:number<span class="Special"> <- </span>get in:address:buffer/deref, length:offset +<span class="CommentedCode">#? $print [size ], len:number, [ </span> +<span class="CommentedCode">#? ] #? 1</span> + s:address:array:character<span class="Special"> <- </span>get in:address:buffer/deref, data:offset <span class="Comment"># we can't just return s because it is usually the wrong length</span> result:address:array:character<span class="Special"> <- </span>new character:type, len:number i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> |