about summary refs log tree commit diff stats
path: root/html/071print.mu.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-14 16:04:45 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-14 16:04:45 -0700
commit65361948ca7975553757a0e0df4ac7352413044c (patch)
tree22063c089f67cb0d82623f2edc2c16b7e4389d41 /html/071print.mu.html
parent64586540eccbc0880341782d329b419ab9d002de (diff)
downloadmu-65361948ca7975553757a0e0df4ac7352413044c.tar.gz
1376 - update github docs
Diffstat (limited to 'html/071print.mu.html')
-rw-r--r--html/071print.mu.html364
1 files changed, 245 insertions, 119 deletions
diff --git a/html/071print.mu.html b/html/071print.mu.html
index 4f69abd9..2e0c0dee 100644
--- a/html/071print.mu.html
+++ b/html/071print.mu.html
@@ -2,7 +2,7 @@
 <html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-<title>Mu - 071print.mu</title>
+<title>~/Desktop/s/mu/071print.mu</title>
 <meta name="Generator" content="Vim/7.4">
 <meta name="plugin-version" content="vim7.4_v1">
 <meta name="syntax" content="none">
@@ -14,8 +14,9 @@ pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-
 body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
 * { font-size: 1em; }
 .CommentedCode { color: #6c6c6c; }
-.Comment { color: #8080ff; }
 .Delimiter { color: #c000c0; }
+.Comment { color: #8080ff; }
+.Constant { color: #008080; }
 .Special { color: #ff6060; }
 .Identifier { color: #008080; }
 -->
@@ -32,182 +33,258 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
 <span class="Comment"># Wrappers around print primitives that take a 'screen' object and are thus</span>
 <span class="Comment"># easier to test.</span>
 
-container screen <span class="Delimiter">[</span>
-  num-rows:integer
-  num-columns:integer
-  cursor-row:integer
-  cursor-column:integer
+container screen [
+  num-rows:number
+  num-columns:number
+  cursor-row:number
+  cursor-column:number
   data:address:array:character
-<span class="Delimiter">]</span>
+]
 
-recipe init-fake-screen <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal/capacity
+recipe init-fake-screen [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal/capacity</span>
   result:address:screen<span class="Special"> &lt;- </span>new screen:type
-  width:address:integer<span class="Special"> &lt;- </span>get-address result:address:screen/deref, num-columns:offset
-  width:address:integer/deref<span class="Special"> &lt;- </span>next-ingredient
-  height:address:integer<span class="Special"> &lt;- </span>get-address result:address:screen/deref, num-rows:offset
-  height:address:integer/deref<span class="Special"> &lt;- </span>next-ingredient
-  row:address:integer<span class="Special"> &lt;- </span>get-address result:address:screen/deref, cursor-row:offset
-  row:address:integer/deref<span class="Special"> &lt;- </span>copy 0:literal
-  column:address:integer<span class="Special"> &lt;- </span>get-address result:address:screen/deref, cursor-column:offset
-  column:address:integer/deref<span class="Special"> &lt;- </span>copy 0:literal
-  bufsize:integer<span class="Special"> &lt;- </span>multiply width:address:integer/deref, height:address:integer/deref
+  width:address:number<span class="Special"> &lt;- </span>get-address result:address:screen/deref, num-columns:offset
+  width:address:number/deref<span class="Special"> &lt;- </span>next-ingredient
+  height:address:number<span class="Special"> &lt;- </span>get-address result:address:screen/deref, num-rows:offset
+  height:address:number/deref<span class="Special"> &lt;- </span>next-ingredient
+  row:address:number<span class="Special"> &lt;- </span>get-address result:address:screen/deref, cursor-row:offset
+  row:address:number/deref<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
+  column:address:number<span class="Special"> &lt;- </span>get-address result:address:screen/deref, cursor-column:offset
+  column:address:number/deref<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
+  bufsize:number<span class="Special"> &lt;- </span>multiply width:address:number/deref, height:address:number/deref
   buf:address:address:array:character<span class="Special"> &lt;- </span>get-address result:address:screen/deref, data:offset
-  buf:address:address:array:character/deref<span class="Special"> &lt;- </span>new character:literal, bufsize:integer
+  buf:address:address:array:character/deref<span class="Special"> &lt;- </span>new <span class="Constant">character:literal</span>, bufsize:number
   clear-screen result:address:screen
   <span class="Identifier">reply</span> result:address:screen
-<span class="Delimiter">]</span>
+]
 
-recipe clear-screen <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe clear-screen [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
+<span class="CommentedCode">#?   $print [clearing screen</span>
+<span class="CommentedCode">#? ] #? 1</span>
   <span class="Comment"># if x exists</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
     <span class="Comment"># clear fake screen</span>
     buf:address:array:character<span class="Special"> &lt;- </span>get x:address:screen/deref, data:offset
-    max:integer<span class="Special"> &lt;- </span>length buf:address:array:character/deref
-    i:integer<span class="Special"> &lt;- </span>copy 0:literal
+    max:number<span class="Special"> &lt;- </span>length buf:address:array:character/deref
+    i:number<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
     <span class="Delimiter">{</span>
-      done?:boolean<span class="Special"> &lt;- </span>greater-or-equal i:integer, max:integer
+      done?:boolean<span class="Special"> &lt;- </span>greater-or-equal i:number, max:number
       <span class="Identifier">break-if</span> done?:boolean
-      c:address:character<span class="Special"> &lt;- </span>index-address buf:address:array:character/deref, i:integer
-      c:address:character/deref<span class="Special"> &lt;- </span>copy <span class="Delimiter">[</span> <span class="Delimiter">]</span>
-      i:integer<span class="Special"> &lt;- </span>add i:integer, 1:literal
+      c:address:character<span class="Special"> &lt;- </span>index-address buf:address:array:character/deref, i:number
+      c:address:character/deref<span class="Special"> &lt;- </span>copy <span class="Constant">[ ]</span>
+      i:number<span class="Special"> &lt;- </span>add i:number, <span class="Constant">1:literal</span>
       <span class="Identifier">loop</span>
     <span class="Delimiter">}</span>
+    <span class="Comment"># reset cursor</span>
+    cur:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-row:offset
+    cur:address:number/deref<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
+    cur:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
+    cur:address:number/deref<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   clear-display
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-recipe print-character <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe print-character [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   c:character<span class="Special"> &lt;- </span>next-ingredient
-<span class="CommentedCode">#?   $print x:address:character #? 1</span>
-<span class="CommentedCode">#?   $print [ print-character #? 1</span>
-<span class="CommentedCode">#? ] #? 1</span>
   <span class="Delimiter">{</span>
     <span class="Comment"># if x exists</span>
+    <span class="Comment"># (handle special cases exactly like in the real screen)</span>
     <span class="Identifier">break-unless</span> x:address:screen
-<span class="CommentedCode">#?   $print [print-character2 #? 1</span>
+    row:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-row:offset
+    column:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
+    width:number<span class="Special"> &lt;- </span>get x:address:screen/deref, num-columns:offset
+    height:number<span class="Special"> &lt;- </span>get x:address:screen/deref, num-rows:offset
+    max-row:number<span class="Special"> &lt;- </span>subtract height:number, <span class="Constant">1:literal</span>
+    <span class="Comment"># special-case: newline</span>
+    <span class="Delimiter">{</span>
+      newline?:boolean<span class="Special"> &lt;- </span>equal c:character, <span class="Constant">10:literal/newlin</span>
+<span class="CommentedCode">#?       $print c:character, [ ], newline?:boolean, [ </span>
 <span class="CommentedCode">#? ] #? 1</span>
+      <span class="Identifier">break-unless</span> newline?:boolean
+      <span class="Delimiter">{</span>
+        <span class="Comment"># unless cursor is already at bottom</span>
+        at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal row:address:number/deref, max-row:number
+        <span class="Identifier">break-if</span> at-bottom?:boolean
+        <span class="Comment"># move it to the next row</span>
+        column:address:number/deref<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
+        row:address:number/deref<span class="Special"> &lt;- </span>add row:address:number/deref, <span class="Constant">1:literal</span>
+      <span class="Delimiter">}</span>
+      <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
+    <span class="Delimiter">}</span>
     <span class="Comment"># save character in fake screen</span>
-    row:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-row:offset
-    column:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
-    width:integer<span class="Special"> &lt;- </span>get x:address:screen/deref, num-columns:offset
-    index:integer<span class="Special"> &lt;- </span>multiply row:address:integer/deref, width:integer
-    index:integer<span class="Special"> &lt;- </span>add index:integer, column:address:integer/deref
+    index:number<span class="Special"> &lt;- </span>multiply row:address:number/deref, width:number
+    index:number<span class="Special"> &lt;- </span>add index:number, column:address:number/deref
     buf:address:array:character<span class="Special"> &lt;- </span>get x:address:screen/deref, data:offset
-    cursor:address:character<span class="Special"> &lt;- </span>index-address buf:address:array:character/deref, index:integer
-<span class="CommentedCode">#?     $print cursor:address:character #? 1</span>
-<span class="CommentedCode">#?     $print [ #? 1</span>
+    cursor:address:character<span class="Special"> &lt;- </span>index-address buf:address:array:character/deref, index:number
+    <span class="Comment"># special-case: backspace</span>
+    <span class="Delimiter">{</span>
+      backspace?:boolean<span class="Special"> &lt;- </span>equal c:character, <span class="Constant">8:literal</span>
+      <span class="Identifier">break-unless</span> backspace?:boolean
+      <span class="Delimiter">{</span>
+        <span class="Comment"># unless cursor is already at left margin</span>
+        at-left?:boolean<span class="Special"> &lt;- </span>lesser-or-equal column:address:number/deref, <span class="Constant">0:literal</span>
+        <span class="Identifier">break-if</span> at-left?:boolean
+        <span class="Comment"># clear previous location</span>
+        column:address:number/deref<span class="Special"> &lt;- </span>subtract column:address:number/deref, <span class="Constant">1:literal</span>
+        cursor:address:character<span class="Special"> &lt;- </span>subtract cursor:address:character, <span class="Constant">1:literal</span>
+        cursor:address:character/deref<span class="Special"> &lt;- </span>copy <span class="Constant">32:literal/space</span>
+      <span class="Delimiter">}</span>
+      <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
+    <span class="Delimiter">}</span>
+<span class="CommentedCode">#?     $print [saving character ], c:character, [ to fake screen ], cursor:address/screen, [ </span>
 <span class="CommentedCode">#? ] #? 1</span>
-    cursor:address:character/deref<span class="Special"> &lt;- </span>copy c:character  <span class="Comment"># todo: newline, etc.</span>
+    cursor:address:character/deref<span class="Special"> &lt;- </span>copy c:character
     <span class="Comment"># increment column unless it's already all the way to the right</span>
     <span class="Delimiter">{</span>
-      at-right?:boolean<span class="Special"> &lt;- </span>equal column:address:integer/deref, width:integer
+      at-right?:boolean<span class="Special"> &lt;- </span>equal column:address:number/deref, width:number
       <span class="Identifier">break-if</span> at-right?:boolean
-      column:address:integer/deref<span class="Special"> &lt;- </span>add column:address:integer/deref, 1:literal
+      column:address:number/deref<span class="Special"> &lt;- </span>add column:address:number/deref, <span class="Constant">1:literal</span>
     <span class="Delimiter">}</span>
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   print-character-to-display c:character
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-scenario print-character-at-top-left <span class="Delimiter">[</span>
-  run <span class="Delimiter">[</span>
+scenario print-character-at-top-left [
+  run [
 <span class="CommentedCode">#?     $start-tracing #? 3</span>
-    1:address:screen<span class="Special"> &lt;- </span>init-fake-screen 3:literal/width, 2:literal/height
-    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, 97:literal  <span class="Comment"># 'a'</span>
+    1:address:screen<span class="Special"> &lt;- </span>init-fake-screen <span class="Constant">3:literal/width</span>, <span class="Constant">2:literal/height</span>
+    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, <span class="Constant">97:literal</span>  <span class="Comment"># 'a'</span>
     2:address:array:character<span class="Special"> &lt;- </span>get 1:address:screen/deref, data:offset
     3:array:character<span class="Special"> &lt;- </span>copy 2:address:array:character/deref
-  <span class="Delimiter">]</span>
-  memory-should-contain <span class="Delimiter">[</span>
+  ]
+  memory-should-contain [
     3<span class="Special"> &lt;- </span>6  <span class="Comment"># width*height</span>
     4<span class="Special"> &lt;- </span>97  <span class="Comment"># 'a'</span>
     5<span class="Special"> &lt;- </span>0
-  <span class="Delimiter">]</span>
-<span class="Delimiter">]</span>
+  ]
+]
 
-recipe clear-line <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+scenario print-backspace-character [
+  run [
+<span class="CommentedCode">#?     $start-tracing #? 3</span>
+    1:address:screen<span class="Special"> &lt;- </span>init-fake-screen <span class="Constant">3:literal/width</span>, <span class="Constant">2:literal/height</span>
+    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, <span class="Constant">97:literal</span>  <span class="Comment"># 'a'</span>
+    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, <span class="Constant">8:literal</span>  <span class="Comment"># backspace</span>
+    2:number<span class="Special"> &lt;- </span>get 1:address:screen/deref, cursor-column:offset
+    3:address:array:character<span class="Special"> &lt;- </span>get 1:address:screen/deref, data:offset
+    4:array:character<span class="Special"> &lt;- </span>copy 3:address:array:character/deref
+  ]
+  memory-should-contain [
+    2<span class="Special"> &lt;- </span>0  <span class="Comment"># cursor column</span>
+    4<span class="Special"> &lt;- </span>6  <span class="Comment"># width*height</span>
+    5<span class="Special"> &lt;- </span>32  <span class="Comment"># space, not 'a'</span>
+    6<span class="Special"> &lt;- </span>0
+  ]
+]
+
+scenario print-newline-character [
+  run [
+<span class="CommentedCode">#?     $start-tracing #? 3</span>
+    1:address:screen<span class="Special"> &lt;- </span>init-fake-screen <span class="Constant">3:literal/width</span>, <span class="Constant">2:literal/height</span>
+    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, <span class="Constant">97:literal</span>  <span class="Comment"># 'a'</span>
+    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, <span class="Constant">10:literal/newline</span>
+    2:number<span class="Special"> &lt;- </span>get 1:address:screen/deref, cursor-row:offset
+    3:number<span class="Special"> &lt;- </span>get 1:address:screen/deref, cursor-column:offset
+    4:address:array:character<span class="Special"> &lt;- </span>get 1:address:screen/deref, data:offset
+    5:array:character<span class="Special"> &lt;- </span>copy 4:address:array:character/deref
+  ]
+  memory-should-contain [
+    2<span class="Special"> &lt;- </span>1  <span class="Comment"># cursor row</span>
+    3<span class="Special"> &lt;- </span>0  <span class="Comment"># cursor column</span>
+    5<span class="Special"> &lt;- </span>6  <span class="Comment"># width*height</span>
+    6<span class="Special"> &lt;- </span>97  <span class="Comment"># 'a'</span>
+    7<span class="Special"> &lt;- </span>0
+  ]
+]
+
+recipe clear-line [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, clear line in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
-    n:integer<span class="Special"> &lt;- </span>get x:address:screen/deref, num-columns:offset
-    column:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
-    original-column:integer<span class="Special"> &lt;- </span>copy column:address:integer/deref
+    n:number<span class="Special"> &lt;- </span>get x:address:screen/deref, num-columns:offset
+    column:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
+    original-column:number<span class="Special"> &lt;- </span>copy column:address:number/deref
     <span class="Comment"># space over the entire line</span>
+<span class="CommentedCode">#?     $start-tracing #? 1</span>
     <span class="Delimiter">{</span>
-      done?:boolean<span class="Special"> &lt;- </span>greater-or-equal column:address:integer/deref, n:integer
+<span class="CommentedCode">#?       $print column:address:number/deref, [ </span>
+<span class="CommentedCode">#? ] #? 1</span>
+      done?:boolean<span class="Special"> &lt;- </span>greater-or-equal column:address:number/deref, n:number
       <span class="Identifier">break-if</span> done?:boolean
-      print-character x:address:screen, <span class="Delimiter">[</span> <span class="Delimiter">]</span>  <span class="Comment"># implicitly updates 'column'</span>
+      print-character x:address:screen, <span class="Constant">[ ]</span>  <span class="Comment"># implicitly updates 'column'</span>
       <span class="Identifier">loop</span>
     <span class="Delimiter">}</span>
     <span class="Comment"># now back to where the cursor was</span>
-    column:address:integer/deref<span class="Special"> &lt;- </span>copy original-column:integer
+    column:address:number/deref<span class="Special"> &lt;- </span>copy original-column:number
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   clear-line-on-display
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-recipe cursor-position <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe cursor-position [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, lookup cursor in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
-    row:integer<span class="Special"> &lt;- </span>get x:address:screen/deref, cursor-row:offset
-    column:integer<span class="Special"> &lt;- </span>get x:address:screen/deref, cursor-column:offset
-    <span class="Identifier">reply</span> row:integer, column:integer
+    row:number<span class="Special"> &lt;- </span>get x:address:screen/deref, cursor-row:offset
+    column:number<span class="Special"> &lt;- </span>get x:address:screen/deref, cursor-column:offset
+    <span class="Identifier">reply</span> row:number, column:number, x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
-  row:integer, column:integer<span class="Special"> &lt;- </span>cursor-position-on-display
-  <span class="Identifier">reply</span> row:integer, column:integer
-<span class="Delimiter">]</span>
+  row:number, column:number<span class="Special"> &lt;- </span>cursor-position-on-display
+  <span class="Identifier">reply</span> row:number, column:number, x:address:screen/same-as-ingredient:0
+]
 
-recipe move-cursor <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe move-cursor [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
-  new-row:integer<span class="Special"> &lt;- </span>next-ingredient
-  new-column:integer<span class="Special"> &lt;- </span>next-ingredient
+  new-row:number<span class="Special"> &lt;- </span>next-ingredient
+  new-column:number<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, move cursor in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
-    row:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref cursor-row:offset
-    row:address:integer/deref<span class="Special"> &lt;- </span>copy new-row:integer
-    column:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref cursor-column:offset
-    column:address:integer/deref<span class="Special"> &lt;- </span>copy new-column:integer
+    row:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-row:offset
+    row:address:number/deref<span class="Special"> &lt;- </span>copy new-row:number
+    column:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
+    column:address:number/deref<span class="Special"> &lt;- </span>copy new-column:number
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
-  move-cursor-on-display new-row:integer, new-column:integer
+  move-cursor-on-display new-row:number, new-column:number
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-scenario clear-line-erases-printed-characters <span class="Delimiter">[</span>
-  run <span class="Delimiter">[</span>
-<span class="CommentedCode">#?     $start-tracing #? 3</span>
-    1:address:screen<span class="Special"> &lt;- </span>init-fake-screen 3:literal/width, 2:literal/height
+scenario clear-line-erases-printed-characters [
+  run [
+<span class="CommentedCode">#?     $start-tracing #? 4</span>
+    1:address:screen<span class="Special"> &lt;- </span>init-fake-screen <span class="Constant">3:literal/width</span>, <span class="Constant">2:literal/height</span>
     <span class="Comment"># print a character</span>
-    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, 97:literal  <span class="Comment"># 'a'</span>
+    1:address:screen<span class="Special"> &lt;- </span>print-character 1:address:screen, <span class="Constant">97:literal</span>  <span class="Comment"># 'a'</span>
     <span class="Comment"># move cursor to start of line</span>
-    1:address:screen<span class="Special"> &lt;- </span>move-cursor 1:address:screen, 0:literal/row, 0:literal/column
+    1:address:screen<span class="Special"> &lt;- </span>move-cursor 1:address:screen, <span class="Constant">0:literal/row</span>, <span class="Constant">0:literal/column</span>
     <span class="Comment"># clear line</span>
     1:address:screen<span class="Special"> &lt;- </span>clear-line 1:address:screen
     2:address:array:character<span class="Special"> &lt;- </span>get 1:address:screen/deref, data:offset
     3:array:character<span class="Special"> &lt;- </span>copy 2:address:array:character/deref
-  <span class="Delimiter">]</span>
+  ]
   <span class="Comment"># screen should be blank</span>
-  memory-should-contain <span class="Delimiter">[</span>
+  memory-should-contain [
     3<span class="Special"> &lt;- </span>6  <span class="Comment"># width*height</span>
     4<span class="Special"> &lt;- </span>0
     5<span class="Special"> &lt;- </span>0
@@ -215,94 +292,143 @@ scenario clear-line-erases-printed-characters <span class="Delimiter">[</span>
     7<span class="Special"> &lt;- </span>0
     8<span class="Special"> &lt;- </span>0
     9<span class="Special"> &lt;- </span>0
-  <span class="Delimiter">]</span>
-<span class="Delimiter">]</span>
+  ]
+]
 
-recipe cursor-down <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe cursor-down [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, move cursor in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
     <span class="Delimiter">{</span>
       <span class="Comment"># if row &lt; height</span>
-      height:integer<span class="Special"> &lt;- </span>get x:address:screen/deref, num-rows:offset
-      row:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref cursor-row:offset
-      at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal row:address:integer/deref, height:integer
+      height:number<span class="Special"> &lt;- </span>get x:address:screen/deref, num-rows:offset
+      row:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-row:offset
+      at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal row:address:number/deref, height:number
       <span class="Identifier">break-if</span> at-bottom?:boolean
       <span class="Comment"># row = row+1</span>
-      row:address:integer/deref<span class="Special"> &lt;- </span>add row:address:integer, 1:literal
+<span class="CommentedCode">#?       $print [AAA: ], row:address:number, [ -&gt; ], row:address:number/deref, [ </span>
+<span class="CommentedCode">#? ] #? 1</span>
+      row:address:number/deref<span class="Special"> &lt;- </span>add row:address:number/deref, <span class="Constant">1:literal</span>
+<span class="CommentedCode">#?       $print [BBB: ], row:address:number, [ -&gt; ], row:address:number/deref, [ </span>
+<span class="CommentedCode">#? ] #? 1</span>
+<span class="CommentedCode">#?       $start-tracing #? 1</span>
     <span class="Delimiter">}</span>
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   move-cursor-down-on-display
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-recipe cursor-up <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe cursor-up [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, move cursor in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
     <span class="Delimiter">{</span>
       <span class="Comment"># if row &gt;= 0</span>
-      row:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref cursor-row:offset
-      at-top?:boolean<span class="Special"> &lt;- </span>lesser-than row:address:integer/deref, 0:literal
+      row:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-row:offset
+      at-top?:boolean<span class="Special"> &lt;- </span>lesser-than row:address:number/deref, <span class="Constant">0:literal</span>
       <span class="Identifier">break-if</span> at-top?:boolean
       <span class="Comment"># row = row-1</span>
-      row:address:integer/deref<span class="Special"> &lt;- </span>subtract row:address:integer, 1:literal
+      row:address:number/deref<span class="Special"> &lt;- </span>subtract row:address:number/deref, <span class="Constant">1:literal</span>
     <span class="Delimiter">}</span>
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   move-cursor-up-on-display
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-recipe cursor-right <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe cursor-right [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, move cursor in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
     <span class="Delimiter">{</span>
       <span class="Comment"># if column &lt; width</span>
-      width:integer<span class="Special"> &lt;- </span>get x:address:screen/deref, num-columns:offset
-      column:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref cursor-column:offset
-      at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal column:address:integer/deref, width:integer
+      width:number<span class="Special"> &lt;- </span>get x:address:screen/deref, num-columns:offset
+      column:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
+      at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal column:address:number/deref, width:number
       <span class="Identifier">break-if</span> at-bottom?:boolean
       <span class="Comment"># column = column+1</span>
-      column:address:integer/deref<span class="Special"> &lt;- </span>add column:address:integer, 1:literal
+      column:address:number/deref<span class="Special"> &lt;- </span>add column:address:number/deref, <span class="Constant">1:literal</span>
     <span class="Delimiter">}</span>
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   move-cursor-right-on-display
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
 
-recipe cursor-left <span class="Delimiter">[</span>
-  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
+recipe cursor-left [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
   x:address:screen<span class="Special"> &lt;- </span>next-ingredient
   <span class="Comment"># if x exists, move cursor in fake screen</span>
   <span class="Delimiter">{</span>
     <span class="Identifier">break-unless</span> x:address:screen
     <span class="Delimiter">{</span>
       <span class="Comment"># if column &gt;= 0</span>
-      column:address:integer<span class="Special"> &lt;- </span>get-address x:address:screen/deref cursor-column:offset
-      at-top?:boolean<span class="Special"> &lt;- </span>lesser-than column:address:integer/deref, 0:literal
+      column:address:number<span class="Special"> &lt;- </span>get-address x:address:screen/deref, cursor-column:offset
+      at-top?:boolean<span class="Special"> &lt;- </span>lesser-than column:address:number/deref, <span class="Constant">0:literal</span>
       <span class="Identifier">break-if</span> at-top?:boolean
       <span class="Comment"># column = column-1</span>
-      column:address:integer/deref<span class="Special"> &lt;- </span>subtract column:address:integer, 1:literal
+      column:address:number/deref<span class="Special"> &lt;- </span>subtract column:address:number/deref, <span class="Constant">1:literal</span>
     <span class="Delimiter">}</span>
     <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
   <span class="Delimiter">}</span>
   <span class="Comment"># otherwise, real screen</span>
   move-cursor-left-on-display
   <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
-<span class="Delimiter">]</span>
+]
+
+recipe cursor-to-start-of-line [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
+  x:address:screen<span class="Special"> &lt;- </span>next-ingredient
+  row:number, _, x:address:screen<span class="Special"> &lt;- </span>cursor-position x:address:screen
+  column:number<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
+  x:address:screen<span class="Special"> &lt;- </span>move-cursor x:address:screen, row:number, column:number
+  <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
+]
+
+recipe cursor-to-next-line [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
+  x:address:screen<span class="Special"> &lt;- </span>next-ingredient
+  x:address:screen<span class="Special"> &lt;- </span>cursor-down x:address:screen
+  x:address:screen<span class="Special"> &lt;- </span>cursor-to-start-of-line x:address:screen
+  <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
+]
+
+recipe print-string [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
+  x:address:screen<span class="Special"> &lt;- </span>next-ingredient
+  s:address:array:character<span class="Special"> &lt;- </span>next-ingredient
+  len:number<span class="Special"> &lt;- </span>length s:address:array:character/deref
+  i:number<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
+  <span class="Delimiter">{</span>
+    done?:boolean<span class="Special"> &lt;- </span>greater-or-equal i:number, len:number
+    <span class="Identifier">break-if</span> done?:boolean
+    c:character<span class="Special"> &lt;- </span>index s:address:array:character/deref, i:number
+    print-character x:address:screen c:character
+    i:number<span class="Special"> &lt;- </span>add i:number, <span class="Constant">1:literal</span>
+    <span class="Identifier">loop</span>
+  <span class="Delimiter">}</span>
+  <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
+]
+
+recipe print-integer [
+  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
+  x:address:screen<span class="Special"> &lt;- </span>next-ingredient
+  n:number<span class="Special"> &lt;- </span>next-ingredient
+  <span class="Comment"># todo: other bases besides decimal</span>
+  s:address:array:character<span class="Special"> &lt;- </span>integer-to-decimal-string n:number
+  print-string x:address:screen, s:address:array:character
+  <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0
+]
 </pre>
 </body>
 </html>