about summary refs log tree commit diff stats
path: root/html/edit
diff options
context:
space:
mode:
Diffstat (limited to 'html/edit')
-rw-r--r--html/edit/001-editor.mu.html232
-rw-r--r--html/edit/002-typing.mu.html596
-rw-r--r--html/edit/003-shortcuts.mu.html1418
-rw-r--r--html/edit/004-programming-environment.mu.html414
-rw-r--r--html/edit/005-sandbox.mu.html474
-rw-r--r--html/edit/006-sandbox-copy.mu.html90
-rw-r--r--html/edit/007-sandbox-delete.mu.html84
-rw-r--r--html/edit/008-sandbox-edit.mu.html64
-rw-r--r--html/edit/009-sandbox-test.mu.html80
-rw-r--r--html/edit/010-sandbox-trace.mu.html90
-rw-r--r--html/edit/011-errors.mu.html132
-rw-r--r--html/edit/012-editor-undo.mu.html888
12 files changed, 2281 insertions, 2281 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html
index a0044e7a..01b0bf0a 100644
--- a/html/edit/001-editor.mu.html
+++ b/html/edit/001-editor.mu.html
@@ -87,22 +87,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Comment"># no clipping of bounds</span>
-  right<span class="Special"> &lt;- </span>subtract right, <span class="Constant">1</span>
-  result<span class="Special"> &lt;- </span>new <span class="Constant">editor:type</span>
+  right <span class="Special">&lt;-</span> subtract right,<span class="Constant"> 1</span>
+  result <span class="Special">&lt;-</span> new <span class="Constant">editor:type</span>
   <span class="Comment"># initialize screen-related fields</span>
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">left:offset</span>, left
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">right:offset</span>, right
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">left:offset</span>, left
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">right:offset</span>, right
   <span class="Comment"># initialize cursor coordinates</span>
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1/top</span>
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">cursor-column:offset</span>, left
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1/top</span>
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">cursor-column:offset</span>, left
   <span class="Comment"># initialize empty contents</span>
-  init:&amp;:duplex-list:char<span class="Special"> &lt;- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span>
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">data:offset</span>, init
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">top-of-screen:offset</span>, init
-  *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">before-cursor:offset</span>, init
-  result<span class="Special"> &lt;- </span>insert-text result, s
+  init:&amp;:duplex-list:char <span class="Special">&lt;-</span> push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span>
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">data:offset</span>, init
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">top-of-screen:offset</span>, init
+  *result <span class="Special">&lt;-</span> put *result, <span class="Constant">before-cursor:offset</span>, init
+  result <span class="Special">&lt;-</span> insert-text result, s
   <span class="Comment"># initial render to screen, just for some old tests</span>
-  _, _, screen, result<span class="Special"> &lt;- </span>render screen, result
+  _, _, screen, result <span class="Special">&lt;-</span> render screen, result
 <span class="Constant">  &lt;editor-initialization&gt;</span>
 ]
 
@@ -110,42 +110,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Comment"># early exit if text is empty</span>
-  <span class="muControl">return-unless</span> text, editor/same-as-ingredient:<span class="Constant">0</span>
-  len:num<span class="Special"> &lt;- </span>length *text
-  <span class="muControl">return-unless</span> len, editor/same-as-ingredient:<span class="Constant">0</span>
-  idx:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  <span class="muControl">return-unless</span> text, editor/same-as-ingredient:0
+  len:num <span class="Special">&lt;-</span> length *text
+  <span class="muControl">return-unless</span> len, editor/same-as-ingredient:0
+  idx:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span>
   <span class="Comment"># now we can start appending the rest, character by character</span>
-  curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span>
+  curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span>
   <span class="Delimiter">{</span>
-    done?:bool<span class="Special"> &lt;- </span>greater-or-equal idx, len
+    done?:bool <span class="Special">&lt;-</span> greater-or-equal idx, len
     <span class="muControl">break-if</span> done?
-    c:char<span class="Special"> &lt;- </span>index *text, idx
+    c:char <span class="Special">&lt;-</span> index *text, idx
     insert c, curr
     <span class="Comment"># next iter</span>
-    curr<span class="Special"> &lt;- </span>next curr
-    idx<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span>
+    curr <span class="Special">&lt;-</span> next curr
+    idx <span class="Special">&lt;-</span> add idx,<span class="Constant"> 1</span>
     <span class="muControl">loop</span>
   <span class="Delimiter">}</span>
