about summary refs log tree commit diff stats
path: root/html/edit/001-editor.mu.html
diff options
context:
space:
mode:
Diffstat (limited to 'html/edit/001-editor.mu.html')
-rw-r--r--html/edit/001-editor.mu.html100
1 files changed, 40 insertions, 60 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html
index be568c9d..916e93c6 100644
--- a/html/edit/001-editor.mu.html
+++ b/html/edit/001-editor.mu.html
@@ -13,15 +13,15 @@
 pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
 body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 * { font-size: 1.05em; }
+.muControl { color: #c0a020; }
 .muRecipe { color: #ff8700; }
+.muScenario { color: #00af00; }
 .muData { color: #ffff00; }
 .Special { color: #ff6060; }
-.muScenario { color: #00af00; }
 .Comment { color: #9090ff; }
 .Constant { color: #00a0a0; }
 .SalientComment { color: #00ffff; }
 .Delimiter { color: #a04060; }
-.muControl { color: #c0a020; }
 -->
 </style>
 
@@ -37,9 +37,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 
 <span class="Comment"># temporary main for this layer: just render the given string at the given</span>
 <span class="Comment"># screen dimensions, then stop</span>
-<span class="muRecipe">recipe!</span> main [
+<span class="muRecipe">recipe!</span> main text:address:array:character [
   <span class="Constant">local-scope</span>
-  text:address:array:character<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   open-console
   hide-screen <span class="Constant">0/screen</span>
   new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
@@ -52,7 +52,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span>
   run [
     <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc]</span>
-    new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">10/right</span>
+    new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span>
   ]
   screen-should-contain [
     <span class="Comment"># top line of screen reserved for menu</span>
@@ -79,19 +79,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   cursor-column:number
 ]
 
-<span class="Comment"># editor:address, screen &lt;- new-editor s:address:array:character, screen:address, left:number, right:number</span>
-<span class="Comment"># creates a new editor widget and renders its initial appearance to screen.</span>
-<span class="Comment">#   top/left/right constrain the screen area available to the new editor.</span>
-<span class="Comment">#   right is exclusive.</span>
-<span class="muRecipe">recipe</span> new-editor [
+<span class="Comment"># creates a new editor widget and renders its initial appearance to screen</span>
+<span class="Comment">#   top/left/right constrain the screen area available to the new editor</span>
+<span class="Comment">#   right is exclusive</span>
+<span class="muRecipe">recipe</span> new-editor s:address:array:character, screen:address:screen, left:number, right:number<span class="muRecipe"> -&gt; </span>result:address:editor-data [
   <span class="Constant">local-scope</span>
-  s:address:array:character<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   <span class="Comment"># no clipping of bounds</span>
-  left:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  right:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
   right<span class="Special"> &lt;- </span>subtract right, <span class="Constant">1</span>
-  result:address:editor-data<span class="Special"> &lt;- </span>new <span class="Constant">editor-data:type</span>
+  result<span class="Special"> &lt;- </span>new <span class="Constant">editor-data:type</span>
   <span class="Comment"># initialize screen-related fields</span>
   x:address:number<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">left:offset</span>
   *x<span class="Special"> &lt;- </span>copy left
@@ -102,11 +98,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   *x<span class="Special"> &lt;- </span>copy <span class="Constant">1/top</span>
   x<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">cursor-column:offset</span>
   *x<span class="Special"> &lt;- </span>copy left
-  init:address:address:duplex-list<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">data:offset</span>
+  init:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">data:offset</span>
   *init<span class="Special"> &lt;- </span>push-duplex <span class="Constant">167/§</span>, <span class="Constant">0/tail</span>
-  top-of-screen:address:address:duplex-list<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">top-of-screen:offset</span>
+  top-of-screen:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">top-of-screen:offset</span>
   *top-of-screen<span class="Special"> &lt;- </span>copy *init
-  y:address:address:duplex-list<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">before-cursor:offset</span>
+  y:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">before-cursor:offset</span>
   *y<span class="Special"> &lt;- </span>copy *init
   result<span class="Special"> &lt;- </span>insert-text result, s
   <span class="Comment"># initialize cursor to top of screen</span>
@@ -115,20 +111,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   <span class="Comment"># initial render to screen, just for some old tests</span>
   _, _, screen, result<span class="Special"> &lt;- </span>render screen, result
 <span class="Constant">  &lt;editor-initialization&gt;</span>
-  <span class="muControl">reply</span> result
 ]
 
-<span class="muRecipe">recipe</span> insert-text [
+<span class="muRecipe">recipe</span> insert-text editor:address:editor-data, text:address:array:character<span class="muRecipe"> -&gt; </span>editor:address:editor-data [
   <span class="Constant">local-scope</span>
-  editor:address:editor-data<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  text:address:array:character<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   <span class="Comment"># early exit if text is empty</span>
   <span class="muControl">reply-unless</span> text, editor/same-as-ingredient:<span class="Constant">0</span>
   len:number<span class="Special"> &lt;- </span>length *text
   <span class="muControl">reply-unless</span> len, editor/same-as-ingredient:<span class="Constant">0</span>
   idx:number<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:address:duplex-list<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span>
+  curr:address:duplex-list:character<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span>
   <span class="Delimiter">{</span>
     done?:boolean<span class="Special"> &lt;- </span>greater-or-equal idx, len
     <span class="muControl">break-if</span> done?
@@ -145,7 +139,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 <span class="muScenario">scenario</span> editor-initializes-without-data [
   assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span>
   run [
-    <span class="Constant">1</span>:address:editor-data<span class="Special"> &lt;- </span>new-editor <span class="Constant">0/data</span>, screen:address, <span class="Constant">2/left</span>, <span class="Constant">5/right</span>
+    <span class="Constant">1</span>:address:editor-data<span class="Special"> &lt;- </span>new-editor <span class="Constant">0/data</span>, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span>
     <span class="Constant">2</span>:editor-data<span class="Special"> &lt;- </span>copy *<span class="Constant">1</span>:address:editor-data
   ]
   memory-should-contain [
@@ -165,22 +159,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   ]
 ]
 
-<span class="Comment"># last-row:number, last-column:number, screen, editor &lt;- render screen:address, editor:address:editor-data</span>
-<span class="Comment">#</span>
 <span class="Comment"># Assumes cursor should be at coordinates (cursor-row, cursor-column) and</span>
 <span class="Comment"># updates before-cursor to match. Might also move coordinates if they're</span>
 <span class="Comment"># outside text.</span>
-<span class="muRecipe">recipe</span> render [
+<span class="muRecipe">recipe</span> render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -&gt; </span>last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [
   <span class="Constant">local-scope</span>
-  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  editor:address:editor-data<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   <span class="muControl">reply-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:number<span class="Special"> &lt;- </span>get *editor, <span class="Constant">left:offset</span>
   screen-height:number<span class="Special"> &lt;- </span>screen-height screen
   right:number<span class="Special"> &lt;- </span>get *editor, <span class="Constant">right:offset</span>
   <span class="Comment"># traversing editor</span>
-  curr:address:duplex-list<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span>
-  prev:address:duplex-list<span class="Special"> &lt;- </span>copy curr  <span class="Comment"># just in case curr becomes null and we can't compute prev-duplex</span>
+  curr:address:duplex-list:character<span class="Special"> &lt;- </span>get *editor, <span class="Constant">top-of-screen:offset</span>
+  prev:address:duplex-list:character<span class="Special"> &lt;- </span>copy curr  <span class="Comment"># just in case curr becomes null and we can't compute prev-duplex</span>
   curr<span class="Special"> &lt;- </span>next-duplex curr
   <span class="Comment"># traversing screen</span>
 <span class="Constant">  +render-loop-initialization</span>
@@ -189,7 +180,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   column:number<span class="Special"> &lt;- </span>copy left
   cursor-row:address:number<span class="Special"> &lt;- </span>get-address *editor, <span class="Constant">cursor-row:offset</span>
   cursor-column:address:number<span class="Special"> &lt;- </span>get-address *editor, <span class="Constant">cursor-column:offset</span>
-  before-cursor:address:address:duplex-list<span class="Special"> &lt;- </span>get-address *editor, <span class="Constant">before-cursor:offset</span>
+  before-cursor:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *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>
@@ -251,7 +242,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     <span class="muControl">loop</span>
   <span class="Delimiter">}</span>
   <span class="Comment"># save first character off-screen</span>
-  bottom-of-screen:address:address:duplex-list<span class="Special"> &lt;- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</span>
+  bottom-of-screen:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</span>
   *bottom-of-screen<span class="Special"> &lt;- </span>copy curr
   <span class="Comment"># is cursor to the right of the last line? move to end</span>
   <span class="Delimiter">{</span>
@@ -268,11 +259,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   <span class="muControl">reply</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>
 ]
 
-<span class="muRecipe">recipe</span> clear-line-delimited [
+<span class="muRecipe">recipe</span> clear-line-delimited screen:address:screen, column:number, right:number [
   <span class="Constant">local-scope</span>
-  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  column:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  right:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   <span class="Delimiter">{</span>
     done?:boolean<span class="Special"> &lt;- </span>greater-than column, right
     <span class="muControl">break-if</span> done?
@@ -282,13 +271,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   <span class="Delimiter">}</span>
 ]
 
-<span class="muRecipe">recipe</span> clear-screen-from [
+<span class="muRecipe">recipe</span> clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number<span class="muRecipe"> -&gt; </span>screen:address:screen [
   <span class="Constant">local-scope</span>
-  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  row:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  column:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  left:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  right:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   <span class="Comment"># if it's the real screen, use the optimized primitive</span>
   <span class="Delimiter">{</span>
     <span class="muControl">break-if</span> screen
@@ -302,12 +287,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>
 ]
 
-<span class="muRecipe">recipe</span> clear-rest-of-screen [
+<span class="muRecipe">recipe</span> clear-rest-of-screen screen:address:screen, row:number, left:number, right:number [
   <span class="Constant">local-scope</span>
-  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  row:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  left:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  right:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</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-height:number<span class="Special"> &lt;- </span>screen-height screen
@@ -326,7 +308,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   run [
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span>
 <span class="Constant">def]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
   ]
   screen-should-contain [
    <span class="Constant"> .     .</span>
@@ -340,7 +322,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span>
   run [
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">1/left</span>, <span class="Constant">5/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span>
   ]
   screen-should-contain [
    <span class="Constant"> .     .</span>
@@ -354,7 +336,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   run [
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span>
 <span class="Constant">def]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">1/left</span>, <span class="Constant">5/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span>
   ]
   screen-should-contain [
    <span class="Constant"> .     .</span>
@@ -368,7 +350,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span>
   run [
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc def]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
   ]
   screen-should-contain [
    <span class="Constant"> .     .</span>
@@ -388,7 +370,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span>
   run [
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abcde]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
   ]
   <span class="Comment"># still wrap, even though the line would fit. We need room to click on the</span>
   <span class="Comment"># end of the line</span>
@@ -410,7 +392,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span>
   run [
     <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
-    <span class="Constant">2</span>:address:editor-data<span class="Special"> &lt;- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
+    <span class="Constant">2</span>:address:editor-data<span class="Special"> &lt;- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
     <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span>
     <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span>
   ]
@@ -433,7 +415,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span>
 <span class="Constant"># de</span>
 <span class="Constant">f]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span>
   ]
   screen-should-contain [
    <span class="Constant"> .     .</span>
@@ -462,12 +444,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   color<span class="Special"> &lt;- </span>get-color color, c
 ]
 
-<span class="Comment"># color &lt;- get-color color:number, c:character</span>
 <span class="Comment"># so far the previous color is all the information we need; that may change</span>
-<span class="muRecipe">recipe</span> get-color [
+<span class="muRecipe">recipe</span> get-color color:number, c:character<span class="muRecipe"> -&gt; </span>color:number [
   <span class="Constant">local-scope</span>
-  color:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
-  c:character<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
+  <span class="Constant">load-ingredients</span>
   color-is-white?:boolean<span class="Special"> &lt;- </span>equal color, <span class="Constant">7/white</span>
   <span class="Comment"># if color is white and next character is '#', switch color to blue</span>
   <span class="Delimiter">{</span>
@@ -516,7 +496,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     s:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc</span>
 <span class="Constant">d &lt;- e</span>
 <span class="Constant">f]</span>
-    new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">8/right</span>
+    new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span>
   ]
   screen-should-contain [
    <span class="Constant"> .        .</span>