diff options
Diffstat (limited to 'html/edit')
-rw-r--r-- | html/edit/001-editor.mu.html | 136 | ||||
-rw-r--r-- | html/edit/002-typing.mu.html | 416 | ||||
-rw-r--r-- | html/edit/003-shortcuts.mu.html | 1006 | ||||
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 270 | ||||
-rw-r--r-- | html/edit/005-sandbox.mu.html | 394 | ||||
-rw-r--r-- | html/edit/006-sandbox-copy.mu.html | 80 | ||||
-rw-r--r-- | html/edit/007-sandbox-delete.mu.html | 78 | ||||
-rw-r--r-- | html/edit/008-sandbox-edit.mu.html | 64 | ||||
-rw-r--r-- | html/edit/009-sandbox-test.mu.html | 56 | ||||
-rw-r--r-- | html/edit/010-sandbox-trace.mu.html | 74 | ||||
-rw-r--r-- | html/edit/011-errors.mu.html | 186 | ||||
-rw-r--r-- | html/edit/012-editor-undo.mu.html | 782 |
12 files changed, 1771 insertions, 1771 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 8eec4b3f..b61e405d 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -52,7 +52,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> run [ <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -64,26 +64,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muData">container</span> editor-data [ <span class="Comment"># editable text: doubly linked list of characters (head contains a special sentinel)</span> - data:address:duplex-list:character - top-of-screen:address:duplex-list:character - bottom-of-screen:address:duplex-list:character + data:&:duplex-list:char + top-of-screen:&:duplex-list:char + bottom-of-screen:&:duplex-list:char <span class="Comment"># location before cursor inside data</span> - before-cursor:address:duplex-list:character + before-cursor:&:duplex-list:char <span class="Comment"># raw bounds of display area on screen</span> <span class="Comment"># always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen</span> - left:number - right:number - bottom:number + left:num + right:num + bottom:num <span class="Comment"># raw screen coordinates of cursor</span> - cursor-row:number - cursor-column:number + cursor-row:num + cursor-column:num ] <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">def</span> new-editor s:text, screen:address:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:editor-data, screen:address:screen [ +<span class="muRecipe">def</span> new-editor s:text, screen:&:screen, left:num, right:num<span class="muRecipe"> -> </span>result:&:editor-data, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> @@ -96,7 +96,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *result<span class="Special"> <- </span>put *result, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1/top</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">cursor-column:offset</span>, left <span class="Comment"># initialize empty contents</span> - init:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> + init:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">data:offset</span>, init *result<span class="Special"> <- </span>put *result, <span class="Constant">top-of-screen:offset</span>, init *result<span class="Special"> <- </span>put *result, <span class="Constant">before-cursor:offset</span>, init @@ -106,20 +106,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <editor-initialization></span> ] -<span class="muRecipe">def</span> insert-text editor:address:editor-data, text:text<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> insert-text editor:&:editor-data, text:text<span class="muRecipe"> -> </span>editor:&:editor-data [ <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:number<span class="Special"> <- </span>length *text + len:num<span class="Special"> <- </span>length *text <span class="muControl">return-unless</span> len, editor/same-as-ingredient:<span class="Constant">0</span> - idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + idx:num<span class="Special"> <- </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:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal idx, len + done?:bool<span class="Special"> <- </span>greater-or-equal idx, len <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>index *text, idx + c:char<span class="Special"> <- </span>index *text, idx insert c, curr <span class="Comment"># next iter</span> curr<span class="Special"> <- </span>next curr @@ -132,8 +132,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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"> <- </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"> <- </span>copy *<span class="Constant">1</span>:address:editor-data + <span class="Constant">1</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:editor-data<span class="Special"> <- </span>copy *<span class="Constant">1</span>:&:editor-data ] memory-should-contain [ <span class="Comment"># 2 (data) <- just the § sentinel</span> @@ -156,52 +156,52 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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">def</span> render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +<span class="muRecipe">def</span> render screen:&:screen, editor:&:editor-data<span class="muRecipe"> -> </span>last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ <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:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - screen-height:number<span class="Special"> <- </span>screen-height screen - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + screen-height:num<span class="Special"> <- </span>screen-height screen + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> <span class="Comment"># traversing editor</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> curr<span class="Special"> <- </span>next curr <span class="Comment"># traversing screen</span> <span class="Constant"> +render-loop-initialization</span> - color:number<span class="Special"> <- </span>copy <span class="Constant">7/white</span> - row:number<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:number<span class="Special"> <- </span>copy left - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + color:num<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> + column:num<span class="Special"> <- </span>copy left + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> screen<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># update editor-data.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?:boolean<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - at-cursor?:boolean<span class="Special"> <- </span>equal column, cursor-column + at-cursor?:bool<span class="Special"> <- </span>equal column, cursor-column <span class="muControl">break-unless</span> at-cursor? before-cursor<span class="Special"> <- </span>copy prev <span class="Delimiter">}</span> - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> <span class="Constant"> <character-c-received></span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - left-of-cursor?:boolean<span class="Special"> <- </span>lesser-than column, cursor-column + left-of-cursor?:bool<span class="Special"> <- </span>lesser-than column, cursor-column <span class="muControl">break-unless</span> left-of-cursor? cursor-column<span class="Special"> <- </span>copy column before-cursor<span class="Special"> <- </span>prev curr @@ -219,10 +219,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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?:boolean<span class="Special"> <- </span>equal column, right + at-right?:bool<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char<span class="Special"> <- </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"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -240,11 +240,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *editor<span class="Special"> <- </span>put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> - at-cursor-row?:boolean<span class="Special"> <- </span>equal row, cursor-row - cursor-outside-line?:boolean<span class="Special"> <- </span>lesser-or-equal column, cursor-column - before-cursor-on-same-line?:boolean<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? - above-cursor-row?:boolean<span class="Special"> <- </span>lesser-than row, cursor-row - before-cursor?:boolean<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + cursor-outside-line?:bool<span class="Special"> <- </span>lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool<span class="Special"> <- </span>lesser-than row, cursor-row + before-cursor?:bool<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? <span class="muControl">break-unless</span> before-cursor? cursor-row<span class="Special"> <- </span>copy row cursor-column<span class="Special"> <- </span>copy column @@ -257,7 +257,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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> ] -<span class="muRecipe">def</span> clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if it's the real screen, use the optimized primitive</span> @@ -273,14 +273,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">def</span> clear-rest-of-screen screen:address:screen, row:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> clear-rest-of-screen screen:&:screen, row:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> screen<span class="Special"> <- </span>move-cursor screen, row, left - screen-height:number<span class="Special"> <- </span>screen-height screen + screen-height:num<span class="Special"> <- </span>screen-height screen <span class="Delimiter">{</span> - at-bottom-of-screen?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height + at-bottom-of-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> at-bottom-of-screen? screen<span class="Special"> <- </span>move-cursor screen, row, left clear-line-until screen, right @@ -294,7 +294,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -308,7 +308,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor s:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -322,7 +322,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -336,7 +336,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -356,7 +356,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:&: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> @@ -378,9 +378,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -401,7 +401,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant"># de</span> <span class="Constant">f]</span> - new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -431,14 +431,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># so far the previous color is all the information we need; that may change</span> -<span class="muRecipe">def</span> get-color color:number, c:character<span class="muRecipe"> -> </span>color:number [ +<span class="muRecipe">def</span> get-color color:num, c:char<span class="muRecipe"> -> </span>color:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - color-is-white?:boolean<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> + color-is-white?:bool<span class="Special"> <- </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> <span class="muControl">break-unless</span> color-is-white? - starting-comment?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">35/#</span> + starting-comment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">35/#</span> <span class="muControl">break-unless</span> starting-comment? trace <span class="Constant">90</span>, <span class="Constant">[app]</span>, <span class="Constant">[switch color back to blue]</span> color<span class="Special"> <- </span>copy <span class="Constant">12/lightblue</span> @@ -446,9 +446,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># if color is blue and next character is newline, switch color to white</span> <span class="Delimiter">{</span> - color-is-blue?:boolean<span class="Special"> <- </span>equal color, <span class="Constant">12/lightblue</span> + color-is-blue?:bool<span class="Special"> <- </span>equal color, <span class="Constant">12/lightblue</span> <span class="muControl">break-unless</span> color-is-blue? - ending-comment?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + ending-comment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> ending-comment? trace <span class="Constant">90</span>, <span class="Constant">[app]</span>, <span class="Constant">[switch color back to white]</span> color<span class="Special"> <- </span>copy <span class="Constant">7/white</span> @@ -457,16 +457,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if color is white (no comments) and next character is '<', switch color to red</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> color-is-white? - starting-assignment?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">60/<</span> + starting-assignment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">60/<</span> <span class="muControl">break-unless</span> starting-assignment? color<span class="Special"> <- </span>copy <span class="Constant">1/red</span> <span class="muControl">jump</span> <span class="Constant">+exit:label</span> <span class="Delimiter">}</span> <span class="Comment"># if color is red and next character is space, switch color to white</span> <span class="Delimiter">{</span> - color-is-red?:boolean<span class="Special"> <- </span>equal color, <span class="Constant">1/red</span> + color-is-red?:bool<span class="Special"> <- </span>equal color, <span class="Constant">1/red</span> <span class="muControl">break-unless</span> color-is-red? - ending-assignment?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">32/space</span> + ending-assignment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">32/space</span> <span class="muControl">break-unless</span> ending-assignment? color<span class="Special"> <- </span>copy <span class="Constant">7/white</span> <span class="muControl">jump</span> <span class="Constant">+exit:label</span> @@ -482,7 +482,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d <- e</span> <span class="Constant">f]</span> - new-editor s:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index bba168f6..815f5fab 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -41,26 +41,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console - editor:address:editor-data<span class="Special"> <- </span>new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> + editor:&:editor-data<span class="Special"> <- </span>new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> editor-event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, editor close-console ] -<span class="muRecipe">def</span> editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data<span class="muRecipe"> -> </span>screen:address:screen, console:address:console, editor:address:editor-data [ +<span class="muRecipe">def</span> editor-event-loop screen:&:screen, console:&:console, editor:&:editor-data<span class="muRecipe"> -> </span>screen:&:screen, console:&:console, editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</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> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - e:event, console:address:console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console + e:event, console:&:console, found?:bool, quit?:bool<span class="Special"> <- </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> <span class="Comment"># 'touch' event</span> - t:touch-event, is-touch?:boolean<span class="Special"> <- </span>maybe-convert e, <span class="Constant">touch:variant</span> + t:touch-event, is-touch?:bool<span class="Special"> <- </span>maybe-convert e, <span class="Constant">touch:variant</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-touch? move-cursor-in-editor screen, editor, t @@ -69,7 +69,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># keyboard events</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-touch? - screen, editor, go-render?:boolean<span class="Special"> <- </span>handle-keyboard-event screen, editor, e + screen, editor, go-render?:bool<span class="Special"> <- </span>handle-keyboard-event screen, editor, e <span class="Delimiter">{</span> <span class="muControl">break-unless</span> go-render? screen<span class="Special"> <- </span>editor-render screen, editor @@ -80,23 +80,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># process click, return if it was on current editor</span> -<span class="muRecipe">def</span> move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event<span class="muRecipe"> -> </span>in-focus?:boolean, editor:address:editor-data [ +<span class="muRecipe">def</span> move-cursor-in-editor screen:&:screen, editor:&:editor-data, t:touch-event<span class="muRecipe"> -> </span>in-focus?:bool, editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor, <span class="Constant">0/false</span> - click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> + click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> <span class="muControl">return-unless</span> click-row, <span class="Constant">0/false</span> <span class="Comment"># ignore clicks on 'menu'</span> - click-column:number<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - too-far-left?:boolean<span class="Special"> <- </span>lesser-than click-column, left + click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + too-far-left?:bool<span class="Special"> <- </span>lesser-than click-column, left <span class="muControl">return-if</span> too-far-left?, <span class="Constant">0/false</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - too-far-right?:boolean<span class="Special"> <- </span>greater-than click-column, right + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + too-far-right?:bool<span class="Special"> <- </span>greater-than click-column, right <span class="muControl">return-if</span> too-far-right?, <span class="Constant">0/false</span> <span class="Comment"># position cursor</span> <span class="Constant"> <move-cursor-begin></span> editor<span class="Special"> <- </span>snap-cursor screen, editor, click-row, click-column - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> <span class="Comment"># gain focus</span> <span class="muControl">return</span> <span class="Constant">1/true</span> @@ -105,50 +105,50 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># Variant of 'render' that only moves the cursor (coordinates and</span> <span class="Comment"># before-cursor). If it's past the end of a line, it 'slides' it left. If it's</span> <span class="Comment"># past the last line it positions at end of last line.</span> -<span class="muRecipe">def</span> snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> snap-cursor screen:&:screen, editor:&:editor-data, target-row:num, target-column:num<span class="muRecipe"> -> </span>editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:number<span class="Special"> <- </span>screen-height screen + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + screen-height:num<span class="Special"> <- </span>screen-height screen <span class="Comment"># count newlines until screen row</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> curr<span class="Special"> <- </span>next curr - row:number<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:number<span class="Special"> <- </span>copy left + row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> + column:num<span class="Special"> <- </span>copy left *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, target-row - cursor-row:number<span class="Special"> <- </span>copy target-row + cursor-row:num<span class="Special"> <- </span>copy target-row *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, target-column - cursor-column:number<span class="Special"> <- </span>copy target-column - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-column:num<span class="Special"> <- </span>copy target-column + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr - off-screen?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># update editor-data.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?:boolean<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - at-cursor?:boolean<span class="Special"> <- </span>equal column, cursor-column + at-cursor?:bool<span class="Special"> <- </span>equal column, cursor-column <span class="muControl">break-unless</span> at-cursor? before-cursor<span class="Special"> <- </span>copy prev *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - left-of-cursor?:boolean<span class="Special"> <- </span>lesser-than column, cursor-column + left-of-cursor?:bool<span class="Special"> <- </span>lesser-than column, cursor-column <span class="muControl">break-unless</span> left-of-cursor? cursor-column<span class="Special"> <- </span>copy column *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column @@ -165,7 +165,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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?:boolean<span class="Special"> <- </span>equal column, right + at-right?:bool<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? column<span class="Special"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -179,11 +179,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> - at-cursor-row?:boolean<span class="Special"> <- </span>equal row, cursor-row - cursor-outside-line?:boolean<span class="Special"> <- </span>lesser-or-equal column, cursor-column - before-cursor-on-same-line?:boolean<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? - above-cursor-row?:boolean<span class="Special"> <- </span>lesser-than row, cursor-row - before-cursor?:boolean<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + cursor-outside-line?:bool<span class="Special"> <- </span>lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool<span class="Special"> <- </span>lesser-than row, cursor-row + before-cursor?:bool<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? <span class="muControl">break-unless</span> before-cursor? cursor-row<span class="Special"> <- </span>copy row *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row @@ -196,39 +196,39 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># Process an event 'e' and try to minimally update the screen.</span> <span class="Comment"># Set 'go-render?' to true to indicate the caller must perform a non-minimal update.</span> -<span class="muRecipe">def</span> handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event<span class="muRecipe"> -> </span>screen:address:screen, editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">def</span> handle-keyboard-event screen:&:screen, editor:&:editor-data, e:event<span class="muRecipe"> -> </span>screen:&:screen, editor:&:editor-data, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> editor - screen-width:number<span class="Special"> <- </span>screen-width screen - screen-height:number<span class="Special"> <- </span>screen-height screen - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - save-row:number<span class="Special"> <- </span>copy cursor-row - save-column:number<span class="Special"> <- </span>copy cursor-column + screen-width:num<span class="Special"> <- </span>screen-width screen + screen-height:num<span class="Special"> <- </span>screen-height screen + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + save-row:num<span class="Special"> <- </span>copy cursor-row + save-column:num<span class="Special"> <- </span>copy cursor-column <span class="Comment"># character</span> <span class="Delimiter">{</span> - c:character, is-unicode?:boolean<span class="Special"> <- </span>maybe-convert e, <span class="Constant">text:variant</span> + c:char, is-unicode?:bool<span class="Special"> <- </span>maybe-convert e, <span class="Constant">text:variant</span> <span class="muControl">break-unless</span> is-unicode? trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[handle-keyboard-event: special character]</span> <span class="Comment"># exceptions for special characters go here</span> <span class="Constant"> <handle-special-character></span> <span class="Comment"># ignore any other special characters</span> - regular-character?:boolean<span class="Special"> <- </span>greater-or-equal c, <span class="Constant">32/space</span> + regular-character?:bool<span class="Special"> <- </span>greater-or-equal c, <span class="Constant">32/space</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> regular-character? <span class="Comment"># otherwise type it in</span> <span class="Constant"> <insert-character-begin></span> - editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, c, screen + editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, c, screen <span class="Constant"> <insert-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># special key to modify the text or move the cursor</span> - k:number, is-keycode?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + k:num, is-keycode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> assert is-keycode?, <span class="Constant">[event was of unknown type; neither keyboard nor mouse]</span> <span class="Comment"># handlers for each special key will go here</span> <span class="Constant"> <handle-special-key></span> @@ -236,35 +236,35 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> ] -<span class="muRecipe">def</span> insert-at-cursor editor:address:editor-data, c:character, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean [ +<span class="muRecipe">def</span> insert-at-cursor editor:&:editor-data, c:char, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor-data, screen:&:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> insert c, before-cursor before-cursor<span class="Special"> <- </span>next before-cursor *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - save-row:number<span class="Special"> <- </span>copy cursor-row - save-column:number<span class="Special"> <- </span>copy cursor-column - screen-width:number<span class="Special"> <- </span>screen-width screen - screen-height:number<span class="Special"> <- </span>screen-height screen + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + save-row:num<span class="Special"> <- </span>copy cursor-row + save-column:num<span class="Special"> <- </span>copy cursor-column + screen-width:num<span class="Special"> <- </span>screen-width screen + screen-height:num<span class="Special"> <- </span>screen-height screen <span class="Comment"># occasionally we'll need to mess with the cursor</span> <span class="Constant"> <insert-character-special-case></span> <span class="Comment"># but mostly we'll just move the cursor right</span> cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - next:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="Delimiter">{</span> <span class="Comment"># at end of all text? no need to scroll? just print the character and leave</span> - at-end?:boolean<span class="Special"> <- </span>equal next, <span class="Constant">0/null</span> + at-end?:bool<span class="Special"> <- </span>equal next, <span class="Constant">0/null</span> <span class="muControl">break-unless</span> at-end? - bottom:number<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> - at-bottom?:boolean<span class="Special"> <- </span>equal save-row, bottom - at-right?:boolean<span class="Special"> <- </span>equal save-column, right - overflow?:boolean<span class="Special"> <- </span>and at-bottom?, at-right? + bottom:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> + at-bottom?:bool<span class="Special"> <- </span>equal save-row, bottom + at-right?:bool<span class="Special"> <- </span>equal save-column, right + overflow?:bool<span class="Special"> <- </span>and at-bottom?, at-right? <span class="muControl">break-if</span> overflow? move-cursor screen, save-row, save-column print screen, c @@ -274,20 +274,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="Comment"># not at right margin? print the character and rest of line</span> <span class="muControl">break-unless</span> next - at-right?:boolean<span class="Special"> <- </span>greater-or-equal cursor-column, screen-width + at-right?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, screen-width <span class="muControl">break-if</span> at-right? - curr:address:duplex-list:character<span class="Special"> <- </span>copy before-cursor + curr:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor move-cursor screen, save-row, save-column - curr-column:number<span class="Special"> <- </span>copy save-column + curr-column:num<span class="Special"> <- </span>copy save-column <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - at-right?:boolean<span class="Special"> <- </span>greater-than curr-column, right + at-right?:bool<span class="Special"> <- </span>greater-than curr-column, right <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? print screen, currc curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> @@ -302,12 +302,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># helper for tests</span> -<span class="muRecipe">def</span> editor-render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>screen:address:screen, editor:address:editor-data [ +<span class="muRecipe">def</span> editor-render screen:&:screen, editor:&:editor-data<span class="muRecipe"> -> </span>screen:&:screen, editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - row:number, column:number<span class="Special"> <- </span>render screen, editor + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + row:num, column:num<span class="Special"> <- </span>render screen, editor clear-line-until screen, right row<span class="Special"> <- </span>add row, <span class="Constant">1</span> draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> @@ -318,11 +318,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-empty-event-queue [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console <span class="Constant">[]</span> run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -335,16 +335,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> <span class="Comment"># on the 'b'</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -362,15 +362,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># last line, to the right of text</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -383,15 +383,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># interior line, to the right of text</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -404,15 +404,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">7</span> <span class="Comment"># below text</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> @@ -425,17 +425,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Comment"># editor occupies only left half of screen</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on right half of screen</span> left-click <span class="Constant">3</span>, <span class="Constant">8</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -453,17 +453,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks-in-menu-area [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on first, 'menu' row</span> left-click <span class="Constant">0</span>, <span class="Constant">3</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to cursor</span> memory-should-contain [ @@ -475,14 +475,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-into-empty-editor [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ type <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -496,8 +496,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ @@ -506,7 +506,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -520,15 +520,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -543,15 +543,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -566,15 +566,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -589,15 +589,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -613,15 +613,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> type <span class="Constant">[ef]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -636,13 +636,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -657,14 +657,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># type a letter</span> assume-console [ type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># no wrap yet</span> screen-should-contain [ @@ -679,7 +679,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># now wrap</span> screen-should-contain [ @@ -696,17 +696,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># type more text at the start</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> type <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ @@ -729,26 +729,26 @@ 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:number<span class="Special"> <- </span>copy right - before-wrap-column:number<span class="Special"> <- </span>subtract wrap-column, <span class="Constant">1</span> - at-wrap?:boolean<span class="Special"> <- </span>greater-or-equal cursor-column, wrap-column - just-before-wrap?:boolean<span class="Special"> <- </span>greater-or-equal cursor-column, before-wrap-column - next:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + wrap-column:num<span class="Special"> <- </span>copy right + before-wrap-column:num<span class="Special"> <- </span>subtract wrap-column, <span class="Constant">1</span> + at-wrap?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, wrap-column + just-before-wrap?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, before-wrap-column + next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="Comment"># at end of line? next == 0 || next.value == 10/newline</span> - at-end-of-line?:boolean<span class="Special"> <- </span>equal next, <span class="Constant">0</span> + at-end-of-line?:bool<span class="Special"> <- </span>equal next, <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - next-character:character<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> + next-character:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> at-end-of-line?<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + move-cursor-to-next-line?:bool<span class="Special"> <- </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"> <- </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:number<span class="Special"> <- </span>copy left + potential-new-cursor-column:num<span class="Special"> <- </span>copy left <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> at-end-of-line? @@ -756,7 +756,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:number<span class="Special"> <- </span>add left, <span class="Constant">1/make-room-for-wrap-indicator</span> + potential-new-cursor-column:num<span class="Special"> <- </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"> <- </span>copy potential-new-cursor-column @@ -765,7 +765,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *editor<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height + below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> <span class="Delimiter">}</span> @@ -777,15 +777,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 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> type <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -806,7 +806,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor containing two lines</span> contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">xyz]</span> - <span class="Constant">1</span>:address:editor-data/<span class="Special">raw <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:&:editor-data/<span class="Special">raw <- </span>new-editor contents, 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> @@ -818,7 +818,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[de]</span> <span class="Comment"># trigger wrap</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">1</span>:address:editor-data/<span class="Special">raw</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">1</span>:&:editor-data/<span class="Special">raw</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -832,15 +832,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> type <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -858,7 +858,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if newline, move cursor to start of next line, and maybe align indent with previous line</span> <span class="muData">container</span> editor-data [ - indent?:boolean + indent?:bool ] <span class="muRecipe">after</span> <span class="Constant"><editor-initialization></span> [ @@ -868,13 +868,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -887,7 +887,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Constant"> <insert-enter-begin></span> editor<span class="Special"> <- </span>insert-new-line-and-indent editor, screen @@ -897,15 +897,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> insert-new-line-and-indent editor:address:editor-data, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean [ +<span class="muRecipe">def</span> insert-new-line-and-indent editor:&:editor-data, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor-data, screen:&:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:number<span class="Special"> <- </span>screen-height screen + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + screen-height:num<span class="Special"> <- </span>screen-height screen <span class="Comment"># insert newline</span> insert <span class="Constant">10/newline</span>, before-cursor before-cursor<span class="Special"> <- </span>next before-cursor @@ -916,7 +916,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># maybe scroll</span> <span class="Delimiter">{</span> - below-screen?:boolean<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> + below-screen?:bool<span class="Special"> <- </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"> <scroll-down></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -924,16 +924,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Delimiter">}</span> <span class="Comment"># indent if necessary</span> - indent?:boolean<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> + indent?:bool<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> <span class="muControl">return-unless</span> indent? - d:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-previous-line:address:duplex-list:character<span class="Special"> <- </span>prev before-cursor - indent:number<span class="Special"> <- </span>line-indent end-of-previous-line, d - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + d:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + end-of-previous-line:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor + indent:num<span class="Special"> <- </span>line-indent end-of-previous-line, d + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - indent-done?:boolean<span class="Special"> <- </span>greater-or-equal i, indent + indent-done?:bool<span class="Special"> <- </span>greater-or-equal i, indent <span class="muControl">break-if</span> indent-done? - editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen i<span class="Special"> <- </span>add i, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -941,23 +941,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># takes a pointer 'curr' into the doubly-linked list and its sentinel, counts</span> <span class="Comment"># the number of spaces at the start of the line containing 'curr'.</span> -<span class="muRecipe">def</span> line-indent curr:address:duplex-list:character, start:address:duplex-list:character<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">def</span> line-indent curr:&:duplex-list:char, start:&:duplex-list:char<span class="muRecipe"> -> </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + result:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="muControl">return-unless</span> curr - at-start?:boolean<span class="Special"> <- </span>equal curr, start + at-start?:bool<span class="Special"> <- </span>equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> curr<span class="Special"> <- </span>prev curr <span class="muControl">break-unless</span> curr - at-start?:boolean<span class="Special"> <- </span>equal curr, start + at-start?:bool<span class="Special"> <- </span>equal curr, start <span class="muControl">break-if</span> at-start? - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">32/space</span> + is-space?:bool<span class="Special"> <- </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"> <- </span>add result, <span class="Constant">1</span> @@ -974,13 +974,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -994,7 +994,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 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -1006,7 +1006,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># line should be fully cleared</span> screen-should-contain [ @@ -1023,7 +1023,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -1031,9 +1031,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ @@ -1047,7 +1047,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -1056,9 +1056,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press <span class="Constant">65506</span> <span class="Comment"># end paste</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ @@ -1069,7 +1069,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - paste-start?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65507/paste-start</span> + paste-start?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65507/paste-start</span> <span class="muControl">break-unless</span> paste-start? *editor<span class="Special"> <- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -1079,7 +1079,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - paste-end?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65506/paste-end</span> + paste-end?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65506/paste-end</span> <span class="muControl">break-unless</span> paste-end? *editor<span class="Special"> <- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -1089,28 +1089,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## helpers</span> -<span class="muRecipe">def</span> draw-horizontal screen:address:screen, row:number, x:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> draw-horizontal screen:&:screen, row:num, x:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? style<span class="Special"> <- </span>copy <span class="Constant">9472/horizontal</span> <span class="Delimiter">}</span> - color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool<span class="Special"> <- </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"> <- </span>copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - bg-color:number, bg-color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + bg-color:num, bg-color-found?:bool<span class="Special"> <- </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"> <- </span>copy <span class="Constant">0/black</span> <span class="Delimiter">}</span> screen<span class="Special"> <- </span>move-cursor screen, row, x <span class="Delimiter">{</span> - continue?:boolean<span class="Special"> <- </span>lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor-data semantics</span> + continue?:bool<span class="Special"> <- </span>lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor-data semantics</span> <span class="muControl">break-unless</span> continue? print screen, style, color, bg-color x<span class="Special"> <- </span>add x, <span class="Constant">1</span> diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index ce053fd8..90879f62 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -43,12 +43,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># just one character in final line</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press tab ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -59,11 +59,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - tab?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">9/tab</span> + tab?:bool<span class="Special"> <- </span>equal c, <span class="Constant">9/tab</span> <span class="muControl">break-unless</span> tab? <span class="Constant"> <insert-character-begin></span> - editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen - editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen <span class="Constant"> <insert-character-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">return</span> @@ -75,17 +75,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-backspace-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -102,10 +102,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - delete-previous-character?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">8/backspace</span> + delete-previous-character?:bool<span class="Special"> <- </span>equal c, <span class="Constant">8/backspace</span> <span class="muControl">break-unless</span> delete-previous-character? <span class="Constant"> <backspace-character-begin></span> - editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character<span class="Special"> <- </span>delete-before-cursor editor, screen + editor, screen, go-render?:bool, backspaced-cell:&:duplex-list:char<span class="Special"> <- </span>delete-before-cursor editor, screen <span class="Constant"> <backspace-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -114,45 +114,45 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># return values:</span> <span class="Comment"># go-render? - whether caller needs to update the screen</span> <span class="Comment"># backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc.</span> -<span class="muRecipe">def</span> delete-before-cursor editor:address:editor-data, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean, backspaced-cell:address:duplex-list:character [ +<span class="muRecipe">def</span> delete-before-cursor editor:&:editor-data, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor-data, screen:&:screen, go-render?:bool, backspaced-cell:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - data:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + data:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> <span class="Comment"># if at start of text (before-cursor at § sentinel), return</span> - prev:address:duplex-list:character<span class="Special"> <- </span>prev before-cursor + prev:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor go-render?, backspaced-cell<span class="Special"> <- </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:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - editor, scroll?:boolean<span class="Special"> <- </span>move-cursor-coordinates-left editor - backspaced-cell:address:duplex-list:character<span class="Special"> <- </span>copy before-cursor + original-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + editor, scroll?:bool<span class="Special"> <- </span>move-cursor-coordinates-left editor + backspaced-cell:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor data<span class="Special"> <- </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"> <- </span>copy prev *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> scroll? - screen-width:number<span class="Special"> <- </span>screen-width screen - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + screen-width:num<span class="Special"> <- </span>screen-width screen + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># did we just backspace over a newline?</span> - same-row?:boolean<span class="Special"> <- </span>equal cursor-row, original-row + same-row?:bool<span class="Special"> <- </span>equal cursor-row, original-row go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">return-unless</span> same-row? - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - curr:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - curr-column:number<span class="Special"> <- </span>copy cursor-column + curr-column:num<span class="Special"> <- </span>copy cursor-column <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:boolean<span class="Special"> <- </span>greater-or-equal curr-column, right + at-right?:bool<span class="Special"> <- </span>greater-or-equal curr-column, right go-render?<span class="Special"> <- </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:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? screen<span class="Special"> <- </span>print screen, currc curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> @@ -160,21 +160,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> screen<span class="Special"> <- </span>print screen, space go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] -<span class="muRecipe">def</span> move-cursor-coordinates-left editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">def</span> move-cursor-coordinates-left editor:&:editor-data<span class="muRecipe"> -> </span>editor:&:editor-data, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + left:num<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal cursor-column, left + at-left-margin?:bool<span class="Special"> <- </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"> <- </span>subtract cursor-column, <span class="Constant">1</span> @@ -183,8 +183,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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?:boolean<span class="Special"> <- </span>equal cursor-row, <span class="Constant">1</span> <span class="Comment"># exclude menu bar</span> - go-render?:boolean<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + top-of-screen?:bool<span class="Special"> <- </span>equal cursor-row, <span class="Constant">1</span> <span class="Comment"># exclude menu bar</span> + go-render?:bool<span class="Special"> <- </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"> <- </span>subtract cursor-row, <span class="Constant">1</span> @@ -197,19 +197,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:character<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - previous-character-is-newline?:boolean<span class="Special"> <- </span>equal previous-character, <span class="Constant">10/newline</span> + previous-character:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> + previous-character-is-newline?:bool<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-line:number<span class="Special"> <- </span>previous-line-length before-cursor, d - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - width:number<span class="Special"> <- </span>subtract right, left - wrap?:boolean<span class="Special"> <- </span>greater-than end-of-line, width + d:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + end-of-line:num<span class="Special"> <- </span>previous-line-length before-cursor, d + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + width:num<span class="Special"> <- </span>subtract right, left + wrap?:bool<span class="Special"> <- </span>greater-than end-of-line, width <span class="Delimiter">{</span> <span class="muControl">break-unless</span> wrap? - _, column-offset:number<span class="Special"> <- </span>divide-with-remainder end-of-line, width + _, column-offset:num<span class="Special"> <- </span>divide-with-remainder end-of-line, width cursor-column<span class="Special"> <- </span>add left, column-offset *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">}</span> @@ -222,27 +222,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> cursor-column<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> <span class="Comment"># leave room for wrap icon</span> *editor<span class="Special"> <- </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> <span class="Comment"># the length of the previous line before the 'curr' pointer.</span> -<span class="muRecipe">def</span> previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">def</span> previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char<span class="muRecipe"> -> </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + result:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="muControl">return-unless</span> curr - at-start?:boolean<span class="Special"> <- </span>equal curr, start + at-start?:bool<span class="Special"> <- </span>equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> curr<span class="Special"> <- </span>prev curr <span class="muControl">break-unless</span> curr - at-start?:boolean<span class="Special"> <- </span>equal curr, start + at-start?:bool<span class="Special"> <- </span>equal curr, start <span class="muControl">break-if</span> at-start? - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? result<span class="Special"> <- </span>add result, <span class="Constant">1</span> <span class="muControl">loop</span> @@ -254,15 +254,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># just one character in final line</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -281,8 +281,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc def</span> <span class="Constant">ghi jkl]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor at the start of the second and hit backspace</span> assume-console [ @@ -290,7 +290,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># resulting single line should wrap correctly</span> screen-should-contain [ @@ -306,8 +306,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># confirm that it wraps</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -322,7 +322,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># resulting single line should wrap correctly and not overflow its bounds</span> screen-should-contain [ @@ -339,14 +339,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-delete-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -360,7 +360,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -373,44 +373,44 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - delete-next-character?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65522/delete</span> + delete-next-character?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65522/delete</span> <span class="muControl">break-unless</span> delete-next-character? <span class="Constant"> <delete-character-begin></span> - editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character<span class="Special"> <- </span>delete-at-cursor editor, screen + editor, screen, go-render?:bool, deleted-cell:&:duplex-list:char<span class="Special"> <- </span>delete-at-cursor editor, screen <span class="Constant"> <delete-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> delete-at-cursor editor:address:editor-data, screen:address:screen<span class="muRecipe"> -> </span>editor:address:editor-data, screen:address:screen, go-render?:boolean, deleted-cell:address:duplex-list:character [ +<span class="muRecipe">def</span> delete-at-cursor editor:&:editor-data, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor-data, screen:&:screen, go-render?:bool, deleted-cell:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - data:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - deleted-cell:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + data:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + deleted-cell:&:duplex-list:char<span class="Special"> <- </span>next before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> deleted-cell - currc:character<span class="Special"> <- </span>get *deleted-cell, <span class="Constant">value:offset</span> + currc:char<span class="Special"> <- </span>get *deleted-cell, <span class="Constant">value:offset</span> data<span class="Special"> <- </span>remove deleted-cell, data - deleted-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + deleted-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> go-render?<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>next before-cursor <span class="Comment"># refresh after remove above</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="Comment"># refresh after remove above</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - curr-column:number<span class="Special"> <- </span>copy cursor-column - screen-width:number<span class="Special"> <- </span>screen-width screen + curr-column:num<span class="Special"> <- </span>copy cursor-column + screen-width:num<span class="Special"> <- </span>screen-width screen <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:boolean<span class="Special"> <- </span>greater-or-equal curr-column, screen-width + at-right?:bool<span class="Special"> <- </span>greater-or-equal curr-column, screen-width go-render?<span class="Special"> <- </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:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? screen<span class="Special"> <- </span>print screen, currc curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> @@ -418,7 +418,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> screen<span class="Special"> <- </span>print screen, space go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] @@ -428,15 +428,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-right-with-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ press right-arrow type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -449,41 +449,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-next-character?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65514/right-arrow</span> + move-to-next-character?:bool<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + next-cursor:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="muControl">break-unless</span> next-cursor <span class="Comment"># scan to next character</span> <span class="Constant"> <move-cursor-begin></span> before-cursor<span class="Special"> <- </span>copy next-cursor *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - editor, go-render?:boolean<span class="Special"> <- </span>move-cursor-coordinates-right editor, screen-height + editor, go-render?:bool<span class="Special"> <- </span>move-cursor-coordinates-right editor, screen-height screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">2/right-arrow</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">2/right-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> move-cursor-coordinates-right editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">def</span> move-cursor-coordinates-right editor:&:editor-data, screen-height:num<span class="muRecipe"> -> </span>editor:&:editor-data, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </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:character<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - was-at-newline?:boolean<span class="Special"> <- </span>equal old-cursor-character, <span class="Constant">10/newline</span> + old-cursor-character:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> + was-at-newline?:bool<span class="Special"> <- </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"> <- </span>add cursor-row, <span class="Constant">1</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>copy left *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - below-screen?:boolean<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> + below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> below-screen? <span class="Constant"> <scroll-down></span> @@ -495,20 +495,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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:number<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> - at-wrap?:boolean<span class="Special"> <- </span>equal cursor-column, wrap-column + wrap-column:num<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> + at-wrap?:bool<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="muControl">break-unless</span> next - next-character:character<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> - newline?:boolean<span class="Special"> <- </span>equal next-character, <span class="Constant">10/newline</span> + next-character:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> + newline?:bool<span class="Special"> <- </span>equal next-character, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> newline? cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>copy left *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - below-screen?:boolean<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> + below-screen?:bool<span class="Special"> <- </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> <span class="Constant"> <scroll-down></span> cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> @@ -526,8 +526,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> assume-console [ @@ -537,7 +537,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow <span class="Comment"># next line</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] 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> @@ -545,7 +545,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -561,8 +561,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ press right-arrow press right-arrow @@ -571,7 +571,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -585,17 +585,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 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -615,8 +615,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># line just barely wrapping</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> assume-console [ @@ -624,9 +624,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -637,9 +637,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -651,17 +651,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-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">4</span> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -681,8 +681,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> assume-console [ @@ -691,7 +691,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># new character should be in next line</span> screen-should-contain [ @@ -711,8 +711,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-left-with-key [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> @@ -720,7 +720,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -733,18 +733,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-previous-character?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65515/left-arrow</span> + move-to-previous-character?:bool<span class="Special"> <- </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> <span class="Comment"># if not at start of text (before-cursor at § sentinel)</span> - prev:address:duplex-list:character<span class="Special"> <- </span>prev before-cursor + prev:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> prev <span class="Constant"> <move-cursor-begin></span> editor, go-render?<span class="Special"> <- </span>move-cursor-coordinates-left editor before-cursor<span class="Special"> <- </span>copy prev *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">1/left-arrow</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">1/left-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -755,8 +755,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize editor with two lines</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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 [ @@ -764,9 +764,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -781,8 +781,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> @@ -792,7 +792,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -809,8 +809,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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 [ @@ -819,7 +819,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># left-arrow should have had no effect</span> screen-should-contain [ @@ -838,8 +838,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> d] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> assume-console [ @@ -848,7 +848,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -864,8 +864,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -880,9 +880,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> @@ -896,8 +896,8 @@ d] <span class="Comment"># initialize editor with a wrapping line followed by a second line</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -912,9 +912,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># previous row</span> @@ -928,8 +928,8 @@ d] <span class="Comment"># initialize editor with a line on the verge of wrapping, followed by a second line</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcd</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -944,9 +944,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> @@ -963,17 +963,17 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -984,7 +984,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -997,46 +997,46 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-previous-line?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65517/up-arrow</span> + move-to-previous-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65517/up-arrow</span> <span class="muControl">break-unless</span> move-to-previous-line? <span class="Constant"> <move-cursor-begin></span> editor, go-render?<span class="Special"> <- </span>move-to-previous-line editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">3/up-arrow</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">3/up-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> move-to-previous-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">def</span> move-to-previous-line editor:&:editor-data<span class="muRecipe"> -> </span>editor:&:editor-data, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - already-at-top?:boolean<span class="Special"> <- </span>lesser-or-equal cursor-row, <span class="Constant">1/top</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + already-at-top?:bool<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>copy before-cursor + curr:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor <span class="Delimiter">{</span> - old:address:duplex-list:character<span class="Special"> <- </span>copy curr - c2:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal c2, <span class="Constant">10/newline</span> + old:&:duplex-list:char<span class="Special"> <- </span>copy curr + c2:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal c2, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr:address:duplex-list:character<span class="Special"> <- </span>before-previous-line curr, editor - no-motion?:boolean<span class="Special"> <- </span>equal curr, old + curr:&:duplex-list:char<span class="Special"> <- </span>before-previous-line curr, editor + no-motion?:bool<span class="Special"> <- </span>equal curr, old go-render?<span class="Special"> <- </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"> <- </span>copy curr curr<span class="Special"> <- </span>before-previous-line curr, editor - no-motion?:boolean<span class="Special"> <- </span>equal curr, old + no-motion?:bool<span class="Special"> <- </span>equal curr, old go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-motion? <span class="Delimiter">}</span> @@ -1045,16 +1045,16 @@ d] cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> *editor<span class="Special"> <- </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:number<span class="Special"> <- </span>copy cursor-column + target-column:num<span class="Special"> <- </span>copy cursor-column cursor-column<span class="Special"> <- </span>copy left *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal cursor-column, target-column + done?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, target-column <span class="muControl">break-if</span> done? - curr:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="muControl">break-unless</span> curr - currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </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"> <- </span>copy curr @@ -1079,17 +1079,17 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1100,7 +1100,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1115,17 +1115,17 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new [ <span class="muRecipe">def</span>] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1136,7 +1136,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1153,8 +1153,8 @@ d] <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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 [ @@ -1162,9 +1162,9 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1175,7 +1175,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1192,17 +1192,17 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> assume-console [ press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># ..and ends at (2, 0)</span> memory-should-contain [ @@ -1214,7 +1214,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1227,38 +1227,38 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-next-line?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> + move-to-next-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> move-to-next-line? <span class="Constant"> <move-cursor-begin></span> editor, go-render?<span class="Special"> <- </span>move-to-next-line editor, screen-height - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">4/down-arrow</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">4/down-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> move-to-next-line editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">def</span> move-to-next-line editor:&:editor-data, screen-height:num<span class="muRecipe"> -> </span>editor:&:editor-data, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - last-line:number<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> - already-at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal cursor-row, last-line + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + last-line:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> + already-at-bottom?:bool<span class="Special"> <- </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:number<span class="Special"> <- </span>subtract right, left - next-line:address:duplex-list:character<span class="Special"> <- </span>before-start-of-next-line before-cursor, max + max:num<span class="Special"> <- </span>subtract right, left + next-line:&:duplex-list:char<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal next-line, before-cursor + no-motion?:bool<span class="Special"> <- </span>equal next-line, before-cursor <span class="muControl">break-unless</span> no-motion? - scroll?:boolean<span class="Special"> <- </span>greater-than cursor-row, <span class="Constant">1</span> + scroll?:bool<span class="Special"> <- </span>greater-than cursor-row, <span class="Constant">1</span> <span class="muControl">break-if</span> scroll?, <span class="Constant">+try-to-scroll:label</span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return</span> @@ -1267,16 +1267,16 @@ d] *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row before-cursor<span class="Special"> <- </span>copy next-line *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - target-column:number<span class="Special"> <- </span>copy cursor-column + target-column:num<span class="Special"> <- </span>copy cursor-column cursor-column<span class="Special"> <- </span>copy left *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal cursor-column, target-column + done?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, target-column <span class="muControl">break-if</span> done? - curr:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="muControl">break-unless</span> curr - currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </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"> <- </span>copy curr @@ -1297,17 +1297,17 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1318,7 +1318,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1335,8 +1335,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> assume-console [ @@ -1344,9 +1344,9 @@ d] press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1358,11 +1358,11 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - move-to-start-of-line?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">1/ctrl-a</span> + move-to-start-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">1/ctrl-a</span> <span class="muControl">break-unless</span> move-to-start-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-start-of-line editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return</span> @@ -1371,33 +1371,33 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-start-of-line?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65521/home</span> + move-to-start-of-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65521/home</span> <span class="muControl">break-unless</span> move-to-start-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-start-of-line editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> move-to-start-of-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> move-to-start-of-line editor:&:editor-data<span class="muRecipe"> -> </span>editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># update cursor column</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - cursor-column:number<span class="Special"> <- </span>copy left + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + cursor-column:num<span class="Special"> <- </span>copy left *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># update before-cursor</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - init:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + init:&:duplex-list:char<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal before-cursor, init + at-start-of-text?:bool<span class="Special"> <- </span>equal before-cursor, init <span class="muControl">break-if</span> at-start-of-text? - prev:character<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - at-start-of-line?:boolean<span class="Special"> <- </span>equal prev, <span class="Constant">10/newline</span> + prev:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> + at-start-of-line?:bool<span class="Special"> <- </span>equal prev, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-start-of-line? before-cursor<span class="Special"> <- </span>prev before-cursor *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor @@ -1410,8 +1410,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> assume-console [ @@ -1419,9 +1419,9 @@ d] press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1435,7 +1435,7 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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 [ @@ -1443,9 +1443,9 @@ d] press home ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1459,8 +1459,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> assume-console [ @@ -1468,9 +1468,9 @@ d] press home ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1486,8 +1486,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> assume-console [ @@ -1495,9 +1495,9 @@ d] press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1510,9 +1510,9 @@ d] type <span class="Constant">[z]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1530,11 +1530,11 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - move-to-end-of-line?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">5/ctrl-e</span> + move-to-end-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">5/ctrl-e</span> <span class="muControl">break-unless</span> move-to-end-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-end-of-line editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return</span> @@ -1543,28 +1543,28 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-end-of-line?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65520/end</span> + move-to-end-of-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65520/end</span> <span class="muControl">break-unless</span> move-to-end-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-end-of-line editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> move-to-end-of-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> move-to-end-of-line editor:&:editor-data<span class="muRecipe"> -> </span>editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-column:num<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="muControl">break-unless</span> next <span class="Comment"># end of text</span> - nextc:character<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> - at-end-of-line?:boolean<span class="Special"> <- </span>equal nextc, <span class="Constant">10/newline</span> + nextc:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> + at-end-of-line?:bool<span class="Special"> <- </span>equal nextc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-end-of-line? before-cursor<span class="Special"> <- </span>copy next *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor @@ -1578,8 +1578,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> assume-console [ @@ -1587,9 +1587,9 @@ d] press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1603,8 +1603,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> assume-console [ @@ -1612,9 +1612,9 @@ d] press end ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1628,8 +1628,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> assume-console [ @@ -1637,9 +1637,9 @@ d] press end ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1655,14 +1655,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1676,41 +1676,41 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - delete-to-start-of-line?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">21/ctrl-u</span> + delete-to-start-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">21/ctrl-u</span> <span class="muControl">break-unless</span> delete-to-start-of-line? <span class="Constant"> <delete-to-start-of-line-begin></span> - deleted-cells:address:duplex-list:character<span class="Special"> <- </span>delete-to-start-of-line editor + deleted-cells:&:duplex-list:char<span class="Special"> <- </span>delete-to-start-of-line editor <span class="Constant"> <delete-to-start-of-line-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> delete-to-start-of-line editor:address:editor-data<span class="muRecipe"> -> </span>result:address:duplex-list:character, editor:address:editor-data [ +<span class="muRecipe">def</span> delete-to-start-of-line editor:&:editor-data<span class="muRecipe"> -> </span>result:&:duplex-list:char, editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - init:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - start:address:duplex-list:character<span class="Special"> <- </span>copy before-cursor - end:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + init:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + start:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor + end:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="Delimiter">{</span> - at-start-of-text?:boolean<span class="Special"> <- </span>equal start, init + at-start-of-text?:bool<span class="Special"> <- </span>equal start, init <span class="muControl">break-if</span> at-start-of-text? - curr:character<span class="Special"> <- </span>get *start, <span class="Constant">value:offset</span> - at-start-of-line?:boolean<span class="Special"> <- </span>equal curr, <span class="Constant">10/newline</span> + curr:char<span class="Special"> <- </span>get *start, <span class="Constant">value:offset</span> + at-start-of-line?:bool<span class="Special"> <- </span>equal curr, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-start-of-line? start<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>next start + result:&:duplex-list:char<span class="Special"> <- </span>next start remove-between start, end <span class="Comment"># adjust cursor</span> before-cursor<span class="Special"> <- </span>copy start *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, left ] @@ -1718,14 +1718,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1741,14 +1741,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1764,14 +1764,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1789,14 +1789,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1810,27 +1810,27 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - delete-to-end-of-line?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">11/ctrl-k</span> + delete-to-end-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">11/ctrl-k</span> <span class="muControl">break-unless</span> delete-to-end-of-line? <span class="Constant"> <delete-to-end-of-line-begin></span> - deleted-cells:address:duplex-list:character<span class="Special"> <- </span>delete-to-end-of-line editor + deleted-cells:&:duplex-list:char<span class="Special"> <- </span>delete-to-end-of-line editor <span class="Constant"> <delete-to-end-of-line-end></span> go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> delete-to-end-of-line editor:address:editor-data<span class="muRecipe"> -> </span>result:address:duplex-list:character, editor:address:editor-data [ +<span class="muRecipe">def</span> delete-to-end-of-line editor:&:editor-data<span class="muRecipe"> -> </span>result:&:duplex-list:char, editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - start:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - end:address:duplex-list:character<span class="Special"> <- </span>next start + start:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + end:&:duplex-list:char<span class="Special"> <- </span>next start <span class="Delimiter">{</span> - at-end-of-text?:boolean<span class="Special"> <- </span>equal end, <span class="Constant">0/null</span> + at-end-of-text?:bool<span class="Special"> <- </span>equal end, <span class="Constant">0/null</span> <span class="muControl">break-if</span> at-end-of-text? - curr:character<span class="Special"> <- </span>get *end, <span class="Constant">value:offset</span> - at-end-of-line?:boolean<span class="Special"> <- </span>equal curr, <span class="Constant">10/newline</span> + curr:char<span class="Special"> <- </span>get *end, <span class="Constant">value:offset</span> + at-end-of-line?:bool<span class="Special"> <- </span>equal curr, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-end-of-line? end<span class="Special"> <- </span>next end <span class="muControl">loop</span> @@ -1844,14 +1844,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1867,14 +1867,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes just last character</span> screen-should-contain [ @@ -1890,14 +1890,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1913,14 +1913,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes just the final character</span> screen-should-contain [ @@ -1936,14 +1936,14 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1965,7 +1965,7 @@ d] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -1978,7 +1978,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -1991,14 +1991,14 @@ d] <span class="muRecipe">after</span> <span class="Constant"><scroll-down></span> [ trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll down]</span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - max:number<span class="Special"> <- </span>subtract right, left - old-top:address:duplex-list:character<span class="Special"> <- </span>copy top-of-screen + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + max:num<span class="Special"> <- </span>subtract right, left + old-top:&:duplex-list:char<span class="Special"> <- </span>copy top-of-screen top-of-screen<span class="Special"> <- </span>before-start-of-next-line top-of-screen, max *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - no-movement?:boolean<span class="Special"> <- </span>equal old-top, top-of-screen + no-movement?:bool<span class="Special"> <- </span>equal old-top, top-of-screen go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-movement? ] @@ -2006,25 +2006,25 @@ d] <span class="Comment"># takes a pointer into the doubly-linked list, scans ahead at most 'max'</span> <span class="Comment"># positions until the next newline</span> <span class="Comment"># beware: never return null pointer.</span> -<span class="muRecipe">def</span> before-start-of-next-line original:address:duplex-list:character, max:number<span class="muRecipe"> -> </span>curr:address:duplex-list:character [ +<span class="muRecipe">def</span> before-start-of-next-line original:&:duplex-list:char, max:num<span class="muRecipe"> -> </span>curr:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - count:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:address:duplex-list:character<span class="Special"> <- </span>copy original + count:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr:&:duplex-list:char<span class="Special"> <- </span>copy original <span class="Comment"># skip the initial newline if it exists</span> <span class="Delimiter">{</span> - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> at-newline? curr<span class="Special"> <- </span>next curr count<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-or-equal count, max + done?:bool<span class="Special"> <- </span>greater-or-equal count, max <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? curr<span class="Special"> <- </span>next curr count<span class="Special"> <- </span>add count, <span class="Constant">1</span> @@ -2043,7 +2043,7 @@ d] <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2056,7 +2056,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2075,14 +2075,14 @@ d] <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line containing a wrap icon</span> screen-should-contain [ @@ -2096,7 +2096,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2114,16 +2114,16 @@ d] <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdef]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> type <span class="Constant">[g]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2144,16 +2144,16 @@ d] <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> type [ ] ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2175,16 +2175,16 @@ d] <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2207,16 +2207,16 @@ d] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2235,8 +2235,8 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> assume-console [ @@ -2244,9 +2244,9 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should scroll, moving cursor to end of text</span> memory-should-contain [ @@ -2257,7 +2257,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2272,9 +2272,9 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen stops scrolling because cursor is already at top</span> memory-should-contain [ @@ -2286,7 +2286,7 @@ d] type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2307,7 +2307,7 @@ d] <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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 @@ -2315,7 +2315,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen scrolls down 3 lines</span> screen-should-contain [ @@ -2336,7 +2336,7 @@ d] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2349,7 +2349,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2362,11 +2362,11 @@ d] <span class="muRecipe">after</span> <span class="Constant"><scroll-up></span> [ trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll up]</span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list:character<span class="Special"> <- </span>copy top-of-screen + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char<span class="Special"> <- </span>copy top-of-screen top-of-screen<span class="Special"> <- </span>before-previous-line top-of-screen, editor *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - no-movement?:boolean<span class="Special"> <- </span>equal old-top, top-of-screen + no-movement?:bool<span class="Special"> <- </span>equal old-top, top-of-screen go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-movement? ] @@ -2374,39 +2374,39 @@ d] <span class="Comment"># takes a pointer into the doubly-linked list, scans back to before start of</span> <span class="Comment"># previous *wrapped* line</span> <span class="Comment"># beware: never return null pointer</span> -<span class="muRecipe">def</span> before-previous-line in:address:duplex-list:character, editor:address:editor-data<span class="muRecipe"> -> </span>out:address:duplex-list:character [ +<span class="muRecipe">def</span> before-previous-line in:&:duplex-list:char, editor:&:editor-data<span class="muRecipe"> -> </span>out:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:address:duplex-list:character<span class="Special"> <- </span>copy in - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + curr:&:duplex-list:char<span class="Special"> <- </span>copy in + c:char<span class="Special"> <- </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:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - max-line-length:number<span class="Special"> <- </span>subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> - sentinel:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - len:number<span class="Special"> <- </span>previous-line-length curr, sentinel + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + max-line-length:num<span class="Special"> <- </span>subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> + sentinel:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + len:num<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>prev curr + prev:&:duplex-list:char<span class="Special"> <- </span>prev curr <span class="muControl">return-unless</span> prev, curr <span class="muControl">return</span> prev <span class="Delimiter">}</span> - _, max:number<span class="Special"> <- </span>divide-with-remainder len, max-line-length + _, max:num<span class="Special"> <- </span>divide-with-remainder len, max-line-length <span class="Comment"># remainder 0 => scan one width-worth</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> max max<span class="Special"> <- </span>copy max-line-length <span class="Delimiter">}</span> max<span class="Special"> <- </span>add max, <span class="Constant">1</span> - count:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + count:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># skip 'max' characters</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal count, max + done?:bool<span class="Special"> <- </span>greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:address:duplex-list:character<span class="Special"> <- </span>prev curr + prev:&:duplex-list:char<span class="Special"> <- </span>prev curr <span class="muControl">break-unless</span> prev curr<span class="Special"> <- </span>copy prev count<span class="Special"> <- </span>add count, <span class="Constant">1</span> @@ -2424,7 +2424,7 @@ d] <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2436,7 +2436,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2449,7 +2449,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2468,13 +2468,13 @@ d] <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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 ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2488,7 +2488,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2503,7 +2503,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2518,7 +2518,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2541,7 +2541,7 @@ d] <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2553,7 +2553,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2566,7 +2566,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2587,12 +2587,12 @@ d] c d e] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2604,7 +2604,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2616,7 +2616,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2635,13 +2635,13 @@ e] <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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 ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2654,9 +2654,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2679,7 +2679,7 @@ e] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2694,7 +2694,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2708,7 +2708,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen remains unchanged</span> screen-should-contain [ @@ -2727,7 +2727,7 @@ e] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2739,7 +2739,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2752,15 +2752,15 @@ e] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - page-down?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">6/ctrl-f</span> + page-down?:bool<span class="Special"> <- </span>equal c, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - old-top:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> page-down editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:boolean<span class="Special"> <- </span>equal top-of-screen, old-top + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top go-render?<span class="Special"> <- </span>not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -2768,15 +2768,15 @@ e] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - page-down?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - old-top:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> page-down editor - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:boolean<span class="Special"> <- </span>equal top-of-screen, old-top + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top go-render?<span class="Special"> <- </span>not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -2784,21 +2784,21 @@ e] <span class="Comment"># page-down skips entire wrapped lines, so it can't scroll past lines</span> <span class="Comment"># taking up the entire screen</span> -<span class="muRecipe">def</span> page-down editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> page-down editor:&:editor-data<span class="muRecipe"> -> </span>editor:&:editor-data [ <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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> + bottom-of-screen:&:duplex-list:char<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>prev bottom-of-screen + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>prev bottom-of-screen *editor<span class="Special"> <- </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:character<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - newline?:boolean<span class="Special"> <- </span>equal last, <span class="Constant">10/newline</span> - <span class="muControl">break-unless</span> newline?:boolean + last:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> + newline?:bool<span class="Special"> <- </span>equal last, <span class="Constant">10/newline</span> + <span class="muControl">break-unless</span> newline?:bool before-cursor<span class="Special"> <- </span>prev before-cursor *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> @@ -2812,8 +2812,8 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2825,7 +2825,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen remains unmodified</span> screen-should-contain [ @@ -2844,7 +2844,7 @@ e] <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2857,7 +2857,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2875,7 +2875,7 @@ e] <span class="Comment"># and still has something left over</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2888,7 +2888,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2907,7 +2907,7 @@ e] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -2919,7 +2919,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2933,7 +2933,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2946,15 +2946,15 @@ e] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - page-up?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">2/ctrl-b</span> + page-up?:bool<span class="Special"> <- </span>equal c, <span class="Constant">2/ctrl-b</span> <span class="muControl">break-unless</span> page-up? - old-top:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> editor<span class="Special"> <- </span>page-up editor, screen-height - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:boolean<span class="Special"> <- </span>equal top-of-screen, old-top + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top go-render?<span class="Special"> <- </span>not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -2962,31 +2962,31 @@ e] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - page-up?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - old-top:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> editor<span class="Special"> <- </span>page-up editor, screen-height - undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:boolean<span class="Special"> <- </span>equal top-of-screen, old-top + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool<span class="Special"> <- </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"> <- </span>not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> page-up editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> page-up editor:&:editor-data, screen-height:num<span class="muRecipe"> -> </span>editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - max:number<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> - count:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + max:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> + count:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal count, max + done?:bool<span class="Special"> <- </span>greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:address:duplex-list:character<span class="Special"> <- </span>before-previous-line top-of-screen, editor + prev:&:duplex-list:char<span class="Special"> <- </span>before-previous-line top-of-screen, editor <span class="muControl">break-unless</span> prev top-of-screen<span class="Special"> <- </span>copy prev *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen @@ -3007,7 +3007,7 @@ e] <span class="Constant">f</span> <span class="Constant">g</span> <span class="Constant">h]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -3020,7 +3020,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows third page</span> screen-should-contain [ @@ -3034,7 +3034,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows second page</span> screen-should-contain [ @@ -3048,7 +3048,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -3074,7 +3074,7 @@ e] <span class="Constant">n</span> <span class="Constant">o]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -3091,7 +3091,7 @@ e] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -3107,7 +3107,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3127,7 +3127,7 @@ e] <span class="Comment"># and still has something left over</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -3140,7 +3140,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -3154,7 +3154,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3177,7 +3177,7 @@ e] <span class="Constant">gxx</span> <span class="Constant">hxx</span> <span class="Constant">]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -3188,7 +3188,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3200,7 +3200,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3213,7 +3213,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3235,7 +3235,7 @@ exy fxy gxy ] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> @@ -3246,7 +3246,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3258,7 +3258,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3271,7 +3271,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 24b66e0d..a50eacb9 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -45,90 +45,90 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:&:programming-environment-data<span class="Special"> <- </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> ] <span class="muData">container</span> programming-environment-data [ - recipes:address:editor-data - current-sandbox:address:editor-data - sandbox-in-focus?:boolean <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> + recipes:&:editor-data + current-sandbox:&:editor-data + sandbox-in-focus?:bool <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> ] -<span class="muRecipe">def</span> new-programming-environment screen:address:screen, initial-recipe-contents:text, initial-sandbox-contents:text<span class="muRecipe"> -> </span>result:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">def</span> new-programming-environment screen:&:screen, initial-recipe-contents:text, initial-sandbox-contents:text<span class="muRecipe"> -> </span>result:&:programming-environment-data, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - width:number<span class="Special"> <- </span>screen-width screen - height:number<span class="Special"> <- </span>screen-height screen + width:num<span class="Special"> <- </span>screen-width screen + height:num<span class="Special"> <- </span>screen-height screen <span class="Comment"># top menu</span> result<span class="Special"> <- </span>new <span class="Constant">programming-environment-data: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:number<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> - button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> + button-start:num<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> + button-on-screen?:bool<span class="Special"> <- </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"> <- </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:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> + divider:num, _<span class="Special"> <- </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:address:editor-data<span class="Special"> <- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right + recipes:&:editor-data<span class="Special"> <- </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:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, sandbox-left, width/right + sandbox-left:num<span class="Special"> <- </span>add divider, <span class="Constant">1</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, sandbox-left, width/right *result<span class="Special"> <- </span>put *result, <span class="Constant">recipes:offset</span>, recipes *result<span class="Special"> <- </span>put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox *result<span class="Special"> <- </span>put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> <span class="Constant"> <programming-environment-initialization></span> ] -<span class="muRecipe">def</span> event-loop screen:address:screen, console:address:console, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, console:address:console, env:address:programming-environment-data [ +<span class="muRecipe">def</span> event-loop screen:&:screen, console:&:console, env:&:programming-environment-data<span class="muRecipe"> -> </span>screen:&:screen, console:&:console, env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + recipes:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + render-all-on-no-more-events?:bool<span class="Special"> <- </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, console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console + e:event, console, found?:bool, quit?:bool<span class="Special"> <- </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> <span class="Constant"> <handle-event></span> <span class="Comment"># check for global events that will trigger regardless of which editor has focus</span> <span class="Delimiter">{</span> - k:number, is-keycode?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + k:num, is-keycode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> <span class="muControl">break-unless</span> is-keycode? <span class="Constant"> <global-keypress></span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - c:character, is-unicode?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">text:variant</span> + c:char, is-unicode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">text:variant</span> <span class="muControl">break-unless</span> is-unicode? <span class="Constant"> <global-type></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?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">touch:variant</span> + t:touch-event, is-touch?:bool<span class="Special"> <- </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:number<span class="Special"> <- </span>get t, <span class="Constant">type:offset</span> - is-left-click?:boolean<span class="Special"> <- </span>equal touch-type, <span class="Constant">65513/mouse-left</span> + touch-type:num<span class="Special"> <- </span>get t, <span class="Constant">type:offset</span> + is-left-click?:bool<span class="Special"> <- </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:label</span> - click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - click-column:number<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> + click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> + click-column:num<span class="Special"> <- </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"> <global-touch></span> <span class="Comment"># send to both editors</span> _<span class="Special"> <- </span>move-cursor-in-editor screen, recipes, t - sandbox-in-focus?:boolean<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, t + sandbox-in-focus?:bool<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, t *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> @@ -136,10 +136,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">resize:variant</span> + r:resize-event, is-resize?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>has-more-events? console + more-events?:bool<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> @@ -155,13 +155,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>handle-keyboard-event screen, recipes, e:event + screen, recipes, render?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>has-more-events? console + more-events?:bool<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> @@ -186,10 +186,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - screen, current-sandbox, render?:boolean<span class="Special"> <- </span>handle-keyboard-event screen, current-sandbox, e:event + screen, current-sandbox, render?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>has-more-events? console + more-events?:bool<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> @@ -220,24 +220,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> resize screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">def</span> resize screen:&:screen, env:&:programming-environment-data<span class="muRecipe"> -> </span>env:&:programming-environment-data, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> clear-screen screen <span class="Comment"># update screen dimensions</span> - width:number<span class="Special"> <- </span>screen-width screen - divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> + width:num<span class="Special"> <- </span>screen-width screen + divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> <span class="Comment"># update recipe editor</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - right:number<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> + recipes:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + right:num<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> *recipes<span class="Special"> <- </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"> <- </span>put *recipes, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">cursor-column:offset</span>, <span class="Constant">0</span> <span class="Comment"># update sandbox editor</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + left:num<span class="Special"> <- </span>add divider, <span class="Constant">1</span> *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">left:offset</span>, left - right:number<span class="Special"> <- </span>subtract width, <span class="Constant">1</span> + right:num<span class="Special"> <- </span>subtract width, <span class="Constant">1</span> *current-sandbox<span class="Special"> <- </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"> <- </span>put *current-sandbox, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> @@ -247,49 +247,49 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># Variant of 'render' that updates cursor-row and cursor-column based on</span> <span class="Comment"># before-cursor (rather than the other way around). If before-cursor moves</span> <span class="Comment"># off-screen, it resets cursor-row and cursor-column.</span> -<span class="muRecipe">def</span> render-without-moving-cursor screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +<span class="muRecipe">def</span> render-without-moving-cursor screen:&:screen, editor:&:editor-data<span class="muRecipe"> -> </span>last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ <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:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - screen-height:number<span class="Special"> <- </span>screen-height screen - right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list:character<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + screen-height:num<span class="Special"> <- </span>screen-height screen + right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> curr<span class="Special"> <- </span>next curr <span class="Constant"> +render-loop-initialization</span> - color:number<span class="Special"> <- </span>copy <span class="Constant">7/white</span> - row:number<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:number<span class="Special"> <- </span>copy left + color:num<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> + column:num<span class="Special"> <- </span>copy left <span class="Comment"># save before-cursor</span> - old-before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + old-before-cursor:&:duplex-list:char<span class="Special"> <- </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"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, row *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, column - top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, top-of-screen screen<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool<span class="Special"> <- </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-data.cursor-row and editor-data.cursor-column based on</span> <span class="Comment"># old-before-cursor</span> <span class="Delimiter">{</span> - at-cursor?:boolean<span class="Special"> <- </span>equal old-before-cursor, prev + at-cursor?:bool<span class="Special"> <- </span>equal old-before-cursor, prev <span class="muControl">break-unless</span> at-cursor? *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, row *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, column *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, old-before-cursor <span class="Delimiter">}</span> - c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> <span class="Constant"> <character-c-received></span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </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 @@ -304,10 +304,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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?:boolean<span class="Special"> <- </span>equal column, right + at-right?:bool<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char<span class="Special"> <- </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"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -334,7 +334,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize both halves of screen</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -342,11 +342,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># check cursor column in each</span> run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:&:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:programming-environment-data, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">4</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:&:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:programming-environment-data, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:num<span class="Special"> <- </span>get *<span class="Constant">6</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -360,8 +360,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize both halves of screen</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, 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> @@ -370,11 +370,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:&:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:programming-environment-data, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">4</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:&:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:programming-environment-data, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:num<span class="Special"> <- </span>get *<span class="Constant">6</span>:&:editor-data, <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> @@ -388,8 +388,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># show the cursor at the right window</span> run [ - <span class="Constant">8</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">8</span>:character/cursor + <span class="Constant">8</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">8</span>:char/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -405,8 +405,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render ] <span class="Comment"># divider isn't messed up</span> screen-should-contain [ @@ -423,14 +423,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># is cursor at the right place?</span> screen-should-contain [ @@ -444,9 +444,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[z]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># cursor should still be right</span> screen-should-contain [ @@ -464,8 +464,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊abc .</span> @@ -479,9 +479,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># cursor moves to end of old line</span> screen-should-contain [ @@ -492,47 +492,47 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> render-all screen:address:screen, env:address:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ +<span class="muRecipe">def</span> render-all screen:&:screen, env:&:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:programming-environment-data [ <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> 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:number<span class="Special"> <- </span>screen-width screen + width:num<span class="Special"> <- </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:number<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> - button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> + button-start:num<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> + button-on-screen?:bool<span class="Special"> <- </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"> <- </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:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> - height:number<span class="Special"> <- </span>screen-height screen + divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> + height:num<span class="Special"> <- </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"> <- </span>render-recipes screen, env, render-editor screen<span class="Special"> <- </span>render-sandbox-side screen, env, render-editor <span class="Constant"> <render-components-end></span> <span class="Comment">#</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + recipes:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:bool<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment">#</span> show-screen screen ] -<span class="muRecipe">def</span> render-recipes screen:address:screen, env:address:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ +<span class="muRecipe">def</span> render-recipes screen:&:screen, env:&:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:programming-environment-data [ <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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> <span class="Comment"># render recipes</span> - left:number<span class="Special"> <- </span>get *recipes, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *recipes, <span class="Constant">right:offset</span> - row:number, column:number, screen<span class="Special"> <- </span>call render-editor, screen, recipes + left:num<span class="Special"> <- </span>get *recipes, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *recipes, <span class="Constant">right:offset</span> + row:num, column:num, screen<span class="Special"> <- </span>call render-editor, screen, recipes clear-line-until screen, right row<span class="Special"> <- </span>add row, <span class="Constant">1</span> <span class="Constant"> <render-recipe-components-end></span> @@ -543,13 +543,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">def</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ +<span class="muRecipe">def</span> render-sandbox-side screen:&:screen, env:&:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> - row:number, column:number, screen, current-sandbox<span class="Special"> <- </span>call render-editor, screen, current-sandbox + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + left:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> + row:num, column:num, screen, current-sandbox<span class="Special"> <- </span>call render-editor, screen, current-sandbox clear-line-until screen, right row<span class="Special"> <- </span>add row, <span class="Constant">1</span> <span class="Comment"># draw solid line after code (you'll see why in later layers)</span> @@ -558,48 +558,48 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color clear-screen-from screen, row, left, left, right ] -<span class="muRecipe">def</span> update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> update-cursor screen:&:screen, recipes:&:editor-data, current-sandbox:&:editor-data, sandbox-in-focus?:bool, env:&:programming-environment-data<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Constant"> <update-cursor-special-cases></span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - cursor-row:number<span class="Special"> <- </span>get *recipes, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *recipes, <span class="Constant">cursor-column:offset</span> + cursor-row:num<span class="Special"> <- </span>get *recipes, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </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:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-column:offset</span> + cursor-row:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">}</span> screen<span class="Special"> <- </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> -<span class="muRecipe">def</span> render-code screen:address:screen, s:text, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">def</span> render-code screen:&:screen, s:text, left:num, right:num, row:num<span class="muRecipe"> -> </span>row:num, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - color:number<span class="Special"> <- </span>copy <span class="Constant">7/white</span> - column:number<span class="Special"> <- </span>copy left + color:num<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + column:num<span class="Special"> <- </span>copy left screen<span class="Special"> <- </span>move-cursor screen, row, column - screen-height:number<span class="Special"> <- </span>screen-height screen - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:number<span class="Special"> <- </span>length *s + screen-height:num<span class="Special"> <- </span>screen-height screen + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + len:num<span class="Special"> <- </span>length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? done?<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>index *s, i + c:char<span class="Special"> <- </span>index *s, i <span class="Constant"><character-c-received></span> <span class="Comment"># only line different from render</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:boolean<span class="Special"> <- </span>equal column, right + at-right?:bool<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char<span class="Special"> <- </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"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -609,13 +609,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color i<span class="Special"> <- </span>add i, <span class="Constant">1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-than column, right + done?:bool<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> print screen, space column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> @@ -629,7 +629,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:boolean<span class="Special"> <- </span>equal column, left + was-at-left?:bool<span class="Special"> <- </span>equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? @@ -642,9 +642,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> - redraw-screen?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">12/ctrl-l</span> + redraw-screen?:bool<span class="Special"> <- </span>equal c, <span class="Constant">12/ctrl-l</span> <span class="muControl">break-unless</span> redraw-screen? - screen<span class="Special"> <- </span>render-all screen, env:address:programming-environment-data, render + screen<span class="Special"> <- </span>render-all screen, env:&:programming-environment-data, render sync-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> @@ -655,9 +655,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> - switch-side?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">14/ctrl-n</span> + switch-side?:bool<span class="Special"> <- </span>equal c, <span class="Constant">14/ctrl-n</span> <span class="muControl">break-unless</span> switch-side? - sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus?:bool<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> sandbox-in-focus?<span class="Special"> <- </span>not sandbox-in-focus? *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env @@ -667,22 +667,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## helpers</span> -<span class="muRecipe">def</span> draw-vertical screen:address:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> draw-vertical screen:&:screen, col:num, y:num, bottom:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? style<span class="Special"> <- </span>copy <span class="Constant">9474/vertical</span> <span class="Delimiter">}</span> - color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool<span class="Special"> <- </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"> <- </span>copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - continue?:boolean<span class="Special"> <- </span>lesser-than y, bottom + continue?:bool<span class="Special"> <- </span>lesser-than y, bottom <span class="muControl">break-unless</span> continue? screen<span class="Special"> <- </span>move-cursor screen, y, col print screen, style, color diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 47a291e5..b6585eda 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -48,7 +48,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox env<span class="Special"> <- </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 @@ -56,9 +56,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> programming-environment-data [ - sandbox:address:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> - render-from:number - number-of-sandboxes:number + sandbox:&:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> + render-from:num + number-of-sandboxes:num ] <span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ @@ -70,10 +70,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color response:text <span class="Comment"># coordinates to track clicks</span> <span class="Comment"># constraint: will be 0 for sandboxes at positions before env.render-from</span> - starting-row-on-screen:number - code-ending-row-on-screen:number <span class="Comment"># past end of code</span> - screen:address:screen <span class="Comment"># prints in the sandbox go here</span> - next-sandbox:address:sandbox-data + starting-row-on-screen:num + code-ending-row-on-screen:num <span class="Comment"># past end of code</span> + screen:&:screen <span class="Comment"># prints in the sandbox go here</span> + next-sandbox:&:sandbox-data ] <span class="muScenario">scenario</span> run-and-show-results [ @@ -83,13 +83,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ @@ -139,7 +139,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ @@ -162,10 +162,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Comment"># F4? load all code and run all sandboxes.</span> <span class="Delimiter">{</span> - do-run?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65532/F4</span> + do-run?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> - error?:boolean, env, screen<span class="Special"> <- </span>run-sandboxes env, screen + error?:bool, env, screen<span class="Special"> <- </span>run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> screen<span class="Special"> <- </span>render-all screen, env, render <span class="Delimiter">{</span> @@ -177,39 +177,39 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> run-sandboxes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">def</span> run-sandboxes env:&:programming-environment-data, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - errors-found?:boolean, env, screen<span class="Special"> <- </span>update-recipes env, screen + errors-found?:bool, env, screen<span class="Special"> <- </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"> <run-sandboxes-begin></span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> sandbox-contents:text<span class="Special"> <- </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-data</span> - new-sandbox:address:sandbox-data<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> + new-sandbox:&:sandbox-data<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> *new-sandbox<span class="Special"> <- </span>put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents <span class="Comment"># push to head of sandbox list</span> - dest:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + dest:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> *new-sandbox<span class="Special"> <- </span>put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox:offset</span>, new-sandbox <span class="Comment"># update sandbox count</span> - sandbox-count:number<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> sandbox-count<span class="Special"> <- </span>add sandbox-count, <span class="Constant">1</span> *env<span class="Special"> <- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count <span class="Comment"># clear sandbox editor</span> - init:address:duplex-list:character<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> + init:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">data:offset</span>, init *current-sandbox<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr curr<span class="Special"> <- </span>update-sandbox curr, env, idx @@ -222,10 +222,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># copy code from recipe editor, persist, load into mu</span> <span class="Comment"># replaced in a later layer (whereupon errors-found? will actually be set)</span> -<span class="muRecipe">def</span> update-recipes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">def</span> update-recipes env:&:programming-environment-data, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> in:text<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in @@ -233,30 +233,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">def!</span> update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data, env:address:programming-environment-data [ +<span class="muRecipe">def!</span> update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox-data, env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:address:screen<span class="Special"> <- </span>run-sandboxed data + response:text, _, fake-screen:&:screen<span class="Special"> <- </span>run-sandboxed data *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen ] -<span class="muRecipe">def</span> update-status screen:address:screen, msg:text, color:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> update-status screen:&:screen, msg:text, color:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span> screen<span class="Special"> <- </span>print screen, msg, color, <span class="Constant">238/grey/background</span> ] -<span class="muRecipe">def</span> save-sandboxes env:address:programming-environment-data [ +<span class="muRecipe">def</span> save-sandboxes env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </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>* >/dev/null <span class="Constant">2</span>>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> - curr:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr data:text<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> @@ -269,18 +269,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def!</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ +<span class="muRecipe">def!</span> render-sandbox-side screen:&:screen, env:&:programming-environment-data, <span class="Delimiter">{</span>render-editor: (<span class="muRecipe">recipe</span> (address screen) (address editor-data)<span class="muRecipe"> -> </span>number number (address screen) (address editor-data))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:programming-environment-data [ <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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - row:number, column:number<span class="Special"> <- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span> - left:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + row:num, column:num<span class="Special"> <- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span> + left:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + right:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> <span class="Comment"># render sandbox editor</span> - render-from:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> <span class="Delimiter">{</span> - render-current-sandbox?:boolean<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + render-current-sandbox?:bool<span class="Special"> <- </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"> <- </span>call render-editor, screen, current-sandbox clear-screen-from screen, row, column, left, right @@ -288,19 +288,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Comment"># render sandboxes</span> draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + sandbox:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> row, screen<span class="Special"> <- </span>render-sandboxes screen, sandbox, left, right, row, render-from clear-rest-of-screen screen, row, left, right ] -<span class="muRecipe">def</span> render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number<span class="muRecipe"> -> </span>row:number, screen:address:screen, sandbox:address:sandbox-data [ +<span class="muRecipe">def</span> render-sandboxes screen:&:screen, sandbox:&:sandbox-data, left:num, right:num, row:num, render-from:num, idx:num<span class="muRecipe"> -> </span>row:num, screen:&:screen, sandbox:&:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox - screen-height:number<span class="Special"> <- </span>screen-height screen - at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height - <span class="muControl">return-if</span> at-bottom?:boolean - hidden?:boolean<span class="Special"> <- </span>lesser-than idx, render-from + screen-height:num<span class="Special"> <- </span>screen-height screen + at-bottom?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + <span class="muControl">return-if</span> at-bottom?:bool + hidden?:bool<span class="Special"> <- </span>lesser-than idx, render-from <span class="Delimiter">{</span> <span class="muControl">break-if</span> hidden? <span class="Comment"># render sandbox menu</span> @@ -319,8 +319,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sandbox-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> <span class="Constant"> <render-sandbox-results></span> <span class="Delimiter">{</span> - sandbox-screen:address:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> - empty-screen?:boolean<span class="Special"> <- </span>fake-screen-is-empty? sandbox-screen + sandbox-screen:&:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> + empty-screen?:bool<span class="Special"> <- </span>fake-screen-is-empty? sandbox-screen <span class="muControl">break-if</span> empty-screen? row, screen<span class="Special"> <- </span>render-screen screen, sandbox-screen, left, right, row <span class="Delimiter">}</span> @@ -330,7 +330,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color row, screen<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height + at-bottom?:bool<span class="Special"> <- </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, <span class="Constant">9473/horizontal-double</span> @@ -343,28 +343,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <end-render-sandbox-reset-hidden></span> <span class="Delimiter">}</span> <span class="Comment"># draw next sandbox</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> - next-idx:number<span class="Special"> <- </span>add idx, <span class="Constant">1</span> + next-sandbox:&:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-idx:num<span class="Special"> <- </span>add idx, <span class="Constant">1</span> row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] -<span class="muRecipe">def</span> render-sandbox-menu screen:address:screen, sandbox-index:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> move-cursor-to-column screen, left - edit-button-left:number, edit-button-right:number, copy-button-left:number, copy-button-right:number, delete-button-left:number<span class="Special"> <- </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"> <- </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:number<span class="Special"> <- </span>subtract edit-button-left, <span class="Constant">1</span> + start-buttons:num<span class="Special"> <- </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:number<span class="Special"> <- </span>cursor-position screen - at-start-of-copy-button?:boolean<span class="Special"> <- </span>equal col, copy-button-left + _, col:num<span class="Special"> <- </span>cursor-position screen + at-start-of-copy-button?:bool<span class="Special"> <- </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:number<span class="Special"> <- </span>cursor-position screen - at-start-of-delete-button?:boolean<span class="Special"> <- </span>equal col, delete-button-left + _, col:num<span class="Special"> <- </span>cursor-position screen + at-start-of-delete-button?:bool<span class="Special"> <- </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> @@ -373,45 +373,45 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons</span> <span class="Comment"># delete-button-right == right</span> <span class="Comment"># all left/right pairs are inclusive</span> -<span class="muRecipe">def</span> sandbox-menu-columns left:number, right:number<span class="muRecipe"> -> </span>edit-button-left:number, edit-button-right:number, copy-button-left:number, copy-button-right:number, delete-button-left:number [ +<span class="muRecipe">def</span> sandbox-menu-columns left:num, right:num<span class="muRecipe"> -> </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:number<span class="Special"> <- </span>add left, <span class="Constant">4/space-for-sandbox-index</span> - buttons-space:number<span class="Special"> <- </span>subtract right, start-buttons - button-width:number<span class="Special"> <- </span>divide-with-remainder buttons-space, <span class="Constant">3</span> <span class="Comment"># integer division</span> - buttons-wide-enough?:boolean<span class="Special"> <- </span>greater-or-equal button-width, <span class="Constant">8</span> + start-buttons:num<span class="Special"> <- </span>add left, <span class="Constant">4/space-for-sandbox-index</span> + buttons-space:num<span class="Special"> <- </span>subtract right, start-buttons + button-width:num<span class="Special"> <- </span>divide-with-remainder buttons-space, <span class="Constant">3</span> <span class="Comment"># integer division</span> + buttons-wide-enough?:bool<span class="Special"> <- </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:number<span class="Special"> <- </span>copy start-buttons - copy-button-left:number<span class="Special"> <- </span>add start-buttons, button-width - edit-button-right:number<span class="Special"> <- </span>subtract copy-button-left, <span class="Constant">1</span> - delete-button-left:number<span class="Special"> <- </span>subtract right, button-width - copy-button-right:number<span class="Special"> <- </span>subtract delete-button-left, <span class="Constant">1</span> + edit-button-left:num<span class="Special"> <- </span>copy start-buttons + copy-button-left:num<span class="Special"> <- </span>add start-buttons, button-width + edit-button-right:num<span class="Special"> <- </span>subtract copy-button-left, <span class="Constant">1</span> + delete-button-left:num<span class="Special"> <- </span>subtract right, button-width + copy-button-right:num<span class="Special"> <- </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> <span class="Comment"># clear rest of last line, move cursor to next line</span> -<span class="muRecipe">def</span> render-text screen:address:screen, s:text, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">def</span> render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num<span class="muRecipe"> -> </span>row:num, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - column:number<span class="Special"> <- </span>copy left + column:num<span class="Special"> <- </span>copy left screen<span class="Special"> <- </span>move-cursor screen, row, column - screen-height:number<span class="Special"> <- </span>screen-height screen - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:number<span class="Special"> <- </span>length *s + screen-height:num<span class="Special"> <- </span>screen-height screen + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + len:num<span class="Special"> <- </span>length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? done?<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>index *s, i + c:char<span class="Special"> <- </span>index *s, i <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:boolean<span class="Special"> <- </span>equal column, right + at-right?:bool<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:character<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char<span class="Special"> <- </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"> <- </span>copy left row<span class="Special"> <- </span>add row, <span class="Constant">1</span> @@ -421,13 +421,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color i<span class="Special"> <- </span>add i, <span class="Constant">1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-than column, right + done?:bool<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> print screen, space column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> @@ -441,7 +441,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:boolean<span class="Special"> <- </span>equal column, left + was-at-left?:bool<span class="Special"> <- </span>equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? @@ -451,13 +451,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># assumes programming environment has no sandboxes; restores them from previous session</span> -<span class="muRecipe">def</span> restore-sandboxes env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data [ +<span class="muRecipe">def</span> restore-sandboxes env:&:programming-environment-data<span class="muRecipe"> -> </span>env:&:programming-environment-data [ <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:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:address:sandbox-data<span class="Special"> <- </span>copy <span class="Constant">0</span> - prev:address:sandbox-data<span class="Special"> <- </span>copy <span class="Constant">0</span> + idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr:&:sandbox-data<span class="Special"> <- </span>copy <span class="Constant">0</span> + prev:&:sandbox-data<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> filename:text<span class="Special"> <- </span>to-text idx contents:text<span class="Special"> <- </span>restore filename @@ -485,7 +485,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># print the fake sandbox screen to 'screen' with appropriate delimiters</span> <span class="Comment"># leave cursor at start of next line</span> -<span class="muRecipe">def</span> render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">def</span> render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num<span class="muRecipe"> -> </span>row:num, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox-screen @@ -493,39 +493,39 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color row<span class="Special"> <- </span>render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row screen<span class="Special"> <- </span>move-cursor screen, row, left <span class="Comment"># start printing sandbox-screen</span> - column:number<span class="Special"> <- </span>copy left - s-width:number<span class="Special"> <- </span>screen-width sandbox-screen - s-height:number<span class="Special"> <- </span>screen-height sandbox-screen - buf:address:array:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> - stop-printing:number<span class="Special"> <- </span>add left, s-width, <span class="Constant">3</span> - max-column:number<span class="Special"> <- </span>min stop-printing, right - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:number<span class="Special"> <- </span>length *buf - screen-height:number<span class="Special"> <- </span>screen-height screen + column:num<span class="Special"> <- </span>copy left + s-width:num<span class="Special"> <- </span>screen-width sandbox-screen + s-height:num<span class="Special"> <- </span>screen-height sandbox-screen + buf:&:@:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> + stop-printing:num<span class="Special"> <- </span>add left, s-width, <span class="Constant">3</span> + max-column:num<span class="Special"> <- </span>min stop-printing, right + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + len:num<span class="Special"> <- </span>length *buf + screen-height:num<span class="Special"> <- </span>screen-height screen <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? done?<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> done? column<span class="Special"> <- </span>copy left screen<span class="Special"> <- </span>move-cursor screen, row, column <span class="Comment"># initial leader for each row: two spaces and a '.'</span> - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char<span class="Special"> <- </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:character<span class="Special"> <- </span>copy <span class="Constant">46/period</span> + full-stop:char<span class="Special"> <- </span>copy <span class="Constant">46/period</span> print screen, full-stop, <span class="Constant">245/grey</span> column<span class="Special"> <- </span>add left, <span class="Constant">3</span> <span class="Delimiter">{</span> <span class="Comment"># print row</span> - row-done?:boolean<span class="Special"> <- </span>greater-or-equal column, max-column + row-done?:bool<span class="Special"> <- </span>greater-or-equal column, max-column <span class="muControl">break-if</span> row-done? curr:screen-cell<span class="Special"> <- </span>index *buf, i - c:character<span class="Special"> <- </span>get curr, <span class="Constant">contents:offset</span> - color:number<span class="Special"> <- </span>get curr, <span class="Constant">color:offset</span> + c:char<span class="Special"> <- </span>get curr, <span class="Constant">contents:offset</span> + color:num<span class="Special"> <- </span>get curr, <span class="Constant">color:offset</span> <span class="Delimiter">{</span> <span class="Comment"># damp whites down to grey</span> - white?:boolean<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> + white?:bool<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> <span class="muControl">break-unless</span> white? color<span class="Special"> <- </span>copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> @@ -539,7 +539,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="Delimiter">{</span> <span class="Comment"># clear rest of current line</span> - line-done?:boolean<span class="Special"> <- </span>greater-than column, right + line-done?:bool<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> line-done? print screen, space column<span class="Special"> <- </span>add column, <span class="Constant">1</span> @@ -557,23 +557,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">local-scope</span> -<span class="Constant">z:number <- add 2, 2</span> +<span class="Constant">z:num <- 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> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .local-scope ┊0 edit copy delete .</span> - <span class="Constant"> .z:number <- add 2, 2 ┊foo .</span> + <span class="Constant"> .z:num <- add 2, 2 ┊foo .</span> <span class="Constant"> .reply z ┊4 .</span> <span class="Constant"> .] ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> @@ -587,7 +587,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># check that screen updates the result on the right</span> screen-should-contain [ @@ -595,7 +595,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .local-scope ┊0 edit copy delete .</span> - <span class="Constant"> .z:number <- add 2, 3 ┊foo .</span> + <span class="Constant"> .z:num <- add 2, 3 ┊foo .</span> <span class="Constant"> .reply z ┊5 .</span> <span class="Constant"> .] ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> @@ -610,13 +610,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editor</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># check that it prints a little toy screen</span> screen-should-contain [ @@ -636,18 +636,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> editor-contents editor:address:editor-data<span class="muRecipe"> -> </span>result:text [ +<span class="muRecipe">def</span> editor-contents editor:&:editor-data<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> - curr:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> + curr:&:duplex-list:char<span class="Special"> <- </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"> <- </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:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> buf<span class="Special"> <- </span>append buf, c curr<span class="Special"> <- </span>next curr <span class="muControl">loop</span> @@ -658,15 +658,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-provides-edited-contents [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> type <span class="Constant">[def]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:text<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:address:editor-data - <span class="Constant">4</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:text + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:text<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:&:editor-data + <span class="Constant">4</span>:@:char<span class="Special"> <- </span>copy *<span class="Constant">3</span>:text ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> @@ -679,13 +679,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> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter press down-arrow ] - event-loop screen, console:address:console, env + event-loop screen, console:&:console, env <span class="Comment"># no scroll</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -700,16 +700,16 @@ 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:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter press up-arrow press down-arrow <span class="Comment"># while cursor isn't at bottom</span> ] - event-loop screen, console:address:console, env - cursor:character<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, cursor + event-loop screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor <span class="Comment"># cursor moves back to bottom</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -724,7 +724,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># layers will add other stuff to the left side below the editor (error messages)</span> <span class="muData">container</span> programming-environment-data [ - recipe-bottom:number + recipe-bottom:num ] <span class="muRecipe">after</span> <span class="Constant"><render-recipe-components-end></span> [ @@ -734,22 +734,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - down-arrow?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> + down-arrow?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> down-arrow? - recipe-editor:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - recipe-cursor-row:number<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">cursor-row:offset</span> - recipe-editor-bottom:number<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">bottom:offset</span> - at-bottom-of-editor?:boolean<span class="Special"> <- </span>greater-or-equal recipe-cursor-row, recipe-editor-bottom + recipe-editor:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipe-cursor-row:num<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">cursor-row:offset</span> + recipe-editor-bottom:num<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">bottom:offset</span> + at-bottom-of-editor?:bool<span class="Special"> <- </span>greater-or-equal recipe-cursor-row, recipe-editor-bottom <span class="muControl">break-unless</span> at-bottom-of-editor? - more-to-scroll?:boolean<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool<span class="Special"> <- </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:label</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:boolean<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool<span class="Special"> <- </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:label</span> <span class="Delimiter">}</span> @@ -758,19 +758,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">6/ctrl-f</span> + page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:boolean<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool<span class="Special"> <- </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:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> more-to-scroll? env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> more-to-scroll? env:&:programming-environment-data, screen:&:screen<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipe-bottom:number<span class="Special"> <- </span>get *env, <span class="Constant">recipe-bottom:offset</span> - height:number<span class="Special"> <- </span>screen-height screen + recipe-bottom:num<span class="Special"> <- </span>get *env, <span class="Constant">recipe-bottom:offset</span> + height:num<span class="Special"> <- </span>screen-height screen result<span class="Special"> <- </span>greater-or-equal recipe-bottom, height ] @@ -778,7 +778,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:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ <span class="Comment"># add a line</span> @@ -788,7 +788,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># try to scroll</span> press page-down <span class="Comment"># or ctrl-f</span> ] - event-loop screen, console:address:console, env + event-loop screen, console:&:console, env <span class="Comment"># no scroll, and cursor remains at top line</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -803,7 +803,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:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> + env:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> <span class="Constant">cd]</span> render-all screen, env, render assume-console [ @@ -814,9 +814,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># move cursor</span> press down-arrow ] - event-loop screen, console:address:console, env - cursor:character<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, cursor + event-loop screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor <span class="Comment"># no scroll on recipe side, cursor moves on sandbox side</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -835,13 +835,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize sandbox side</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render assume-console [ <span class="Comment"># create a sandbox</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -855,9 +855,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -873,9 +873,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># sandbox editor displays again, cursor is in editor</span> screen-should-contain [ @@ -891,16 +891,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-down?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + sandbox:&:sandbox-data<span class="Special"> <- </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:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - number-of-sandboxes:number<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - max:number<span class="Special"> <- </span>subtract number-of-sandboxes, <span class="Constant">1</span> - at-end?:boolean<span class="Special"> <- </span>greater-or-equal render-from, max + render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + number-of-sandboxes:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> + max:num<span class="Special"> <- </span>subtract number-of-sandboxes, <span class="Constant">1</span> + at-end?:bool<span class="Special"> <- </span>greater-or-equal render-from, max <span class="muControl">jump-if</span> at-end?, <span class="Constant">+finish-event:label</span> <span class="Comment"># render nothing</span> render-from<span class="Special"> <- </span>add render-from, <span class="Constant">1</span> *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, render-from @@ -916,10 +916,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><update-cursor-special-cases></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - render-from:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - scrolling?:boolean<span class="Special"> <- </span>greater-or-equal render-from, <span class="Constant">0</span> + render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + scrolling?:bool<span class="Special"> <- </span>greater-or-equal render-from, <span class="Constant">0</span> <span class="muControl">break-unless</span> scrolling? - cursor-column:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + cursor-column:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> screen<span class="Special"> <- </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> @@ -929,10 +929,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-up?:boolean<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - render-from:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - at-beginning?:boolean<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + at-beginning?:bool<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> <span class="muControl">break-if</span> at-beginning? render-from<span class="Special"> <- </span>subtract render-from, <span class="Constant">1</span> *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, render-from @@ -945,15 +945,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># sandbox belonging to 'env' whose next-sandbox is 'in'</span> <span class="Comment"># return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox</span> -<span class="muRecipe">def</span> previous-sandbox env:address:programming-environment-data, in:address:sandbox-data<span class="muRecipe"> -> </span>out:address:sandbox-data [ +<span class="muRecipe">def</span> previous-sandbox env:&:programming-environment-data, in:&:sandbox-data<span class="muRecipe"> -> </span>out:&:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + curr:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">return-unless</span> curr, <span class="Constant">0/nil</span> - next:address:sandbox-data<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + next:&:sandbox-data<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal next, in + found?:bool<span class="Special"> <- </span>equal next, in <span class="muControl">break-if</span> found? curr<span class="Special"> <- </span>copy next next<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> @@ -970,20 +970,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">]</span> <span class="Comment"># create a sandbox</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data <span class="Comment"># hit 'down' in recipe editor</span> assume-console [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># cursor moves down on recipe side</span> screen-should-contain [ @@ -1001,8 +1001,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n @@ -1011,9 +1011,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊␣ .</span> @@ -1031,9 +1031,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -1053,7 +1053,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># just second sandbox displayed</span> screen-should-contain [ @@ -1070,7 +1070,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># no change</span> screen-should-contain [ @@ -1087,7 +1087,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># back to displaying both sandboxes without editor</span> screen-should-contain [ @@ -1106,9 +1106,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> screen-should-contain [ @@ -1128,9 +1128,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] <span class="Comment"># no change</span> screen-should-contain [ @@ -1153,15 +1153,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create a sandbox</span> assume-console [ press ctrl-n type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -1177,7 +1177,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -1195,7 +1195,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> screen-should-contain [ @@ -1213,7 +1213,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index fe86e811..987f38f9 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -48,8 +48,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">69</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># it copies into editor</span> screen-should-contain [ @@ -83,7 +83,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -110,8 +110,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -127,7 +127,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">84</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># it copies into editor</span> screen-should-contain [ @@ -145,7 +145,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -162,7 +162,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'copy' button</span> <span class="Delimiter">{</span> - copy?:boolean<span class="Special"> <- </span>should-attempt-copy? click-row, click-column, env + copy?:bool<span class="Special"> <- </span>should-attempt-copy? click-row, click-column, env <span class="muControl">break-unless</span> copy? copy?, env<span class="Special"> <- </span>try-copy-sandbox click-row, env <span class="muControl">break-unless</span> copy? @@ -175,34 +175,34 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># some preconditions for attempting to copy a sandbox</span> -<span class="muRecipe">def</span> should-attempt-copy? click-row:number, click-column:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> should-attempt-copy? click-row:num, click-column:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>result:bool [ <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?:boolean<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool<span class="Special"> <- </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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - _, _, copy-button-left:number, copy-button-right:number, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - copy-button-vertical-area?:boolean<span class="Special"> <- </span>within-range? click-column, copy-button-left, copy-button-right + sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> + _, _, copy-button-left:num, copy-button-right:num, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + copy-button-vertical-area?:bool<span class="Special"> <- </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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> result<span class="Special"> <- </span>empty-editor? current-sandbox ] -<span class="muRecipe">def</span> try-copy-sandbox click-row:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-copy-button?:boolean, env:address:programming-environment-data [ +<span class="muRecipe">def</span> try-copy-sandbox click-row:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-copy-button?:bool, env:&:programming-environment-data [ <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:address:sandbox-data<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox-data<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1/true</span> text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text <span class="Comment"># reset scroll</span> *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> @@ -210,14 +210,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *env<span class="Special"> <- </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:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>result:address:sandbox-data [ +<span class="muRecipe">def</span> find-sandbox env:&:programming-environment-data, click-row:num<span class="muRecipe"> -> </span>result:&:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + curr-sandbox:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr-sandbox - start:number<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:boolean<span class="Special"> <- </span>equal click-row, start + start:num<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool<span class="Special"> <- </span>equal click-row, start <span class="muControl">return-if</span> found?, curr-sandbox curr-sandbox<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> @@ -225,32 +225,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Constant">0/not-found</span> ] -<span class="muRecipe">def</span> click-on-sandbox-area? click-row:number, click-column:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> click-on-sandbox-area? click-row:num, click-column:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - on-sandbox-side?:boolean<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-left-margin:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + on-sandbox-side?:bool<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&:sandbox-data<span class="Special"> <- </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:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + first-sandbox-begins:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> result<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins ] -<span class="muRecipe">def</span> empty-editor? editor:address:editor-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> empty-editor? editor:&:editor-data<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - head:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - first:address:duplex-list:character<span class="Special"> <- </span>next head + head:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + first:&:duplex-list:char<span class="Special"> <- </span>next head result<span class="Special"> <- </span>not first ] -<span class="muRecipe">def</span> within-range? x:number, low:number, high:number<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> within-range? x:num, low:num, high:num<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - not-too-far-left?:boolean<span class="Special"> <- </span>greater-or-equal x, low - not-too-far-right?:boolean<span class="Special"> <- </span>lesser-or-equal x, high + not-too-far-left?:bool<span class="Special"> <- </span>greater-or-equal x, low + not-too-far-right?:bool<span class="Special"> <- </span>lesser-or-equal x, high result<span class="Special"> <- </span>and not-too-far-left? not-too-far-right? ] @@ -267,8 +267,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -286,7 +286,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">70</span> <span class="Comment"># click 'copy' button</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># copy doesn't happen</span> screen-should-contain [ @@ -304,7 +304,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 94ca6a6c..668faca9 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -39,7 +39,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="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run a few commands</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -48,7 +48,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 2, 2]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -69,7 +69,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">7</span>, <span class="Constant">85</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -87,7 +87,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">99</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -101,7 +101,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'delete' button</span> <span class="Delimiter">{</span> - delete?:boolean<span class="Special"> <- </span>should-attempt-delete? click-row, click-column, env + delete?:bool<span class="Special"> <- </span>should-attempt-delete? click-row, click-column, env <span class="muControl">break-unless</span> delete? delete?, env<span class="Special"> <- </span>try-delete-sandbox click-row, env <span class="muControl">break-unless</span> delete? @@ -114,68 +114,68 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># some preconditions for attempting to delete a sandbox</span> -<span class="muRecipe">def</span> should-attempt-delete? click-row:number, click-column:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> should-attempt-delete? click-row:num, click-column:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>result:bool [ <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?:boolean<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool<span class="Special"> <- </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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - _, _, _, _, delete-button-left:number<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> + _, _, _, _, delete-button-left:num<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin result<span class="Special"> <- </span>within-range? click-column, delete-button-left, sandbox-right-margin ] -<span class="muRecipe">def</span> try-delete-sandbox click-row:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-delete-button?:boolean, env:address:programming-environment-data [ +<span class="muRecipe">def</span> try-delete-sandbox click-row:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-delete-button?:bool, env:&:programming-environment-data [ <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:address:sandbox-data<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox-data<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1/true</span> env<span class="Special"> <- </span>delete-sandbox env, sandbox ] -<span class="muRecipe">def</span> delete-sandbox env:address:programming-environment-data, sandbox:address:sandbox-data<span class="muRecipe"> -> </span>env:address:programming-environment-data [ +<span class="muRecipe">def</span> delete-sandbox env:&:programming-environment-data, sandbox:&:sandbox-data<span class="muRecipe"> -> </span>env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - first-sandbox?:boolean<span class="Special"> <- </span>equal curr-sandbox, sandbox + curr-sandbox:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox?:bool<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&:sandbox-data<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> *env<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>copy curr-sandbox + prev-sandbox:&:sandbox-data<span class="Special"> <- </span>copy curr-sandbox curr-sandbox<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal curr-sandbox, sandbox + found?:bool<span class="Special"> <- </span>equal curr-sandbox, sandbox <span class="muControl">break-if</span> found? prev-sandbox<span class="Special"> <- </span>copy curr-sandbox curr-sandbox<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&:sandbox-data<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> *prev-sandbox<span class="Special"> <- </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:number<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> sandbox-count<span class="Special"> <- </span>subtract sandbox-count, <span class="Constant">1</span> *env<span class="Special"> <- </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:number<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - reset-scroll?:boolean<span class="Special"> <- </span>equal render-from, sandbox-count + render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + reset-scroll?:bool<span class="Special"> <- </span>equal render-from, sandbox-count <span class="muControl">break-unless</span> reset-scroll? *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> <span class="Delimiter">}</span> @@ -187,8 +187,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n @@ -198,7 +198,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 press page-down ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -213,7 +213,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">6</span>, <span class="Constant">99</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -233,8 +233,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n @@ -244,7 +244,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 press page-down ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -259,7 +259,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">99</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -279,8 +279,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n @@ -291,7 +291,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down press page-down ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -306,7 +306,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">99</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># implicitly scroll up to first sandbox</span> screen-should-contain [ @@ -327,8 +327,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n @@ -337,7 +337,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -357,7 +357,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># shouldn't go past last sandbox</span> screen-should-contain [ diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 18926f44..1fcf071f 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -47,8 +47,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -64,7 +64,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -81,7 +81,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -107,8 +107,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -124,7 +124,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">68</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -141,7 +141,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -157,7 +157,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'edit' button</span> <span class="Delimiter">{</span> - edit?:boolean<span class="Special"> <- </span>should-attempt-edit? click-row, click-column, env + edit?:bool<span class="Special"> <- </span>should-attempt-edit? click-row, click-column, env <span class="muControl">break-unless</span> edit? edit?, env<span class="Special"> <- </span>try-edit-sandbox click-row, env <span class="muControl">break-unless</span> edit? @@ -170,35 +170,35 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># some preconditions for attempting to edit a sandbox</span> -<span class="muRecipe">def</span> should-attempt-edit? click-row:number, click-column:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> should-attempt-edit? click-row:num, click-column:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>result:bool [ <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?:boolean<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool<span class="Special"> <- </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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - edit-button-left:number, edit-button-right:number, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - edit-button-vertical-area?:boolean<span class="Special"> <- </span>within-range? click-column, edit-button-left, edit-button-right + sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> + edit-button-left:num, edit-button-right:num, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + edit-button-vertical-area?:bool<span class="Special"> <- </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:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> result<span class="Special"> <- </span>empty-editor? current-sandbox ] -<span class="muRecipe">def</span> try-edit-sandbox click-row:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-edit-button?:boolean, env:address:programming-environment-data [ +<span class="muRecipe">def</span> try-edit-sandbox click-row:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-edit-button?:bool, env:&:programming-environment-data [ <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:address:sandbox-data<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox-data<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># 'edit' button = 'copy' button + 'delete' button</span> text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text env<span class="Special"> <- </span>delete-sandbox env, sandbox <span class="Comment"># reset scroll</span> @@ -214,12 +214,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -240,7 +240,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">65</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -257,8 +257,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n @@ -269,7 +269,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down press page-down ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -284,7 +284,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -305,8 +305,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n @@ -315,7 +315,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -334,7 +334,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># no change in contents</span> screen-should-contain [ @@ -356,7 +356,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># screen should show just final sandbox with the right index (1)</span> screen-should-contain [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 1772865b..1967fa7d 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -48,8 +48,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">5</span>, <span class="Constant">51</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># color toggles to green</span> screen-should-contain-in-color <span class="Constant">2/green</span>, [ @@ -80,8 +80,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should remain unmoved</span> run [ - <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor + <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -104,7 +104,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># result turns red</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -121,7 +121,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># this requires tracking a couple more things</span> <span class="muData">container</span> sandbox-data [ - response-starting-row-on-screen:number + response-starting-row-on-screen:num expected-response:text ] @@ -148,18 +148,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># check if it's inside the output of any sandbox</span> <span class="Delimiter">{</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - click-column:number<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - on-sandbox-side?:boolean<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> + on-sandbox-side?:bool<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox - first-sandbox-begins:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - below-sandbox-editor?:boolean<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> + below-sandbox-editor?:bool<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>find-click-in-sandbox-output env, click-row + sandbox:&:sandbox-data<span class="Special"> <- </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"> <- </span>toggle-expected-response sandbox @@ -173,33 +173,33 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> find-click-in-sandbox-output env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">def</span> find-click-in-sandbox-output env:&:programming-environment-data, click-row:num<span class="muRecipe"> -> </span>sandbox:&:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - start:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:boolean<span class="Special"> <- </span>greater-or-equal click-row, start + sandbox:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + start:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + clicked-on-sandboxes?:bool<span class="Special"> <- </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 < sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox - next-start:number<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:boolean<span class="Special"> <- </span>lesser-than click-row, next-start + next-start:num<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool<span class="Special"> <- </span>lesser-than click-row, next-start <span class="muControl">break-if</span> found? sandbox<span class="Special"> <- </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:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + response-starting-row:num<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>greater-or-equal click-row, response-starting-row + click-in-response?:bool<span class="Special"> <- </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 ] -<span class="muRecipe">def</span> toggle-expected-response sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">def</span> toggle-expected-response sandbox:&:sandbox-data<span class="muRecipe"> -> </span>sandbox:&:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> expected-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> @@ -223,13 +223,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, row expected-response:text<span class="Special"> <- </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?:boolean<span class="Special"> <- </span>equal expected-response, sandbox-response + response-is-expected?:bool<span class="Special"> <- </span>equal expected-response, sandbox-response <span class="Delimiter">{</span> - <span class="muControl">break-if</span> response-is-expected?:boolean + <span class="muControl">break-if</span> response-is-expected?:bool row, screen<span class="Special"> <- </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?:boolean + <span class="muControl">break-unless</span> response-is-expected?:bool row, screen<span class="Special"> <- </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:label</span> diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 177fdee1..25c8ff32 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -48,8 +48,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -64,9 +64,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - <span class="Constant">4</span>:character/cursor-icon<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:screen, <span class="Constant">4</span>:character/cursor-icon + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + <span class="Constant">4</span>:char/cursor-icon<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, <span class="Constant">4</span>:char/cursor-icon ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> screen-should-contain [ @@ -90,8 +90,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">4</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data - print screen:address:screen, <span class="Constant">4</span>:character/cursor-icon + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data + print screen:&:screen, <span class="Constant">4</span>:char/cursor-icon ] <span class="Comment"># trace hidden again</span> screen-should-contain [ @@ -119,8 +119,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -136,7 +136,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># trace now printed above result</span> screen-should-contain [ @@ -163,8 +163,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -178,7 +178,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">5</span>, <span class="Constant">57</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># no change; doesn't die</span> screen-should-contain [ @@ -193,15 +193,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muData">container</span> sandbox-data [ trace:text - display-trace?:boolean + display-trace?:bool ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">def!</span> update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data, env:address:programming-environment-data [ +<span class="muRecipe">def!</span> update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox-data, env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:address:screen, trace:text<span class="Special"> <- </span>run-sandboxed data + response:text, _, fake-screen:&:screen, trace:text<span class="Special"> <- </span>run-sandboxed data *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">trace:offset</span>, trace @@ -211,21 +211,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># check if it's inside the code of any sandbox</span> <span class="Delimiter">{</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - click-column:number<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - on-sandbox-side?:boolean<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> + click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> + on-sandbox-side?:bool<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox - first-sandbox-begins:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - below-sandbox-editor?:boolean<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> + below-sandbox-editor?:bool<span class="Special"> <- </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:address:sandbox-data<span class="Special"> <- </span>find-click-in-sandbox-code env, click-row + sandbox:&:sandbox-data<span class="Special"> <- </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:boolean<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> + x:bool<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> x<span class="Special"> <- </span>not x *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">display-trace?:offset</span>, x hide-screen screen @@ -237,30 +237,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> find-click-in-sandbox-code env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">def</span> find-click-in-sandbox-code env:&:programming-environment-data, click-row:num<span class="muRecipe"> -> </span>sandbox:&:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - start:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:boolean<span class="Special"> <- </span>greater-or-equal click-row, start + start:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + clicked-on-sandboxes?:bool<span class="Special"> <- </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 < sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:address:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&:sandbox-data<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox - next-start:number<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:boolean<span class="Special"> <- </span>lesser-than click-row, next-start + next-start:num<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool<span class="Special"> <- </span>lesser-than click-row, next-start <span class="muControl">break-if</span> found? sandbox<span class="Special"> <- </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:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> - click-above-response?:boolean<span class="Special"> <- </span>lesser-than click-row, code-ending-row - start:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-below-menu?:boolean<span class="Special"> <- </span>greater-than click-row, start - click-on-sandbox-code?:boolean<span class="Special"> <- </span>and click-above-response?, click-below-menu? + code-ending-row:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + click-above-response?:bool<span class="Special"> <- </span>lesser-than click-row, code-ending-row + start:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-below-menu?:bool<span class="Special"> <- </span>greater-than click-row, start + click-on-sandbox-code?:bool<span class="Special"> <- </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> @@ -271,7 +271,7 @@ 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"><render-sandbox-results></span> [ <span class="Delimiter">{</span> - display-trace?:boolean<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> + display-trace?:bool<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> <span class="muControl">break-unless</span> display-trace? sandbox-trace:text<span class="Special"> <- </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> diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 6d0117bb..771be1b6 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -40,10 +40,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># copy code from recipe editor, persist, load into mu, save any errors</span> -<span class="muRecipe">def!</span> update-recipes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">def!</span> update-recipes env:&:programming-environment-data, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> in:text<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in recipe-errors:text<span class="Special"> <- </span>reload in @@ -76,7 +76,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> programming-environment-data [ - error-index:number <span class="Comment"># index of first sandbox with an error (or -1 if none)</span> + error-index:num <span class="Comment"># index of first sandbox with an error (or -1 if none)</span> ] <span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ @@ -89,8 +89,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">before</span> <span class="Constant"><run-sandboxes-end></span> [ <span class="Delimiter">{</span> - error-index:number<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> - sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> + error-index:num<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> + sandboxes-completed-successfully?:bool<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> <span class="muControl">break-if</span> sandboxes-completed-successfully? errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="Delimiter">}</span> @@ -99,8 +99,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> recipe-errors - error-index:number<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> - sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> + error-index:num<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> + sandboxes-completed-successfully?:bool<span class="Special"> <- </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"> <- </span>to-text error-index status:text<span class="Special"> <- </span>interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text @@ -112,26 +112,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color errors:text ] -<span class="muRecipe">def!</span> update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:sandbox-data, env:address:programming-environment-data [ +<span class="muRecipe">def!</span> update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox-data, env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, errors:text, fake-screen:address:screen, trace:text, completed?:boolean<span class="Special"> <- </span>run-sandboxed data + response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool<span class="Special"> <- </span>run-sandboxed data *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">errors:offset</span>, errors *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen *sandbox<span class="Special"> <- </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?:boolean + <span class="muControl">break-if</span> completed?:bool errors<span class="Special"> <- </span>new <span class="Constant">[took too long!</span> <span class="Constant">]</span> *sandbox<span class="Special"> <- </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:number<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> - error-not-set?:boolean<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> + error-index:num<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> + error-not-set?:bool<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> <span class="muControl">break-unless</span> error-not-set? *env<span class="Special"> <- </span>put *env, <span class="Constant">error-index:offset</span>, idx <span class="Delimiter">}</span> @@ -154,25 +154,25 @@ 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="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> -<span class="Constant"> get 123:number, foo:offset</span> +<span class="Constant"> get 123:num, foo:offset</span> <span class="Constant">]</span>] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . get 123:number, foo:offset ┊ .</span> + <span class="Constant"> . get 123:num, foo:offset ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: unknown element 'foo' in container 'number' ┊ .</span> <span class="Constant"> .foo: first ingredient of 'get' should be a contai↩┊ .</span> - <span class="Constant"> .ner, but got '123:number' ┊ .</span> + <span class="Constant"> .ner, but got '123:num' ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -184,7 +184,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> <span class="Constant"> .foo: unknown element 'foo' in container 'number' .</span> <span class="Constant"> .foo: first ingredient of 'get' should be a contai .</span> - <span class="Constant"> .ner, but got '123:number' .</span> + <span class="Constant"> .ner, but got '123:num' .</span> <span class="Constant"> . .</span> ] ] @@ -194,7 +194,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="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> <span class="Comment"># create invalid sandbox 1</span> @@ -205,7 +205,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># status line shows that error is in first sandbox</span> screen-should-contain [ @@ -218,7 +218,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="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> <span class="Comment"># create invalid sandbox 2</span> @@ -232,7 +232,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># status line shows that error is in second sandbox</span> screen-should-contain [ @@ -245,12 +245,12 @@ 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="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 <span class="Comment"># generate error</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">58</span> @@ -259,7 +259,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 <span class="Comment"># update sandbox</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># error should disappear</span> screen-should-contain [ @@ -281,21 +281,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> -<span class="Constant">y:address:number <- copy 0</span> +<span class="Constant">y:&:num <- copy 0</span> <span class="Constant">z <- add x, y</span> <span class="Constant">]</span>] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .load-ingredients ┊0 edit copy delete .</span> - <span class="Constant"> .y:address:number <- copy 0 ┊foo 2 .</span> + <span class="Constant"> .y:&:num <- copy 0 ┊foo 2 .</span> <span class="Constant"> .z <- add x, y ┊foo_2: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .] ┊t 'y' .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -306,7 +306,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># error should remain unchanged</span> screen-should-contain [ @@ -314,7 +314,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .load-ingredients ┊0 edit copy delete .</span> - <span class="Constant"> .y:address:number <- copy 0 ┊foo 2 .</span> + <span class="Constant"> .y:&:num <- copy 0 ┊foo 2 .</span> <span class="Constant"> .z <- add x, y ┊foo_3: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .] ┊t 'y' .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -326,24 +326,24 @@ 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> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:list:_elem -> n:number [</span> + <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe length l:&:list:_elem -> n:num [</span> <span class="Constant">]</span>] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[x:address:list:number <- copy 0</span> + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[x:&:list:num <- copy 0</span> <span class="Constant">to-text x]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run it once</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data <span class="Comment"># no errors anywhere on screen (can't check anything else, since to-text will return an address)</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> - <span class="Constant"> . <- .</span> + <span class="Constant"> . <- .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -360,7 +360,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># still no errors</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -368,7 +368,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> - <span class="Constant"> . <- .</span> + <span class="Constant"> . <- .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -390,12 +390,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span>] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -416,12 +416,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -441,27 +441,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> -<span class="Constant"> x:address:point <- new point:type</span> -<span class="Constant"> get x:address:point, 1:offset</span> +<span class="Constant"> x:&:point <- new point:type</span> +<span class="Constant"> get x:&:point, 1:offset</span> <span class="Constant">]</span>] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . local-scope ┊ .</span> - <span class="Constant"> . x:address:point <- new point:type ┊ .</span> - <span class="Constant"> . get x:address:point, 1:offset ┊ .</span> + <span class="Constant"> . x:&:point <- new point:type ┊ .</span> + <span class="Constant"> . get x:&:point, 1:offset ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: first ingredient of 'get' should be a contai↩┊ .</span> - <span class="Constant"> .ner, but got 'x:address:point' ┊ .</span> + <span class="Constant"> .ner, but got 'x:&:point' ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -473,29 +473,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> -<span class="Constant"> x:number <- copy 0</span> -<span class="Constant"> y:address:point <- new point:type</span> -<span class="Constant"> get *y:address:point, x:number</span> +<span class="Constant"> x:num <- copy 0</span> +<span class="Constant"> y:&:point <- new point:type</span> +<span class="Constant"> get *y:&:point, x:num</span> <span class="Constant">]</span>] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . local-scope ┊ .</span> - <span class="Constant"> . x:number <- copy 0 ┊ .</span> - <span class="Constant"> . y:address:point <- new point:type ┊ .</span> - <span class="Constant"> . get *y:address:point, x:number ┊ .</span> + <span class="Constant"> . x:num <- copy 0 ┊ .</span> + <span class="Constant"> . y:&:point <- new point:type ┊ .</span> + <span class="Constant"> . get *y:&:point, x:num ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: second ingredient of 'get' should have type ↩┊ .</span> - <span class="Constant"> .'offset', but got 'x:number' ┊ .</span> + <span class="Constant"> .'offset', but got 'x:num' ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -508,20 +508,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> -<span class="Constant"> x:number <- copy y:number</span> +<span class="Constant"> x:num <- copy y:num</span> <span class="Constant">]</span>] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . local-scope ┊ .</span> - <span class="Constant"> . x:number <- copy y:number ┊ .</span> + <span class="Constant"> . x:num <- copy y:num ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: use before set: 'y' ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> @@ -532,14 +532,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . local-scope ┊ .</span> - <span class="Constant"> . x:number <- copy y:number ┊ .</span> + <span class="Constant"> . x:num <- copy y:num ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: use before set: 'y' ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> @@ -553,14 +553,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># left editor is empty</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># check that screen prints error message in red</span> screen-should-contain [ @@ -568,10 +568,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊0 edit copy delete .</span> - <span class="Constant"> . ┊get 1234:number, foo:offset .</span> + <span class="Constant"> . ┊get 1234:num, foo:offset .</span> <span class="Constant"> . ┊unknown element 'foo' in container 'number' .</span> <span class="Constant"> . ┊first ingredient of 'get' should be a container,↩.</span> - <span class="Constant"> . ┊ but got '1234:number' .</span> + <span class="Constant"> . ┊ but got '1234:num' .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] @@ -580,7 +580,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> - <span class="Constant"> . get 1234:number, foo:offset .</span> + <span class="Constant"> . get 1234:num, foo:offset .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -593,7 +593,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> <span class="Constant"> . unknown element 'foo' in container 'number' .</span> <span class="Constant"> . first ingredient of 'get' should be a container, .</span> - <span class="Constant"> . but got '1234:number' .</span> + <span class="Constant"> . but got '1234:num' .</span> <span class="Constant"> . .</span> ] screen-should-contain-in-color <span class="Constant">245/grey</span>, [ @@ -616,15 +616,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># left editor is empty</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># check that screen prints error message just once</span> screen-should-contain [ @@ -632,10 +632,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊0 edit copy delete .</span> - <span class="Constant"> . ┊get 1234:number, foo:offset .</span> + <span class="Constant"> . ┊get 1234:num, foo:offset .</span> <span class="Constant"> . ┊unknown element 'foo' in container 'number' .</span> <span class="Constant"> . ┊first ingredient of 'get' should be a container,↩.</span> - <span class="Constant"> . ┊ but got '1234:number' .</span> + <span class="Constant"> . ┊ but got '1234:num' .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] @@ -652,13 +652,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> @@ -678,28 +678,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># generate a stash and a error</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant">local-scope</span> -<span class="Constant">a:number <- next-ingredient</span> -<span class="Constant">b:number <- next-ingredient</span> +<span class="Constant">a:num <- next-ingredient</span> +<span class="Constant">b:num <- next-ingredient</span> <span class="Constant">stash [dividing by]</span>, b -_, c:number<span class="Special"> <- </span>divide-with-remainder a, b +_, c:num<span class="Special"> <- </span>divide-with-remainder a, b <span class="muControl">reply</span> b ]] <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data <span class="Comment"># screen prints error message</span> screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .a:number <- next-ingredient ┊0 edit copy delete .</span> - <span class="Constant"> .b:number <- next-ingredient ┊foo 4, 0 .</span> - <span class="Constant"> .stash [dividing by], b ┊foo: divide by zero in '_, c:number <- divide-wi↩.</span> - <span class="Constant"> ._, c:number <- divide-with-remainder a, b ┊th-remainder a, b' .</span> + <span class="Constant"> .a:num <- next-ingredient ┊0 edit copy delete .</span> + <span class="Constant"> .b:num <- next-ingredient ┊foo 4, 0 .</span> + <span class="Constant"> .stash [dividing by], b ┊foo: divide by zero in '_, c:num <- divide-with-↩.</span> + <span class="Constant"> ._, c:num <- divide-with-remainder a, b ┊remainder a, b' .</span> <span class="Constant"> .reply b ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .] ┊ .</span> ] @@ -708,19 +708,19 @@ _, c:number<span class="Special"> <- </span>divide-with-remainder a, b left-click <span class="Constant">4</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># screen should expand trace</span> screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo [ ┊ .</span> <span class="Constant"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .a:number <- next-ingredient ┊0 edit copy delete .</span> - <span class="Constant"> .b:number <- next-ingredient ┊foo 4, 0 .</span> + <span class="Constant"> .a:num <- next-ingredient ┊0 edit copy delete .</span> + <span class="Constant"> .b:num <- next-ingredient ┊foo 4, 0 .</span> <span class="Constant"> .stash [dividing by], b ┊dividing by 0 .</span> - <span class="Constant"> ._, c:number <- divide-with-remainder a, b ┊14 instructions run .</span> - <span class="Constant"> .reply b ┊foo: divide by zero in '_, c:number <- divide-wi↩.</span> - <span class="Constant"> .] ┊th-remainder a, b' .</span> + <span class="Constant"> ._, c:num <- divide-with-remainder a, b ┊14 instructions run .</span> + <span class="Constant"> .reply b ┊foo: divide by zero in '_, c:num <- divide-with-↩.</span> + <span class="Constant"> .] ┊remainder a, b' .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> ] ] diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index ff375027..0233a08a 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -44,28 +44,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> insert-operation [ - before-row:number - before-column:number - before-top-of-screen:address:duplex-list:character - after-row:number - after-column:number - after-top-of-screen:address:duplex-list:character + before-row:num + before-column:num + before-top-of-screen:&:duplex-list:char + after-row:num + after-column:num + after-top-of-screen:&:duplex-list:char <span class="Comment"># inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate</span> - insert-from:address:duplex-list:character - insert-until:address:duplex-list:character - tag:number <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> + insert-from:&:duplex-list:char + insert-until:&:duplex-list:char + tag:num <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> <span class="Comment"># 0: no coalesce (enter+indent)</span> <span class="Comment"># 1: regular alphanumeric characters</span> ] <span class="muData">container</span> move-operation [ - before-row:number - before-column:number - before-top-of-screen:address:duplex-list:character - after-row:number - after-column:number - after-top-of-screen:address:duplex-list:character - tag:number <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> + before-row:num + before-column:num + before-top-of-screen:&:duplex-list:char + after-row:num + after-column:num + after-top-of-screen:&:duplex-list:char + tag:num <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> <span class="Comment"># 0: no coalesce (touch events, etc)</span> <span class="Comment"># 1: left arrow</span> <span class="Comment"># 2: right arrow</span> @@ -74,16 +74,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> delete-operation [ - before-row:number - before-column:number - before-top-of-screen:address:duplex-list:character - after-row:number - after-column:number - after-top-of-screen:address:duplex-list:character - deleted-text:address:duplex-list:character - delete-from:address:duplex-list:character - delete-until:address:duplex-list:character - tag:number <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> + before-row:num + before-column:num + before-top-of-screen:&:duplex-list:char + after-row:num + after-column:num + after-top-of-screen:&:duplex-list:char + deleted-text:&:duplex-list:char + delete-from:&:duplex-list:char + delete-until:&:duplex-list:char + tag:num <span class="Comment"># event causing this operation; might be used to coalesce runs of similar events</span> <span class="Comment"># 0: no coalesce (ctrl-k, ctrl-u)</span> <span class="Comment"># 1: backspace</span> <span class="Comment"># 2: delete</span> @@ -91,21 +91,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># every editor accumulates a list of operations to undo/redo</span> <span class="muData">container</span> editor-data [ - undo:address:list:address:operation - redo:address:list:address:operation + undo:&:list:&:operation + redo:&:list:&:operation ] <span class="Comment"># ctrl-z - undo operation</span> <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - undo?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">26/ctrl-z</span> + undo?:bool<span class="Special"> <- </span>equal c, <span class="Constant">26/ctrl-z</span> <span class="muControl">break-unless</span> undo? - undo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> undo - op:address:operation<span class="Special"> <- </span>first undo + op:&:operation<span class="Special"> <- </span>first undo undo<span class="Special"> <- </span>rest undo *editor<span class="Special"> <- </span>put *editor, <span class="Constant">undo:offset</span>, undo - redo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> + redo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> redo<span class="Special"> <- </span>push op, redo *editor<span class="Special"> <- </span>put *editor, <span class="Constant">redo:offset</span>, redo <span class="Constant"> <handle-undo></span> @@ -116,14 +116,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># ctrl-y - redo operation</span> <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - redo?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">25/ctrl-y</span> + redo?:bool<span class="Special"> <- </span>equal c, <span class="Constant">25/ctrl-y</span> <span class="muControl">break-unless</span> redo? - redo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> + redo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> <span class="muControl">break-unless</span> redo - op:address:operation<span class="Special"> <- </span>first redo + op:&:operation<span class="Special"> <- </span>first redo redo<span class="Special"> <- </span>rest redo *editor<span class="Special"> <- </span>put *editor, <span class="Constant">redo:offset</span>, redo - undo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> undo<span class="Special"> <- </span>push op, undo *editor<span class="Special"> <- </span>put *editor, <span class="Constant">undo:offset</span>, undo <span class="Constant"> <handle-redo></span> @@ -137,18 +137,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[0]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># character should be gone</span> screen-should-contain [ @@ -162,7 +162,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -174,24 +174,24 @@ 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"><insert-character-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><insert-character-end></span> [ - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - undo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + undo:&:list:&:operation<span class="Special"> <- </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:address:operation<span class="Special"> <- </span>first undo - typing:insert-operation, is-insert?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + op:&:operation<span class="Special"> <- </span>first undo + typing:insert-operation, is-insert?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - previous-coalesce-tag:number<span class="Special"> <- </span>get typing, <span class="Constant">tag:offset</span> + previous-coalesce-tag:num<span class="Special"> <- </span>get typing, <span class="Constant">tag:offset</span> <span class="muControl">break-unless</span> previous-coalesce-tag - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-until:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + insert-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor typing<span class="Special"> <- </span>put typing, <span class="Constant">insert-until:offset</span>, insert-until typing<span class="Special"> <- </span>put typing, <span class="Constant">after-row:offset</span>, cursor-row typing<span class="Special"> <- </span>put typing, <span class="Constant">after-column:offset</span>, cursor-column @@ -200,9 +200,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break</span> <span class="Constant">+done-adding-insert-operation:label</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - insert-from:address:duplex-list:character<span class="Special"> <- </span>next cursor-before - insert-to:address:duplex-list:character<span class="Special"> <- </span>next insert-from - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + insert-from:&:duplex-list:char<span class="Special"> <- </span>next cursor-before + insert-to:&:duplex-list:char<span class="Special"> <- </span>next insert-from + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, insert-from, insert-to, <span class="Constant">1/coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-insert-operation</span> @@ -210,20 +210,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># enter operations never coalesce with typing before or after</span> <span class="muRecipe">after</span> <span class="Constant"><insert-enter-begin></span> [ - cursor-row-before:number<span class="Special"> <- </span>copy cursor-row - cursor-column-before:number<span class="Special"> <- </span>copy cursor-column - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row-before:num<span class="Special"> <- </span>copy cursor-row + cursor-column-before:num<span class="Special"> <- </span>copy cursor-column + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><insert-enter-end></span> [ - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> <span class="Comment"># never coalesce</span> - insert-from:address:duplex-list:character<span class="Special"> <- </span>next cursor-before - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-to:address:duplex-list:character<span class="Special"> <- </span>next before-cursor - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + insert-from:&:duplex-list:char<span class="Special"> <- </span>next cursor-before + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + insert-to:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, insert-from, insert-to, <span class="Constant">0/never-coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op ] @@ -232,13 +232,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># redo stack, because it's now obsolete.</span> <span class="Comment"># Beware: since we're counting cursor moves as operations, this means just</span> <span class="Comment"># moving the cursor can lose work on the undo stack.</span> -<span class="muRecipe">def</span> add-operation editor:address:editor-data, op:address:operation<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">def</span> add-operation editor:&:editor-data, op:&:operation<span class="muRecipe"> -> </span>editor:&:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - undo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> undo<span class="Special"> <- </span>push op undo *editor<span class="Special"> <- </span>put *editor, <span class="Constant">undo:offset</span>, undo - redo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> + redo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> redo<span class="Special"> <- </span>copy <span class="Constant">0</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">redo:offset</span>, redo <span class="muControl">return</span> editor/same-as-ingredient:<span class="Constant">0</span> @@ -246,19 +246,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-undo></span> [ <span class="Delimiter">{</span> - typing:insert-operation, is-insert?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + typing:insert-operation, is-insert?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - start:address:duplex-list:character<span class="Special"> <- </span>get typing, <span class="Constant">insert-from:offset</span> - end:address:duplex-list:character<span class="Special"> <- </span>get typing, <span class="Constant">insert-until:offset</span> + start:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">insert-from:offset</span> + end:&:duplex-list:char<span class="Special"> <- </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:address:duplex-list:character<span class="Special"> <- </span>prev start + before-cursor:&:duplex-list:char<span class="Special"> <- </span>prev start *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor remove-between before-cursor, end cursor-row<span class="Special"> <- </span>get typing, <span class="Constant">before-row:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>get typing, <span class="Constant">before-column:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:address:duplex-list:character<span class="Special"> <- </span>get typing, <span class="Constant">before-top-of-screen:offset</span> + top:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">before-top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -267,18 +267,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[012]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># all characters must be gone</span> screen-should-contain [ @@ -293,13 +293,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># type some characters</span> assume-console [ type <span class="Constant">[012]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .012a .</span> @@ -311,7 +311,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -325,7 +325,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -339,14 +339,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># new line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">8</span> press enter ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . abc .</span> @@ -355,8 +355,8 @@ 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>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -366,10 +366,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">5</span> @@ -386,7 +386,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -402,13 +402,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -420,7 +420,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -434,7 +434,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -446,10 +446,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-redo></span> [ <span class="Delimiter">{</span> - typing:insert-operation, is-insert?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + typing:insert-operation, is-insert?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? before-cursor<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-from:address:duplex-list:character<span class="Special"> <- </span>get typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> + insert-from:&:duplex-list:char<span class="Special"> <- </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> @@ -457,7 +457,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>get typing, <span class="Constant">after-column:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:address:duplex-list:character<span class="Special"> <- </span>get typing, <span class="Constant">after-top-of-screen:offset</span> + top:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">after-top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -466,13 +466,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -484,7 +484,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -498,7 +498,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -514,18 +514,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[1]</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># do some more work</span> assume-console [ type <span class="Constant">[0]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .0abc .</span> @@ -538,7 +538,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># nothing should happen</span> screen-should-contain [ @@ -554,8 +554,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ press tab @@ -566,7 +566,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press tab type <span class="Constant">[efg]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . ab cd .</span> @@ -574,8 +574,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> @@ -585,11 +585,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># typing in second line deleted, but not indent</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -606,11 +606,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> @@ -626,11 +626,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># empty screen</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -646,11 +646,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> @@ -666,11 +666,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># newline and indent inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -687,11 +687,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> @@ -713,21 +713,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># click undone</span> memory-should-contain [ @@ -739,7 +739,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -751,25 +751,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><move-cursor-begin></span> [ - cursor-row-before:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column-before:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row-before:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column-before:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><move-cursor-end></span> [ - top-after:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </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:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> undo - op:address:operation<span class="Special"> <- </span>first undo - move:move-operation, is-move?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> + op:&:operation<span class="Special"> <- </span>first undo + move:move-operation, is-move?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? - previous-coalesce-tag:number<span class="Special"> <- </span>get move, <span class="Constant">tag:offset</span> - coalesce?:boolean<span class="Special"> <- </span>equal undo-coalesce-tag, previous-coalesce-tag + previous-coalesce-tag:num<span class="Special"> <- </span>get move, <span class="Constant">tag:offset</span> + coalesce?:bool<span class="Special"> <- </span>equal undo-coalesce-tag, previous-coalesce-tag <span class="muControl">break-unless</span> coalesce? move<span class="Special"> <- </span>put move, <span class="Constant">after-row:offset</span>, cursor-row move<span class="Special"> <- </span>put move, <span class="Constant">after-column:offset</span>, cursor-column @@ -777,7 +777,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *op<span class="Special"> <- </span>merge <span class="Constant">1/move-operation</span>, move <span class="muControl">break</span> <span class="Constant">+done-adding-move-operation:label</span> <span class="Delimiter">}</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">1/move-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, undo-coalesce-tag editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-move-operation</span> @@ -785,14 +785,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-undo></span> [ <span class="Delimiter">{</span> - move:move-operation, is-move?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> + move:move-operation, is-move?:bool<span class="Special"> <- </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"> <- </span>get move, <span class="Constant">before-row:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>get move, <span class="Constant">before-column:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:address:duplex-list:character<span class="Special"> <- </span>get move, <span class="Constant">before-top-of-screen:offset</span> + top:&:duplex-list:char<span class="Special"> <- </span>get move, <span class="Constant">before-top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -804,15 +804,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&: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> press right-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> <span class="Comment"># screen scrolls</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -829,9 +829,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moved back</span> memory-should-contain [ @@ -850,7 +850,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -866,22 +866,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press left-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -893,7 +893,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -910,16 +910,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -929,9 +929,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -943,7 +943,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -960,22 +960,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press down-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -987,7 +987,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1007,21 +1007,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># scroll the page</span> assume-console [ press ctrl-f ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1042,21 +1042,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># scroll the page</span> assume-console [ press page-down ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1077,22 +1077,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># scroll the page down and up</span> assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1113,22 +1113,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># scroll the page down and up</span> assume-console [ press page-down press page-up ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1146,22 +1146,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> press ctrl-a ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1173,7 +1173,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1190,22 +1190,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> press home ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1217,7 +1217,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1234,22 +1234,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> press ctrl-e ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1261,7 +1261,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1278,22 +1278,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> press end ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1305,7 +1305,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1322,8 +1322,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> @@ -1331,9 +1331,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1343,9 +1343,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># up-arrow is undone</span> memory-should-contain [ @@ -1357,9 +1357,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># both right-arrows are undone</span> memory-should-contain [ @@ -1376,21 +1376,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data <span class="Comment"># redo</span> assume-console [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to left-click</span> memory-should-contain [ @@ -1402,7 +1402,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1415,14 +1415,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-redo></span> [ <span class="Delimiter">{</span> - move:move-operation, is-move?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> + move:move-operation, is-move?:bool<span class="Special"> <- </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"> <- </span>get move, <span class="Constant">after-row:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>get move, <span class="Constant">after-column:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:address:duplex-list:character<span class="Special"> <- </span>get move, <span class="Constant">after-top-of-screen:offset</span> + top:&:duplex-list:char<span class="Special"> <- </span>get move, <span class="Constant">after-top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -1431,16 +1431,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <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> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data assume-console [ type <span class="Constant">[abc]</span> left-click <span class="Constant">1</span>, <span class="Constant">1</span> type <span class="Constant">[d]</span> ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .adbc .</span> @@ -1456,9 +1456,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># last letter typed is deleted</span> screen-should-contain [ @@ -1476,9 +1476,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to screen; cursor moves</span> screen-should-contain [ @@ -1496,9 +1496,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen empty</span> screen-should-contain [ @@ -1516,9 +1516,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># first insert</span> screen-should-contain [ @@ -1536,9 +1536,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves</span> screen-should-contain [ @@ -1557,9 +1557,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># second insert</span> screen-should-contain [ @@ -1580,23 +1580,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># insert some text and hit backspace</span> assume-console [ type <span class="Constant">[abc]</span> press backspace press backspace ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1606,10 +1606,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1625,10 +1625,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1643,27 +1643,27 @@ 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"><backspace-character-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><backspace-character-end></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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - undo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + undo:&:list:&:operation<span class="Special"> <- </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:address:operation<span class="Special"> <- </span>first undo - deletion:delete-operation, is-delete?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + op:&:operation<span class="Special"> <- </span>first undo + deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - previous-coalesce-tag:number<span class="Special"> <- </span>get deletion, <span class="Constant">tag:offset</span> - coalesce?:boolean<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> + previous-coalesce-tag:num<span class="Special"> <- </span>get deletion, <span class="Constant">tag:offset</span> + coalesce?:bool<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> <span class="muControl">break-unless</span> coalesce? deletion<span class="Special"> <- </span>put deletion, <span class="Constant">delete-from:offset</span>, before-cursor - backspaced-so-far:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> + backspaced-so-far:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> insert-range backspaced-cell, backspaced-so-far deletion<span class="Special"> <- </span>put deletion, <span class="Constant">deleted-text:offset</span>, backspaced-cell deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-row:offset</span>, cursor-row @@ -1673,8 +1673,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break</span> <span class="Constant">+done-adding-backspace-operation:label</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">1/coalesce-backspace</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-backspace-operation</span> @@ -1683,12 +1683,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-undo></span> [ <span class="Delimiter">{</span> - deletion:delete-operation, is-delete?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - anchor:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">delete-from:offset</span> + anchor:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">delete-from:offset</span> <span class="muControl">break-unless</span> anchor - deleted:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> - old-cursor:address:duplex-list:character<span class="Special"> <- </span>last deleted + deleted:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> + old-cursor:&:duplex-list:char<span class="Special"> <- </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"> <- </span>copy old-cursor @@ -1696,25 +1696,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>get deletion, <span class="Constant">before-column:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> + top:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-redo></span> [ <span class="Delimiter">{</span> - deletion:delete-operation, is-delete?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - start:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">delete-from:offset</span> - end:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">delete-until:offset</span> - data:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + start:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">delete-from:offset</span> + end:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">delete-until:offset</span> + data:&:duplex-list:char<span class="Special"> <- </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"> <- </span>get deletion, <span class="Constant">after-row:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row cursor-column<span class="Special"> <- </span>get deletion, <span class="Constant">after-column:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> + top:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -1725,8 +1725,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ type <span class="Constant">[abcdef]</span> @@ -1736,15 +1736,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press delete press delete ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .af .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1754,10 +1754,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1773,10 +1773,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1792,10 +1792,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1811,11 +1811,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1831,11 +1831,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1851,11 +1851,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1869,28 +1869,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><delete-character-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-character-end></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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - undo:address:list:address:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + undo:&:list:&:operation<span class="Special"> <- </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:address:operation<span class="Special"> <- </span>first undo - deletion:delete-operation, is-delete?:boolean<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + op:&:operation<span class="Special"> <- </span>first undo + deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - previous-coalesce-tag:number<span class="Special"> <- </span>get deletion, <span class="Constant">tag:offset</span> - coalesce?:boolean<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> + previous-coalesce-tag:num<span class="Special"> <- </span>get deletion, <span class="Constant">tag:offset</span> + coalesce?:bool<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> <span class="muControl">break-unless</span> coalesce? - delete-until:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + delete-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor deletion<span class="Special"> <- </span>put deletion, <span class="Constant">delete-until:offset</span>, delete-until - deleted-so-far:address:duplex-list:character<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> + deleted-so-far:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> deleted-so-far<span class="Special"> <- </span>append deleted-so-far, deleted-cell deletion<span class="Special"> <- </span>put deletion, <span class="Constant">deleted-text:offset</span>, deleted-so-far deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-row:offset</span>, cursor-row @@ -1900,8 +1900,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break</span> <span class="Constant">+done-adding-delete-operation:label</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next before-cursor + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">2/coalesce-delete</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> @@ -1915,14 +1915,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> press ctrl-k ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1930,8 +1930,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1941,7 +1941,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1950,8 +1950,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1961,7 +1961,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -1971,8 +1971,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1982,7 +1982,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1994,16 +1994,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><delete-to-end-of-line-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-to-end-of-line-end></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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next before-cursor - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> @@ -2017,14 +2017,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <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> press ctrl-u ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .c .</span> @@ -2032,8 +2032,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -2043,7 +2043,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2052,8 +2052,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -2063,7 +2063,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -2073,8 +2073,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:number<span class="Special"> <- </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"> <- </span>get *<span class="Constant">2</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -2084,7 +2084,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2096,17 +2096,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><delete-to-start-of-line-begin></span> [ - top-before:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-to-start-of-line-end></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:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - deleted-until:address:duplex-list:character<span class="Special"> <- </span>next before-cursor - cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, save-row/<span class="muRecipe">before</span>, save-column/<span class="muRecipe">before</span>, top-before, cursor-row/<span class="muRecipe">after</span>, cursor-column/<span class="muRecipe">after</span>, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, <span class="Constant">0/never-coalesce</span> editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> @@ -2117,15 +2117,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:&:editor-data <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ type <span class="Constant">[abc]</span> press ctrl-u press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> |