-  <span class="muControl">return</span> editor/same-as-ingredient:<span class="Constant">0</span>
+  <span class="muControl">return</span> editor/same-as-ingredient:0
 ]
 
 <span class="muScenario">scenario</span> editor-initializes-without-data [
   <span class="Constant">local-scope</span>
   assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span>
   run [
-    e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">0/data</span>, screen:&amp;:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span>
-    <span class="Constant">2</span>:editor/<span class="Special">raw &lt;- </span>copy *e
+    e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">0/data</span>, screen:&amp;:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span>
+    2:editor/<span class="Special">raw</span> <span class="Special">&lt;-</span> copy *e
   ]
   memory-should-contain [
     <span class="Comment"># 2 (data) &lt;- just the § sentinel</span>
     <span class="Comment"># 3 (top of screen) &lt;- the § sentinel</span>
-    <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># bottom-of-screen; null since text fits on screen</span>
+   <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span>  <span class="Comment"># bottom-of-screen; null since text fits on screen</span>
     <span class="Comment"># 5 (before cursor) &lt;- the § sentinel</span>
-    <span class="Constant">6</span><span class="Special"> &lt;- </span><span class="Constant">2</span>  <span class="Comment"># left</span>
-    <span class="Constant">7</span><span class="Special"> &lt;- </span><span class="Constant">4</span>  <span class="Comment"># right  (inclusive)</span>
-    <span class="Constant">8</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># bottom</span>
-    <span class="Constant">9</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># cursor row</span>
-    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">2</span>  <span class="Comment"># cursor column</span>
+   <span class="Constant"> 6</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span>  <span class="Comment"># left</span>
+   <span class="Constant"> 7</span> <span class="Special">&lt;-</span><span class="Constant"> 4</span>  <span class="Comment"># right  (inclusive)</span>
+   <span class="Constant"> 8</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span>  <span class="Comment"># bottom</span>
+   <span class="Constant"> 9</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span>  <span class="Comment"># cursor row</span>
+   <span class="Constant"> 10</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span>  <span class="Comment"># cursor column</span>
   ]
   screen-should-contain [
    <span class="Constant"> .     .</span>
@@ -160,102 +160,102 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="muRecipe">def</span> render screen:&amp;:screen, editor:&amp;:editor<span class="muRecipe"> -&gt; </span>last-row:num, last-column:num, screen:&amp;:screen, editor:&amp;:editor [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>
-  left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span>
-  screen-height:num<span class="Special"> &lt;- </span>screen-height screen
-  right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span>
+  <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:0, editor/same-as-ingredient:1
+  left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span>
+  screen-height:num <span class="Special">&lt;-</span> screen-height screen
+  right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span>
   <span class="Comment"># traversing editor</span>
-  curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span>
-  prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy curr  <span class="Comment"># just in case curr becomes null and we can't compute prev</span>
-  curr<span class="Special"> &lt;- </span>next curr
+  curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span>
+  prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy curr  <span class="Comment"># just in case curr becomes null and we can't compute prev</span>
+  curr <span class="Special">&lt;-</span> next curr
   <span class="Comment"># traversing screen</span>
 <span class="Constant">  +render-loop-initialization</span>
-  color:num<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span>
-  row:num<span class="Special"> &lt;- </span>copy <span class="Constant">1/top</span>
-  column:num<span class="Special"> &lt;- </span>copy left
-  cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span>
-  cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span>
-  before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span>
-  screen<span class="Special"> &lt;- </span>move-cursor screen, row, column
+  color:num <span class="Special">&lt;-</span> copy <span class="Constant">7/white</span>
+  row:num <span class="Special">&lt;-</span> copy <span class="Constant">1/top</span>
+  column:num <span class="Special">&lt;-</span> copy left
+  cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span>
+  cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span>
+  before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span>
+  screen <span class="Special">&lt;-</span> move-cursor screen, row, column
   <span class="Delimiter">{</span>
 <span class="Constant">    +next-character</span>
     <span class="muControl">break-unless</span> curr
-    off-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal row, screen-height
+    off-screen?:bool <span class="Special">&lt;-</span> greater-or-equal row, screen-height
     <span class="muControl">break-if</span> off-screen?
     <span class="Comment"># update editor.before-cursor</span>
     <span class="Comment"># Doing so at the start of each iteration ensures it stays one step behind</span>
     <span class="Comment"># the current character.</span>
     <span class="Delimiter">{</span>
-      at-cursor-row?:bool<span class="Special"> &lt;- </span>equal row, cursor-row
+      at-cursor-row?:bool <span class="Special">&lt;-</span> equal row, cursor-row
       <span class="muControl">break-unless</span> at-cursor-row?
-      at-cursor?:bool<span class="Special"> &lt;- </span>equal column, cursor-column
+      at-cursor?:bool <span class="Special">&lt;-</span> equal column, cursor-column
       <span class="muControl">break-unless</span> at-cursor?
-      before-cursor<span class="Special"> &lt;- </span>copy prev
+      before-cursor <span class="Special">&lt;-</span> copy prev
     <span class="Delimiter">}</span>
-    c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span>
+    c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span>
 <span class="Constant">    &lt;character-c-received&gt;</span>
     <span class="Delimiter">{</span>
       <span class="Comment"># newline? move to left rather than 0</span>
-      newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span>
+      newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span>
       <span class="muControl">break-unless</span> newline?
       <span class="Comment"># adjust cursor if necessary</span>
       <span class="Delimiter">{</span>
-        at-cursor-row?:bool<span class="Special"> &lt;- </span>equal row, cursor-row
+        at-cursor-row?:bool <span class="Special">&lt;-</span> equal row, cursor-row
         <span class="muControl">break-unless</span> at-cursor-row?
-        left-of-cursor?:bool<span class="Special"> &lt;- </span>lesser-than column, cursor-column
+        left-of-cursor?:bool <span class="Special">&lt;-</span> lesser-than column, cursor-column
         <span class="muControl">break-unless</span> left-of-cursor?
-        cursor-column<span class="Special"> &lt;- </span>copy column
-        before-cursor<span class="Special"> &lt;- </span>prev curr
+        cursor-column <span class="Special">&lt;-</span> copy column
+        before-cursor <span class="Special">&lt;-</span> prev curr
       <span class="Delimiter">}</span>
       <span class="Comment"># clear rest of line in this window</span>
       clear-line-until screen, right
       <span class="Comment"># skip to next line</span>
-      row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
-      column<span class="Special"> &lt;- </span>copy left
-      screen<span class="Special"> &lt;- </span>move-cursor screen, row, column
-      curr<span class="Special"> &lt;- </span>next curr
-      prev<span class="Special"> &lt;- </span>next prev
+      row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span>
+      column <span class="Special">&lt;-</span> copy left
+      screen <span class="Special">&lt;-</span> move-cursor screen, row, column
+      curr <span class="Special">&lt;-</span> next curr
+      prev <span class="Special">&lt;-</span> next prev
       <span class="muControl">loop</span> <span class="Constant">+next-character</span>
     <span class="Delimiter">}</span>
     <span class="Delimiter">{</span>
       <span class="Comment"># at right? wrap. even if there's only one more letter left; we need</span>
       <span class="Comment"># room for clicking on the cursor after it.</span>
-      at-right?:bool<span class="Special"> &lt;- </span>equal column, right
+      at-right?:bool <span class="Special">&lt;-</span> equal column, right
       <span class="muControl">break-unless</span> at-right?
       <span class="Comment"># print wrap icon</span>
-      wrap-icon:char<span class="Special"> &lt;- </span>copy <span class="Constant">8617/loop-back-to-left</span>
+      wrap-icon:char <span class="Special">&lt;-</span> copy <span class="Constant">8617/loop-back-to-left</span>
       print screen, wrap-icon, <span class="Constant">245/grey</span>
-      column<span class="Special"> &lt;- </span>copy left
-      row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
-      screen<span class="Special"> &lt;- </span>move-cursor screen, row, column
+      column <span class="Special">&lt;-</span> copy left
+      row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span>
+      screen <span class="Special">&lt;-</span> move-cursor screen, row, column
>push_back<span class="Delimiter">(</span><a href='060rewrite_literal_string.cc.html#L36'>rewrite_literal_string_to_text</a><span class="Delimiter">);</span>  <span class="Comment">// idempotent</span>
<span id="L17" class="LineNr">17 </span>
<span id="L18" class="LineNr">18 </span><span class="Delimiter">:(before &quot;End Globals&quot;)</span>
<span id="L19" class="LineNr">19 </span>set&lt;string&gt; recipes_taking_literal_strings<span class="Delimiter">;</span>
<span id="L20" class="LineNr">20 </span><span class="Delimiter">:(code)</span>
<span id="L21" class="LineNr">21 </span><span class="Normal">void</span> <a href='060rewrite_literal_string.cc.html#L21'>initialize_transform_rewrite_literal_string_to_text</a><span class="Delimiter">()</span> <span class="Delimiter">{</span>
<span id="L22" class="LineNr">22 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;$print&quot;</span><span class="Delimiter">);</span>
<span id="L23" class="LineNr">23 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;$dump-trace&quot;</span><span class="Delimiter">);</span>
<span id="L24" class="LineNr">24 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;$system&quot;</span><span class="Delimiter">);</span>
<span id="L25" class="LineNr">25 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;trace&quot;</span><span class="Delimiter">);</span>
<span id="L26" class="LineNr">26 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;stash&quot;</span><span class="Delimiter">);</span>
<span id="L27" class="LineNr">27 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;new&quot;</span><span class="Delimiter">);</span>
<span id="L28" class="LineNr">28 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span><span class="Delimiter">);</span>
<span id="L29" class="LineNr">29 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;memory-should-contain&quot;</span><span class="Delimiter">);</span>
<span id="L30" class="LineNr">30 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;trace-should-contain&quot;</span><span class="Delimiter">);</span>
<span id="L31" class="LineNr">31 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;trace-should-not-contain&quot;</span><span class="Delimiter">);</span>
<span id="L32" class="LineNr">32 </span>  recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">&quot;check-trace-count-for-label&quot;</span><span class="Delimiter">);</span>
<span id="L33" class="LineNr">33 </span>  <span class="Comment">// End initialize_transform_rewrite_literal_string_to_text()</span>
<span id="L34" class="LineNr">34 </span><span class="Delimiter">}</span>
<span id="L35" class="LineNr">35 </span>
<span id="L36" class="LineNr">36 </span><span class="Normal">void</span> <a href='060rewrite_literal_string.cc.html#L36'>rewrite_literal_string_to_text</a><span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L37" class="LineNr">37 </span>  recipe&amp; caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span>
<span id="L38" class="LineNr">38 </span>  <a href='003trace.cc.html#L161'>trace</a><span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;--- rewrite literal strings in <a href='010vm.cc.html#L19'>recipe</a> &quot;</span> &lt;&lt; caller<span class="Delimiter">.</span>name &lt;&lt; <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span>
<span id="L39" class="LineNr">39 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span><a href='060rewrite_literal_string.cc.html#L62'>contains_numeric_locations</a><span class="Delimiter">(</span>caller<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L40" class="LineNr">40 </span>  vector&lt;instruction&gt; new_instructions<span class="Delimiter">;</span>
<span id="L41" class="LineNr">41 </span>  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L42" class="LineNr">42 </span>  <span class="Conceal">¦</span> instruction&amp; inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
<span id="L43" class="LineNr">43 </span>  <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>recipes_taking_literal_strings<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name<span class="Delimiter">)</span> == recipes_taking_literal_strings<span class="Delimiter">.</span><a href='003trace.cc.html#L185'>end</a><span class="Delimiter">())</span> <span class="Delimiter">{</span>
<span id="L44" class="LineNr">44 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span>  j &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span>  ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L45" class="LineNr">45 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal_text<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
<span id="L46" class="LineNr">46 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='010vm.cc.html#L32'>instruction</a> def<span class="Delimiter">;</span>
<span id="L47" class="LineNr">47 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> ostringstream ingredient_name<span class="Delimiter">;</span>
<span id="L48" class="LineNr">48 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> ingredient_name &lt;&lt; inst<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">'_'</span> &lt;&lt; i &lt;&lt; <span class="Constant">'_'</span> &lt;&lt; j &lt;&lt; <span class="Constant">&quot;:text&quot;</span><span class="Delimiter">;</span>
<span id="L49" class="LineNr">49 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> def<span class="Delimiter">.</span>name = <span class="Constant">&quot;new&quot;</span><span class="Delimiter">;</span>
<span id="L50" class="LineNr">50 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> def<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span>
<span id="L51" class="LineNr">51 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> def<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">()));</span>
<span id="L52" class="LineNr">52 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>def<span class="Delimiter">);</span>
<span id="L53" class="LineNr">53 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span><a href='050scenario.cc.html#L60'>clear</a><span class="Delimiter">();</span>  <span class="Comment">// reclaim old memory</span>
<span id="L54" class="LineNr">54 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> = reagent<span class="Delimiter">(</span>ingredient_name<span class="Delimiter">.</span>str<span class="Delimiter">());</span>
<span id="L55" class="LineNr">55 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span>
<span id="L56" class="LineNr">56 </span>  <span class="Conceal">¦</span> <span class="Delimiter">}</span>
<span id="L57" class="LineNr">57 </span>  <span class="Conceal">¦</span> new_instructions<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span>
<span id="L58" class="LineNr">58 </span>  <span class="Delimiter">}</span>
<span id="L59" class="LineNr">59 </span>  caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_instructions<span class="Delimiter">);</span>
<span id="L60" class="LineNr">60 </span><span class="Delimiter">}</span>
<span id="L61" class="LineNr">61 </span>
<span id="L62" class="LineNr">62 </span><span class="Normal">bool</span> <a href='060rewrite_literal_string.cc.html#L62'>contains_numeric_locations</a><span class="Delimiter">(</span><span class="Normal">const</span> recipe&amp; caller<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L63" class="LineNr">63 </span>  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L64" class="LineNr">64 </span>  <span class="Conceal">¦</span> <span class="Normal">const</span> instruction&amp; inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
<span id="L65" class="LineNr">65 </span>  <span class="Conceal">¦</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span>  in &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span>  ++in<span class="Delimiter">)</span>
<span id="L66" class="LineNr">66 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='042name.cc.html#L141'>is_numeric_location</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span>
<span id="L67" class="LineNr">67 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span>
<span id="L68" class="LineNr">68 </span>  <span class="Conceal">¦</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span>  out &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span>  ++out<span class="Delimiter">)</span>
<span id="L69" class="LineNr">69 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='042name.cc.html#L141'>is_numeric_location</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span>
<span id="L70" class="LineNr">70 </span>  <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span>
<span id="L71" class="LineNr">71 </span>  <span class="Delimiter">}</span>
<span id="L72" class="LineNr">72 </span>  <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
<span id="L73" class="LineNr">73 </span><span class="Delimiter">}</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->
span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ type <span class="Constant">[0]</span> - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> type <span class="Constant">[d]</span> ] run [ @@ -516,17 +516,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">7</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 4 for first letter, 3 for second</span> + check-trace-count-for-label<span class="Constant"> 7</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 4 for first letter, 3 for second</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of last line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># right of last line</span> type <span class="Constant">[d]</span> ] run [ @@ -538,19 +538,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of non-last line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># right of non-last line</span> type <span class="Constant">[e]</span> ] run [ @@ -563,17 +563,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[d]</span> ] run [ @@ -585,19 +585,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[e]</span> ] run [ @@ -610,19 +610,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[ef]</span> ] run [ @@ -635,13 +635,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[ab]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[ab]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e assume-console [ type <span class="Constant">[01]</span> @@ -662,7 +662,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Comment"># type a letter</span> assume-console [ @@ -700,24 +700,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdefg</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Comment"># type more text at the start</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> type <span class="Constant">[abc]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] <span class="Comment"># but line is wrapped</span> screen-should-contain [ @@ -735,47 +735,47 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if either:</span> <span class="Comment"># a) we're at the end of the line and at the column of the wrap indicator, or</span> <span class="Comment"># b) we're not at end of line and just before the column of the wrap indicator</span> - wrap-column:num<span class="Special"> &lt;- </span>copy right - before-wrap-column:num<span class="Special"> &lt;- </span>subtract wrap-column, <span class="Constant">1</span> - at-wrap?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-column, wrap-column - just-before-wrap?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-column, before-wrap-column - next:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + wrap-column:num <span class="Special">&lt;-</span> copy right + before-wrap-column:num <span class="Special">&lt;-</span> subtract wrap-column,<span class="Constant"> 1</span> + at-wrap?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-column, wrap-column + just-before-wrap?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-column, before-wrap-column + next:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="Comment"># at end of line? next == 0 || next.value == 10/newline</span> - at-end-of-line?:bool<span class="Special"> &lt;- </span>equal next, <span class="Constant">0</span> + at-end-of-line?:bool <span class="Special">&lt;-</span> equal next,<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - next-character:char<span class="Special"> &lt;- </span>get *next, <span class="Constant">value:offset</span> - at-end-of-line?<span class="Special"> &lt;- </span>equal next-character, <span class="Constant">10/newline</span> + next-character:char <span class="Special">&lt;-</span> get *next, <span class="Constant">value:offset</span> + at-end-of-line? <span class="Special">&lt;-</span> equal next-character, <span class="Constant">10/newline</span> <span class="Delimiter">}</span> <span class="Comment"># break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?))</span> - move-cursor-to-next-line?:bool<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + move-cursor-to-next-line?:bool <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - move-cursor-to-next-line?<span class="Special"> &lt;- </span>copy just-before-wrap? + move-cursor-to-next-line? <span class="Special">&lt;-</span> copy just-before-wrap? <span class="Comment"># if we're moving the cursor because it's in the middle of a wrapping</span> <span class="Comment"># line, adjust it to left-most column</span> - potential-new-cursor-column:num<span class="Special"> &lt;- </span>copy left + potential-new-cursor-column:num <span class="Special">&lt;-</span> copy left <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> at-end-of-line? - move-cursor-to-next-line?<span class="Special"> &lt;- </span>copy at-wrap? + move-cursor-to-next-line? <span class="Special">&lt;-</span> copy at-wrap? <span class="Comment"># if we're moving the cursor because it's at the end of a wrapping line,</span> <span class="Comment"># adjust it to one past the left-most column to make room for the</span> <span class="Comment"># newly-inserted wrap-indicator</span> - potential-new-cursor-column:num<span class="Special"> &lt;- </span>add left, <span class="Constant">1/make-room-for-wrap-indicator</span> + potential-new-cursor-column:num <span class="Special">&lt;-</span> add left, <span class="Constant">1/make-room-for-wrap-indicator</span> <span class="Delimiter">}</span> <span class="muControl">break-unless</span> move-cursor-to-next-line? - cursor-column<span class="Special"> &lt;- </span>copy potential-new-cursor-column - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - cursor-row<span class="Special"> &lt;- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> copy potential-new-cursor-column + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-row <span class="Special">&lt;-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Comment"># if we're out of the screen, scroll down</span> <span class="Delimiter">{</span> - below-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-row, screen-height + below-screen?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-row, screen-height <span class="muControl">break-unless</span> below-screen? <span class="Constant"> &lt;scroll-down&gt;</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -783,15 +783,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Comment"># right before the wrap icon</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> <span class="Comment"># right before the wrap icon</span> type <span class="Constant">[f]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -801,8 +801,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column</span> ] ] @@ -810,9 +810,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># create an editor containing two lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">xyz]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> @@ -820,7 +820,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> <span class="Comment"># at end of first line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> <span class="Comment"># at end of first line</span> type <span class="Constant">[de]</span> <span class="Comment"># trigger wrap</span> ] run [ @@ -838,15 +838,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># line is full; no wrap icon yet</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># line is full; no wrap icon yet</span> type <span class="Constant">[01]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -856,8 +856,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] ] @@ -868,13 +868,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;editor-initialization&gt;</span> [ - *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> + *result <span class="Special">&lt;-</span> put *result, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -893,12 +893,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Constant"> &lt;insert-enter-begin&gt;</span> - editor<span class="Special"> &lt;- </span>insert-new-line-and-indent editor, screen + editor <span class="Special">&lt;-</span> insert-new-line-and-indent editor, screen <span class="Constant"> &lt;insert-enter-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -906,41 +906,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> insert-new-line-and-indent editor:&amp;:editor, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, screen:&amp;:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:num<span class="Special"> &lt;- </span>screen-height screen + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + screen-height:num <span class="Special">&lt;-</span> screen-height screen <span class="Comment"># insert newline</span> insert <span class="Constant">10/newline</span>, before-cursor - before-cursor<span class="Special"> &lt;- </span>next before-cursor - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row<span class="Special"> &lt;- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>copy left - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special">&lt;-</span> next before-cursor + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special">&lt;-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> copy left + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># maybe scroll</span> <span class="Delimiter">{</span> - below-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> + below-screen?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> <span class="muControl">break-unless</span> below-screen? <span class="Constant"> &lt;scroll-down&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> - cursor-row<span class="Special"> &lt;- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> + cursor-row <span class="Special">&lt;-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Delimiter">}</span> <span class="Comment"># indent if necessary</span> - indent?:bool<span class="Special"> &lt;- </span>get *editor, <span class="Constant">indent?:offset</span> + indent?:bool <span class="Special">&lt;-</span> get *editor, <span class="Constant">indent?:offset</span> <span class="muControl">return-unless</span> indent? - d:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> - end-of-previous-line:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev before-cursor - indent:num<span class="Special"> &lt;- </span>line-indent end-of-previous-line, d - i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + d:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> + end-of-previous-line:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev before-cursor + indent:num <span class="Special">&lt;-</span> line-indent end-of-previous-line, d + i:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - indent-done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, indent + indent-done?:bool <span class="Special">&lt;-</span> greater-or-equal i, indent <span class="muControl">break-if</span> indent-done? - editor, screen, go-render?:bool<span class="Special"> &lt;- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen - i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span> + editor, screen, go-render?:bool <span class="Special">&lt;-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen + i <span class="Special">&lt;-</span> add i,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -950,28 +950,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> line-indent curr:&amp;:duplex-list:char, start:&amp;:duplex-list:char<span class="muRecipe"> -&gt; </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + result:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="muControl">return-unless</span> curr - at-start?:bool<span class="Special"> &lt;- </span>equal curr, start + at-start?:bool <span class="Special">&lt;-</span> equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> - curr<span class="Special"> &lt;- </span>prev curr + curr <span class="Special">&lt;-</span> prev curr <span class="muControl">break-unless</span> curr - at-start?:bool<span class="Special"> &lt;- </span>equal curr, start + at-start?:bool <span class="Special">&lt;-</span> equal curr, start <span class="muControl">break-if</span> at-start? - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment"># if c is a space, increment result</span> - is-space?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">32/space</span> + is-space?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">32/space</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-space? - result<span class="Special"> &lt;- </span>add result, <span class="Constant">1</span> + result <span class="Special">&lt;-</span> add result,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Comment"># if c is not a space, reset result</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-space? - result<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + result <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -980,7 +980,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -1000,7 +1000,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-clears-previous-line-completely-after-inserting-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -1027,70 +1027,70 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[ab</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 8</span> type [ ] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> <span class="Comment"># cursor column (indented)</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> <span class="Comment"># cursor column (indented)</span> ] ] <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[ab</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline' surrounded by paste markers</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">8</span> - press <span class="Constant">65507</span> <span class="Comment"># start paste</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 8</span> + press<span class="Constant"> 65507</span> <span class="Comment"># start paste</span> press enter - press <span class="Constant">65506</span> <span class="Comment"># end paste</span> + press<span class="Constant"> 65506</span> <span class="Comment"># end paste</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> <span class="Comment"># cursor column (not indented)</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column (not indented)</span> ] ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - paste-start?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65507/paste-start</span> + paste-start?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65507/paste-start</span> <span class="muControl">break-unless</span> paste-start? - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - paste-end?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65506/paste-end</span> + paste-end?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65506/paste-end</span> <span class="muControl">break-unless</span> paste-end? - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1100,28 +1100,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> draw-horizontal screen:&amp;:screen, row:num, x:num, right:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:char, style-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool <span class="Special">&lt;-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? - style<span class="Special"> &lt;- </span>copy <span class="Constant">9472/horizontal</span> + style <span class="Special">&lt;-</span> copy <span class="Constant">9472/horizontal</span> <span class="Delimiter">}</span> - color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool <span class="Special">&lt;-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> <span class="muControl">break-if</span> color-found? - color<span class="Special"> &lt;- </span>copy <span class="Constant">245/grey</span> + color <span class="Special">&lt;-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span> + bg-color:num, bg-color-found?:bool <span class="Special">&lt;-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> bg-color-found? - bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span> + bg-color <span class="Special">&lt;-</span> copy <span class="Constant">0/black</span> <span class="Delimiter">}</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, row, x + screen <span class="Special">&lt;-</span> move-cursor screen, row, x <span class="Delimiter">{</span> - continue?:bool<span class="Special"> &lt;- </span>lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor semantics</span> + continue?:bool <span class="Special">&lt;-</span> lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor semantics</span> <span class="muControl">break-unless</span> continue? print screen, style, color, bg-color - x<span class="Special"> &lt;- </span>add x, <span class="Constant">1</span> + x <span class="Special">&lt;-</span> add x,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 2dc6965f..cc243281 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -42,9 +42,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[ab</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press tab ] @@ -60,13 +60,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - tab?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">9/tab</span> + tab?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">9/tab</span> <span class="muControl">break-unless</span> tab? <span class="Constant"> &lt;insert-character-begin&gt;</span> - editor, screen, go-render?:bool<span class="Special"> &lt;- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen - editor, screen, go-render?:bool<span class="Special"> &lt;- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool <span class="Special">&lt;-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool <span class="Special">&lt;-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen <span class="Constant"> &lt;insert-character-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -76,17 +76,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-backspace-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press backspace ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -95,18 +95,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - delete-previous-character?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">8/backspace</span> + delete-previous-character?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">8/backspace</span> <span class="muControl">break-unless</span> delete-previous-character? <span class="Constant"> &lt;backspace-character-begin&gt;</span> - editor, screen, go-render?:bool, backspaced-cell:&amp;:duplex-list:char<span class="Special"> &lt;- </span>delete-before-cursor editor, screen + editor, screen, go-render?:bool, backspaced-cell:&amp;:duplex-list:char <span class="Special">&lt;-</span> delete-before-cursor editor, screen <span class="Constant"> &lt;backspace-character-end&gt;</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -118,114 +118,114 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> delete-before-cursor editor:&amp;:editor, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, screen:&amp;:screen, go-render?:bool, backspaced-cell:&amp;:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - data:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + data:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># if at start of text (before-cursor at § sentinel), return</span> - prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev before-cursor - go-render?, backspaced-cell<span class="Special"> &lt;- </span>copy <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> + prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev before-cursor + go-render?, backspaced-cell <span class="Special">&lt;-</span> copy <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> <span class="muControl">return-unless</span> prev - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[delete-before-cursor]</span> - original-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - editor, scroll?:bool<span class="Special"> &lt;- </span>move-cursor-coordinates-left editor - backspaced-cell:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy before-cursor - data<span class="Special"> &lt;- </span>remove before-cursor, data <span class="Comment"># will also neatly trim next/prev pointers in backspaced-cell/before-cursor</span> - before-cursor<span class="Special"> &lt;- </span>copy prev - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[delete-before-cursor]</span> + original-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + editor, scroll?:bool <span class="Special">&lt;-</span> move-cursor-coordinates-left editor + backspaced-cell:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy before-cursor + data <span class="Special">&lt;-</span> remove before-cursor, data <span class="Comment"># will also neatly trim next/prev pointers in backspaced-cell/before-cursor</span> + before-cursor <span class="Special">&lt;-</span> copy prev + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> scroll? - screen-width:num<span class="Special"> &lt;- </span>screen-width screen - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> + screen-width:num <span class="Special">&lt;-</span> screen-width screen + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># did we just backspace over a newline?</span> - same-row?:bool<span class="Special"> &lt;- </span>equal cursor-row, original-row - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + same-row?:bool <span class="Special">&lt;-</span> equal cursor-row, original-row + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-unless</span> same-row? - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - screen<span class="Special"> &lt;- </span>move-cursor screen, cursor-row, cursor-column - curr-column:num<span class="Special"> &lt;- </span>copy cursor-column + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + screen <span class="Special">&lt;-</span> move-cursor screen, cursor-row, cursor-column + curr-column:num <span class="Special">&lt;-</span> copy cursor-column <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:bool<span class="Special"> &lt;- </span>greater-or-equal curr-column, right - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + at-right?:bool <span class="Special">&lt;-</span> greater-or-equal curr-column, right + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - screen<span class="Special"> &lt;- </span>print screen, currc - curr-column<span class="Special"> &lt;- </span>add curr-column, <span class="Constant">1</span> - curr<span class="Special"> &lt;- </span>next curr + screen <span class="Special">&lt;-</span> print screen, currc + curr-column <span class="Special">&lt;-</span> add curr-column,<span class="Constant"> 1</span> + curr <span class="Special">&lt;-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - space:char<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span> - screen<span class="Special"> &lt;- </span>print screen, space - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + space:char <span class="Special">&lt;-</span> copy <span class="Constant">32/space</span> + screen <span class="Special">&lt;-</span> print screen, space + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> ] <span class="muRecipe">def</span> move-cursor-coordinates-left editor:&amp;:editor<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> <span class="Comment"># if not at left margin, move one character left</span> <span class="Delimiter">{</span> - at-left-margin?:bool<span class="Special"> &lt;- </span>equal cursor-column, left + at-left-margin?:bool <span class="Special">&lt;-</span> equal cursor-column, left <span class="muControl">break-if</span> at-left-margin? - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[decrementing cursor column]</span> - cursor-column<span class="Special"> &lt;- </span>subtract cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[decrementing cursor column]</span> + cursor-column <span class="Special">&lt;-</span> subtract cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># if at left margin, we must move to previous row:</span> - top-of-screen?:bool<span class="Special"> &lt;- </span>equal cursor-row, <span class="Constant">1</span> <span class="Comment"># exclude menu bar</span> - go-render?:bool<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + top-of-screen?:bool <span class="Special">&lt;-</span> equal cursor-row,<span class="Constant"> 1</span> <span class="Comment"># exclude menu bar</span> + go-render?:bool <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> top-of-screen? - cursor-row<span class="Special"> &lt;- </span>subtract cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-row <span class="Special">&lt;-</span> subtract cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> top-of-screen? <span class="Constant"> &lt;scroll-up&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># case 1: if previous character was newline, figure out how long the previous line is</span> - previous-character:char<span class="Special"> &lt;- </span>get *before-cursor, <span class="Constant">value:offset</span> - previous-character-is-newline?:bool<span class="Special"> &lt;- </span>equal previous-character, <span class="Constant">10/newline</span> + previous-character:char <span class="Special">&lt;-</span> get *before-cursor, <span class="Constant">value:offset</span> + previous-character-is-newline?:bool <span class="Special">&lt;-</span> equal previous-character, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> previous-character-is-newline? <span class="Comment"># compute length of previous line</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[switching to previous line]</span> - d:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> - end-of-line:num<span class="Special"> &lt;- </span>previous-line-length before-cursor, d - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - width:num<span class="Special"> &lt;- </span>subtract right, left - wrap?:bool<span class="Special"> &lt;- </span>greater-than end-of-line, width + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[switching to previous line]</span> + d:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> + end-of-line:num <span class="Special">&lt;-</span> previous-line-length before-cursor, d + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + width:num <span class="Special">&lt;-</span> subtract right, left + wrap?:bool <span class="Special">&lt;-</span> greater-than end-of-line, width <span class="Delimiter">{</span> <span class="muControl">break-unless</span> wrap? - _, column-offset:num<span class="Special"> &lt;- </span>divide-with-remainder end-of-line, width - cursor-column<span class="Special"> &lt;- </span>add left, column-offset - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + _, column-offset:num <span class="Special">&lt;-</span> divide-with-remainder end-of-line, width + cursor-column <span class="Special">&lt;-</span> add left, column-offset + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> wrap? - cursor-column<span class="Special"> &lt;- </span>add left, end-of-line - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-column <span class="Special">&lt;-</span> add left, end-of-line + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">}</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># case 2: if previous-character was not newline, we're just at a wrapped line</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[wrapping to previous line]</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - cursor-column<span class="Special"> &lt;- </span>subtract right, <span class="Constant">1</span> <span class="Comment"># leave room for wrap icon</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[wrapping to previous line]</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + cursor-column <span class="Special">&lt;-</span> subtract right,<span class="Constant"> 1</span> <span class="Comment"># leave room for wrap icon</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column ] <span class="Comment"># takes a pointer 'curr' into the doubly-linked list and its sentinel, counts</span> @@ -233,19 +233,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> previous-line-length curr:&amp;:duplex-list:char, start:&amp;:duplex-list:char<span class="muRecipe"> -&gt; </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + result:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="muControl">return-unless</span> curr - at-start?:bool<span class="Special"> &lt;- </span>equal curr, start + at-start?:bool <span class="Special">&lt;-</span> equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> - curr<span class="Special"> &lt;- </span>prev curr + curr <span class="Special">&lt;-</span> prev curr <span class="muControl">break-unless</span> curr - at-start?:bool<span class="Special"> &lt;- </span>equal curr, start + at-start?:bool <span class="Special">&lt;-</span> equal curr, start <span class="muControl">break-if</span> at-start? - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - result<span class="Special"> &lt;- </span>add result, <span class="Constant">1</span> + result <span class="Special">&lt;-</span> add result,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -254,17 +254,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[ab</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> <span class="Comment"># cursor at only character in final line</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> <span class="Comment"># cursor at only character in final line</span> press backspace ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -273,8 +273,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] ] @@ -282,14 +282,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc def</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc def</span> <span class="Constant">ghi jkl]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor at the start of the second and hit backspace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press backspace ] run [ @@ -309,7 +309,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor in part of the screen with a long line</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc def ghij]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc def ghij]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> editor-render screen, e <span class="Comment"># confirm that it wraps</span> screen-should-contain [ @@ -321,7 +321,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor somewhere in the middle of the top screen line and hit backspace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> press backspace ] run [ @@ -342,7 +342,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-delete-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ @@ -357,7 +357,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> <span class="Constant"> $clear-trace</span> assume-console [ press delete @@ -371,15 +371,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length to overwrite</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length to overwrite</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - delete-next-character?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65522/delete</span> + delete-next-character?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65522/delete</span> <span class="muControl">break-unless</span> delete-next-character? <span class="Constant"> &lt;delete-character-begin&gt;</span> - editor, screen, go-render?:bool, deleted-cell:&amp;:duplex-list:char<span class="Special"> &lt;- </span>delete-at-cursor editor, screen + editor, screen, go-render?:bool, deleted-cell:&amp;:duplex-list:char <span class="Special">&lt;-</span> delete-at-cursor editor, screen <span class="Constant"> &lt;delete-character-end&gt;</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -388,42 +388,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> delete-at-cursor editor:&amp;:editor, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, screen:&amp;:screen, go-render?:bool, deleted-cell:&amp;:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - data:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> - deleted-cell:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + data:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> + deleted-cell:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> deleted-cell - currc:char<span class="Special"> &lt;- </span>get *deleted-cell, <span class="Constant">value:offset</span> - data<span class="Special"> &lt;- </span>remove deleted-cell, data - deleted-newline?:bool<span class="Special"> &lt;- </span>equal currc, <span class="Constant">10/newline</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + currc:char <span class="Special">&lt;-</span> get *deleted-cell, <span class="Constant">value:offset</span> + data <span class="Special">&lt;-</span> remove deleted-cell, data + deleted-newline?:bool <span class="Special">&lt;-</span> equal currc, <span class="Constant">10/newline</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> deleted-newline? <span class="Comment"># wasn't a newline? render rest of line</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor <span class="Comment"># refresh after remove above</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, cursor-row, cursor-column - curr-column:num<span class="Special"> &lt;- </span>copy cursor-column - screen-width:num<span class="Special"> &lt;- </span>screen-width screen + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="Comment"># refresh after remove above</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + screen <span class="Special">&lt;-</span> move-cursor screen, cursor-row, cursor-column + curr-column:num <span class="Special">&lt;-</span> copy cursor-column + screen-width:num <span class="Special">&lt;-</span> screen-width screen <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:bool<span class="Special"> &lt;- </span>greater-or-equal curr-column, screen-width - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + at-right?:bool <span class="Special">&lt;-</span> greater-or-equal curr-column, screen-width + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - screen<span class="Special"> &lt;- </span>print screen, currc - curr-column<span class="Special"> &lt;- </span>add curr-column, <span class="Constant">1</span> - curr<span class="Special"> &lt;- </span>next curr + screen <span class="Special">&lt;-</span> print screen, currc + curr-column <span class="Special">&lt;-</span> add curr-column,<span class="Constant"> 1</span> + curr <span class="Special">&lt;-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - space:char<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span> - screen<span class="Special"> &lt;- </span>print screen, space - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + space:char <span class="Special">&lt;-</span> copy <span class="Constant">32/space</span> + screen <span class="Special">&lt;-</span> print screen, space + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> ] <span class="Comment"># right arrow</span> @@ -431,7 +431,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-right-with-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ @@ -447,23 +447,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 0 and following characters</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 0 and following characters</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - move-to-next-character?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65514/right-arrow</span> + move-to-next-character?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65514/right-arrow</span> <span class="muControl">break-unless</span> move-to-next-character? <span class="Comment"># if not at end of text</span> - next-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + next-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="muControl">break-unless</span> next-cursor <span class="Comment"># scan to next character</span> <span class="Constant"> &lt;move-cursor-begin&gt;</span> - before-cursor<span class="Special"> &lt;- </span>copy next-cursor - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - editor, go-render?:bool<span class="Special"> &lt;- </span>move-cursor-coordinates-right editor, screen-height - screen<span class="Special"> &lt;- </span>move-cursor screen, cursor-row, cursor-column - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">2/right-arrow</span> + before-cursor <span class="Special">&lt;-</span> copy next-cursor + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + editor, go-render?:bool <span class="Special">&lt;-</span> move-cursor-coordinates-right editor, screen-height + screen <span class="Special">&lt;-</span> move-cursor screen, cursor-row, cursor-column + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">2/right-arrow</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -472,65 +472,65 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> move-cursor-coordinates-right editor:&amp;:editor, screen-height:num<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor <span class="Constant">before-cursor:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor <span class="Constant">before-cursor:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> <span class="Comment"># if crossed a newline, move cursor to start of next row</span> <span class="Delimiter">{</span> - old-cursor-character:char<span class="Special"> &lt;- </span>get *before-cursor, <span class="Constant">value:offset</span> - was-at-newline?:bool<span class="Special"> &lt;- </span>equal old-cursor-character, <span class="Constant">10/newline</span> + old-cursor-character:char <span class="Special">&lt;-</span> get *before-cursor, <span class="Constant">value:offset</span> + was-at-newline?:bool <span class="Special">&lt;-</span> equal old-cursor-character, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> was-at-newline? - cursor-row<span class="Special"> &lt;- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>copy left - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - below-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + cursor-row <span class="Special">&lt;-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> copy left + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + below-screen?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> below-screen? <span class="Constant"> &lt;scroll-down&gt;</span> - cursor-row<span class="Special"> &lt;- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + cursor-row <span class="Special">&lt;-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># if the line wraps, move cursor to start of next row</span> <span class="Delimiter">{</span> <span class="Comment"># if we're at the column just before the wrap indicator</span> - wrap-column:num<span class="Special"> &lt;- </span>subtract right, <span class="Constant">1</span> - at-wrap?:bool<span class="Special"> &lt;- </span>equal cursor-column, wrap-column + wrap-column:num <span class="Special">&lt;-</span> subtract right,<span class="Constant"> 1</span> + at-wrap?:bool <span class="Special">&lt;-</span> equal cursor-column, wrap-column <span class="muControl">break-unless</span> at-wrap? <span class="Comment"># and if next character isn't newline</span> - next:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + next:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="muControl">break-unless</span> next - next-character:char<span class="Special"> &lt;- </span>get *next, <span class="Constant">value:offset</span> - newline?:bool<span class="Special"> &lt;- </span>equal next-character, <span class="Constant">10/newline</span> + next-character:char <span class="Special">&lt;-</span> get *next, <span class="Constant">value:offset</span> + newline?:bool <span class="Special">&lt;-</span> equal next-character, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> newline? - cursor-row<span class="Special"> &lt;- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>copy left - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - below-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> - <span class="muControl">return-unless</span> below-screen?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + cursor-row <span class="Special">&lt;-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> copy left + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + below-screen?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> + <span class="muControl">return-unless</span> below-screen?, editor/same-as-ingredient:0, <span class="Constant">0/no-more-render</span> <span class="Constant"> &lt;scroll-down&gt;</span> - cursor-row<span class="Special"> &lt;- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + cursor-row <span class="Special">&lt;-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># otherwise move cursor one character right</span> - cursor-column<span class="Special"> &lt;- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + cursor-column <span class="Special">&lt;-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> @@ -543,7 +543,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># type something and ensure it goes where it should</span> assume-console [ type <span class="Constant">[0]</span> @@ -558,15 +558,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length of second line</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length of second line</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ press right-arrow @@ -590,17 +590,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -610,32 +610,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># line just barely wrapping</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] <span class="Comment"># now hit right arrow again</span> assume-console [ @@ -643,30 +643,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -676,23 +676,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press right-arrow type <span class="Constant">[0]</span> ] @@ -707,7 +707,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># todo: ctrl-right: next word-end</span> @@ -717,11 +717,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-left-with-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -734,23 +734,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - move-to-previous-character?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65515/left-arrow</span> + move-to-previous-character?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65515/left-arrow</span> <span class="muControl">break-unless</span> move-to-previous-character? - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[left arrow]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[left arrow]</span> <span class="Comment"># if not at start of text (before-cursor at § sentinel)</span> - prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev before-cursor - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev before-cursor + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> prev <span class="Constant"> &lt;move-cursor-begin&gt;</span> - editor, go-render?<span class="Special"> &lt;- </span>move-cursor-coordinates-left editor - before-cursor<span class="Special"> &lt;- </span>copy prev - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">1/left-arrow</span> + editor, go-render? <span class="Special">&lt;-</span> move-cursor-coordinates-left editor + before-cursor <span class="Special">&lt;-</span> copy prev + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">1/left-arrow</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -760,42 +760,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of second line (so there's no previous newline)</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with three lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s:text, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s:text, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor further down (so there's a newline before the character at</span> <span class="Comment"># the cursor)</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -809,21 +809,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .g .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of text, press left-arrow, then type a character</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 0</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -838,22 +838,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .g .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> ] - check-trace-count-for-label <span class="Constant">4</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of first line</span> + check-trace-count-for-label<span class="Constant"> 4</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of first line</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> d] - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e:&amp;:editor <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -867,14 +867,14 @@ d] <span class="Constant"> .d .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-across-wrap-with-left-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -886,28 +886,28 @@ d] ] <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> <span class="Comment"># right margin except wrap icon</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> <span class="Comment"># previous row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> <span class="Comment"># right margin except wrap icon</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line followed by a second line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -919,28 +919,28 @@ d] ] <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> <span class="Comment"># previous row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> <span class="Comment"># end of wrapped line</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> <span class="Comment"># previous row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> <span class="Comment"># end of wrapped line</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a line on the verge of wrapping, followed by a second line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcd</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcd</span> <span class="Constant">e]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -952,19 +952,19 @@ d] ] <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">4</span> <span class="Comment"># end of wrapped line</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> <span class="Comment"># previous row</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 4</span> <span class="Comment"># end of wrapped line</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># todo: ctrl-left: previous word-start</span> @@ -974,25 +974,25 @@ d] <span class="muScenario">scenario</span> editor-moves-to-previous-line-with-up-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1010,11 +1010,11 @@ d] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - move-to-previous-line?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65517/up-arrow</span> + move-to-previous-line?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65517/up-arrow</span> <span class="muControl">break-unless</span> move-to-previous-line? <span class="Constant"> &lt;move-cursor-begin&gt;</span> - editor, go-render?<span class="Special"> &lt;- </span>move-to-previous-line editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">3/up-arrow</span> + editor, go-render? <span class="Special">&lt;-</span> move-to-previous-line editor + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">3/up-arrow</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -1023,67 +1023,67 @@ d] <span class="muRecipe">def</span> move-to-previous-line editor:&amp;:editor<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - already-at-top?:bool<span class="Special"> &lt;- </span>lesser-or-equal cursor-row, <span class="Constant">1/top</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + already-at-top?:bool <span class="Special">&lt;-</span> lesser-or-equal cursor-row, <span class="Constant">1/top</span> <span class="Delimiter">{</span> <span class="Comment"># if cursor not at top, move it</span> <span class="muControl">break-if</span> already-at-top? <span class="Comment"># if not at newline, move to start of line (previous newline)</span> <span class="Comment"># then scan back another line</span> <span class="Comment"># if either step fails, give up without modifying cursor or coordinates</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy before-cursor + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy before-cursor <span class="Delimiter">{</span> - old:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy curr - c2:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal c2, <span class="Constant">10/newline</span> + old:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy curr + c2:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal c2, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>before-previous-line curr, editor - no-motion?:bool<span class="Special"> &lt;- </span>equal curr, old - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> before-previous-line curr, editor + no-motion?:bool <span class="Special">&lt;-</span> equal curr, old + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-motion? <span class="Delimiter">}</span> <span class="Delimiter">{</span> - old<span class="Special"> &lt;- </span>copy curr - curr<span class="Special"> &lt;- </span>before-previous-line curr, editor - no-motion?:bool<span class="Special"> &lt;- </span>equal curr, old - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + old <span class="Special">&lt;-</span> copy curr + curr <span class="Special">&lt;-</span> before-previous-line curr, editor + no-motion?:bool <span class="Special">&lt;-</span> equal curr, old + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-motion? <span class="Delimiter">}</span> - before-cursor<span class="Special"> &lt;- </span>copy curr - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row<span class="Special"> &lt;- </span>subtract cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + before-cursor <span class="Special">&lt;-</span> copy curr + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special">&lt;-</span> subtract cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Comment"># scan ahead to right column or until end of line</span> - target-column:num<span class="Special"> &lt;- </span>copy cursor-column - cursor-column<span class="Special"> &lt;- </span>copy left - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + target-column:num <span class="Special">&lt;-</span> copy cursor-column + cursor-column <span class="Special">&lt;-</span> copy left + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-column, target-column + done?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-column, target-column <span class="muControl">break-if</span> done? - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="muControl">break-unless</span> curr - currc:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment">#</span> - before-cursor<span class="Special"> &lt;- </span>copy curr - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-column<span class="Special"> &lt;- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special">&lt;-</span> copy curr + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special">&lt;-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="muControl">loop</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># if cursor already at top, scroll up</span> <span class="muControl">break-unless</span> already-at-top? <span class="Constant"> &lt;scroll-up&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1091,25 +1091,25 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-previous-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[ab</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[ab</span> <span class="Constant">def]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1128,25 +1128,25 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-empty-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new [ + s:text <span class="Special">&lt;-</span> new [ <span class="muRecipe">def</span>] - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1166,27 +1166,27 @@ d] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># start out with three lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># click on the third line and hit up-arrow, so you end up just after a newline</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1207,9 +1207,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-next-line-with-down-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> @@ -1218,15 +1218,15 @@ d] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># ..and ends at (2, 0)</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1244,11 +1244,11 @@ d] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - move-to-next-line?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65516/down-arrow</span> + move-to-next-line?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> move-to-next-line? <span class="Constant"> &lt;move-cursor-begin&gt;</span> - editor, go-render?<span class="Special"> &lt;- </span>move-to-next-line editor, screen-height - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">4/down-arrow</span> + editor, go-render? <span class="Special">&lt;-</span> move-to-next-line editor, screen-height + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">4/down-arrow</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -1257,81 +1257,81 @@ d] <span class="muRecipe">def</span> move-to-next-line editor:&amp;:editor, screen-height:num<span class="muRecipe"> -&gt; </span>editor:&amp;:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - last-line:num<span class="Special"> &lt;- </span>subtract screen-height, <span class="Constant">1</span> - already-at-bottom?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-row, last-line + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + last-line:num <span class="Special">&lt;-</span> subtract screen-height,<span class="Constant"> 1</span> + already-at-bottom?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-row, last-line <span class="Delimiter">{</span> <span class="Comment"># if cursor not at bottom, move it</span> <span class="muControl">break-if</span> already-at-bottom? <span class="Comment"># scan to start of next line, then to right column or until end of line</span> - max:num<span class="Special"> &lt;- </span>subtract right, left - next-line:&amp;:duplex-list:char<span class="Special"> &lt;- </span>before-start-of-next-line before-cursor, max + max:num <span class="Special">&lt;-</span> subtract right, left + next-line:&amp;:duplex-list:char <span class="Special">&lt;-</span> before-start-of-next-line before-cursor, max <span class="Delimiter">{</span> <span class="Comment"># already at end of buffer? try to scroll up (so we can see more</span> <span class="Comment"># warnings or sandboxes below)</span> - no-motion?:bool<span class="Special"> &lt;- </span>equal next-line, before-cursor + no-motion?:bool <span class="Special">&lt;-</span> equal next-line, before-cursor <span class="muControl">break-unless</span> no-motion? - scroll?:bool<span class="Special"> &lt;- </span>greater-than cursor-row, <span class="Constant">1</span> + scroll?:bool <span class="Special">&lt;-</span> greater-than cursor-row,<span class="Constant"> 1</span> <span class="muControl">break-if</span> scroll?, <span class="Constant">+try-to-scroll</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - cursor-row<span class="Special"> &lt;- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - before-cursor<span class="Special"> &lt;- </span>copy next-line - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - target-column:num<span class="Special"> &lt;- </span>copy cursor-column - cursor-column<span class="Special"> &lt;- </span>copy left - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-row <span class="Special">&lt;-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + before-cursor <span class="Special">&lt;-</span> copy next-line + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + target-column:num <span class="Special">&lt;-</span> copy cursor-column + cursor-column <span class="Special">&lt;-</span> copy left + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal cursor-column, target-column + done?:bool <span class="Special">&lt;-</span> greater-or-equal cursor-column, target-column <span class="muControl">break-if</span> done? - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="muControl">break-unless</span> curr - currc:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment">#</span> - before-cursor<span class="Special"> &lt;- </span>copy curr - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-column<span class="Special"> &lt;- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special">&lt;-</span> copy curr + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special">&lt;-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="muControl">loop</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Constant"> +try-to-scroll</span> <span class="Constant"> &lt;scroll-down&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> editor-adjusts-column-at-next-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">de]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press down-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1352,51 +1352,51 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press ctrl-a ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - move-to-start-of-line?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">1/ctrl-a</span> + move-to-start-of-line?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">1/ctrl-a</span> <span class="muControl">break-unless</span> move-to-start-of-line? <span class="Constant"> &lt;move-cursor-begin&gt;</span> move-to-start-of-line editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - move-to-start-of-line?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65521/home</span> + move-to-start-of-line?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65521/home</span> <span class="muControl">break-unless</span> move-to-start-of-line? <span class="Constant"> &lt;move-cursor-begin&gt;</span> move-to-start-of-line editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1405,21 +1405,21 @@ d] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># update cursor column</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>copy left - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + cursor-column:num <span class="Special">&lt;-</span> copy left + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># update before-cursor</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - init:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + init:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># while not at start of line, move </span> <span class="Delimiter">{</span> - at-start-of-text?:bool<span class="Special"> &lt;- </span>equal before-cursor, init + at-start-of-text?:bool <span class="Special">&lt;-</span> equal before-cursor, init <span class="muControl">break-if</span> at-start-of-text? - prev:char<span class="Special"> &lt;- </span>get *before-cursor, <span class="Constant">value:offset</span> - at-start-of-line?:bool<span class="Special"> &lt;- </span>equal prev, <span class="Constant">10/newline</span> + prev:char <span class="Special">&lt;-</span> get *before-cursor, <span class="Constant">value:offset</span> + at-start-of-line?:bool <span class="Special">&lt;-</span> equal prev, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-start-of-line? - before-cursor<span class="Special"> &lt;- </span>prev before-cursor - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor <span class="Special">&lt;-</span> prev before-cursor + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor assert before-cursor, <span class="Constant">[move-to-start-of-line tried to move before start of text]</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -1428,78 +1428,78 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press ctrl-a ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press 'home'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press home ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press home ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># ctrl-e/end - move cursor to end of line</span> @@ -1507,39 +1507,39 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press ctrl-e ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># editor inserts future characters at cursor</span> assume-console [ type <span class="Constant">[z]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">4</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 4</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1548,31 +1548,31 @@ d] <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - move-to-end-of-line?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">5/ctrl-e</span> + move-to-end-of-line?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">5/ctrl-e</span> <span class="muControl">break-unless</span> move-to-end-of-line? <span class="Constant"> &lt;move-cursor-begin&gt;</span> move-to-end-of-line editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - move-to-end-of-line?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65520/end</span> + move-to-end-of-line?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65520/end</span> <span class="muControl">break-unless</span> move-to-end-of-line? <span class="Constant"> &lt;move-cursor-begin&gt;</span> move-to-end-of-line editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1580,19 +1580,19 @@ d] <span class="muRecipe">def</span> move-to-end-of-line editor:&amp;:editor<span class="muRecipe"> -&gt; </span>editor:&amp;:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># while not at start of line, move </span> <span class="Delimiter">{</span> - next:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + next:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="muControl">break-unless</span> next <span class="Comment"># end of text</span> - nextc:char<span class="Special"> &lt;- </span>get *next, <span class="Constant">value:offset</span> - at-end-of-line?:bool<span class="Special"> &lt;- </span>equal nextc, <span class="Constant">10/newline</span> + nextc:char <span class="Special">&lt;-</span> get *next, <span class="Constant">value:offset</span> + at-end-of-line?:bool <span class="Special">&lt;-</span> equal nextc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-end-of-line? - before-cursor<span class="Special"> &lt;- </span>copy next - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-column<span class="Special"> &lt;- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special">&lt;-</span> copy next + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special">&lt;-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -1600,79 +1600,79 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-e ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press end ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press end ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># ctrl-u - delete text from start of line until (but not at) cursor</span> @@ -1680,12 +1680,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line, press ctrl-u</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 2</span> press ctrl-u ] run [ @@ -1703,12 +1703,12 @@ d] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - delete-to-start-of-line?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">21/ctrl-u</span> + delete-to-start-of-line?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">21/ctrl-u</span> <span class="muControl">break-unless</span> delete-to-start-of-line? <span class="Constant"> &lt;delete-to-start-of-line-begin&gt;</span> - deleted-cells:&amp;:duplex-list:char<span class="Special"> &lt;- </span>delete-to-start-of-line editor + deleted-cells:&amp;:duplex-list:char <span class="Special">&lt;-</span> delete-to-start-of-line editor <span class="Constant"> &lt;delete-to-start-of-line-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1717,39 +1717,39 @@ d] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - init:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - start:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy before-cursor - end:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor + init:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + start:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy before-cursor + end:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor <span class="Delimiter">{</span> - at-start-of-text?:bool<span class="Special"> &lt;- </span>equal start, init + at-start-of-text?:bool <span class="Special">&lt;-</span> equal start, init <span class="muControl">break-if</span> at-start-of-text? - curr:char<span class="Special"> &lt;- </span>get *start, <span class="Constant">value:offset</span> - at-start-of-line?:bool<span class="Special"> &lt;- </span>equal curr, <span class="Constant">10/newline</span> + curr:char <span class="Special">&lt;-</span> get *start, <span class="Constant">value:offset</span> + at-start-of-line?:bool <span class="Special">&lt;-</span> equal curr, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-start-of-line? - start<span class="Special"> &lt;- </span>prev start + start <span class="Special">&lt;-</span> prev start assert start, <span class="Constant">[delete-to-start-of-line tried to move before start of text]</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next start + result:&amp;:duplex-list:char <span class="Special">&lt;-</span> next start remove-between start, end <span class="Comment"># adjust cursor</span> - before-cursor<span class="Special"> &lt;- </span>copy start - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, left + before-cursor <span class="Special">&lt;-</span> copy start + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, left ] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line (no newline before), press ctrl-u</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press ctrl-u ] run [ @@ -1768,12 +1768,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line, press ctrl-u</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press ctrl-u ] run [ @@ -1792,12 +1792,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-final-line-with-ctrl-u [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of final line, press ctrl-u</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press ctrl-u ] run [ @@ -1818,12 +1818,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line, press ctrl-k</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press ctrl-k ] run [ @@ -1841,12 +1841,12 @@ d] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - delete-to-end-of-line?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">11/ctrl-k</span> + delete-to-end-of-line?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">11/ctrl-k</span> <span class="muControl">break-unless</span> delete-to-end-of-line? <span class="Constant"> &lt;delete-to-end-of-line-begin&gt;</span> - deleted-cells:&amp;:duplex-list:char<span class="Special"> &lt;- </span>delete-to-end-of-line editor + deleted-cells:&amp;:duplex-list:char <span class="Special">&lt;-</span> delete-to-end-of-line editor <span class="Constant"> &lt;delete-to-end-of-line-end&gt;</span> - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1855,31 +1855,31 @@ d] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - start:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - end:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next start + start:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + end:&amp;:duplex-list:char <span class="Special">&lt;-</span> next start <span class="Delimiter">{</span> - at-end-of-text?:bool<span class="Special"> &lt;- </span>equal end, <span class="Constant">0/null</span> + at-end-of-text?:bool <span class="Special">&lt;-</span> equal end, <span class="Constant">0/null</span> <span class="muControl">break-if</span> at-end-of-text? - curr:char<span class="Special"> &lt;- </span>get *end, <span class="Constant">value:offset</span> - at-end-of-line?:bool<span class="Special"> &lt;- </span>equal curr, <span class="Constant">10/newline</span> + curr:char <span class="Special">&lt;-</span> get *end, <span class="Constant">value:offset</span> + at-end-of-line?:bool <span class="Special">&lt;-</span> equal curr, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-end-of-line? - end<span class="Special"> &lt;- </span>next end + end <span class="Special">&lt;-</span> next end <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result<span class="Special"> &lt;- </span>next start + result <span class="Special">&lt;-</span> next start remove-between start, end ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line (no newline after), press ctrl-k</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-k ] run [ @@ -1898,12 +1898,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of line</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press ctrl-k ] run [ @@ -1922,12 +1922,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press ctrl-k ] run [ @@ -1946,12 +1946,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-5 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of text</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 2</span> press ctrl-k ] run [ @@ -1970,12 +1970,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-6 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[123</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of text</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press ctrl-k ] run [ @@ -1998,11 +1998,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with &gt;3 lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2011,7 +2011,7 @@ d] ] <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2027,16 +2027,16 @@ d] ] <span class="muRecipe">after</span> <span class="Constant">&lt;scroll-down&gt;</span> [ - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll down]</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - max:num<span class="Special"> &lt;- </span>subtract right, left - old-top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy top-of-screen - top-of-screen<span class="Special"> &lt;- </span>before-start-of-next-line top-of-screen, max - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - no-movement?:bool<span class="Special"> &lt;- </span>equal old-top, top-of-screen - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll down]</span> + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + max:num <span class="Special">&lt;-</span> subtract right, left + old-top:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy top-of-screen + top-of-screen <span class="Special">&lt;-</span> before-start-of-next-line top-of-screen, max + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen + no-movement?:bool <span class="Special">&lt;-</span> equal old-top, top-of-screen + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-movement? ] @@ -2046,25 +2046,25 @@ d] <span class="muRecipe">def</span> before-start-of-next-line original:&amp;:duplex-list:char, max:num<span class="muRecipe"> -&gt; </span>curr:&amp;:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - count:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy original + count:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy original <span class="Comment"># skip the initial newline if it exists</span> <span class="Delimiter">{</span> - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> at-newline? - curr<span class="Special"> &lt;- </span>next curr - count<span class="Special"> &lt;- </span>add count, <span class="Constant">1</span> + curr <span class="Special">&lt;-</span> next curr + count <span class="Special">&lt;-</span> add count,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">return-unless</span> curr, original - done?:bool<span class="Special"> &lt;- </span>greater-or-equal count, max + done?:bool <span class="Special">&lt;-</span> greater-or-equal count, max <span class="muControl">break-if</span> done? - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr<span class="Special"> &lt;- </span>next curr - count<span class="Special"> &lt;- </span>add count, <span class="Constant">1</span> + curr <span class="Special">&lt;-</span> next curr + count <span class="Special">&lt;-</span> add count,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return-unless</span> curr, original @@ -2077,11 +2077,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2090,7 +2090,7 @@ d] ] <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2110,14 +2110,14 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor starts with a long line wrapping twice</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdefghij</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2151,19 +2151,19 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long line in the third line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdef]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end, type a character</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 4</span> type <span class="Constant">[g]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2173,8 +2173,8 @@ d] <span class="Constant"> .g .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] ] @@ -2182,19 +2182,19 @@ d] <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># position cursor after last line and type newline</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 4</span> type [ ] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2204,8 +2204,8 @@ d] <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] ] @@ -2214,19 +2214,19 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2236,8 +2236,8 @@ d] <span class="Constant"> .gh .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] ] @@ -2246,20 +2246,20 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains more lines than can fit on screen</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2269,33 +2269,33 @@ d] <span class="Constant"> .d .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] ] <span class="muScenario">scenario</span> editor-scrolls-at-end-on-down-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">de]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press down-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should scroll, moving cursor to end of text</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] assume-console [ type <span class="Constant">[0]</span> @@ -2312,20 +2312,20 @@ d] <span class="Comment"># try to move down again</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press down-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen stops scrolling because cursor is already at top</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[1]</span> ] @@ -2345,18 +2345,18 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a few pages of lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># scroll down one page and one line</span> assume-console [ press page-down - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2378,11 +2378,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with &gt;3 lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2407,13 +2407,13 @@ d] ] <span class="muRecipe">after</span> <span class="Constant">&lt;scroll-up&gt;</span> [ - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll up]</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - old-top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy top-of-screen - top-of-screen<span class="Special"> &lt;- </span>before-previous-line top-of-screen, editor - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - no-movement?:bool<span class="Special"> &lt;- </span>equal old-top, top-of-screen - go-render?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll up]</span> + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy top-of-screen + top-of-screen <span class="Special">&lt;-</span> before-previous-line top-of-screen, editor + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen + no-movement?:bool <span class="Special">&lt;-</span> equal old-top, top-of-screen + go-render? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-movement? ] @@ -2423,39 +2423,39 @@ d] <span class="muRecipe">def</span> before-previous-line in:&amp;:duplex-list:char, editor:&amp;:editor<span class="muRecipe"> -&gt; </span>out:&amp;:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy in - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy in + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> <span class="Comment"># compute max, number of characters to skip</span> <span class="Comment"># 1 + len%(width-1)</span> <span class="Comment"># except rotate second term to vary from 1 to width-1 rather than 0 to width-2</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - max-line-length:num<span class="Special"> &lt;- </span>subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> - sentinel:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> - len:num<span class="Special"> &lt;- </span>previous-line-length curr, sentinel + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + max-line-length:num <span class="Special">&lt;-</span> subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> + sentinel:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> + len:num <span class="Special">&lt;-</span> previous-line-length curr, sentinel <span class="Delimiter">{</span> <span class="muControl">break-if</span> len <span class="Comment"># empty line; just skip this newline</span> - prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev curr + prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev curr <span class="muControl">return-unless</span> prev, curr <span class="muControl">return</span> prev <span class="Delimiter">}</span> - _, max:num<span class="Special"> &lt;- </span>divide-with-remainder len, max-line-length + _, max:num <span class="Special">&lt;-</span> divide-with-remainder len, max-line-length <span class="Comment"># remainder 0 =&gt; scan one width-worth</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> max - max<span class="Special"> &lt;- </span>copy max-line-length + max <span class="Special">&lt;-</span> copy max-line-length <span class="Delimiter">}</span> - max<span class="Special"> &lt;- </span>add max, <span class="Constant">1</span> - count:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + max <span class="Special">&lt;-</span> add max,<span class="Constant"> 1</span> + count:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="Comment"># skip 'max' characters</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal count, max + done?:bool <span class="Special">&lt;-</span> greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev curr + prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev curr <span class="muControl">break-unless</span> prev - curr<span class="Special"> &lt;- </span>copy prev - count<span class="Special"> &lt;- </span>add count, <span class="Constant">1</span> + curr <span class="Special">&lt;-</span> copy prev + count <span class="Special">&lt;-</span> add count,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> curr @@ -2467,11 +2467,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2512,11 +2512,11 @@ d] <span class="Comment"># screen has 1 line for menu + 4 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor starts with a long line wrapping twice, occupying 3 of the 4 lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdefghij</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down @@ -2586,11 +2586,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcde↩ .</span> @@ -2631,13 +2631,13 @@ d] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with some lines around an empty line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> c d e] - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> assume-console [ press page-down ] @@ -2681,12 +2681,12 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains &gt;3 lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down @@ -2706,8 +2706,8 @@ e] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2717,8 +2717,8 @@ e] <span class="Constant"> .d .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] ] @@ -2727,11 +2727,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with &gt;3 lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2776,11 +2776,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2805,32 +2805,32 @@ e] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - page-down?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">6/ctrl-f</span> + page-down?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - old-top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> &lt;move-cursor-begin&gt;</span> page-down editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> &lt;- </span>equal top-of-screen, old-top - go-render?<span class="Special"> &lt;- </span>not no-movement? + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special">&lt;-</span> equal top-of-screen, old-top + go-render? <span class="Special">&lt;-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - page-down?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - old-top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> &lt;move-cursor-begin&gt;</span> page-down editor - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> &lt;- </span>equal top-of-screen, old-top - go-render?<span class="Special"> &lt;- </span>not no-movement? + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special">&lt;-</span> equal top-of-screen, old-top + go-render? <span class="Special">&lt;-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -2841,32 +2841,32 @@ e] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if editor contents don't overflow screen, do nothing</span> - bottom-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> + bottom-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">bottom-of-screen:offset</span> <span class="muControl">return-unless</span> bottom-of-screen <span class="Comment"># if not, position cursor at final character</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev bottom-of-screen - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev bottom-of-screen + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Comment"># keep one line in common with previous page</span> <span class="Delimiter">{</span> - last:char<span class="Special"> &lt;- </span>get *before-cursor, <span class="Constant">value:offset</span> - newline?:bool<span class="Special"> &lt;- </span>equal last, <span class="Constant">10/newline</span> + last:char <span class="Special">&lt;-</span> get *before-cursor, <span class="Constant">value:offset</span> + newline?:bool <span class="Special">&lt;-</span> equal last, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline?:bool - before-cursor<span class="Special"> &lt;- </span>prev before-cursor - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor <span class="Special">&lt;-</span> prev before-cursor + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> <span class="Comment"># move cursor and top-of-screen to start of that line</span> move-to-start-of-line editor - before-cursor<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, before-cursor + before-cursor <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, before-cursor ] <span class="muScenario">scenario</span> editor-does-not-scroll-past-end [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e screen-should-contain [ <span class="Constant"> . .</span> @@ -2895,11 +2895,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long last line</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2929,9 +2929,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2960,11 +2960,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -3003,33 +3003,33 @@ e] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - page-up?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">2/ctrl-b</span> + page-up?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">2/ctrl-b</span> <span class="muControl">break-unless</span> page-up? - old-top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> &lt;move-cursor-begin&gt;</span> - editor<span class="Special"> &lt;- </span>page-up editor, screen-height - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + editor <span class="Special">&lt;-</span> page-up editor, screen-height + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> &lt;- </span>equal top-of-screen, old-top - go-render?<span class="Special"> &lt;- </span>not no-movement? + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special">&lt;-</span> equal top-of-screen, old-top + go-render? <span class="Special">&lt;-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-key&gt;</span> [ <span class="Delimiter">{</span> - page-up?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - old-top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> &lt;move-cursor-begin&gt;</span> - editor<span class="Special"> &lt;- </span>page-up editor, screen-height - undo-coalesce-tag:num<span class="Special"> &lt;- </span>copy <span class="Constant">0/never</span> + editor <span class="Special">&lt;-</span> page-up editor, screen-height + undo-coalesce-tag:num <span class="Special">&lt;-</span> copy <span class="Constant">0/never</span> <span class="Constant"> &lt;move-cursor-end&gt;</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> &lt;- </span>equal top-of-screen, old-top + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special">&lt;-</span> equal top-of-screen, old-top <span class="Comment"># don't bother re-rendering if nothing changed. todo: test this</span> - go-render?<span class="Special"> &lt;- </span>not no-movement? + go-render? <span class="Special">&lt;-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -3037,17 +3037,17 @@ e] <span class="muRecipe">def</span> page-up editor:&amp;:editor, screen-height:num<span class="muRecipe"> -&gt; </span>editor:&amp;:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - max:num<span class="Special"> &lt;- </span>subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> - count:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + max:num <span class="Special">&lt;-</span> subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> + count:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal count, max + done?:bool <span class="Special">&lt;-</span> greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>before-previous-line top-of-screen, editor + prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> before-previous-line top-of-screen, editor <span class="muControl">break-unless</span> prev - top-of-screen<span class="Special"> &lt;- </span>copy prev - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - count<span class="Special"> &lt;- </span>add count, <span class="Constant">1</span> + top-of-screen <span class="Special">&lt;-</span> copy prev + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen + count <span class="Special">&lt;-</span> add count,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -3057,7 +3057,7 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with 8 lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> @@ -3065,7 +3065,7 @@ e] <span class="Constant">f</span> <span class="Constant">g</span> <span class="Constant">h]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -3122,7 +3122,7 @@ e] <span class="Comment"># screen has 1 line for menu + 5 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">6/height</span> <span class="Comment"># editor contains a long line in the first page</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh</span> <span class="Constant">i</span> @@ -3133,7 +3133,7 @@ e] <span class="Constant">n</span> <span class="Constant">o]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3146,7 +3146,7 @@ e] <span class="Comment"># scroll down a page and a line</span> assume-console [ press page-down - left-click <span class="Constant">5</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 5</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -3185,9 +3185,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3229,7 +3229,7 @@ e] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[axx</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[axx</span> <span class="Constant">bxx</span> <span class="Constant">cxx</span> <span class="Constant">dxx</span> @@ -3238,7 +3238,7 @@ e] <span class="Constant">gxx</span> <span class="Constant">hxx</span> <span class="Constant">]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axx .</span> @@ -3288,7 +3288,7 @@ e] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[axy</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[axy</span> <span class="Constant">bxy</span> <span class="Constant">cxy</span> @@ -3297,7 +3297,7 @@ exy fxy gxy ] - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axy .</span> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 14ff221b..9019e0d1 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -41,10 +41,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text<span class="Special"> &lt;- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text<span class="Special"> &lt;- </span>new <span class="Constant">[]</span> + initial-recipe:text <span class="Special">&lt;-</span> restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text <span class="Special">&lt;-</span> new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox render-all <span class="Constant">0/screen</span>, env, render event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> @@ -59,111 +59,111 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-programming-environment screen:&amp;:screen, initial-recipe-contents:text, initial-sandbox-contents:text<span class="muRecipe"> -&gt; </span>result:&amp;:environment, screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - width:num<span class="Special"> &lt;- </span>screen-width screen - height:num<span class="Special"> &lt;- </span>screen-height screen + width:num <span class="Special">&lt;-</span> screen-width screen + height:num <span class="Special">&lt;-</span> screen-height screen <span class="Comment"># top menu</span> - result<span class="Special"> &lt;- </span>new <span class="Constant">environment:type</span> - draw-horizontal screen, <span class="Constant">0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> - button-start:num<span class="Special"> &lt;- </span>subtract width, <span class="Constant">20</span> - button-on-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal button-start, <span class="Constant">0</span> + result <span class="Special">&lt;-</span> new <span class="Constant">environment:type</span> + draw-horizontal screen,<span class="Constant"> 0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> + button-start:num <span class="Special">&lt;-</span> subtract width,<span class="Constant"> 20</span> + button-on-screen?:bool <span class="Special">&lt;-</span> greater-or-equal button-start,<span class="Constant"> 0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start + screen <span class="Special">&lt;-</span> move-cursor screen, <span class="Constant">0/row</span>, button-start print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> - divider:num, _<span class="Special"> &lt;- </span>divide-with-remainder width, <span class="Constant">2</span> + divider:num, _ <span class="Special">&lt;-</span> divide-with-remainder width,<span class="Constant"> 2</span> draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment"># recipe editor on the left</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right + recipes:&amp;:editor <span class="Special">&lt;-</span> new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right <span class="Comment"># sandbox editor on the right</span> - sandbox-left:num<span class="Special"> &lt;- </span>add divider, <span class="Constant">1</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>new-editor initial-sandbox-contents, screen, sandbox-left, width/right - *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">recipes:offset</span>, recipes - *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox - *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> + sandbox-left:num <span class="Special">&lt;-</span> add divider,<span class="Constant"> 1</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> new-editor initial-sandbox-contents, screen, sandbox-left, width/right + *result <span class="Special">&lt;-</span> put *result, <span class="Constant">recipes:offset</span>, recipes + *result <span class="Special">&lt;-</span> put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox + *result <span class="Special">&lt;-</span> put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> <span class="Constant"> &lt;programming-environment-initialization&gt;</span> ] <span class="muRecipe">def</span> event-loop screen:&amp;:screen, console:&amp;:console, env:&amp;:environment<span class="muRecipe"> -&gt; </span>screen:&amp;:screen, console:&amp;:console, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:bool<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:bool <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Comment"># if we fall behind we'll stop updating the screen, but then we have to</span> <span class="Comment"># render the entire screen when we catch up.</span> <span class="Comment"># todo: test this</span> - render-all-on-no-more-events?:bool<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + render-all-on-no-more-events?:bool <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="Comment"># looping over each (keyboard or touch) event as it occurs</span> <span class="Constant"> +next-event</span> - e:event, found?:bool, quit?:bool, console<span class="Special"> &lt;- </span>read-event console + e:event, found?:bool, quit?:bool, console <span class="Special">&lt;-</span> read-event console <span class="muControl">loop-unless</span> found? <span class="muControl">break-if</span> quit? <span class="Comment"># only in tests</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> <span class="Constant"> &lt;handle-event&gt;</span> <span class="Comment"># check for global events that will trigger regardless of which editor has focus</span> <span class="Delimiter">{</span> - k:num, is-keycode?:bool<span class="Special"> &lt;- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + k:num, is-keycode?:bool <span class="Special">&lt;-</span> maybe-convert e:event, <span class="Constant">keycode:variant</span> <span class="muControl">break-unless</span> is-keycode? <span class="Constant"> &lt;global-keypress&gt;</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - c:char, is-unicode?:bool<span class="Special"> &lt;- </span>maybe-convert e:event, <span class="Constant">text:variant</span> + c:char, is-unicode?:bool <span class="Special">&lt;-</span> maybe-convert e:event, <span class="Constant">text:variant</span> <span class="muControl">break-unless</span> is-unicode? <span class="Constant"> &lt;global-type&gt;</span> <span class="Delimiter">}</span> <span class="Comment"># 'touch' event - send to both sides, see what picks it up</span> <span class="Delimiter">{</span> - t:touch-event, is-touch?:bool<span class="Special"> &lt;- </span>maybe-convert e:event, <span class="Constant">touch:variant</span> + t:touch-event, is-touch?:bool <span class="Special">&lt;-</span> maybe-convert e:event, <span class="Constant">touch:variant</span> <span class="muControl">break-unless</span> is-touch? <span class="Comment"># ignore all but 'left-click' events for now</span> <span class="Comment"># todo: test this</span> - touch-type:num<span class="Special"> &lt;- </span>get t, <span class="Constant">type:offset</span> - is-left-click?:bool<span class="Special"> &lt;- </span>equal touch-type, <span class="Constant">65513/mouse-left</span> + touch-type:num <span class="Special">&lt;-</span> get t, <span class="Constant">type:offset</span> + is-left-click?:bool <span class="Special">&lt;-</span> equal touch-type, <span class="Constant">65513/mouse-left</span> <span class="muControl">loop-unless</span> is-left-click?, <span class="Constant">+next-event</span> - click-row:num<span class="Special"> &lt;- </span>get t, <span class="Constant">row:offset</span> - click-column:num<span class="Special"> &lt;- </span>get t, <span class="Constant">column:offset</span> + click-row:num <span class="Special">&lt;-</span> get t, <span class="Constant">row:offset</span> + click-column:num <span class="Special">&lt;-</span> get t, <span class="Constant">column:offset</span> <span class="Comment"># later exceptions for non-editor touches will go here</span> <span class="Constant"> &lt;global-touch&gt;</span> <span class="Comment"># send to both editors</span> - _<span class="Special"> &lt;- </span>move-cursor-in-editor screen, recipes, t - sandbox-in-focus?:bool<span class="Special"> &lt;- </span>move-cursor-in-editor screen, current-sandbox, t - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + _ <span class="Special">&lt;-</span> move-cursor-in-editor screen, recipes, t + sandbox-in-focus?:bool <span class="Special">&lt;-</span> move-cursor-in-editor screen, current-sandbox, t + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Comment"># 'resize' event - redraw editor</span> <span class="Comment"># todo: test this after supporting resize in assume-console</span> <span class="Delimiter">{</span> - r:resize-event, is-resize?:bool<span class="Special"> &lt;- </span>maybe-convert e:event, <span class="Constant">resize:variant</span> + r:resize-event, is-resize?:bool <span class="Special">&lt;-</span> maybe-convert e:event, <span class="Constant">resize:variant</span> <span class="muControl">break-unless</span> is-resize? <span class="Comment"># if more events, we're still resizing; wait until we stop</span> - more-events?:bool<span class="Special"> &lt;- </span>has-more-events? console + more-events?:bool <span class="Special">&lt;-</span> has-more-events? console <span class="Delimiter">{</span> <span class="muControl">break-unless</span> more-events? - render-all-on-no-more-events?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> + render-all-on-no-more-events? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> more-events? - env, screen<span class="Special"> &lt;- </span>resize screen, env - screen<span class="Special"> &lt;- </span>render-all screen, env, render-without-moving-cursor - render-all-on-no-more-events?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> <span class="Comment"># full render done</span> + env, screen <span class="Special">&lt;-</span> resize screen, env + screen <span class="Special">&lt;-</span> render-all screen, env, render-without-moving-cursor + render-all-on-no-more-events? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="Comment"># full render done</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Comment"># if it's not global and not a touch event, send to appropriate editor</span> <span class="Delimiter">{</span> hide-screen screen - sandbox-in-focus?:bool<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus?:bool <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - screen, recipes, render?:bool<span class="Special"> &lt;- </span>handle-keyboard-event screen, recipes, e:event + screen, recipes, render?:bool <span class="Special">&lt;-</span> handle-keyboard-event screen, recipes, e:event <span class="Comment"># refresh screen only if no more events</span> <span class="Comment"># if there are more events to process, wait for them to clear up, then make sure you render-all afterward.</span> - more-events?:bool<span class="Special"> &lt;- </span>has-more-events? console + more-events?:bool <span class="Special">&lt;-</span> has-more-events? console <span class="Delimiter">{</span> <span class="muControl">break-unless</span> more-events? - render-all-on-no-more-events?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> + render-all-on-no-more-events? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> @@ -171,27 +171,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render-all-on-no-more-events? <span class="Comment"># no more events, and we have to force render</span> - screen<span class="Special"> &lt;- </span>render-all screen, env, render - render-all-on-no-more-events?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + screen <span class="Special">&lt;-</span> render-all screen, env, render + render-all-on-no-more-events? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Comment"># no more events, no force render</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render? - screen<span class="Special"> &lt;- </span>render-recipes screen, env, render + screen <span class="Special">&lt;-</span> render-recipes screen, env, render <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - screen, current-sandbox, render?:bool<span class="Special"> &lt;- </span>handle-keyboard-event screen, current-sandbox, e:event + screen, current-sandbox, render?:bool <span class="Special">&lt;-</span> handle-keyboard-event screen, current-sandbox, e:event <span class="Comment"># refresh screen only if no more events</span> <span class="Comment"># if there are more events to process, wait for them to clear up, then make sure you render-all afterward.</span> - more-events?:bool<span class="Special"> &lt;- </span>has-more-events? console + more-events?:bool <span class="Special">&lt;-</span> has-more-events? console <span class="Delimiter">{</span> <span class="muControl">break-unless</span> more-events? - render-all-on-no-more-events?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> + render-all-on-no-more-events? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> @@ -199,20 +199,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render-all-on-no-more-events? <span class="Comment"># no more events, and we have to force render</span> - screen<span class="Special"> &lt;- </span>render-all screen, env, render - render-all-on-no-more-events?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + screen <span class="Special">&lt;-</span> render-all screen, env, render + render-all-on-no-more-events? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Comment"># no more events, no force render</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render? - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Constant"> +finish-event</span> - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="Delimiter">}</span> <span class="muControl">loop</span> @@ -223,24 +223,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> clear-screen screen <span class="Comment"># update screen dimensions</span> - width:num<span class="Special"> &lt;- </span>screen-width screen - divider:num, _<span class="Special"> &lt;- </span>divide-with-remainder width, <span class="Constant">2</span> + width:num <span class="Special">&lt;-</span> screen-width screen + divider:num, _ <span class="Special">&lt;-</span> divide-with-remainder width,<span class="Constant"> 2</span> <span class="Comment"># update recipe editor</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - right:num<span class="Special"> &lt;- </span>subtract divider, <span class="Constant">1</span> - *recipes<span class="Special"> &lt;- </span>put *recipes, <span class="Constant">right:offset</span>, right + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + right:num <span class="Special">&lt;-</span> subtract divider,<span class="Constant"> 1</span> + *recipes <span class="Special">&lt;-</span> put *recipes, <span class="Constant">right:offset</span>, right <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> - *recipes<span class="Special"> &lt;- </span>put *recipes, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> - *recipes<span class="Special"> &lt;- </span>put *recipes, <span class="Constant">cursor-column:offset</span>, <span class="Constant">0</span> + *recipes <span class="Special">&lt;-</span> put *recipes, <span class="Constant">cursor-row:offset</span>,<span class="Constant"> 1</span> + *recipes <span class="Special">&lt;-</span> put *recipes, <span class="Constant">cursor-column:offset</span>,<span class="Constant"> 0</span> <span class="Comment"># update sandbox editor</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:num<span class="Special"> &lt;- </span>add divider, <span class="Constant">1</span> - *current-sandbox<span class="Special"> &lt;- </span>put *current-sandbox, <span class="Constant">left:offset</span>, left - right:num<span class="Special"> &lt;- </span>subtract width, <span class="Constant">1</span> - *current-sandbox<span class="Special"> &lt;- </span>put *current-sandbox, <span class="Constant">right:offset</span>, right + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + left:num <span class="Special">&lt;-</span> add divider,<span class="Constant"> 1</span> + *current-sandbox <span class="Special">&lt;-</span> put *current-sandbox, <span class="Constant">left:offset</span>, left + right:num <span class="Special">&lt;-</span> subtract width,<span class="Constant"> 1</span> + *current-sandbox <span class="Special">&lt;-</span> put *current-sandbox, <span class="Constant">right:offset</span>, right <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> - *current-sandbox<span class="Special"> &lt;- </span>put *current-sandbox, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> - *current-sandbox<span class="Special"> &lt;- </span>put *current-sandbox, <span class="Constant">cursor-column:offset</span>, left + *current-sandbox <span class="Special">&lt;-</span> put *current-sandbox, <span class="Constant">cursor-row:offset</span>,<span class="Constant"> 1</span> + *current-sandbox <span class="Special">&lt;-</span> put *current-sandbox, <span class="Constant">cursor-column:offset</span>, left ] <span class="Comment"># Variant of 'render' that updates cursor-row and cursor-column based on</span> @@ -249,81 +249,81 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-without-moving-cursor screen:&amp;:screen, editor:&amp;:editor<span class="muRecipe"> -&gt; </span>last-row:num, last-column:num, screen:&amp;:screen, editor:&amp;:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> - left:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span> - screen-height:num<span class="Special"> &lt;- </span>screen-height screen - right:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:&amp;:duplex-list:char<span class="Special"> &lt;- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> - curr<span class="Special"> &lt;- </span>next curr + <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + left:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">left:offset</span> + screen-height:num <span class="Special">&lt;-</span> screen-height screen + right:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">right:offset</span> + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&amp;:duplex-list:char <span class="Special">&lt;-</span> copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr <span class="Special">&lt;-</span> next curr <span class="Constant"> +render-loop-initialization</span> - color:num<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span> - row:num<span class="Special"> &lt;- </span>copy <span class="Constant">1/top</span> - column:num<span class="Special"> &lt;- </span>copy left + color:num <span class="Special">&lt;-</span> copy <span class="Constant">7/white</span> + row:num <span class="Special">&lt;-</span> copy <span class="Constant">1/top</span> + column:num <span class="Special">&lt;-</span> copy left <span class="Comment"># save before-cursor</span> - old-before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> + old-before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> <span class="Comment"># initialze cursor-row/cursor-column/before-cursor to the top of the screen</span> <span class="Comment"># by default</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, row - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, column - top-of-screen:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, top-of-screen - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, row + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, column + top-of-screen:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, top-of-screen + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr - off-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal row, screen-height + off-screen?:bool <span class="Special">&lt;-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># if we find old-before-cursor still on the new resized screen, update</span> <span class="Comment"># editor.cursor-row and editor.cursor-column based on</span> <span class="Comment"># old-before-cursor</span> <span class="Delimiter">{</span> - at-cursor?:bool<span class="Special"> &lt;- </span>equal old-before-cursor, prev + at-cursor?:bool <span class="Special">&lt;-</span> equal old-before-cursor, prev <span class="muControl">break-unless</span> at-cursor? - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, row - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, column - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, old-before-cursor + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, row + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, column + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, old-before-cursor <span class="Delimiter">}</span> - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> <span class="Constant"> &lt;character-c-received&gt;</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> clear-line-until screen, right <span class="Comment"># skip to next line</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - column<span class="Special"> &lt;- </span>copy left - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column - curr<span class="Special"> &lt;- </span>next curr - prev<span class="Special"> &lt;- </span>next prev + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + column <span class="Special">&lt;-</span> copy left + screen <span class="Special">&lt;-</span> move-cursor screen, row, column + curr <span class="Special">&lt;-</span> next curr + prev <span class="Special">&lt;-</span> next prev <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap. even if there's only one more letter left; we need</span> <span class="Comment"># room for clicking on the cursor after it.</span> - at-right?:bool<span class="Special"> &lt;- </span>equal column, right + at-right?:bool <span class="Special">&lt;-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> &lt;- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special">&lt;-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> &lt;- </span>copy left - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + column <span class="Special">&lt;-</span> copy left + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="Comment"># don't increment curr</span> <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - curr<span class="Special"> &lt;- </span>next curr - prev<span class="Special"> &lt;- </span>next prev - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + curr <span class="Special">&lt;-</span> next curr + prev <span class="Special">&lt;-</span> next prev + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># save first character off-screen</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">bottom:offset</span>, row - <span class="muControl">return</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">bottom:offset</span>, row + <span class="muControl">return</span> row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] @@ -332,23 +332,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> <span class="Comment"># focus on both sides</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> - left-click <span class="Constant">1</span>, <span class="Constant">17</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 17</span> ] <span class="Comment"># check cursor column in each</span> run [ event-loop screen, console, env - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *recipes, <span class="Constant">cursor-column:offset</span> - sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:num/<span class="Special">raw &lt;- </span>get *sandbox, <span class="Constant">cursor-column:offset</span> + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *recipes, <span class="Constant">cursor-column:offset</span> + sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + 7:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">7</span><span class="Special"> &lt;- </span><span class="Constant">17</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 7</span> <span class="Special">&lt;-</span><span class="Constant"> 17</span> ] ] @@ -357,21 +357,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> render-all screen, env, render <span class="Comment"># type one letter in each of them</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> type <span class="Constant">[0]</span> - left-click <span class="Constant">1</span>, <span class="Constant">17</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 17</span> type <span class="Constant">[1]</span> ] run [ event-loop screen, console, env - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw &lt;- </span>get *recipes, <span class="Constant">cursor-column:offset</span> - sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:num/<span class="Special">raw &lt;- </span>get *sandbox, <span class="Constant">cursor-column:offset</span> + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *recipes, <span class="Constant">cursor-column:offset</span> + sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + 7:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . run (F4) . # this line has a different background, but we don't test that yet</span> @@ -380,12 +380,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . ╎ .</span> ] memory-should-contain [ - <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">2</span> <span class="Comment"># cursor column of recipe editor</span> - <span class="Constant">7</span><span class="Special"> &lt;- </span><span class="Constant">18</span> <span class="Comment"># cursor column of sandbox editor</span> + <span class="Constant"> 5</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> <span class="Comment"># cursor column of recipe editor</span> + <span class="Constant"> 7</span> <span class="Special">&lt;-</span><span class="Constant"> 18</span> <span class="Comment"># cursor column of sandbox editor</span> ] <span class="Comment"># show the cursor at the right window</span> run [ - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] screen-should-contain [ @@ -401,7 +401,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> run [ - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> render-all screen, env, render ] <span class="Comment"># divider isn't messed up</span> @@ -418,13 +418,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> render-all screen, env, render <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># is cursor at the right place?</span> @@ -440,7 +440,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor should still be right</span> @@ -457,9 +457,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize sandbox side with two lines</span> - s:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + s:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, s:text + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, s:text render-all screen, env, render screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -470,12 +470,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># position cursor at start of second line and hit backspace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">16</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 16</span> press backspace ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor moves to end of old line</span> @@ -490,31 +490,31 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-all screen:&amp;:screen, env:&amp;:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -&gt; </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -&gt; </span>screen:&amp;:screen, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> hide-screen screen <span class="Comment"># top menu</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render top menu]</span> - width:num<span class="Special"> &lt;- </span>screen-width screen - draw-horizontal screen, <span class="Constant">0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> - button-start:num<span class="Special"> &lt;- </span>subtract width, <span class="Constant">20</span> - button-on-screen?:bool<span class="Special"> &lt;- </span>greater-or-equal button-start, <span class="Constant">0</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render top menu]</span> + width:num <span class="Special">&lt;-</span> screen-width screen + draw-horizontal screen,<span class="Constant"> 0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> + button-start:num <span class="Special">&lt;-</span> subtract width,<span class="Constant"> 20</span> + button-on-screen?:bool <span class="Special">&lt;-</span> greater-or-equal button-start,<span class="Constant"> 0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start + screen <span class="Special">&lt;-</span> move-cursor screen, <span class="Constant">0/row</span>, button-start print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> - divider:num, _<span class="Special"> &lt;- </span>divide-with-remainder width, <span class="Constant">2</span> - height:num<span class="Special"> &lt;- </span>screen-height screen + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> + divider:num, _ <span class="Special">&lt;-</span> divide-with-remainder width,<span class="Constant"> 2</span> + height:num <span class="Special">&lt;-</span> screen-height screen draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment">#</span> - screen<span class="Special"> &lt;- </span>render-recipes screen, env, render-editor - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render-editor + screen <span class="Special">&lt;-</span> render-recipes screen, env, render-editor + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render-editor <span class="Constant"> &lt;render-components-end&gt;</span> <span class="Comment">#</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:bool<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:bool <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment">#</span> show-screen screen ] @@ -522,18 +522,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-recipes screen:&amp;:screen, env:&amp;:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -&gt; </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -&gt; </span>screen:&amp;:screen, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render recipes]</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render recipes]</span> + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> <span class="Comment"># render recipes</span> - left:num<span class="Special"> &lt;- </span>get *recipes, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *recipes, <span class="Constant">right:offset</span> - row:num, column:num, screen<span class="Special"> &lt;- </span>call render-editor, screen, recipes + left:num <span class="Special">&lt;-</span> get *recipes, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *recipes, <span class="Constant">right:offset</span> + row:num, column:num, screen <span class="Special">&lt;-</span> call render-editor, screen, recipes clear-line-until screen, right - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> <span class="Constant"> &lt;render-recipe-components-end&gt;</span> <span class="Comment"># draw dotted line after recipes</span> draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> clear-screen-from screen, row, left, left, right ] @@ -541,15 +541,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-sandbox-side screen:&amp;:screen, env:&amp;:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -&gt; </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -&gt; </span>screen:&amp;:screen, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">right:offset</span> - row:num, column:num, screen, current-sandbox<span class="Special"> &lt;- </span>call render-editor, screen, current-sandbox + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + left:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">right:offset</span> + row:num, column:num, screen, current-sandbox <span class="Special">&lt;-</span> call render-editor, screen, current-sandbox clear-line-until screen, right - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> <span class="Comment"># draw solid line after code (you'll see why in later layers)</span> draw-horizontal screen, row, left, right - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> clear-screen-from screen, row, left, left, right ] @@ -559,15 +559,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> &lt;update-cursor-special-cases&gt;</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - cursor-row:num<span class="Special"> &lt;- </span>get *recipes, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *recipes, <span class="Constant">cursor-column:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *recipes, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *recipes, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - cursor-row:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">cursor-column:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">}</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, cursor-row, cursor-column + screen <span class="Special">&lt;-</span> move-cursor screen, cursor-row, cursor-column ] <span class="Comment"># like 'render' for texts, but with colorization for comments like in the editor</span> @@ -575,60 +575,60 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - color:num<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span> - column:num<span class="Special"> &lt;- </span>copy left - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column - screen-height:num<span class="Special"> &lt;- </span>screen-height screen - i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> &lt;- </span>length *s + color:num <span class="Special">&lt;-</span> copy <span class="Constant">7/white</span> + column:num <span class="Special">&lt;-</span> copy left + screen <span class="Special">&lt;-</span> move-cursor screen, row, column + screen-height:num <span class="Special">&lt;-</span> screen-height screen + i:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special">&lt;-</span> length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, len + done?:bool <span class="Special">&lt;-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> &lt;- </span>greater-or-equal row, screen-height + done? <span class="Special">&lt;-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:char<span class="Special"> &lt;- </span>index *s, i + c:char <span class="Special">&lt;-</span> index *s, i <span class="Constant">&lt;character-c-received&gt;</span> <span class="Comment"># only line different from render</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:bool<span class="Special"> &lt;- </span>equal column, right + at-right?:bool <span class="Special">&lt;-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> &lt;- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special">&lt;-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> &lt;- </span>copy left - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + column <span class="Special">&lt;-</span> copy left + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Comment"># retry i</span> <span class="Delimiter">}</span> - i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span> + i <span class="Special">&lt;-</span> add i,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-than column, right + done?:bool <span class="Special">&lt;-</span> greater-than column, right <span class="muControl">break-if</span> done? - space:char<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special">&lt;-</span> copy <span class="Constant">32/space</span> print screen, space - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - column<span class="Special"> &lt;- </span>copy left - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + column <span class="Special">&lt;-</span> copy left + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:bool<span class="Special"> &lt;- </span>equal column, left + was-at-left?:bool <span class="Special">&lt;-</span> equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> move-cursor screen, row, left ] @@ -637,9 +637,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-type&gt;</span> [ <span class="Delimiter">{</span> - redraw-screen?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">12/ctrl-l</span> + redraw-screen?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">12/ctrl-l</span> <span class="muControl">break-unless</span> redraw-screen? - screen<span class="Special"> &lt;- </span>render-all screen, env:&amp;:environment, render + screen <span class="Special">&lt;-</span> render-all screen, env:&amp;:environment, render sync-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -650,12 +650,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-type&gt;</span> [ <span class="Delimiter">{</span> - switch-side?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">14/ctrl-n</span> + switch-side?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">14/ctrl-n</span> <span class="muControl">break-unless</span> switch-side? - sandbox-in-focus?:bool<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> - sandbox-in-focus?<span class="Special"> &lt;- </span>not sandbox-in-focus? - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + sandbox-in-focus?:bool <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus? <span class="Special">&lt;-</span> not sandbox-in-focus? + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> ] @@ -665,23 +665,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> draw-vertical screen:&amp;:screen, col:num, y:num, bottom:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:char, style-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool <span class="Special">&lt;-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? - style<span class="Special"> &lt;- </span>copy <span class="Constant">9474/vertical</span> + style <span class="Special">&lt;-</span> copy <span class="Constant">9474/vertical</span> <span class="Delimiter">}</span> - color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool <span class="Special">&lt;-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> <span class="muControl">break-if</span> color-found? - color<span class="Special"> &lt;- </span>copy <span class="Constant">245/grey</span> + color <span class="Special">&lt;-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - continue?:bool<span class="Special"> &lt;- </span>lesser-than y, bottom + continue?:bool <span class="Special">&lt;-</span> lesser-than y, bottom <span class="muControl">break-unless</span> continue? - screen<span class="Special"> &lt;- </span>move-cursor screen, y, col + screen <span class="Special">&lt;-</span> move-cursor screen, y, col print screen, style, color - y<span class="Special"> &lt;- </span>add y, <span class="Constant">1</span> + y <span class="Special">&lt;-</span> add y,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 735a45de..91e61166 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -45,11 +45,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text<span class="Special"> &lt;- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text<span class="Special"> &lt;- </span>new <span class="Constant">[]</span> + initial-recipe:text <span class="Special">&lt;-</span> restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text <span class="Special">&lt;-</span> new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox - env<span class="Special"> &lt;- </span>restore-sandboxes env + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env <span class="Special">&lt;-</span> restore-sandboxes env render-all <span class="Constant">0/screen</span>, env, render event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;programming-environment-initialization&gt;</span> [ - *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *result <span class="Special">&lt;-</span> put *result, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> ] <span class="muData">container</span> sandbox [ @@ -82,7 +82,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -133,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># run another command</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 80</span> type <span class="Constant">[add 2, 2]</span> press F4 ] @@ -161,17 +161,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-keypress&gt;</span> [ <span class="Comment"># F4? load all code and run all sandboxes.</span> <span class="Delimiter">{</span> - do-run?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65532/F4</span> + do-run?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? - screen<span class="Special"> &lt;- </span>update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> - error?:bool, env, screen<span class="Special"> &lt;- </span>run-sandboxes env, screen + screen <span class="Special">&lt;-</span> update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> + error?:bool, env, screen <span class="Special">&lt;-</span> run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> - screen<span class="Special"> &lt;- </span>render-all screen, env, render + screen <span class="Special">&lt;-</span> render-all screen, env, render <span class="Delimiter">{</span> <span class="muControl">break-if</span> error? - screen<span class="Special"> &lt;- </span>update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> + screen <span class="Special">&lt;-</span> update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> ] @@ -179,41 +179,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> run-sandboxes env:&amp;:environment, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>errors-found?:bool, env:&amp;:environment, screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - errors-found?:bool, env, screen<span class="Special"> &lt;- </span>update-recipes env, screen + errors-found?:bool, env, screen <span class="Special">&lt;-</span> update-recipes env, screen <span class="muControl">return-if</span> errors-found? <span class="Comment"># check contents of right editor (sandbox)</span> <span class="Constant"> &lt;run-sandboxes-begin&gt;</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> - sandbox-contents:text<span class="Special"> &lt;- </span>editor-contents current-sandbox + sandbox-contents:text <span class="Special">&lt;-</span> editor-contents current-sandbox <span class="muControl">break-unless</span> sandbox-contents <span class="Comment"># if contents exist, first save them</span> <span class="Comment"># run them and turn them into a new sandbox</span> - new-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>new <span class="Constant">sandbox:type</span> - *new-sandbox<span class="Special"> &lt;- </span>put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents + new-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> new <span class="Constant">sandbox:type</span> + *new-sandbox <span class="Special">&lt;-</span> put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents <span class="Comment"># push to head of sandbox list</span> - dest:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - *new-sandbox<span class="Special"> &lt;- </span>put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox:offset</span>, new-sandbox + dest:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + *new-sandbox <span class="Special">&lt;-</span> put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox:offset</span>, new-sandbox <span class="Comment"># update sandbox count</span> - sandbox-count:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - sandbox-count<span class="Special"> &lt;- </span>add sandbox-count, <span class="Constant">1</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count + sandbox-count:num <span class="Special">&lt;-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count <span class="Special">&lt;-</span> add sandbox-count,<span class="Constant"> 1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count <span class="Comment"># clear sandbox editor</span> - init:&amp;:duplex-list:char<span class="Special"> &lt;- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - *current-sandbox<span class="Special"> &lt;- </span>put *current-sandbox, <span class="Constant">data:offset</span>, init - *current-sandbox<span class="Special"> &lt;- </span>put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init + init:&amp;:duplex-list:char <span class="Special">&lt;-</span> push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> + *current-sandbox <span class="Special">&lt;-</span> put *current-sandbox, <span class="Constant">data:offset</span>, init + *current-sandbox <span class="Special">&lt;-</span> put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init <span class="Delimiter">}</span> <span class="Comment"># save all sandboxes before running, just in case we die when running</span> save-sandboxes env <span class="Comment"># run all sandboxes</span> - curr:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + curr:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + idx:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - curr<span class="Special"> &lt;- </span>update-sandbox curr, env, idx - curr<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span> - idx<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span> + curr <span class="Special">&lt;-</span> update-sandbox curr, env, idx + curr <span class="Special">&lt;-</span> get *curr, <span class="Constant">next-sandbox:offset</span> + idx <span class="Special">&lt;-</span> add idx,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Constant"> &lt;run-sandboxes-end&gt;</span> @@ -224,46 +224,46 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> update-recipes env:&amp;:environment, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>errors-found?:bool, env:&amp;:environment, screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - in:text<span class="Special"> &lt;- </span>editor-contents recipes + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + in:text <span class="Special">&lt;-</span> editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in - errors-found?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + errors-found? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> ] <span class="Comment"># replaced in a later layer</span> <span class="muRecipe">def!</span> update-sandbox sandbox:&amp;:sandbox, env:&amp;:environment, idx:num<span class="muRecipe"> -&gt; </span>sandbox:&amp;:sandbox, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:&amp;:screen<span class="Special"> &lt;- </span>run-sandboxed data - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + data:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:&amp;:screen <span class="Special">&lt;-</span> run-sandboxed data + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen ] <span class="muRecipe">def</span> update-status screen:&amp;:screen, msg:text, color:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span> - screen<span class="Special"> &lt;- </span>print screen, msg, color, <span class="Constant">238/grey/background</span> + screen <span class="Special">&lt;-</span> move-cursor screen,<span class="Constant"> 0</span>,<span class="Constant"> 2</span> + screen <span class="Special">&lt;-</span> print screen, msg, color, <span class="Constant">238/grey/background</span> ] <span class="muRecipe">def</span> save-sandboxes env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> <span class="Comment"># first clear previous versions, in case we deleted some sandbox</span> - $system <span class="Constant">[rm lesson/[0-9]</span>* <span class="Constant">&gt;/dev/null</span> <span class="Constant">2</span>&gt;/dev/null] <span class="Comment"># some shells can't handle '&gt;&amp;'</span> - curr:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + $system <span class="Constant">[rm lesson/[0-9]</span>* <span class="Constant">&gt;/dev/null</span> 2&gt;/dev/null] <span class="Comment"># some shells can't handle '&gt;&amp;'</span> + curr:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + idx:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - data:text<span class="Special"> &lt;- </span>get *curr, <span class="Constant">data:offset</span> - filename:text<span class="Special"> &lt;- </span>to-text idx + data:text <span class="Special">&lt;-</span> get *curr, <span class="Constant">data:offset</span> + filename:text <span class="Special">&lt;-</span> to-text idx save filename, data <span class="Constant"> &lt;end-save-sandbox&gt;</span> - idx<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span> - curr<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + idx <span class="Special">&lt;-</span> add idx,<span class="Constant"> 1</span> + curr <span class="Special">&lt;-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -271,24 +271,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> render-sandbox-side screen:&amp;:screen, env:&amp;:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -&gt; </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -&gt; </span>screen:&amp;:screen, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - row:num, column:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span> - left:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">right:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + row:num, column:num <span class="Special">&lt;-</span> copy<span class="Constant"> 1</span>,<span class="Constant"> 0</span> + left:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">left:offset</span> + right:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">right:offset</span> <span class="Comment"># render sandbox editor</span> - render-from:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span> + render-from:num <span class="Special">&lt;-</span> get *env, <span class="Constant">render-from:offset</span> <span class="Delimiter">{</span> - render-current-sandbox?:bool<span class="Special"> &lt;- </span>equal render-from, <span class="Constant">-1</span> + render-current-sandbox?:bool <span class="Special">&lt;-</span> equal render-from,<span class="Constant"> -1</span> <span class="muControl">break-unless</span> render-current-sandbox? - row, column, screen, current-sandbox<span class="Special"> &lt;- </span>call render-editor, screen, current-sandbox + row, column, screen, current-sandbox <span class="Special">&lt;-</span> call render-editor, screen, current-sandbox clear-screen-from screen, row, column, left, right - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Comment"># render sandboxes</span> draw-horizontal screen, row, left, right - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - row, screen<span class="Special"> &lt;- </span>render-sandboxes screen, sandbox, left, right, row, render-from + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + row, screen <span class="Special">&lt;-</span> render-sandboxes screen, sandbox, left, right, row, render-from clear-rest-of-screen screen, row, left, right ] @@ -296,40 +296,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox - screen-height:num<span class="Special"> &lt;- </span>screen-height screen - at-bottom?:bool<span class="Special"> &lt;- </span>greater-or-equal row, screen-height + screen-height:num <span class="Special">&lt;-</span> screen-height screen + at-bottom?:bool <span class="Special">&lt;-</span> greater-or-equal row, screen-height <span class="muControl">return-if</span> at-bottom?:bool - hidden?:bool<span class="Special"> &lt;- </span>lesser-than idx, render-from + hidden?:bool <span class="Special">&lt;-</span> lesser-than idx, render-from <span class="Delimiter">{</span> <span class="muControl">break-if</span> hidden? <span class="Comment"># render sandbox menu</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, row, left - screen<span class="Special"> &lt;- </span>render-sandbox-menu screen, idx, left, right + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special">&lt;-</span> move-cursor screen, row, left + screen <span class="Special">&lt;-</span> render-sandbox-menu screen, idx, left, right <span class="Comment"># save menu row so we can detect clicks to it later</span> - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, row + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, row <span class="Comment"># render sandbox contents</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, row, left - sandbox-data:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span> - row, screen<span class="Special"> &lt;- </span>render-code screen, sandbox-data, left, right, row - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special">&lt;-</span> move-cursor screen, row, left + sandbox-data:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">data:offset</span> + row, screen <span class="Special">&lt;-</span> render-code screen, sandbox-data, left, right, row + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row <span class="Comment"># render sandbox warnings, screen or response, in that order</span> - sandbox-response:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">response:offset</span> + sandbox-response:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">response:offset</span> <span class="Constant"> &lt;render-sandbox-results&gt;</span> <span class="Delimiter">{</span> - sandbox-screen:&amp;:screen<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">screen:offset</span> - empty-screen?:bool<span class="Special"> &lt;- </span>fake-screen-is-empty? sandbox-screen + sandbox-screen:&amp;:screen <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">screen:offset</span> + empty-screen?:bool <span class="Special">&lt;-</span> fake-screen-is-empty? sandbox-screen <span class="muControl">break-if</span> empty-screen? - row, screen<span class="Special"> &lt;- </span>render-screen screen, sandbox-screen, left, right, row + row, screen <span class="Special">&lt;-</span> render-screen screen, sandbox-screen, left, right, row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> empty-screen? <span class="Constant"> &lt;render-sandbox-response&gt;</span> - row, screen<span class="Special"> &lt;- </span>render-text screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row + row, screen <span class="Special">&lt;-</span> render-text screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> <span class="Constant"> +render-sandbox-end</span> - at-bottom?:bool<span class="Special"> &lt;- </span>greater-or-equal row, screen-height + at-bottom?:bool <span class="Special">&lt;-</span> greater-or-equal row, screen-height <span class="muControl">return-if</span> at-bottom? <span class="Comment"># draw solid line after sandbox</span> draw-horizontal screen, row, left, right @@ -337,33 +337,33 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if hidden, reset row attributes</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> hidden? - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, <span class="Constant">0</span> - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>,<span class="Constant"> 0</span> <span class="Constant"> &lt;end-render-sandbox-reset-hidden&gt;</span> <span class="Delimiter">}</span> <span class="Comment"># draw next sandbox</span> - next-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> - next-idx:num<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span> - row, screen<span class="Special"> &lt;- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx + next-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-idx:num <span class="Special">&lt;-</span> add idx,<span class="Constant"> 1</span> + row, screen <span class="Special">&lt;-</span> render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] <span class="muRecipe">def</span> render-sandbox-menu screen:&amp;:screen, sandbox-index:num, left:num, right:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> move-cursor-to-column screen, left - edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num<span class="Special"> &lt;- </span>sandbox-menu-columns left, right + edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <span class="Special">&lt;-</span> sandbox-menu-columns left, right print screen, sandbox-index, <span class="Constant">232/dark-grey</span>, <span class="Constant">245/grey</span> - start-buttons:num<span class="Special"> &lt;- </span>subtract edit-button-left, <span class="Constant">1</span> + start-buttons:num <span class="Special">&lt;-</span> subtract edit-button-left,<span class="Constant"> 1</span> clear-line-until screen, start-buttons, <span class="Constant">245/grey</span> print screen, <span class="Constant">[edit]</span>, <span class="Constant">232/black</span>, <span class="Constant">94/background-orange</span> clear-line-until screen, edit-button-right, <span class="Constant">94/background-orange</span> - _, col:num<span class="Special"> &lt;- </span>cursor-position screen - at-start-of-copy-button?:bool<span class="Special"> &lt;- </span>equal col, copy-button-left + _, col:num <span class="Special">&lt;-</span> cursor-position screen + at-start-of-copy-button?:bool <span class="Special">&lt;-</span> equal col, copy-button-left assert at-start-of-copy-button?, <span class="Constant">[aaa]</span> print screen, <span class="Constant">[copy]</span>, <span class="Constant">232/black</span>, <span class="Constant">58/background-green</span> clear-line-until screen, copy-button-right, <span class="Constant">58/background-green</span> - _, col:num<span class="Special"> &lt;- </span>cursor-position screen - at-start-of-delete-button?:bool<span class="Special"> &lt;- </span>equal col, delete-button-left + _, col:num <span class="Special">&lt;-</span> cursor-position screen + at-start-of-delete-button?:bool <span class="Special">&lt;-</span> equal col, delete-button-left assert at-start-of-delete-button?, <span class="Constant">[bbb]</span> print screen, <span class="Constant">[delete]</span>, <span class="Constant">232/black</span>, <span class="Constant">52/background-red</span> clear-line-until screen, right, <span class="Constant">52/background-red</span> @@ -375,16 +375,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> sandbox-menu-columns left:num, right:num<span class="muRecipe"> -&gt; </span>edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - start-buttons:num<span class="Special"> &lt;- </span>add left, <span class="Constant">4/space-for-sandbox-index</span> - buttons-space:num<span class="Special"> &lt;- </span>subtract right, start-buttons - button-width:num<span class="Special"> &lt;- </span>divide-with-remainder buttons-space, <span class="Constant">3</span> <span class="Comment"># integer division</span> - buttons-wide-enough?:bool<span class="Special"> &lt;- </span>greater-or-equal button-width, <span class="Constant">8</span> + start-buttons:num <span class="Special">&lt;-</span> add left, <span class="Constant">4/space-for-sandbox-index</span> + buttons-space:num <span class="Special">&lt;-</span> subtract right, start-buttons + button-width:num <span class="Special">&lt;-</span> divide-with-remainder buttons-space,<span class="Constant"> 3</span> <span class="Comment"># integer division</span> + buttons-wide-enough?:bool <span class="Special">&lt;-</span> greater-or-equal button-width,<span class="Constant"> 8</span> assert buttons-wide-enough?, <span class="Constant">[sandbox must be at least 30 or so characters wide]</span> - edit-button-left:num<span class="Special"> &lt;- </span>copy start-buttons - copy-button-left:num<span class="Special"> &lt;- </span>add start-buttons, button-width - edit-button-right:num<span class="Special"> &lt;- </span>subtract copy-button-left, <span class="Constant">1</span> - delete-button-left:num<span class="Special"> &lt;- </span>subtract right, button-width - copy-button-right:num<span class="Special"> &lt;- </span>subtract delete-button-left, <span class="Constant">1</span> + edit-button-left:num <span class="Special">&lt;-</span> copy start-buttons + copy-button-left:num <span class="Special">&lt;-</span> add start-buttons, button-width + edit-button-right:num <span class="Special">&lt;-</span> subtract copy-button-left,<span class="Constant"> 1</span> + delete-button-left:num <span class="Special">&lt;-</span> subtract right, button-width + copy-button-right:num <span class="Special">&lt;-</span> subtract delete-button-left,<span class="Constant"> 1</span> ] <span class="Comment"># print a text 's' to 'editor' in 'color' starting at 'row'</span> @@ -393,58 +393,58 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - column:num<span class="Special"> &lt;- </span>copy left - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column - screen-height:num<span class="Special"> &lt;- </span>screen-height screen - i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> &lt;- </span>length *s + column:num <span class="Special">&lt;-</span> copy left + screen <span class="Special">&lt;-</span> move-cursor screen, row, column + screen-height:num <span class="Special">&lt;-</span> screen-height screen + i:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special">&lt;-</span> length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, len + done?:bool <span class="Special">&lt;-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> &lt;- </span>greater-or-equal row, screen-height + done? <span class="Special">&lt;-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:char<span class="Special"> &lt;- </span>index *s, i + c:char <span class="Special">&lt;-</span> index *s, i <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:bool<span class="Special"> &lt;- </span>equal column, right + at-right?:bool <span class="Special">&lt;-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> &lt;- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special">&lt;-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> &lt;- </span>copy left - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + column <span class="Special">&lt;-</span> copy left + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Comment"># retry i</span> <span class="Delimiter">}</span> - i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span> + i <span class="Special">&lt;-</span> add i,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-than column, right + done?:bool <span class="Special">&lt;-</span> greater-than column, right <span class="muControl">break-if</span> done? - space:char<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special">&lt;-</span> copy <span class="Constant">32/space</span> print screen, space - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> - column<span class="Special"> &lt;- </span>copy left - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> + column <span class="Special">&lt;-</span> copy left + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:bool<span class="Special"> &lt;- </span>equal column, left + was-at-left?:bool <span class="Special">&lt;-</span> equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> move-cursor screen, row, left ] @@ -454,32 +454,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span> - idx:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - curr:&amp;:sandbox<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - prev:&amp;:sandbox<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> + idx:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + curr:&amp;:sandbox <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + prev:&amp;:sandbox <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - filename:text<span class="Special"> &lt;- </span>to-text idx - contents:text<span class="Special"> &lt;- </span>restore filename + filename:text <span class="Special">&lt;-</span> to-text idx + contents:text <span class="Special">&lt;-</span> restore filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># todo: handle empty sandbox</span> <span class="Comment"># create new sandbox for file</span> - curr<span class="Special"> &lt;- </span>new <span class="Constant">sandbox:type</span> - *curr<span class="Special"> &lt;- </span>put *curr, <span class="Constant">data:offset</span>, contents + curr <span class="Special">&lt;-</span> new <span class="Constant">sandbox:type</span> + *curr <span class="Special">&lt;-</span> put *curr, <span class="Constant">data:offset</span>, contents <span class="Constant"> &lt;end-restore-sandbox&gt;</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> idx - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox:offset</span>, curr + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox:offset</span>, curr <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> idx - *prev<span class="Special"> &lt;- </span>put *prev, <span class="Constant">next-sandbox:offset</span>, curr + *prev <span class="Special">&lt;-</span> put *prev, <span class="Constant">next-sandbox:offset</span>, curr <span class="Delimiter">}</span> - idx<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span> - prev<span class="Special"> &lt;- </span>copy curr + idx <span class="Special">&lt;-</span> add idx,<span class="Constant"> 1</span> + prev <span class="Special">&lt;-</span> copy curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># update sandbox count</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, idx + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, idx ] <span class="Comment"># print the fake sandbox screen to 'screen' with appropriate delimiters</span> @@ -489,62 +489,62 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox-screen <span class="Comment"># print 'screen:'</span> - row<span class="Special"> &lt;- </span>render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row - screen<span class="Special"> &lt;- </span>move-cursor screen, row, left + row <span class="Special">&lt;-</span> render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row + screen <span class="Special">&lt;-</span> move-cursor screen, row, left <span class="Comment"># start printing sandbox-screen</span> - column:num<span class="Special"> &lt;- </span>copy left - s-width:num<span class="Special"> &lt;- </span>screen-width sandbox-screen - s-height:num<span class="Special"> &lt;- </span>screen-height sandbox-screen - buf:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *sandbox-screen, <span class="Constant">data:offset</span> - stop-printing:num<span class="Special"> &lt;- </span>add left, s-width, <span class="Constant">3</span> - max-column:num<span class="Special"> &lt;- </span>min stop-printing, right - i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> &lt;- </span>length *buf - screen-height:num<span class="Special"> &lt;- </span>screen-height screen + column:num <span class="Special">&lt;-</span> copy left + s-width:num <span class="Special">&lt;-</span> screen-width sandbox-screen + s-height:num <span class="Special">&lt;-</span> screen-height sandbox-screen + buf:&amp;:@:screen-cell <span class="Special">&lt;-</span> get *sandbox-screen, <span class="Constant">data:offset</span> + stop-printing:num <span class="Special">&lt;-</span> add left, s-width,<span class="Constant"> 3</span> + max-column:num <span class="Special">&lt;-</span> min stop-printing, right + i:num <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special">&lt;-</span> length *buf + screen-height:num <span class="Special">&lt;-</span> screen-height screen <span class="Delimiter">{</span> - done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, len + done?:bool <span class="Special">&lt;-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> &lt;- </span>greater-or-equal row, screen-height + done? <span class="Special">&lt;-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - column<span class="Special"> &lt;- </span>copy left - screen<span class="Special"> &lt;- </span>move-cursor screen, row, column + column <span class="Special">&lt;-</span> copy left + screen <span class="Special">&lt;-</span> move-cursor screen, row, column <span class="Comment"># initial leader for each row: two spaces and a '.'</span> - space:char<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special">&lt;-</span> copy <span class="Constant">32/space</span> print screen, space, <span class="Constant">245/grey</span> print screen, space, <span class="Constant">245/grey</span> - full-stop:char<span class="Special"> &lt;- </span>copy <span class="Constant">46/period</span> + full-stop:char <span class="Special">&lt;-</span> copy <span class="Constant">46/period</span> print screen, full-stop, <span class="Constant">245/grey</span> - column<span class="Special"> &lt;- </span>add left, <span class="Constant">3</span> + column <span class="Special">&lt;-</span> add left,<span class="Constant"> 3</span> <span class="Delimiter">{</span> <span class="Comment"># print row</span> - row-done?:bool<span class="Special"> &lt;- </span>greater-or-equal column, max-column + row-done?:bool <span class="Special">&lt;-</span> greater-or-equal column, max-column <span class="muControl">break-if</span> row-done? - curr:screen-cell<span class="Special"> &lt;- </span>index *buf, i - c:char<span class="Special"> &lt;- </span>get curr, <span class="Constant">contents:offset</span> - color:num<span class="Special"> &lt;- </span>get curr, <span class="Constant">color:offset</span> + curr:screen-cell <span class="Special">&lt;-</span> index *buf, i + c:char <span class="Special">&lt;-</span> get curr, <span class="Constant">contents:offset</span> + color:num <span class="Special">&lt;-</span> get curr, <span class="Constant">color:offset</span> <span class="Delimiter">{</span> <span class="Comment"># damp whites down to grey</span> - white?:bool<span class="Special"> &lt;- </span>equal color, <span class="Constant">7/white</span> + white?:bool <span class="Special">&lt;-</span> equal color, <span class="Constant">7/white</span> <span class="muControl">break-unless</span> white? - color<span class="Special"> &lt;- </span>copy <span class="Constant">245/grey</span> + color <span class="Special">&lt;-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> - i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> + i <span class="Special">&lt;-</span> add i,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print final '.'</span> print screen, full-stop, <span class="Constant">245/grey</span> - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># clear rest of current line</span> - line-done?:bool<span class="Special"> &lt;- </span>greater-than column, right + line-done?:bool <span class="Special">&lt;-</span> greater-than column, right <span class="muControl">break-if</span> line-done? print screen, space - column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span> + column <span class="Special">&lt;-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span> + row <span class="Special">&lt;-</span> add row,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -554,14 +554,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">z:num &lt;- add 2, 2</span> <span class="Constant">reply z</span> <span class="Constant">]</span>] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -580,7 +580,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># make a change (incrementing one of the args to 'add'), then rerun</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">28</span> <span class="Comment"># one past the value of the second arg</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 28</span> <span class="Comment"># one past the value of the second arg</span> press backspace type <span class="Constant">[3]</span> press F4 @@ -608,7 +608,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> <span class="Comment"># right editor contains an instruction</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the code in the editor</span> assume-console [ press F4 @@ -637,37 +637,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> editor-contents editor:&amp;:editor<span class="muRecipe"> -&gt; </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:&amp;:buffer<span class="Special"> &lt;- </span>new-buffer <span class="Constant">80</span> - curr:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> + buf:&amp;:buffer <span class="Special">&lt;-</span> new-buffer<span class="Constant"> 80</span> + curr:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># skip § sentinel</span> assert curr, <span class="Constant">[editor without data is illegal; must have at least a sentinel]</span> - curr<span class="Special"> &lt;- </span>next curr - <span class="muControl">return-unless</span> curr, <span class="Constant">0</span> + curr <span class="Special">&lt;-</span> next curr + <span class="muControl">return-unless</span> curr,<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - c:char<span class="Special"> &lt;- </span>get *curr, <span class="Constant">value:offset</span> - buf<span class="Special"> &lt;- </span>append buf, c - curr<span class="Special"> &lt;- </span>next curr + c:char <span class="Special">&lt;-</span> get *curr, <span class="Constant">value:offset</span> + buf <span class="Special">&lt;-</span> append buf, c + curr <span class="Special">&lt;-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - result<span class="Special"> &lt;- </span>buffer-to-array buf + result <span class="Special">&lt;-</span> buffer-to-array buf ] <span class="muScenario">scenario</span> editor-provides-edited-contents [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> type <span class="Constant">[def]</span> ] run [ editor-event-loop screen, console, e - s:text<span class="Special"> &lt;- </span>editor-contents e - <span class="Constant">1</span>:@:char/<span class="Special">raw &lt;- </span>copy *s + s:text <span class="Special">&lt;-</span> editor-contents e + 1:@:char/<span class="Special">raw</span> <span class="Special">&lt;-</span> copy *s ] memory-should-contain [ - <span class="Constant">1</span>:array:character<span class="Special"> &lt;- </span><span class="Constant">[abdefc]</span> + 1:array:character <span class="Special">&lt;-</span> <span class="Constant">[abdefc]</span> ] ] @@ -677,7 +677,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter @@ -698,7 +698,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter @@ -706,7 +706,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press down-arrow <span class="Comment"># while cursor isn't at bottom</span> ] event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># cursor moves back to bottom</span> screen-should-contain [ @@ -726,28 +726,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;render-recipe-components-end&gt;</span> [ - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">recipe-bottom:offset</span>, row + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">recipe-bottom:offset</span>, row ] <span class="muRecipe">after</span> <span class="Constant">&lt;global-keypress&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - down-arrow?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65516/down-arrow</span> + down-arrow?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> down-arrow? - recipe-editor:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - recipe-cursor-row:num<span class="Special"> &lt;- </span>get *recipe-editor, <span class="Constant">cursor-row:offset</span> - recipe-editor-bottom:num<span class="Special"> &lt;- </span>get *recipe-editor, <span class="Constant">bottom:offset</span> - at-bottom-of-editor?:bool<span class="Special"> &lt;- </span>greater-or-equal recipe-cursor-row, recipe-editor-bottom + recipe-editor:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + recipe-cursor-row:num <span class="Special">&lt;-</span> get *recipe-editor, <span class="Constant">cursor-row:offset</span> + recipe-editor-bottom:num <span class="Special">&lt;-</span> get *recipe-editor, <span class="Constant">bottom:offset</span> + at-bottom-of-editor?:bool <span class="Special">&lt;-</span> greater-or-equal recipe-cursor-row, recipe-editor-bottom <span class="muControl">break-unless</span> at-bottom-of-editor? - more-to-scroll?:bool<span class="Special"> &lt;- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special">&lt;-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:bool<span class="Special"> &lt;- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special">&lt;-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -756,9 +756,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-type&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">6/ctrl-f</span> + page-down?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:bool<span class="Special"> &lt;- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special">&lt;-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -767,16 +767,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> more-to-scroll? env:&amp;:environment, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipe-bottom:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipe-bottom:offset</span> - height:num<span class="Special"> &lt;- </span>screen-height screen - result<span class="Special"> &lt;- </span>greater-or-equal recipe-bottom, height + recipe-bottom:num <span class="Special">&lt;-</span> get *env, <span class="Constant">recipe-bottom:offset</span> + height:num <span class="Special">&lt;-</span> screen-height screen + result <span class="Special">&lt;-</span> greater-or-equal recipe-bottom, height ] <span class="muScenario">scenario</span> scrolling-down-past-bottom-of-recipe-editor-2 [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ <span class="Comment"># add a line</span> @@ -801,7 +801,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> <span class="Constant">cd]</span> render-all screen, env, render assume-console [ @@ -813,7 +813,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press down-arrow ] event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># no scroll on recipe side, cursor moves on sandbox side</span> screen-should-contain [ @@ -832,7 +832,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ <span class="Comment"># create a sandbox</span> @@ -853,7 +853,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> @@ -871,7 +871,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor displays again, cursor is in editor</span> @@ -888,22 +888,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-keypress&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-down?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> sandbox <span class="Comment"># slide down if possible</span> <span class="Delimiter">{</span> - render-from:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span> - number-of-sandboxes:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - max:num<span class="Special"> &lt;- </span>subtract number-of-sandboxes, <span class="Constant">1</span> - at-end?:bool<span class="Special"> &lt;- </span>greater-or-equal render-from, max + render-from:num <span class="Special">&lt;-</span> get *env, <span class="Constant">render-from:offset</span> + number-of-sandboxes:num <span class="Special">&lt;-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + max:num <span class="Special">&lt;-</span> subtract number-of-sandboxes,<span class="Constant"> 1</span> + at-end?:bool <span class="Special">&lt;-</span> greater-or-equal render-from, max <span class="muControl">jump-if</span> at-end?, <span class="Constant">+finish-event</span> <span class="Comment"># render nothing</span> - render-from<span class="Special"> &lt;- </span>add render-from, <span class="Constant">1</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">render-from:offset</span>, render-from + render-from <span class="Special">&lt;-</span> add render-from,<span class="Constant"> 1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">render-from:offset</span>, render-from <span class="Delimiter">}</span> hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render show-screen screen <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> @@ -913,11 +913,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;update-cursor-special-cases&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - render-from:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span> - scrolling?:bool<span class="Special"> &lt;- </span>greater-or-equal render-from, <span class="Constant">0</span> + render-from:num <span class="Special">&lt;-</span> get *env, <span class="Constant">render-from:offset</span> + scrolling?:bool <span class="Special">&lt;-</span> greater-or-equal render-from,<span class="Constant"> 0</span> <span class="muControl">break-unless</span> scrolling? - cursor-column:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span> - screen<span class="Special"> &lt;- </span>move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> + cursor-column:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">left:offset</span> + screen <span class="Special">&lt;-</span> move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -926,15 +926,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-keypress&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-up?:bool<span class="Special"> &lt;- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool <span class="Special">&lt;-</span> equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - render-from:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span> - at-beginning?:bool<span class="Special"> &lt;- </span>equal render-from, <span class="Constant">-1</span> + render-from:num <span class="Special">&lt;-</span> get *env, <span class="Constant">render-from:offset</span> + at-beginning?:bool <span class="Special">&lt;-</span> equal render-from,<span class="Constant"> -1</span> <span class="muControl">break-if</span> at-beginning? - render-from<span class="Special"> &lt;- </span>subtract render-from, <span class="Constant">1</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">render-from:offset</span>, render-from + render-from <span class="Special">&lt;-</span> subtract render-from,<span class="Constant"> 1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">render-from:offset</span>, render-from hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render show-screen screen <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> @@ -945,15 +945,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> previous-sandbox env:&amp;:environment, in:&amp;:sandbox<span class="muRecipe"> -&gt; </span>out:&amp;:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> + curr:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">return-unless</span> curr, <span class="Constant">0/nil</span> - next:&amp;:sandbox<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + next:&amp;:sandbox <span class="Special">&lt;-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">return-unless</span> next, <span class="Constant">0/nil</span> - found?:bool<span class="Special"> &lt;- </span>equal next, in + found?:bool <span class="Special">&lt;-</span> equal next, in <span class="muControl">break-if</span> found? - curr<span class="Special"> &lt;- </span>copy next - next<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + curr <span class="Special">&lt;-</span> copy next + next <span class="Special">&lt;-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> curr @@ -964,10 +964,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side and create a sandbox</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">]</span> <span class="Comment"># create a sandbox</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ press F4 @@ -979,7 +979,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor moves down on recipe side</span> @@ -997,7 +997,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -1008,7 +1008,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -1028,7 +1028,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> @@ -1103,7 +1103,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> @@ -1125,7 +1125,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># no change</span> @@ -1148,7 +1148,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create a sandbox</span> assume-console [ diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index 8f96e319..0ae24c18 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at left edge of 'copy' button</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">69</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 69</span> ] run [ event-loop screen, console, env @@ -102,11 +102,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -124,7 +124,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at right edge of 'copy' button (just before 'delete')</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">84</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 84</span> ] run [ event-loop screen, console, env @@ -162,13 +162,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-touch&gt;</span> [ <span class="Comment"># support 'copy' button</span> <span class="Delimiter">{</span> - copy?:bool<span class="Special"> &lt;- </span>should-attempt-copy? click-row, click-column, env + copy?:bool <span class="Special">&lt;-</span> should-attempt-copy? click-row, click-column, env <span class="muControl">break-unless</span> copy? - copy?, env<span class="Special"> &lt;- </span>try-copy-sandbox click-row, env + copy?, env <span class="Special">&lt;-</span> try-copy-sandbox click-row, env <span class="muControl">break-unless</span> copy? hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -179,47 +179,47 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:bool<span class="Special"> &lt;- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool <span class="Special">&lt;-</span> click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'copy' button?</span> - first-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">right:offset</span> - _, _, copy-button-left:num, copy-button-right:num, _<span class="Special"> &lt;- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - copy-button-vertical-area?:bool<span class="Special"> &lt;- </span>within-range? click-column, copy-button-left, copy-button-right + sandbox-left-margin:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">right:offset</span> + _, _, copy-button-left:num, copy-button-right:num, _ <span class="Special">&lt;-</span> sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + copy-button-vertical-area?:bool <span class="Special">&lt;-</span> within-range? click-column, copy-button-left, copy-button-right <span class="muControl">reply-unless</span> copy-button-vertical-area?, <span class="Constant">0/false</span> <span class="Comment"># finally, is sandbox editor empty?</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - result<span class="Special"> &lt;- </span>empty-editor? current-sandbox + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + result <span class="Special">&lt;-</span> empty-editor? current-sandbox ] <span class="muRecipe">def</span> try-copy-sandbox click-row:num, env:&amp;:environment<span class="muRecipe"> -&gt; </span>clicked-on-copy-button?:bool, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to copy, if the click was actually on the 'copy' button</span> - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>find-sandbox env, click-row + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> - clicked-on-copy-button?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> - text:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - current-sandbox<span class="Special"> &lt;- </span>insert-text current-sandbox, text + clicked-on-copy-button? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> + text:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">data:offset</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox <span class="Special">&lt;-</span> insert-text current-sandbox, text <span class="Comment"># reset scroll</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> <span class="Comment"># position cursor in sandbox editor</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> ] <span class="muRecipe">def</span> find-sandbox env:&amp;:environment, click-row:num<span class="muRecipe"> -&gt; </span>result:&amp;:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> + curr-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr-sandbox - start:num<span class="Special"> &lt;- </span>get *curr-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:bool<span class="Special"> &lt;- </span>equal click-row, start + start:num <span class="Special">&lt;-</span> get *curr-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool <span class="Special">&lt;-</span> equal click-row, start <span class="muControl">return-if</span> found?, curr-sandbox - curr-sandbox<span class="Special"> &lt;- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + curr-sandbox <span class="Special">&lt;-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> <span class="Constant">0/not-found</span> @@ -228,30 +228,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> click-on-sandbox-area? click-row:num, click-column:num, env:&amp;:environment<span class="muRecipe"> -&gt; </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-left-margin:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span> - on-sandbox-side?:bool<span class="Special"> &lt;- </span>greater-or-equal click-column, sandbox-left-margin + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-left-margin:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">left:offset</span> + on-sandbox-side?:bool <span class="Special">&lt;-</span> greater-or-equal click-column, sandbox-left-margin <span class="muControl">return-unless</span> on-sandbox-side?, <span class="Constant">0/false</span> - first-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">return-unless</span> first-sandbox, <span class="Constant">0/false</span> - first-sandbox-begins:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - result<span class="Special"> &lt;- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + result <span class="Special">&lt;-</span> greater-or-equal click-row, first-sandbox-begins ] <span class="muRecipe">def</span> empty-editor? editor:&amp;:editor<span class="muRecipe"> -&gt; </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - head:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> - first:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next head - result<span class="Special"> &lt;- </span>not first + head:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> + first:&amp;:duplex-list:char <span class="Special">&lt;-</span> next head + result <span class="Special">&lt;-</span> not first ] <span class="muRecipe">def</span> within-range? x:num, low:num, high:num<span class="muRecipe"> -&gt; </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - not-too-far-left?:bool<span class="Special"> &lt;- </span>greater-or-equal x, low - not-too-far-right?:bool<span class="Special"> &lt;- </span>lesser-or-equal x, high - result<span class="Special"> &lt;- </span>and not-too-far-left? not-too-far-right? + not-too-far-left?:bool <span class="Special">&lt;-</span> greater-or-equal x, low + not-too-far-right?:bool <span class="Special">&lt;-</span> lesser-or-equal x, high + result <span class="Special">&lt;-</span> and not-too-far-left? not-too-far-right? ] <span class="muScenario">scenario</span> copy-fails-if-sandbox-editor-not-empty [ @@ -259,11 +259,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -281,9 +281,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># type something into the sandbox editor, then click on the 'copy' button</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">70</span> <span class="Comment"># put cursor in sandbox editor</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 70</span> <span class="Comment"># put cursor in sandbox editor</span> type <span class="Constant">[0]</span> <span class="Comment"># type something</span> - left-click <span class="Constant">3</span>, <span class="Constant">70</span> <span class="Comment"># click 'copy' button</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 70</span> <span class="Comment"># click 'copy' button</span> ] run [ event-loop screen, console, env diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index ffae21e3..5fbf7441 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -38,10 +38,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> <span class="Comment"># run a few commands</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 80</span> type <span class="Constant">[divide-with-remainder 11, 3]</span> press F4 type <span class="Constant">[add 2, 2]</span> @@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete second sandbox by clicking on left edge of 'delete' button</span> assume-console [ - left-click <span class="Constant">7</span>, <span class="Constant">85</span> + left-click<span class="Constant"> 7</span>,<span class="Constant"> 85</span> ] run [ event-loop screen, console, env @@ -83,7 +83,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete first sandbox by clicking at right edge of 'delete' button</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -100,13 +100,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-touch&gt;</span> [ <span class="Comment"># support 'delete' button</span> <span class="Delimiter">{</span> - delete?:bool<span class="Special"> &lt;- </span>should-attempt-delete? click-row, click-column, env + delete?:bool <span class="Special">&lt;-</span> should-attempt-delete? click-row, click-column, env <span class="muControl">break-unless</span> delete? - delete?, env<span class="Special"> &lt;- </span>try-delete-sandbox click-row, env + delete?, env <span class="Special">&lt;-</span> try-delete-sandbox click-row, env <span class="muControl">break-unless</span> delete? hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -117,66 +117,66 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:bool<span class="Special"> &lt;- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool <span class="Special">&lt;-</span> click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'copy' button?</span> - first-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">right:offset</span> - _, _, _, _, delete-button-left:num<span class="Special"> &lt;- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - result<span class="Special"> &lt;- </span>within-range? click-column, delete-button-left, sandbox-right-margin + sandbox-left-margin:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">right:offset</span> + _, _, _, _, delete-button-left:num <span class="Special">&lt;-</span> sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + result <span class="Special">&lt;-</span> within-range? click-column, delete-button-left, sandbox-right-margin ] <span class="muRecipe">def</span> try-delete-sandbox click-row:num, env:&amp;:environment<span class="muRecipe"> -&gt; </span>clicked-on-delete-button?:bool, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to delete, if the click was actually on the 'delete' button</span> - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>find-sandbox env, click-row + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> - clicked-on-delete-button?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> - env<span class="Special"> &lt;- </span>delete-sandbox env, sandbox + clicked-on-delete-button? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> + env <span class="Special">&lt;-</span> delete-sandbox env, sandbox ] <span class="muRecipe">def</span> delete-sandbox env:&amp;:environment, sandbox:&amp;:sandbox<span class="muRecipe"> -&gt; </span>env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - first-sandbox?:bool<span class="Special"> &lt;- </span>equal curr-sandbox, sandbox + curr-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + first-sandbox?:bool <span class="Special">&lt;-</span> equal curr-sandbox, sandbox <span class="Delimiter">{</span> <span class="Comment"># first sandbox? pop</span> <span class="muControl">break-unless</span> first-sandbox? - next-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox:offset</span>, next-sandbox + next-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox:offset</span>, next-sandbox <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># not first sandbox?</span> <span class="muControl">break-if</span> first-sandbox? - prev-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>copy curr-sandbox - curr-sandbox<span class="Special"> &lt;- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + prev-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> copy curr-sandbox + curr-sandbox <span class="Special">&lt;-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="Delimiter">{</span> assert curr-sandbox, <span class="Constant">[sandbox not found! something is wrong.]</span> - found?:bool<span class="Special"> &lt;- </span>equal curr-sandbox, sandbox + found?:bool <span class="Special">&lt;-</span> equal curr-sandbox, sandbox <span class="muControl">break-if</span> found? - prev-sandbox<span class="Special"> &lt;- </span>copy curr-sandbox - curr-sandbox<span class="Special"> &lt;- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + prev-sandbox <span class="Special">&lt;-</span> copy curr-sandbox + curr-sandbox <span class="Special">&lt;-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip sandbox out of its list</span> - next-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> - *prev-sandbox<span class="Special"> &lt;- </span>put *prev-sandbox, <span class="Constant">next-sandbox:offset</span>, next-sandbox + next-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + *prev-sandbox <span class="Special">&lt;-</span> put *prev-sandbox, <span class="Constant">next-sandbox:offset</span>, next-sandbox <span class="Delimiter">}</span> <span class="Comment"># update sandbox count</span> - sandbox-count:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - sandbox-count<span class="Special"> &lt;- </span>subtract sandbox-count, <span class="Constant">1</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count + sandbox-count:num <span class="Special">&lt;-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count <span class="Special">&lt;-</span> subtract sandbox-count,<span class="Constant"> 1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count <span class="Comment"># reset scroll if deleted sandbox was last</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> next-sandbox - render-from:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span> - reset-scroll?:bool<span class="Special"> &lt;- </span>equal render-from, sandbox-count + render-from:num <span class="Special">&lt;-</span> get *env, <span class="Constant">render-from:offset</span> + reset-scroll?:bool <span class="Special">&lt;-</span> equal render-from, sandbox-count <span class="muControl">break-unless</span> reset-scroll? - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> <span class="Delimiter">}</span> ] @@ -185,7 +185,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -208,7 +208,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox</span> assume-console [ - left-click <span class="Constant">6</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 6</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -230,7 +230,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -253,7 +253,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -275,7 +275,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -299,7 +299,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -322,7 +322,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -347,7 +347,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox, then try to scroll down twice</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 99</span> press page-down press page-down ] diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 6b8599b5..43481161 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -39,11 +39,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -61,7 +61,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at left edge of 'edit' button</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env @@ -99,11 +99,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -121,7 +121,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at right edge of 'edit' button (just before 'copy')</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">68</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 68</span> ] run [ event-loop screen, console, env @@ -157,13 +157,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-touch&gt;</span> [ <span class="Comment"># support 'edit' button</span> <span class="Delimiter">{</span> - edit?:bool<span class="Special"> &lt;- </span>should-attempt-edit? click-row, click-column, env + edit?:bool <span class="Special">&lt;-</span> should-attempt-edit? click-row, click-column, env <span class="muControl">break-unless</span> edit? - edit?, env<span class="Special"> &lt;- </span>try-edit-sandbox click-row, env + edit?, env <span class="Special">&lt;-</span> try-edit-sandbox click-row, env <span class="muControl">break-unless</span> edit? hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -174,37 +174,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:bool<span class="Special"> &lt;- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool <span class="Special">&lt;-</span> click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'edit' button?</span> - first-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">right:offset</span> - edit-button-left:num, edit-button-right:num, _<span class="Special"> &lt;- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - edit-button-vertical-area?:bool<span class="Special"> &lt;- </span>within-range? click-column, edit-button-left, edit-button-right + sandbox-left-margin:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">right:offset</span> + edit-button-left:num, edit-button-right:num, _ <span class="Special">&lt;-</span> sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + edit-button-vertical-area?:bool <span class="Special">&lt;-</span> within-range? click-column, edit-button-left, edit-button-right <span class="muControl">reply-unless</span> edit-button-vertical-area?, <span class="Constant">0/false</span> <span class="Comment"># finally, is sandbox editor empty?</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - result<span class="Special"> &lt;- </span>empty-editor? current-sandbox + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + result <span class="Special">&lt;-</span> empty-editor? current-sandbox ] <span class="muRecipe">def</span> try-edit-sandbox click-row:num, env:&amp;:environment<span class="muRecipe"> -&gt; </span>clicked-on-edit-button?:bool, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to edit, if the click was actually on the 'edit' button</span> - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>find-sandbox env, click-row + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> - clicked-on-edit-button?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + clicked-on-edit-button? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="Comment"># 'edit' button = 'copy' button + 'delete' button</span> - text:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span> - current-sandbox<span class="Special"> &lt;- </span>insert-text current-sandbox, text - env<span class="Special"> &lt;- </span>delete-sandbox env, sandbox + text:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">data:offset</span> + current-sandbox:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox <span class="Special">&lt;-</span> insert-text current-sandbox, text + env <span class="Special">&lt;-</span> delete-sandbox env, sandbox <span class="Comment"># reset scroll</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> <span class="Comment"># position cursor in sandbox editor</span> - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> sandbox-with-print-can-be-edited [ @@ -213,7 +213,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> <span class="Comment"># right editor contains an instruction</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 @@ -236,7 +236,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># edit the sandbox</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">65</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 65</span> ] run [ event-loop screen, console, env @@ -255,7 +255,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -279,7 +279,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># edit the second sandbox</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env @@ -302,7 +302,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -327,7 +327,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># edit the second sandbox, then resave</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">60</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 60</span> press F4 ] run [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 1c350a57..30c731ea 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes:text, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes:text, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the '4' in the result</span> assume-console [ - left-click <span class="Constant">5</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 5</span>,<span class="Constant"> 51</span> ] run [ event-loop screen, console, env @@ -80,7 +80,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should remain unmoved</span> run [ - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] screen-should-contain [ @@ -98,7 +98,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># now change the result</span> <span class="Comment"># then rerun</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">11</span> <span class="Comment"># cursor to end of line</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 11</span> <span class="Comment"># cursor to end of line</span> press backspace type <span class="Constant">[3]</span> press F4 @@ -128,19 +128,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># include expected response when saving or restoring a sandbox</span> <span class="muRecipe">before</span> <span class="Constant">&lt;end-save-sandbox&gt;</span> [ <span class="Delimiter">{</span> - expected-response:text<span class="Special"> &lt;- </span>get *curr, <span class="Constant">expected-response:offset</span> + expected-response:text <span class="Special">&lt;-</span> get *curr, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response - filename<span class="Special"> &lt;- </span>append filename, <span class="Constant">[.out]</span> + filename <span class="Special">&lt;-</span> append filename, <span class="Constant">[.out]</span> save filename, expected-response <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;end-restore-sandbox&gt;</span> [ <span class="Delimiter">{</span> - filename<span class="Special"> &lt;- </span>append filename, <span class="Constant">[.out]</span> - contents<span class="Special"> &lt;- </span>restore filename + filename <span class="Special">&lt;-</span> append filename, <span class="Constant">[.out]</span> + contents <span class="Special">&lt;-</span> restore filename <span class="muControl">break-unless</span> contents - *curr<span class="Special"> &lt;- </span>put *curr, <span class="Constant">expected-response:offset</span>, contents + *curr <span class="Special">&lt;-</span> put *curr, <span class="Constant">expected-response:offset</span>, contents <span class="Delimiter">}</span> ] @@ -148,25 +148,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;global-touch&gt;</span> [ <span class="Comment"># check if it's inside the output of any sandbox</span> <span class="Delimiter">{</span> - sandbox-left-margin:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span> - click-column:num<span class="Special"> &lt;- </span>get t, <span class="Constant">column:offset</span> - on-sandbox-side?:bool<span class="Special"> &lt;- </span>greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">left:offset</span> + click-column:num <span class="Special">&lt;-</span> get t, <span class="Constant">column:offset</span> + on-sandbox-side?:bool <span class="Special">&lt;-</span> greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox - first-sandbox-begins:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-row:num<span class="Special"> &lt;- </span>get t, <span class="Constant">row:offset</span> - below-sandbox-editor?:bool<span class="Special"> &lt;- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-row:num <span class="Special">&lt;-</span> get t, <span class="Constant">row:offset</span> + below-sandbox-editor?:bool <span class="Special">&lt;-</span> greater-or-equal click-row, first-sandbox-begins <span class="muControl">break-unless</span> below-sandbox-editor? <span class="Comment"># identify the sandbox whose output is being clicked on</span> - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>find-click-in-sandbox-output env, click-row + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> find-click-in-sandbox-output env, click-row <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its expected-response, and save session</span> - sandbox<span class="Special"> &lt;- </span>toggle-expected-response sandbox + sandbox <span class="Special">&lt;-</span> toggle-expected-response sandbox save-sandboxes env hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> @@ -177,24 +177,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row &gt;= sandbox.starting-row-on-screen</span> - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - start:num<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:bool<span class="Special"> &lt;- </span>greater-or-equal click-row, start + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + start:num <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + clicked-on-sandboxes?:bool <span class="Special">&lt;-</span> greater-or-equal click-row, start assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> <span class="Comment"># while click-row &lt; sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox - next-start:num<span class="Special"> &lt;- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:bool<span class="Special"> &lt;- </span>lesser-than click-row, next-start + next-start:num <span class="Special">&lt;-</span> get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool <span class="Special">&lt;-</span> lesser-than click-row, next-start <span class="muControl">break-if</span> found? - sandbox<span class="Special"> &lt;- </span>copy next-sandbox + sandbox <span class="Special">&lt;-</span> copy next-sandbox <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># return sandbox if click is in its output region</span> - response-starting-row:num<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + response-starting-row:num <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> <span class="muControl">return-unless</span> response-starting-row, <span class="Constant">0/no-click-in-sandbox-output</span> - click-in-response?:bool<span class="Special"> &lt;- </span>greater-or-equal click-row, response-starting-row + click-in-response?:bool <span class="Special">&lt;-</span> greater-or-equal click-row, response-starting-row <span class="muControl">return-unless</span> click-in-response?, <span class="Constant">0/no-click-in-sandbox-output</span> <span class="muControl">return</span> sandbox ] @@ -202,17 +202,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> toggle-expected-response sandbox:&amp;:sandbox<span class="muRecipe"> -&gt; </span>sandbox:&amp;:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - expected-response:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">expected-response:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if expected-response is set, reset</span> <span class="muControl">break-unless</span> expected-response - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">expected-response:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">expected-response:offset</span>,<span class="Constant"> 0</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># if not, set expected response to the current response</span> <span class="muControl">break-if</span> expected-response - response:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">response:offset</span> - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">expected-response:offset</span>, response + response:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">response:offset</span> + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">expected-response:offset</span>, response <span class="Delimiter">}</span> ] @@ -220,24 +220,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;render-sandbox-response&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-response - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, row - expected-response:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, row + expected-response:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response <span class="Comment"># fall-through to print in grey</span> - response-is-expected?:bool<span class="Special"> &lt;- </span>equal expected-response, sandbox-response + response-is-expected?:bool <span class="Special">&lt;-</span> equal expected-response, sandbox-response <span class="Delimiter">{</span> <span class="muControl">break-if</span> response-is-expected?:bool - row, screen<span class="Special"> &lt;- </span>render-text screen, sandbox-response, left, right, <span class="Constant">1/red</span>, row + row, screen <span class="Special">&lt;-</span> render-text screen, sandbox-response, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> response-is-expected?:bool - row, screen<span class="Special"> &lt;- </span>render-text screen, sandbox-response, left, right, <span class="Constant">2/green</span>, row + row, screen <span class="Special">&lt;-</span> render-text screen, sandbox-response, left, right, <span class="Constant">2/green</span>, row <span class="Delimiter">}</span> <span class="muControl">jump</span> <span class="Constant">+render-sandbox-end</span> <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;end-render-sandbox-reset-hidden&gt;</span> [ - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> ] </pre> </body> diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index ece61dee..66943462 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> ]] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -61,11 +61,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the code in the sandbox</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] run [ event-loop screen, console, env - cursor:char<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special">&lt;-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> @@ -87,7 +87,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click again on the same region</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env @@ -110,12 +110,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> - <span class="muControl">reply</span> <span class="Constant">4</span> + <span class="muControl">reply</span><span class="Constant"> 4</span> ]] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -133,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the code in the sandbox</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] run [ event-loop screen, console, env @@ -157,11 +157,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[stash 123456789]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[stash 123456789]</span> <span class="Comment"># create and expand the trace</span> assume-console [ press F4 - left-click <span class="Constant">4</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] event-loop screen, console, env screen-should-contain [ @@ -174,7 +174,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the stash under the edit-button region (or any of the other buttons, really)</span> assume-console [ - left-click <span class="Constant">5</span>, <span class="Constant">57</span> + left-click<span class="Constant"> 5</span>,<span class="Constant"> 57</span> ] run [ event-loop screen, console, env @@ -199,37 +199,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-sandbox sandbox:&amp;:sandbox, env:&amp;:environment, idx:num<span class="muRecipe"> -&gt; </span>sandbox:&amp;:sandbox, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:&amp;:screen, trace:text<span class="Special"> &lt;- </span>run-sandboxed data - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">trace:offset</span>, trace + data:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:&amp;:screen, trace:text <span class="Special">&lt;-</span> run-sandboxed data + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">trace:offset</span>, trace ] <span class="Comment"># clicks on sandbox code toggle its display-trace? flag</span> <span class="muRecipe">after</span> <span class="Constant">&lt;global-touch&gt;</span> [ <span class="Comment"># check if it's inside the code of any sandbox</span> <span class="Delimiter">{</span> - sandbox-left-margin:num<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span> - click-column:num<span class="Special"> &lt;- </span>get t, <span class="Constant">column:offset</span> - on-sandbox-side?:bool<span class="Special"> &lt;- </span>greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num <span class="Special">&lt;-</span> get *current-sandbox, <span class="Constant">left:offset</span> + click-column:num <span class="Special">&lt;-</span> get t, <span class="Constant">column:offset</span> + on-sandbox-side?:bool <span class="Special">&lt;-</span> greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox - first-sandbox-begins:num<span class="Special"> &lt;- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-row:num<span class="Special"> &lt;- </span>get t, <span class="Constant">row:offset</span> - below-sandbox-editor?:bool<span class="Special"> &lt;- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num <span class="Special">&lt;-</span> get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-row:num <span class="Special">&lt;-</span> get t, <span class="Constant">row:offset</span> + below-sandbox-editor?:bool <span class="Special">&lt;-</span> greater-or-equal click-row, first-sandbox-begins <span class="muControl">break-unless</span> below-sandbox-editor? <span class="Comment"># identify the sandbox whose code is being clicked on</span> - sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>find-click-in-sandbox-code env, click-row + sandbox:&amp;:sandbox <span class="Special">&lt;-</span> find-click-in-sandbox-code env, click-row <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its display-trace? property</span> - x:bool<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> - x<span class="Special"> &lt;- </span>not x - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">display-trace?:offset</span>, x + x:bool <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">display-trace?:offset</span> + x <span class="Special">&lt;-</span> not x + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">display-trace?:offset</span>, x hide-screen screen - screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env, render - screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special">&lt;-</span> render-sandbox-side screen, env, render + screen <span class="Special">&lt;-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> @@ -240,26 +240,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row &gt;= sandbox.starting-row-on-screen</span> - sandbox<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span> - start:num<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:bool<span class="Special"> &lt;- </span>greater-or-equal click-row, start + sandbox <span class="Special">&lt;-</span> get *env, <span class="Constant">sandbox:offset</span> + start:num <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + clicked-on-sandboxes?:bool <span class="Special">&lt;-</span> greater-or-equal click-row, start assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> <span class="Comment"># while click-row &lt; sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:&amp;:sandbox<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&amp;:sandbox <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox - next-start:num<span class="Special"> &lt;- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:bool<span class="Special"> &lt;- </span>lesser-than click-row, next-start + next-start:num <span class="Special">&lt;-</span> get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool <span class="Special">&lt;-</span> lesser-than click-row, next-start <span class="muControl">break-if</span> found? - sandbox<span class="Special"> &lt;- </span>copy next-sandbox + sandbox <span class="Special">&lt;-</span> copy next-sandbox <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># return sandbox if click is in its code region</span> - code-ending-row:num<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> - click-above-response?:bool<span class="Special"> &lt;- </span>lesser-than click-row, code-ending-row - start:num<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-below-menu?:bool<span class="Special"> &lt;- </span>greater-than click-row, start - click-on-sandbox-code?:bool<span class="Special"> &lt;- </span>and click-above-response?, click-below-menu? + code-ending-row:num <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + click-above-response?:bool <span class="Special">&lt;-</span> lesser-than click-row, code-ending-row + start:num <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-below-menu?:bool <span class="Special">&lt;-</span> greater-than click-row, start + click-on-sandbox-code?:bool <span class="Special">&lt;-</span> and click-above-response?, click-below-menu? <span class="Delimiter">{</span> <span class="muControl">break-if</span> click-on-sandbox-code? <span class="muControl">return</span> <span class="Constant">0/no-click-in-sandbox-output</span> @@ -270,11 +270,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># when rendering a sandbox, dump its trace before response/warning if display-trace? property is set</span> <span class="muRecipe">after</span> <span class="Constant">&lt;render-sandbox-results&gt;</span> [ <span class="Delimiter">{</span> - display-trace?:bool<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> + display-trace?:bool <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">display-trace?:offset</span> <span class="muControl">break-unless</span> display-trace? - sandbox-trace:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">trace:offset</span> + sandbox-trace:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">trace:offset</span> <span class="muControl">break-unless</span> sandbox-trace <span class="Comment"># nothing to print; move on</span> - row, screen<span class="Special"> &lt;- </span>render-text screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row + row, screen <span class="Special">&lt;-</span> render-text screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> <span class="Constant"> &lt;render-sandbox-trace-done&gt;</span> ] diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 146b2b15..2bdf811a 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -43,24 +43,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-recipes env:&amp;:environment, screen:&amp;:screen<span class="muRecipe"> -&gt; </span>errors-found?:bool, env:&amp;:environment, screen:&amp;:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&amp;:editor<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span> - in:text<span class="Special"> &lt;- </span>editor-contents recipes + recipes:&amp;:editor <span class="Special">&lt;-</span> get *env, <span class="Constant">recipes:offset</span> + in:text <span class="Special">&lt;-</span> editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in - recipe-errors:text<span class="Special"> &lt;- </span>reload in - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">recipe-errors:offset</span>, recipe-errors + recipe-errors:text <span class="Special">&lt;-</span> reload in + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">recipe-errors:offset</span>, recipe-errors <span class="Comment"># if recipe editor has errors, stop</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-errors update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> - errors-found?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + errors-found? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - errors-found?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span> + errors-found? <span class="Special">&lt;-</span> copy <span class="Constant">0/false</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;render-components-end&gt;</span> [ - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> - recipe-errors:text<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipe-errors:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> + recipe-errors:text <span class="Special">&lt;-</span> get *env, <span class="Constant">recipe-errors:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-errors update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> @@ -69,9 +69,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">before</span> <span class="Constant">&lt;render-recipe-components-end&gt;</span> [ <span class="Delimiter">{</span> - recipe-errors:text<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipe-errors:offset</span> + recipe-errors:text <span class="Special">&lt;-</span> get *env, <span class="Constant">recipe-errors:offset</span> <span class="muControl">break-unless</span> recipe-errors - row, screen<span class="Special"> &lt;- </span>render-text screen, recipe-errors, left, right, <span class="Constant">1/red</span>, row + row, screen <span class="Special">&lt;-</span> render-text screen, recipe-errors, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> ] @@ -80,30 +80,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;programming-environment-initialization&gt;</span> [ - *result<span class="Special"> &lt;- </span>put *result, <span class="Constant">error-index:offset</span>, <span class="Constant">-1</span> + *result <span class="Special">&lt;-</span> put *result, <span class="Constant">error-index:offset</span>,<span class="Constant"> -1</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;run-sandboxes-begin&gt;</span> [ - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">error-index:offset</span>, <span class="Constant">-1</span> + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">error-index:offset</span>,<span class="Constant"> -1</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;run-sandboxes-end&gt;</span> [ <span class="Delimiter">{</span> - error-index:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">error-index:offset</span> - sandboxes-completed-successfully?:bool<span class="Special"> &lt;- </span>equal error-index, <span class="Constant">-1</span> + error-index:num <span class="Special">&lt;-</span> get *env, <span class="Constant">error-index:offset</span> + sandboxes-completed-successfully?:bool <span class="Special">&lt;-</span> equal error-index,<span class="Constant"> -1</span> <span class="muControl">break-if</span> sandboxes-completed-successfully? - errors-found?<span class="Special"> &lt;- </span>copy <span class="Constant">1/true</span> + errors-found? <span class="Special">&lt;-</span> copy <span class="Constant">1/true</span> <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;render-components-end&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> recipe-errors - error-index:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">error-index:offset</span> - sandboxes-completed-successfully?:bool<span class="Special"> &lt;- </span>equal error-index, <span class="Constant">-1</span> + error-index:num <span class="Special">&lt;-</span> get *env, <span class="Constant">error-index:offset</span> + sandboxes-completed-successfully?:bool <span class="Special">&lt;-</span> equal error-index,<span class="Constant"> -1</span> <span class="muControl">break-if</span> sandboxes-completed-successfully? - error-index-text:text<span class="Special"> &lt;- </span>to-text error-index - status:text<span class="Special"> &lt;- </span>interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text + error-index-text:text <span class="Special">&lt;-</span> to-text error-index + status:text <span class="Special">&lt;-</span> interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text update-status screen, status, <span class="Constant">1/red</span> <span class="Delimiter">}</span> ] @@ -115,35 +115,35 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-sandbox sandbox:&amp;:sandbox, env:&amp;:environment, idx:num<span class="muRecipe"> -&gt; </span>sandbox:&amp;:sandbox, env:&amp;:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, errors:text, fake-screen:&amp;:screen, trace:text, completed?:bool<span class="Special"> &lt;- </span>run-sandboxed data - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">errors:offset</span>, errors - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">trace:offset</span>, trace + data:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, errors:text, fake-screen:&amp;:screen, trace:text, completed?:bool <span class="Special">&lt;-</span> run-sandboxed data + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">errors:offset</span>, errors + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">trace:offset</span>, trace <span class="Delimiter">{</span> <span class="muControl">break-if</span> errors <span class="muControl">break-if</span> completed?:bool - errors<span class="Special"> &lt;- </span>new <span class="Constant">[took too long!</span> + errors <span class="Special">&lt;-</span> new <span class="Constant">[took too long!</span> <span class="Constant">]</span> - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">errors:offset</span>, errors + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">errors:offset</span>, errors <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> errors - error-index:num<span class="Special"> &lt;- </span>get *env, <span class="Constant">error-index:offset</span> - error-not-set?:bool<span class="Special"> &lt;- </span>equal error-index, <span class="Constant">-1</span> + error-index:num <span class="Special">&lt;-</span> get *env, <span class="Constant">error-index:offset</span> + error-not-set?:bool <span class="Special">&lt;-</span> equal error-index,<span class="Constant"> -1</span> <span class="muControl">break-unless</span> error-not-set? - *env<span class="Special"> &lt;- </span>put *env, <span class="Constant">error-index:offset</span>, idx + *env <span class="Special">&lt;-</span> put *env, <span class="Constant">error-index:offset</span>, idx <span class="Delimiter">}</span> ] <span class="Comment"># make sure we render any trace</span> <span class="muRecipe">after</span> <span class="Constant">&lt;render-sandbox-trace-done&gt;</span> [ <span class="Delimiter">{</span> - sandbox-errors:text<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">errors:offset</span> + sandbox-errors:text <span class="Special">&lt;-</span> get *sandbox, <span class="Constant">errors:offset</span> <span class="muControl">break-unless</span> sandbox-errors - *sandbox<span class="Special"> &lt;- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, <span class="Constant">0</span> <span class="Comment"># no response</span> - row, screen<span class="Special"> &lt;- </span>render-text screen, sandbox-errors, left, right, <span class="Constant">1/red</span>, row + *sandbox <span class="Special">&lt;-</span> put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> <span class="Comment"># no response</span> + row, screen <span class="Special">&lt;-</span> render-text screen, sandbox-errors, left, right, <span class="Constant">1/red</span>, row <span class="Comment"># don't try to print anything more for this sandbox</span> <span class="muControl">jump</span> <span class="Constant">+render-sandbox-end</span> <span class="Delimiter">}</span> @@ -153,11 +153,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> get 123:num, foo:offset</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -193,9 +193,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 80</span> <span class="Comment"># create invalid sandbox 1</span> type <span class="Constant">[get foo, x:offset]</span> press F4 @@ -216,9 +216,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 80</span> <span class="Comment"># create invalid sandbox 2</span> type <span class="Constant">[get foo, x:offset]</span> press F4 @@ -242,7 +242,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> assume-console [ press F4 <span class="Comment"># generate error</span> ] @@ -250,7 +250,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color event-loop screen, console, env ] assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">58</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 58</span> press ctrl-k type <span class="Constant">[add 2, 2]</span> <span class="Comment"># valid code</span> press F4 <span class="Comment"># update sandbox</span> @@ -276,13 +276,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[recipe foo x:_elem -&gt; z:_elem [</span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[recipe foo x:_elem -&gt; z:_elem [</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Constant">y:&amp;:num &lt;- copy 0</span> <span class="Constant">z &lt;- add x, y</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo 2]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo 2]</span> assume-console [ press F4 ] @@ -324,12 +324,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># overload a well-known shape-shifting recipe</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[recipe length l:&amp;:list:_elem -&gt; n:num [</span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[recipe length l:&amp;:list:_elem -&gt; n:num [</span> <span class="Constant">]</span>] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - sandbox:text<span class="Special"> &lt;- </span>new <span class="Constant">[x:&amp;:list:num &lt;- copy 0</span> + sandbox:text <span class="Special">&lt;-</span> new <span class="Constant">[x:&amp;:list:num &lt;- copy 0</span> <span class="Constant">to-text x]</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, sandbox + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, sandbox <span class="Comment"># run it once</span> assume-console [ press F4 @@ -384,11 +384,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x &lt;- copy 0</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -410,11 +410,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo \\[</span> <span class="Constant"> x &lt;- copy 0</span> <span class="Constant">]</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -437,13 +437,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:&amp;:point &lt;- new point:type</span> <span class="Constant"> get x:&amp;:point, 1:offset</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -469,14 +469,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:num &lt;- copy 0</span> <span class="Constant"> y:&amp;:point &lt;- new point:type</span> <span class="Constant"> get *y:&amp;:point, x:num</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -504,12 +504,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:num &lt;- copy y:num</span> <span class="Constant">]</span>] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -550,8 +550,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># right editor contains an illegal instruction</span> - sandbox:text<span class="Special"> &lt;- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, sandbox + sandbox:text <span class="Special">&lt;-</span> new <span class="Constant">[get 1234:num, foo:offset]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, sandbox <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -612,8 +612,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># right editor contains an illegal instruction</span> - sandbox:text<span class="Special"> &lt;- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, <span class="Constant">[]</span>, sandbox + sandbox:text <span class="Special">&lt;-</span> new <span class="Constant">[get 1234:num, foo:offset]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, <span class="Constant">[]</span>, sandbox <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 @@ -642,13 +642,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[recipe foo [</span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[recipe foo [</span> <span class="Constant"> {</span> <span class="Constant"> loop</span> <span class="Constant"> }</span> <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 @@ -673,15 +673,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a error</span> - recipes:text<span class="Special"> &lt;- </span>new <span class="Constant">[recipe foo [</span> + recipes:text <span class="Special">&lt;-</span> new <span class="Constant">[recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">a:num &lt;- next-ingredient</span> <span class="Constant">b:num &lt;- next-ingredient</span> <span class="Constant">stash [dividing by]</span>, b -_, c:num<span class="Special"> &lt;- </span>divide-with-remainder a, b +_, c:num <span class="Special">&lt;-</span> divide-with-remainder a, b <span class="muControl">reply</span> b ]] - env:&amp;:environment<span class="Special"> &lt;- </span>new-programming-environment screen, recipes, <span class="Constant">[foo 4, 0]</span> + env:&amp;:environment <span class="Special">&lt;-</span> new-programming-environment screen, recipes, <span class="Constant">[foo 4, 0]</span> <span class="Comment"># run</span> assume-console [ press F4 @@ -701,7 +701,7 @@ _, c:num<span class="Special"> &lt;- </span>divide-with-remainder a, b ] <span class="Comment"># click on the call in the sandbox</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index 0953fed1..56b85dbf 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -98,36 +98,36 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># ctrl-z - undo operation</span> <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - undo?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">26/ctrl-z</span> + undo?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">26/ctrl-z</span> <span class="muControl">break-unless</span> undo? - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> undo - op:&amp;:operation<span class="Special"> &lt;- </span>first undo - undo<span class="Special"> &lt;- </span>rest undo - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">undo:offset</span>, undo - redo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">redo:offset</span> - redo<span class="Special"> &lt;- </span>push op, redo - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">redo:offset</span>, redo + op:&amp;:operation <span class="Special">&lt;-</span> first undo + undo <span class="Special">&lt;-</span> rest undo + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">undo:offset</span>, undo + redo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">redo:offset</span> + redo <span class="Special">&lt;-</span> push op, redo + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">redo:offset</span>, redo <span class="Constant"> &lt;handle-undo&gt;</span> - <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> + <span class="muControl">return</span> screen/same-as-ingredient:0, editor/same-as-ingredient:1, <span class="Constant">1/go-render</span> <span class="Delimiter">}</span> ] <span class="Comment"># ctrl-y - redo operation</span> <span class="muRecipe">after</span> <span class="Constant">&lt;handle-special-character&gt;</span> [ <span class="Delimiter">{</span> - redo?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">25/ctrl-y</span> + redo?:bool <span class="Special">&lt;-</span> equal c, <span class="Constant">25/ctrl-y</span> <span class="muControl">break-unless</span> redo? - redo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">redo:offset</span> + redo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">redo:offset</span> <span class="muControl">break-unless</span> redo - op:&amp;:operation<span class="Special"> &lt;- </span>first redo - redo<span class="Special"> &lt;- </span>rest redo - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">redo:offset</span>, redo - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> - undo<span class="Special"> &lt;- </span>push op, undo - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">undo:offset</span>, undo + op:&amp;:operation <span class="Special">&lt;-</span> first redo + redo <span class="Special">&lt;-</span> rest redo + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">redo:offset</span>, redo + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> + undo <span class="Special">&lt;-</span> push op, undo + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">undo:offset</span>, undo <span class="Constant"> &lt;handle-redo&gt;</span> - <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> + <span class="muControl">return</span> screen/same-as-ingredient:0, editor/same-as-ingredient:1, <span class="Constant">1/go-render</span> <span class="Delimiter">}</span> ] @@ -137,7 +137,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor and type a character</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[0]</span> @@ -174,58 +174,58 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># save operation to undo</span> <span class="muRecipe">after</span> <span class="Constant">&lt;insert-character-begin&gt;</span> [ - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;insert-character-end&gt;</span> [ - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> undo - op:&amp;:operation<span class="Special"> &lt;- </span>first undo - typing:insert-operation, is-insert?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + op:&amp;:operation <span class="Special">&lt;-</span> first undo + typing:insert-operation, is-insert?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - previous-coalesce-tag:num<span class="Special"> &lt;- </span>get typing, <span class="Constant">tag:offset</span> + previous-coalesce-tag:num <span class="Special">&lt;-</span> get typing, <span class="Constant">tag:offset</span> <span class="muControl">break-unless</span> previous-coalesce-tag - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-until:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - typing<span class="Special"> &lt;- </span>put typing, <span class="Constant">insert-until:offset</span>, insert-until - typing<span class="Special"> &lt;- </span>put typing, <span class="Constant">after-row:offset</span>, cursor-row - typing<span class="Special"> &lt;- </span>put typing, <span class="Constant">after-column:offset</span>, cursor-column - typing<span class="Special"> &lt;- </span>put typing, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> &lt;- </span>merge <span class="Constant">0/insert-operation</span>, typing + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + insert-until:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + typing <span class="Special">&lt;-</span> put typing, <span class="Constant">insert-until:offset</span>, insert-until + typing <span class="Special">&lt;-</span> put typing, <span class="Constant">after-row:offset</span>, cursor-row + typing <span class="Special">&lt;-</span> put typing, <span class="Constant">after-column:offset</span>, cursor-column + typing <span class="Special">&lt;-</span> put typing, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special">&lt;-</span> merge <span class="Constant">0/insert-operation</span>, typing <span class="muControl">break</span> <span class="Constant">+done-adding-insert-operation</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - insert-from:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next cursor-before - insert-to:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next insert-from - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> &lt;- </span>merge <span class="Constant">0/insert-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">1/coalesce</span> - editor<span class="Special"> &lt;- </span>add-operation editor, op + insert-from:&amp;:duplex-list:char <span class="Special">&lt;-</span> next cursor-before + insert-to:&amp;:duplex-list:char <span class="Special">&lt;-</span> next insert-from + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + *op <span class="Special">&lt;-</span> merge <span class="Constant">0/insert-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">1/coalesce</span> + editor <span class="Special">&lt;-</span> add-operation editor, op <span class="Constant"> +done-adding-insert-operation</span> ] <span class="Comment"># enter operations never coalesce with typing before or after</span> <span class="muRecipe">after</span> <span class="Constant">&lt;insert-enter-begin&gt;</span> [ - cursor-row-before:num<span class="Special"> &lt;- </span>copy cursor-row - cursor-column-before:num<span class="Special"> &lt;- </span>copy cursor-column - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row-before:num <span class="Special">&lt;-</span> copy cursor-row + cursor-column-before:num <span class="Special">&lt;-</span> copy cursor-column + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;insert-enter-end&gt;</span> [ - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> <span class="Comment"># never coalesce</span> - insert-from:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next cursor-before - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-to:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> &lt;- </span>merge <span class="Constant">0/insert-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">0/never-coalesce</span> - editor<span class="Special"> &lt;- </span>add-operation editor, op + insert-from:&amp;:duplex-list:char <span class="Special">&lt;-</span> next cursor-before + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + insert-to:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + *op <span class="Special">&lt;-</span> merge <span class="Constant">0/insert-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">0/never-coalesce</span> + editor <span class="Special">&lt;-</span> add-operation editor, op ] <span class="Comment"># Everytime you add a new operation to the undo stack, be sure to clear the</span> @@ -235,31 +235,31 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> add-operation editor:&amp;:editor, op:&amp;:operation<span class="muRecipe"> -&gt; </span>editor:&amp;:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> - undo<span class="Special"> &lt;- </span>push op undo - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">undo:offset</span>, undo - redo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">redo:offset</span> - redo<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">redo:offset</span>, redo - <span class="muControl">return</span> editor/same-as-ingredient:<span class="Constant">0</span> + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> + undo <span class="Special">&lt;-</span> push op undo + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">undo:offset</span>, undo + redo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">redo:offset</span> + redo <span class="Special">&lt;-</span> copy<span class="Constant"> 0</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">redo:offset</span>, redo + <span class="muControl">return</span> editor/same-as-ingredient:0 ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-undo&gt;</span> [ <span class="Delimiter">{</span> - typing:insert-operation, is-insert?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + typing:insert-operation, is-insert?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - start:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get typing, <span class="Constant">insert-from:offset</span> - end:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get typing, <span class="Constant">insert-until:offset</span> + start:&amp;:duplex-list:char <span class="Special">&lt;-</span> get typing, <span class="Constant">insert-from:offset</span> + end:&amp;:duplex-list:char <span class="Special">&lt;-</span> get typing, <span class="Constant">insert-until:offset</span> <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>prev start - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> prev start + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor remove-between before-cursor, end - cursor-row<span class="Special"> &lt;- </span>get typing, <span class="Constant">before-row:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>get typing, <span class="Constant">before-column:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get typing, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special">&lt;-</span> get typing, <span class="Constant">before-row:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> get typing, <span class="Constant">before-column:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get typing, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -267,7 +267,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor and type multiple characters</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[012]</span> @@ -293,7 +293,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># type some characters</span> assume-console [ @@ -339,11 +339,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[ abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[ abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># new line</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 8</span> press enter ] editor-event-loop screen, console, e @@ -355,11 +355,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] <span class="Comment"># line is indented</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] <span class="Comment"># undo</span> assume-console [ @@ -368,11 +368,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">5</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 5</span> ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -402,7 +402,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[012]</span> @@ -446,19 +446,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;handle-redo&gt;</span> [ <span class="Delimiter">{</span> - typing:insert-operation, is-insert?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + typing:insert-operation, is-insert?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - before-cursor<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-from:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> + before-cursor <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + insert-from:&amp;:duplex-list:char <span class="Special">&lt;-</span> get typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> <span class="Comment"># assert insert-to matches next(before-cursor)</span> insert-range before-cursor, insert-from <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> &lt;- </span>get typing, <span class="Constant">after-row:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>get typing, <span class="Constant">after-column:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get typing, <span class="Constant">after-top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special">&lt;-</span> get typing, <span class="Constant">after-row:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> get typing, <span class="Constant">after-column:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get typing, <span class="Constant">after-top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -466,7 +466,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[012]</span> @@ -512,10 +512,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text, do some work, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[1]</span> @@ -555,7 +555,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ @@ -575,11 +575,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">7</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 7</span> ] <span class="Comment"># undo</span> assume-console [ @@ -589,11 +589,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># typing in second line deleted, but not indent</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -610,11 +610,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">8</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 8</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -630,11 +630,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># empty screen</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -650,11 +650,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">8</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 8</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -670,11 +670,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># newline and indent inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -691,11 +691,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">7</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 7</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -712,14 +712,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> ] editor-event-loop screen, console, e <span class="Comment"># undo</span> @@ -730,11 +730,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># click undone</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -753,49 +753,49 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;move-cursor-begin&gt;</span> [ - cursor-row-before:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column-before:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row-before:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column-before:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;move-cursor-end&gt;</span> [ - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> undo-coalesce-tag <span class="Comment"># if previous operation was also a move, and also had the same coalesce</span> <span class="Comment"># tag, coalesce with it</span> - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> undo - op:&amp;:operation<span class="Special"> &lt;- </span>first undo - move:move-operation, is-move?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">move:variant</span> + op:&amp;:operation <span class="Special">&lt;-</span> first undo + move:move-operation, is-move?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? - previous-coalesce-tag:num<span class="Special"> &lt;- </span>get move, <span class="Constant">tag:offset</span> - coalesce?:bool<span class="Special"> &lt;- </span>equal undo-coalesce-tag, previous-coalesce-tag + previous-coalesce-tag:num <span class="Special">&lt;-</span> get move, <span class="Constant">tag:offset</span> + coalesce?:bool <span class="Special">&lt;-</span> equal undo-coalesce-tag, previous-coalesce-tag <span class="muControl">break-unless</span> coalesce? - move<span class="Special"> &lt;- </span>put move, <span class="Constant">after-row:offset</span>, cursor-row - move<span class="Special"> &lt;- </span>put move, <span class="Constant">after-column:offset</span>, cursor-column - move<span class="Special"> &lt;- </span>put move, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> &lt;- </span>merge <span class="Constant">1/move-operation</span>, move + move <span class="Special">&lt;-</span> put move, <span class="Constant">after-row:offset</span>, cursor-row + move <span class="Special">&lt;-</span> put move, <span class="Constant">after-column:offset</span>, cursor-column + move <span class="Special">&lt;-</span> put move, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special">&lt;-</span> merge <span class="Constant">1/move-operation</span>, move <span class="muControl">break</span> <span class="Constant">+done-adding-move-operation</span> <span class="Delimiter">}</span> - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> &lt;- </span>merge <span class="Constant">1/move-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag - editor<span class="Special"> &lt;- </span>add-operation editor, op + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + *op <span class="Special">&lt;-</span> merge <span class="Constant">1/move-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag + editor <span class="Special">&lt;-</span> add-operation editor, op <span class="Constant"> +done-adding-move-operation</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-undo&gt;</span> [ <span class="Delimiter">{</span> - move:move-operation, is-move?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">move:variant</span> + move:move-operation, is-move?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> &lt;- </span>get move, <span class="Constant">before-row:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>get move, <span class="Constant">before-column:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get move, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special">&lt;-</span> get move, <span class="Constant">before-row:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> get move, <span class="Constant">before-column:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get move, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -804,18 +804,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 3</span> press right-arrow ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> <span class="Comment"># screen scrolls</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -824,8 +824,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .gh .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] <span class="Comment"># undo</span> assume-console [ @@ -835,11 +835,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moved back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] <span class="Comment"># scroll undone</span> screen-should-contain [ @@ -867,14 +867,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> press left-arrow ] editor-event-loop screen, console, e @@ -886,11 +886,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -912,22 +912,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> press up-arrow ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo</span> assume-console [ @@ -937,11 +937,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -963,14 +963,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press down-arrow ] editor-event-loop screen, console, e @@ -982,11 +982,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1008,13 +1008,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page</span> assume-console [ @@ -1042,13 +1042,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page</span> assume-console [ @@ -1076,13 +1076,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page down and up</span> assume-console [ @@ -1111,13 +1111,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[a</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page down and up</span> assume-console [ @@ -1146,14 +1146,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-a ] editor-event-loop screen, console, e @@ -1165,11 +1165,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1191,14 +1191,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press home ] editor-event-loop screen, console, e @@ -1210,11 +1210,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1236,14 +1236,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-e ] editor-event-loop screen, console, e @@ -1255,11 +1255,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1281,14 +1281,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press end ] editor-event-loop screen, console, e @@ -1300,11 +1300,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1326,24 +1326,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press right-arrow press right-arrow press up-arrow ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1353,11 +1353,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># up-arrow is undone</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] <span class="Comment"># undo again</span> assume-console [ @@ -1367,11 +1367,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># both right-arrows are undone</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] ] @@ -1381,13 +1381,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text, click on a character, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> press ctrl-z ] editor-event-loop screen, console, e @@ -1399,11 +1399,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves to left-click</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1423,15 +1423,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant">&lt;handle-redo&gt;</span> [ <span class="Delimiter">{</span> - move:move-operation, is-move?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">move:variant</span> + move:move-operation, is-move?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> &lt;- </span>get move, <span class="Constant">after-row:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>get move, <span class="Constant">after-column:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get move, <span class="Constant">after-top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special">&lt;-</span> get move, <span class="Constant">after-row:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> get move, <span class="Constant">after-column:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get move, <span class="Constant">after-top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -1439,16 +1439,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type some text, move the cursor, type some more text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[abc]</span> - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> type <span class="Constant">[d]</span> ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .adbc .</span> @@ -1456,8 +1456,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1465,8 +1465,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># last letter typed is deleted</span> screen-should-contain [ @@ -1476,8 +1476,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo again</span> assume-console [ @@ -1485,8 +1485,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to screen; cursor moves</span> screen-should-contain [ @@ -1496,8 +1496,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] <span class="Comment"># undo again</span> assume-console [ @@ -1505,8 +1505,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen empty</span> screen-should-contain [ @@ -1516,8 +1516,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] <span class="Comment"># redo</span> assume-console [ @@ -1525,8 +1525,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># first insert</span> screen-should-contain [ @@ -1536,8 +1536,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] <span class="Comment"># redo again</span> assume-console [ @@ -1545,8 +1545,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves</span> screen-should-contain [ @@ -1557,8 +1557,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor moves</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># redo again</span> assume-console [ @@ -1566,8 +1566,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># second insert</span> screen-should-contain [ @@ -1577,8 +1577,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] ] @@ -1588,7 +1588,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit backspace</span> assume-console [ @@ -1603,11 +1603,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1616,11 +1616,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 3</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1635,11 +1635,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1651,79 +1651,79 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># save operation to undo</span> <span class="muRecipe">after</span> <span class="Constant">&lt;backspace-character-begin&gt;</span> [ - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;backspace-character-end&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> backspaced-cell <span class="Comment"># backspace failed; don't add an undo operation</span> - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> undo - op:&amp;:operation<span class="Special"> &lt;- </span>first undo - deletion:delete-operation, is-delete?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + op:&amp;:operation <span class="Special">&lt;-</span> first undo + deletion:delete-operation, is-delete?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - previous-coalesce-tag:num<span class="Special"> &lt;- </span>get deletion, <span class="Constant">tag:offset</span> - coalesce?:bool<span class="Special"> &lt;- </span>equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> + previous-coalesce-tag:num <span class="Special">&lt;-</span> get deletion, <span class="Constant">tag:offset</span> + coalesce?:bool <span class="Special">&lt;-</span> equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> <span class="muControl">break-unless</span> coalesce? - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">delete-from:offset</span>, before-cursor - backspaced-so-far:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">deleted-text:offset</span> + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">delete-from:offset</span>, before-cursor + backspaced-so-far:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">deleted-text:offset</span> insert-range backspaced-cell, backspaced-so-far - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">deleted-text:offset</span>, backspaced-cell - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">after-row:offset</span>, cursor-row - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">after-column:offset</span>, cursor-column - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> &lt;- </span>merge <span class="Constant">2/delete-operation</span>, deletion + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">deleted-text:offset</span>, backspaced-cell + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">after-row:offset</span>, cursor-row + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">after-column:offset</span>, cursor-column + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special">&lt;-</span> merge <span class="Constant">2/delete-operation</span>, deletion <span class="muControl">break</span> <span class="Constant">+done-adding-backspace-operation</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - deleted-until:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - *op<span class="Special"> &lt;- </span>merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">1/coalesce-backspace</span> - editor<span class="Special"> &lt;- </span>add-operation editor, op + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + deleted-until:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + *op <span class="Special">&lt;-</span> merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">1/coalesce-backspace</span> + editor <span class="Special">&lt;-</span> add-operation editor, op <span class="Constant"> +done-adding-backspace-operation</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-undo&gt;</span> [ <span class="Delimiter">{</span> - deletion:delete-operation, is-delete?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + deletion:delete-operation, is-delete?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - anchor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">delete-from:offset</span> + anchor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">delete-from:offset</span> <span class="muControl">break-unless</span> anchor - deleted:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">deleted-text:offset</span> - old-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>last deleted + deleted:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">deleted-text:offset</span> + old-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> last deleted insert-range anchor, deleted <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - before-cursor<span class="Special"> &lt;- </span>copy old-cursor - cursor-row<span class="Special"> &lt;- </span>get deletion, <span class="Constant">before-row:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>get deletion, <span class="Constant">before-column:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + before-cursor <span class="Special">&lt;-</span> copy old-cursor + cursor-row <span class="Special">&lt;-</span> get deletion, <span class="Constant">before-row:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> get deletion, <span class="Constant">before-column:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant">&lt;handle-redo&gt;</span> [ <span class="Delimiter">{</span> - deletion:delete-operation, is-delete?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + deletion:delete-operation, is-delete?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - start:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">delete-from:offset</span> - end:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">delete-until:offset</span> - data:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span> + start:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">delete-from:offset</span> + end:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">delete-until:offset</span> + data:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">data:offset</span> remove-between start, end <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> &lt;- </span>get deletion, <span class="Constant">after-row:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> &lt;- </span>get deletion, <span class="Constant">after-column:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> &lt;- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special">&lt;-</span> get deletion, <span class="Constant">after-row:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special">&lt;-</span> get deletion, <span class="Constant">after-column:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special">&lt;-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -1733,12 +1733,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ type <span class="Constant">[abcdef]</span> - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press delete press backspace press delete @@ -1751,11 +1751,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo deletes</span> assume-console [ @@ -1764,11 +1764,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1783,11 +1783,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1802,11 +1802,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1822,11 +1822,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1842,11 +1842,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1862,11 +1862,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1877,41 +1877,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;delete-character-begin&gt;</span> [ - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;delete-character-end&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cell <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - undo:&amp;:list:&amp;:operation<span class="Special"> &lt;- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + undo:&amp;:list:&amp;:operation <span class="Special">&lt;-</span> get *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> undo - op:&amp;:operation<span class="Special"> &lt;- </span>first undo - deletion:delete-operation, is-delete?:bool<span class="Special"> &lt;- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + op:&amp;:operation <span class="Special">&lt;-</span> first undo + deletion:delete-operation, is-delete?:bool <span class="Special">&lt;-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - previous-coalesce-tag:num<span class="Special"> &lt;- </span>get deletion, <span class="Constant">tag:offset</span> - coalesce?:bool<span class="Special"> &lt;- </span>equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> + previous-coalesce-tag:num <span class="Special">&lt;-</span> get deletion, <span class="Constant">tag:offset</span> + coalesce?:bool <span class="Special">&lt;-</span> equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> <span class="muControl">break-unless</span> coalesce? - delete-until:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">delete-until:offset</span>, delete-until - deleted-so-far:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get deletion, <span class="Constant">deleted-text:offset</span> - deleted-so-far<span class="Special"> &lt;- </span>append deleted-so-far, deleted-cell - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">deleted-text:offset</span>, deleted-so-far - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">after-row:offset</span>, cursor-row - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">after-column:offset</span>, cursor-column - deletion<span class="Special"> &lt;- </span>put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> &lt;- </span>merge <span class="Constant">2/delete-operation</span>, deletion + delete-until:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">delete-until:offset</span>, delete-until + deleted-so-far:&amp;:duplex-list:char <span class="Special">&lt;-</span> get deletion, <span class="Constant">deleted-text:offset</span> + deleted-so-far <span class="Special">&lt;-</span> append deleted-so-far, deleted-cell + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">deleted-text:offset</span>, deleted-so-far + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">after-row:offset</span>, cursor-row + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">after-column:offset</span>, cursor-column + deletion <span class="Special">&lt;-</span> put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special">&lt;-</span> merge <span class="Constant">2/delete-operation</span>, deletion <span class="muControl">break</span> <span class="Constant">+done-adding-delete-operation</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - deleted-until:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - *op<span class="Special"> &lt;- </span>merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">2/coalesce-delete</span> - editor<span class="Special"> &lt;- </span>add-operation editor, op + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + deleted-until:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + *op <span class="Special">&lt;-</span> merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">2/coalesce-delete</span> + editor <span class="Special">&lt;-</span> add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> <span class="Delimiter">}</span> ] @@ -1922,13 +1922,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press ctrl-k ] editor-event-loop screen, console, e @@ -1939,11 +1939,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1959,11 +1959,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># redo</span> assume-console [ @@ -1980,11 +1980,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -2003,18 +2003,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;delete-to-end-of-line-begin&gt;</span> [ - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;delete-to-end-of-line-end&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cells <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - deleted-until:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> &lt;- </span>merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> - editor<span class="Special"> &lt;- </span>add-operation editor, op + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + deleted-until:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + *op <span class="Special">&lt;-</span> merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> + editor <span class="Special">&lt;-</span> add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> <span class="Delimiter">}</span> ] @@ -2025,13 +2025,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special">&lt;-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press ctrl-u ] editor-event-loop screen, console, e @@ -2042,11 +2042,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] <span class="Comment"># undo</span> assume-console [ @@ -2062,11 +2062,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 2</span> ] <span class="Comment"># redo</span> assume-console [ @@ -2083,11 +2083,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw &lt;- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special">&lt;-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special">&lt;-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special">&lt;-</span><span class="Constant"> 0</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -2106,19 +2106,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant">&lt;delete-to-start-of-line-begin&gt;</span> [ - top-before:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant">&lt;delete-to-start-of-line-end&gt;</span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cells <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - op:&amp;:operation<span class="Special"> &lt;- </span>new <span class="Constant">operation:type</span> - before-cursor:&amp;:duplex-list:char<span class="Special"> &lt;- </span>get *editor, <span class="Constant">before-cursor:offset</span> - deleted-until:&amp;:duplex-list:char<span class="Special"> &lt;- </span>next before-cursor - cursor-row:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> &lt;- </span>get *editor, <span class="Constant">cursor-column:offset</span> - *op<span class="Special"> &lt;- </span>merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> - editor<span class="Special"> &lt;- </span>add-operation editor, op + top-after:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + op:&amp;:operation <span class="Special">&lt;-</span> new <span class="Constant">operation:type</span> + before-cursor:&amp;:duplex-list:char <span class="Special">&lt;-</span> get *editor, <span class="Constant">before-cursor:offset</span> + deleted-until:&amp;:duplex-list:char <span class="Special">&lt;-</span> next before-cursor + cursor-row:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special">&lt;-</span> get *editor, <span class="Constant">cursor-column:offset</span> + *op <span class="Special">&lt;-</span> merge <span class="Constant">2/delete-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> + editor <span class="Special">&lt;-</span> add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> <span class="Delimiter">}</span> ] @@ -2127,7 +2127,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&amp;:editor<span class="Special"> &lt;- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&amp;:editor <span class="Special">&lt;-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [