diff options
Diffstat (limited to 'html/edit')
-rw-r--r-- | html/edit/001-editor.mu.html | 102 | ||||
-rw-r--r-- | html/edit/002-typing.mu.html | 272 | ||||
-rw-r--r-- | html/edit/003-shortcuts.mu.html | 816 | ||||
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 157 | ||||
-rw-r--r-- | html/edit/005-sandbox.mu.html | 729 | ||||
-rw-r--r-- | html/edit/006-sandbox-edit.mu.html | 176 | ||||
-rw-r--r-- | html/edit/007-sandbox-delete.mu.html | 241 | ||||
-rw-r--r-- | html/edit/008-sandbox-test.mu.html | 39 | ||||
-rw-r--r-- | html/edit/009-sandbox-trace.mu.html | 61 | ||||
-rw-r--r-- | html/edit/010-warnings.mu.html | 310 | ||||
-rw-r--r-- | html/edit/011-editor-undo.mu.html | 738 |
11 files changed, 2291 insertions, 1350 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 11d1cb9d..ec683ce7 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -37,7 +37,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># temporary main for this layer: just render the given text at the given</span> <span class="Comment"># screen dimensions, then stop</span> -<span class="muRecipe">recipe!</span> main text:address:array:character [ +<span class="muRecipe">recipe!</span> main text:address:shared:array:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console @@ -51,8 +51,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-prints-text-to-screen [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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,16 +64,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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:address:shared:duplex-list:character + top-of-screen:address:shared:duplex-list:character + bottom-of-screen:address:shared:duplex-list:character <span class="Comment"># location before cursor inside data</span> - before-cursor:address:duplex-list:character + before-cursor:address:shared:duplex-list:character <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 <span class="Comment"># raw screen coordinates of cursor</span> cursor-row:number cursor-column:number @@ -82,7 +83,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># creates a new editor widget and renders its initial appearance to screen</span> <span class="Comment"># top/left/right constrain the screen area available to the new editor</span> <span class="Comment"># right is exclusive</span> -<span class="muRecipe">recipe</span> new-editor s:address:array:character, screen:address:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:editor-data, screen:address:screen [ +<span class="muRecipe">recipe</span> new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:shared:editor-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> @@ -98,11 +99,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *x<span class="Special"> <- </span>copy <span class="Constant">1/top</span> x<span class="Special"> <- </span>get-address *result, <span class="Constant">cursor-column:offset</span> *x<span class="Special"> <- </span>copy left - init:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + init:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *init<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">top-of-screen:offset</span> *top-of-screen<span class="Special"> <- </span>copy *init - y:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">before-cursor:offset</span> + y:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">before-cursor:offset</span> *y<span class="Special"> <- </span>copy *init result<span class="Special"> <- </span>insert-text result, s <span class="Comment"># initialize cursor to top of screen</span> @@ -113,7 +114,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> <editor-initialization></span> ] -<span class="muRecipe">recipe</span> insert-text editor:address:editor-data, text:address:array:character<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> insert-text editor:address:shared:editor-data, text:address:shared:array:character<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># early exit if text is empty</span> @@ -122,7 +123,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply-unless</span> len, editor/same-as-ingredient:<span class="Constant">0</span> idx:number<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:address:shared:duplex-list:character<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 <span class="muControl">break-if</span> done? @@ -139,8 +140,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initializes-without-data [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ - <span class="Constant">1</span>:address:editor-data<span class="Special"> <- </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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:address:shared: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:shared:editor-data ] memory-should-contain [ <span class="Comment"># 2 (data) <- just the § sentinel</span> @@ -149,8 +150,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># 5 (before cursor) <- the § sentinel</span> <span class="Constant">6</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># left</span> <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># right (inclusive)</span> - <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column</span> + <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># bottom</span> + <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -162,7 +164,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Assumes cursor should be at coordinates (cursor-row, cursor-column) and</span> <span class="Comment"># updates before-cursor to match. Might also move coordinates if they're</span> <span class="Comment"># outside text.</span> -<span class="muRecipe">recipe</span> render 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">recipe</span> render screen:address:shared:screen, editor:address:shared:editor-data<span class="muRecipe"> -> </span>last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> @@ -170,8 +172,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen-height:number<span class="Special"> <- </span>screen-height screen right:number<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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:address:shared: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<span class="Special"> <- </span>next curr <span class="Comment"># traversing screen</span> <span class="Constant"> +render-loop-initialization</span> @@ -180,7 +182,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } column:number<span class="Special"> <- </span>copy left cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *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> @@ -228,7 +230,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-right?:boolean<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - print screen, <span class="Constant">8617/loop-back-to-left</span>, <span class="Constant">245/grey</span> + wrap-icon:character<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> screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -242,7 +245,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># save first character off-screen</span> - bottom-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</span> + bottom-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</span> *bottom-of-screen<span class="Special"> <- </span>copy curr <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> @@ -256,22 +259,31 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *cursor-column<span class="Special"> <- </span>copy column *before-cursor<span class="Special"> <- </span>copy prev <span class="Delimiter">}</span> + bottom:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom:offset</span> + *bottom<span class="Special"> <- </span>copy row <span class="muControl">reply</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> ] -<span class="muRecipe">recipe</span> clear-line-delimited screen:address:screen, column:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-line-delimited screen:address:shared:screen, column:number, right:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + bg-color:number, bg-color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> + <span class="Comment"># default bg-color to black</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> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - screen<span class="Special"> <- </span>print screen, <span class="Constant">32/space</span> + screen<span class="Special"> <- </span>print screen, space, <span class="Constant">7/white</span>, bg-color <span class="Comment"># foreground color is mostly unused except if the cursor shows up at this cell</span> column<span class="Special"> <- </span>add column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:shared: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> @@ -287,7 +299,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> clear-rest-of-screen screen:address:screen, row:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:shared: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> @@ -306,9 +318,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -321,8 +333,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-handles-offsets [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -334,9 +346,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines-at-offset [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -349,8 +361,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-wraps-long-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -369,8 +381,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initially-wraps-barely-long-lines [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + new-editor s:address:shared:array:character, screen:address:shared: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> @@ -391,10 +403,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initializes-empty-text [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - <span class="Constant">3</span>:number<span class="Special"> <- </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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -412,10 +424,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> render-colors-comments [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant"># de</span> <span class="Constant">f]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -493,10 +505,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> render-colors-assignment [ assume-screen <span class="Constant">8/width</span>, <span class="Constant">5/height</span> run [ - s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d <- e</span> <span class="Constant">f]</span> - new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + new-editor s:address:shared:array:character, screen:address:shared: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 2585450c..e36c71db 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -37,16 +37,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># temporary main: interactive editor</span> <span class="Comment"># hit ctrl-c to exit</span> -<span class="muRecipe">recipe!</span> main text:address:array:character [ +<span class="muRecipe">recipe!</span> main text:address:shared:array:character [ <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:address:shared: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">recipe</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">recipe</span> editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data<span class="muRecipe"> -> </span>screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> @@ -55,7 +55,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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<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:address:shared:console, found?:boolean, quit?:boolean<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> @@ -80,7 +80,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># process click, return if it was on current editor</span> -<span class="muRecipe">recipe</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">recipe</span> move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event<span class="muRecipe"> -> </span>in-focus?:boolean, editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor, <span class="Constant">0/false</span> @@ -105,7 +105,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</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">recipe</span> snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor @@ -113,8 +113,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> screen-height:number<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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + prev:address:shared: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<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 @@ -122,7 +122,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *cursor-row<span class="Special"> <- </span>copy target-row cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy target-column - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *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 @@ -190,7 +190,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</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">recipe</span> handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event<span class="muRecipe"> -> </span>screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ <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> @@ -199,7 +199,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> save-row:number<span class="Special"> <- </span>copy *cursor-row @@ -230,10 +230,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> ] -<span class="muRecipe">recipe</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">recipe</span> insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> insert c, *before-cursor *before-cursor<span class="Special"> <- </span>next *before-cursor cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> @@ -248,7 +248,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> - next:address:duplex-list:character<span class="Special"> <- </span>next *before-cursor + next:address:shared:duplex-list:character<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> @@ -268,7 +268,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> next at-right?:boolean<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:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor move-cursor screen, save-row, save-column curr-column:number<span class="Special"> <- </span>copy save-column <span class="Delimiter">{</span> @@ -294,7 +294,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># helper for tests</span> -<span class="muRecipe">recipe</span> editor-render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>screen:address:screen, editor:address:editor-data [ +<span class="muRecipe">recipe</span> editor-render screen:address:shared:screen, editor:address:shared:editor-data<span class="muRecipe"> -> </span>screen:address:shared:screen, editor:address:shared: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> @@ -309,12 +309,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -326,17 +326,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -353,16 +353,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -373,17 +373,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -394,17 +394,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -415,19 +415,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-column [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -444,18 +444,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to cursor</span> memory-should-contain [ @@ -466,15 +466,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -487,9 +487,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ @@ -498,7 +498,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -511,16 +511,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -533,17 +533,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -557,16 +557,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -579,17 +579,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -603,17 +603,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -627,14 +627,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ab]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -648,15 +648,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># no wrap yet</span> screen-should-contain [ @@ -671,7 +671,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># now wrap</span> screen-should-contain [ @@ -686,19 +686,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-line-on-insert-2 [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ @@ -738,16 +738,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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">4</span> <span class="Comment"># line is full; no wrap icon yet</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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -764,16 +764,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -790,16 +790,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -827,14 +827,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -857,12 +857,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *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 @@ -882,8 +882,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># indent if necessary</span> indent?:boolean<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> <span class="muControl">reply-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 + d:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + end-of-previous-line:address:shared: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> <span class="Delimiter">{</span> @@ -897,7 +897,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</span> line-indent curr:address:duplex-list:character, start:address:duplex-list:character<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">recipe</span> line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character<span class="muRecipe"> -> </span>result:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -929,14 +929,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -949,8 +949,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -962,7 +962,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># line should be fully cleared</span> screen-should-contain [ @@ -976,10 +976,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -987,9 +987,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ @@ -1000,10 +1000,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -1012,9 +1012,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## helpers</span> -<span class="muRecipe">recipe</span> draw-horizontal screen:address:screen, row:number, x:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> draw-horizontal screen:address:shared:screen, row:number, x:number, right:number<span class="muRecipe"> -> </span>screen:address:shared: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> diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 0f7a60da..243635b0 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -41,14 +41,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-inserts-two-spaces-on-tab [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -74,18 +74,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -105,7 +105,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } delete-previous-character?:boolean<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?:boolean, backspaced-cell:address:shared:duplex-list:character<span class="Special"> <- </span>delete-before-cursor editor, screen <span class="Constant"> <backspace-character-end></span> <span class="muControl">reply</span> <span class="Delimiter">}</span> @@ -114,19 +114,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</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">recipe</span> delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + data:address:shared:duplex-list:character<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:address:shared:duplex-list:character<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">reply-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 + backspaced-cell:address:shared:duplex-list:character<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 go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -140,7 +140,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply-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 + curr:address:shared:duplex-list:character<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 <span class="Delimiter">{</span> @@ -159,14 +159,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - screen<span class="Special"> <- </span>print screen, <span class="Constant">32/space</span> + space:character<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">recipe</span> move-cursor-coordinates-left editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> move-cursor-coordinates-left editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> @@ -198,7 +199,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + d:address:shared: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 *cursor-column<span class="Special"> <- </span>add left, end-of-line <span class="muControl">reply</span> @@ -211,7 +212,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</span> previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character<span class="muRecipe"> -> </span>result:number [ +<span class="muRecipe">recipe</span> previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character<span class="muRecipe"> -> </span>result:number [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -234,17 +235,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-clears-last-line-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -261,10 +262,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-joins-and-wraps-lines-on-backspace [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -272,7 +273,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># resulting single line should wrap correctly</span> screen-should-contain [ @@ -287,9 +288,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-wraps-long-lines-on-backspace [ 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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># confirm that it wraps</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -304,7 +305,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># resulting single line should wrap correctly and not overflow its bounds</span> screen-should-contain [ @@ -320,15 +321,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -342,7 +343,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -358,18 +359,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } delete-next-character?:boolean<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?:boolean, deleted-cell:address:shared:duplex-list:character<span class="Special"> <- </span>delete-at-cursor editor, screen <span class="Constant"> <delete-character-end></span> <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen<span class="muRecipe"> -> </span>editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + data:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + deleted-cell:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">reply-unless</span> deleted-cell currc:character<span class="Special"> <- </span>get *deleted-cell, <span class="Constant">value:offset</span> @@ -378,7 +379,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">reply-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> + curr:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="Comment"># refresh after remove above</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> screen<span class="Special"> <- </span>move-cursor screen, *cursor-row, *cursor-column @@ -400,7 +401,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - screen<span class="Special"> <- </span>print screen, <span class="Constant">32/space</span> + space:character<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> ] @@ -408,16 +410,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -433,7 +435,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move-to-next-character?:boolean<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:address:shared:duplex-list:character<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> @@ -446,10 +448,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> @@ -476,7 +478,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-wrap?:boolean<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:address:shared:duplex-list:character<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> @@ -497,10 +499,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -510,7 +512,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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> @@ -518,7 +520,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -532,10 +534,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data assume-console [ press right-arrow press right-arrow @@ -544,7 +546,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -557,18 +559,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -587,9 +589,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ 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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -597,9 +599,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -610,9 +612,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -623,18 +625,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -652,10 +654,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -664,7 +666,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># new character should be in next line</span> screen-should-contain [ @@ -683,9 +685,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> @@ -693,7 +695,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -710,7 +712,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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:address:shared:duplex-list:character<span class="Special"> <- </span>prev *before-cursor go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">reply-unless</span> prev <span class="Constant"> <move-cursor-begin></span> @@ -725,10 +727,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -736,9 +738,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -750,11 +752,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with three lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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> @@ -764,7 +766,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -778,11 +780,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -791,7 +793,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># left-arrow should have had no effect</span> screen-should-contain [ @@ -807,11 +809,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> assume-console [ @@ -820,7 +822,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -835,9 +837,9 @@ d] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - <span class="Constant">1</span>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -852,9 +854,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -869,19 +871,19 @@ d] <span class="muScenario">scenario</span> editor-moves-to-previous-line-with-up-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -892,7 +894,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -915,12 +917,12 @@ d] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-previous-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data, go-render?:boolean [ +<span class="muRecipe">recipe</span> move-to-previous-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *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> @@ -930,13 +932,13 @@ d] <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:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor <span class="Delimiter">{</span> - old:address:duplex-list:character<span class="Special"> <- </span>copy curr + old:address:shared: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> <span class="muControl">break-if</span> at-newline? - curr:address:duplex-list:character<span class="Special"> <- </span>before-previous-line curr, editor + curr:address:shared:duplex-list:character<span class="Special"> <- </span>before-previous-line curr, editor no-motion?:boolean<span class="Special"> <- </span>equal curr, old go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="muControl">reply-if</span> no-motion? @@ -956,7 +958,7 @@ d] <span class="Delimiter">{</span> done?:boolean<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:address:shared:duplex-list:character<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> @@ -980,19 +982,19 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-previous-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ab</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1003,7 +1005,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1016,19 +1018,19 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-empty-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [ + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new [ def] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1039,7 +1041,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1053,11 +1055,11 @@ def] <span class="muScenario">scenario</span> editor-moves-to-previous-line-from-left-margin [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># start out with three lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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 [ @@ -1065,9 +1067,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1078,7 +1080,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1093,19 +1095,19 @@ def] <span class="muScenario">scenario</span> editor-moves-to-next-line-with-down-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># ..and ends at (2, 0)</span> memory-should-contain [ @@ -1117,7 +1119,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1140,12 +1142,12 @@ def] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> move-to-next-line editor:address:shared:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:shared:editor-data, go-render?:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *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> @@ -1155,7 +1157,7 @@ def] <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 + next-line:address:shared:duplex-list:character<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> @@ -1173,7 +1175,7 @@ def] <span class="Delimiter">{</span> done?:boolean<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:address:shared:duplex-list:character<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> @@ -1193,19 +1195,19 @@ def] <span class="muScenario">scenario</span> editor-adjusts-column-at-next-line [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1216,7 +1218,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1231,10 +1233,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> assume-console [ @@ -1242,9 +1244,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1280,7 +1282,7 @@ def] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-start-of-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> move-to-start-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># update cursor column</span> @@ -1288,8 +1290,8 @@ def] cursor-column:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy left <span class="Comment"># update before-cursor</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + init:address:shared:duplex-list:character<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 @@ -1305,10 +1307,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> assume-console [ @@ -1316,9 +1318,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1330,9 +1332,9 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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 [ @@ -1340,9 +1342,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1354,10 +1356,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> assume-console [ @@ -1365,9 +1367,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1381,10 +1383,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> assume-console [ @@ -1392,9 +1394,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1407,9 +1409,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1451,14 +1453,14 @@ def] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-end-of-line editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> move-to-end-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> cursor-column:address:number<span class="Special"> <- </span>get-address *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:address:shared:duplex-list:character<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> @@ -1471,10 +1473,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> assume-console [ @@ -1482,9 +1484,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1496,10 +1498,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> assume-console [ @@ -1507,9 +1509,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1521,10 +1523,10 @@ def] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> assume-console [ @@ -1532,9 +1534,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1548,16 +1550,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1574,21 +1576,21 @@ def] delete-to-start-of-line?:boolean<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:address:shared:duplex-list:character<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">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> delete-to-start-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:address:shared:duplex-list:character, editor:address:shared: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:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + start:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor + end:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor <span class="Delimiter">{</span> at-start-of-text?:boolean<span class="Special"> <- </span>equal start, init <span class="muControl">break-if</span> at-start-of-text? @@ -1600,7 +1602,7 @@ def] <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:address:shared:duplex-list:character<span class="Special"> <- </span>next start remove-between start, end <span class="Comment"># adjust cursor</span> *before-cursor<span class="Special"> <- </span>copy start @@ -1611,16 +1613,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1634,16 +1636,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1657,16 +1659,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1682,16 +1684,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1708,19 +1710,19 @@ def] delete-to-end-of-line?:boolean<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:address:shared:duplex-list:character<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">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> delete-to-end-of-line editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:address:shared:duplex-list:character, editor:address:shared: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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + end:address:shared:duplex-list:character<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> <span class="muControl">break-if</span> at-end-of-text? @@ -1737,16 +1739,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1760,16 +1762,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes just last character</span> screen-should-contain [ @@ -1783,16 +1785,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1806,16 +1808,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes just the final character</span> screen-should-contain [ @@ -1829,16 +1831,16 @@ def] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[123</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1856,11 +1858,11 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -1873,7 +1875,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -1886,11 +1888,11 @@ def] <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:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *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 + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen *top-of-screen<span class="Special"> <- </span>before-start-of-next-line *top-of-screen, max no-movement?:boolean<span class="Special"> <- </span>equal old-top, *top-of-screen go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> @@ -1900,11 +1902,11 @@ def] <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">recipe</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">recipe</span> before-start-of-next-line original:address:shared:duplex-list:character, max:number<span class="muRecipe"> -> </span>curr:address:shared:duplex-list:character [ <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 + curr:address:shared:duplex-list:character<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> @@ -1933,11 +1935,11 @@ def] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -1950,7 +1952,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -1965,18 +1967,18 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor starts with a long line wrapping twice</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line containing a wrap icon</span> screen-should-contain [ @@ -1990,7 +1992,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2005,19 +2007,19 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long line in the third line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2035,19 +2037,19 @@ def] <span class="muScenario">scenario</span> editor-scrolls-down-on-newline [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># position cursor after last line and type newline</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2066,19 +2068,19 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2097,20 +2099,20 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains more lines than can fit on screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2127,10 +2129,10 @@ def] <span class="muScenario">scenario</span> editor-scrolls-at-end-on-down-arrow [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> assume-console [ @@ -2138,9 +2140,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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 [ @@ -2151,7 +2153,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2166,9 +2168,9 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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 [ @@ -2180,7 +2182,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2194,14 +2196,14 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a few pages of lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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 @@ -2209,7 +2211,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen scrolls down 3 lines</span> screen-should-contain [ @@ -2226,11 +2228,11 @@ def] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2243,7 +2245,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2256,8 +2258,8 @@ def] <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:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen *top-of-screen<span class="Special"> <- </span>before-previous-line *top-of-screen, editor no-movement?:boolean<span class="Special"> <- </span>equal old-top, *top-of-screen go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> @@ -2267,7 +2269,7 @@ def] <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">recipe</span> before-previous-line curr:address:duplex-list:character, editor:address:editor-data<span class="muRecipe"> -> </span>curr:address:duplex-list:character [ +<span class="muRecipe">recipe</span> before-previous-line curr:address:shared:duplex-list:character, editor:address:shared:editor-data<span class="muRecipe"> -> </span>curr:address:shared:duplex-list:character [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> @@ -2277,12 +2279,12 @@ def] 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> + sentinel:address:shared: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 <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:address:shared:duplex-list:character<span class="Special"> <- </span>prev curr <span class="muControl">reply-unless</span> prev, curr <span class="muControl">reply</span> prev <span class="Delimiter">}</span> @@ -2298,7 +2300,7 @@ def] <span class="Delimiter">{</span> done?:boolean<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:address:shared:duplex-list:character<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> @@ -2312,11 +2314,11 @@ def] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2328,7 +2330,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2341,7 +2343,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2356,17 +2358,17 @@ def] <span class="Comment"># screen has 1 line for menu + 4 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor starts with a long line wrapping twice, occupying 3 of the 4 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2380,7 +2382,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2395,7 +2397,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2410,7 +2412,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2429,11 +2431,11 @@ def] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2445,7 +2447,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2458,7 +2460,7 @@ def] 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2473,18 +2475,18 @@ def] <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with some lines around an empty line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> c d e] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2496,7 +2498,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2508,7 +2510,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2522,18 +2524,18 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2546,9 +2548,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2567,11 +2569,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2586,7 +2588,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2600,7 +2602,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen remains unchanged</span> screen-should-contain [ @@ -2615,11 +2617,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2631,7 +2633,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2646,8 +2648,8 @@ e] <span class="Delimiter">{</span> page-down?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <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> @@ -2662,8 +2664,8 @@ e] <span class="Delimiter">{</span> page-down?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <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> @@ -2676,14 +2678,14 @@ 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">recipe</span> page-down editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> page-down editor:address:shared:editor-data<span class="muRecipe"> -> </span>editor:address:shared: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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> <span class="muControl">reply-unless</span> bottom-of-screen <span class="Comment"># if not, position cursor at final character</span> - before-cursor:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> *before-cursor<span class="Special"> <- </span>prev bottom-of-screen <span class="Comment"># keep one line in common with previous page</span> <span class="Delimiter">{</span> @@ -2694,16 +2696,16 @@ e] <span class="Delimiter">}</span> <span class="Comment"># move cursor and top-of-screen to start of that line</span> move-to-start-of-line editor - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top-of-screen<span class="Special"> <- </span>copy *before-cursor ] <span class="muScenario">scenario</span> editor-does-not-scroll-past-end [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2715,7 +2717,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen remains unmodified</span> screen-should-contain [ @@ -2730,11 +2732,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long last line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2747,7 +2749,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2763,9 +2765,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2778,7 +2780,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2793,11 +2795,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2809,7 +2811,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2823,7 +2825,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2838,8 +2840,8 @@ e] <span class="Delimiter">{</span> page-up?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">2/ctrl-b</span> <span class="muControl">break-unless</span> page-up? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <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> @@ -2854,8 +2856,8 @@ e] <span class="Delimiter">{</span> page-up?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *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:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + old-top:address:shared:duplex-list:character<span class="Special"> <- </span>copy *top-of-screen <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> @@ -2867,16 +2869,16 @@ e] <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> page-up editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> page-up editor:address:shared:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:shared: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:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> <span class="Delimiter">{</span> done?:boolean<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:address:shared:duplex-list:character<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 count<span class="Special"> <- </span>add count, <span class="Constant">1</span> @@ -2888,7 +2890,7 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with 8 lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> @@ -2896,7 +2898,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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2909,7 +2911,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows third page</span> screen-should-contain [ @@ -2923,7 +2925,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows second page</span> screen-should-contain [ @@ -2937,7 +2939,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2952,7 +2954,7 @@ e] <span class="Comment"># screen has 1 line for menu + 5 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">6/height</span> <span class="Comment"># editor contains a long line in the first page</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh</span> <span class="Constant">i</span> @@ -2963,7 +2965,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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -2980,7 +2982,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2996,7 +2998,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3014,9 +3016,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -3029,7 +3031,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -3043,7 +3045,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3057,7 +3059,7 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up-past-nonempty-lines [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[axx</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[axx</span> <span class="Constant">bxx</span> <span class="Constant">cxx</span> <span class="Constant">dxx</span> @@ -3066,7 +3068,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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -3077,7 +3079,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3089,7 +3091,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3102,7 +3104,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3115,7 +3117,7 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up-past-empty-lines [ assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[axy</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[axy</span> <span class="Constant">bxy</span> <span class="Constant">cxy</span> @@ -3124,7 +3126,7 @@ exy fxy gxy ] - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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> @@ -3135,7 +3137,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3147,7 +3149,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3160,7 +3162,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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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 7b632086..adcb7c8c 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -20,6 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.CommentedCode { color: #6c6c6c; } .Delimiter { color: #a04060; } .muScenario { color: #00af00; } --> @@ -41,22 +42,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:address:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:address:shared:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:address:shared:array:character<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:address:shared: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 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 + recipes:address:shared:editor-data + current-sandbox:address:shared:editor-data sandbox-in-focus?:boolean <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> ] -<span class="muRecipe">recipe</span> new-programming-environment screen:address:screen, initial-recipe-contents:address:array:character, initial-sandbox-contents:address:array:character<span class="muRecipe"> -> </span>result:address:programming-environment-data, screen:address:screen [ +<span class="muRecipe">recipe</span> new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> width:number<span class="Special"> <- </span>screen-width screen @@ -68,25 +69,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } button-on-screen?:boolean<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 - run-button:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> + run-button:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> print screen, run-button, <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> 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:address:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">recipes:offset</span> + recipes:address:address:shared:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">recipes:offset</span> *recipes<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> new-left:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - current-sandbox:address:address:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:address:shared:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">current-sandbox:offset</span> *current-sandbox<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, new-left, width/right +<span class="Constant"> <programming-environment-initialization></span> ] -<span class="muRecipe">recipe</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">recipe</span> event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen, console:address:shared:console, env:address:shared: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> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> sandbox-in-focus?:address:boolean<span class="Special"> <- </span>get-address *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> @@ -125,7 +127,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># send to both editors</span> _<span class="Special"> <- </span>move-cursor-in-editor screen, recipes, *t *sandbox-in-focus?<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, *t - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *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> <span class="Delimiter">}</span> <span class="Comment"># 'resize' event - redraw editor</span> @@ -207,21 +209,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Constant"> +finish-event</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env show-screen screen <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> resize screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>env:address:shared:programming-environment-data, screen:address:shared: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> <span class="Comment"># update recipe editor</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> right:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">right:offset</span> *right<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> @@ -230,7 +232,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-column:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy <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> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> left:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">left:offset</span> right:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">right:offset</span> *left<span class="Special"> <- </span>add divider, <span class="Constant">1</span> @@ -246,9 +248,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -256,11 +258,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared: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:shared: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> @@ -272,10 +274,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data <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> @@ -284,11 +286,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared: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:shared: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> @@ -302,7 +304,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># show the cursor at the right window</span> run [ - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + <span class="Constant">8</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">8</span>:character/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -316,10 +319,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> run [ - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># divider isn't messed up</span> screen-should-contain [ @@ -334,15 +337,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data <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 - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># is cursor at the right place?</span> screen-should-contain [ @@ -356,8 +360,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[z]</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">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># cursor should still be right</span> screen-should-contain [ @@ -372,11 +377,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize sandbox side with two lines</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character - render-all screen, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊abc .</span> @@ -390,8 +395,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] 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">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># cursor moves to end of old line</span> screen-should-contain [ @@ -402,7 +408,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> render-all screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> render-all screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <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> @@ -410,12 +416,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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 +<span class="CommentedCode">#? $print [draw menu], 10/newline</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> +<span class="CommentedCode">#? $print [draw menu end], 10/newline</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> 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 - run-button:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> + run-button:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ run (F4) ]</span> print screen, run-button, <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> @@ -427,19 +435,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>render-sandbox-side screen, env <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> + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:address:shared: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> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus? + 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">recipe</span> render-recipes screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <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:address:shared: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> @@ -454,10 +462,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <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:address:shared: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>render screen, current-sandbox @@ -469,9 +477,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } clear-screen-from screen, row, left, left, right ] -<span class="muRecipe">recipe</span> update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared: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> @@ -487,7 +496,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</span> render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">recipe</span> render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> s @@ -508,7 +517,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-right?:boolean<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - print screen, <span class="Constant">8617/loop-back-to-left</span>, <span class="Constant">245/grey</span> + wrap-icon:character<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> screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -523,7 +533,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - print screen, <span class="Constant">32/space</span> + space:character<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> <span class="Delimiter">}</span> @@ -546,7 +557,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># like 'render' for texts, but with colorization for comments like in the editor</span> -<span class="muRecipe">recipe</span> render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ +<span class="muRecipe">recipe</span> render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> s @@ -569,7 +580,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } at-right?:boolean<span class="Special"> <- </span>equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - print screen, <span class="Constant">8617/loop-back-to-left</span>, <span class="Constant">245/grey</span> + wrap-icon:character<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> screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -584,7 +596,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? - print screen, <span class="Constant">32/space</span> + space:character<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> <span class="Delimiter">}</span> @@ -612,7 +625,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> redraw-screen?:boolean<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 + screen<span class="Special"> <- </span>render-all screen, env:address:shared:programming-environment-data sync-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> @@ -626,14 +639,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } switch-side?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">14/ctrl-n</span> <span class="muControl">break-unless</span> switch-side? *sandbox-in-focus?<span class="Special"> <- </span>not *sandbox-in-focus? - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *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> <span class="Delimiter">}</span> ] <span class="SalientComment">## helpers</span> -<span class="muRecipe">recipe</span> draw-vertical screen:address:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:shared: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> diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 0b3e3926..c079109e 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -43,10 +43,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:address:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:address:shared:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:address:shared:array:character<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:address:shared: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 event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env @@ -54,42 +54,50 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muData">container</span> programming-environment-data [ - sandbox:address:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> + sandbox:address:shared:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> + render-from:number + number-of-sandboxes:number +] + +<span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ + render-from:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">render-from:offset</span> + *render-from<span class="Special"> <- </span>copy <span class="Constant">-1</span> ] <span class="muData">container</span> sandbox-data [ - data:address:array:character - response:address:array:character - expected-response:address:array:character + data:address:shared:array:character + response:address:shared:array:character + expected-response:address:shared:array:character <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> response-starting-row-on-screen:number - screen:address:screen <span class="Comment"># prints in the sandbox go here</span> - next-sandbox:address:sandbox-data + screen:address:shared:screen <span class="Comment"># prints in the sandbox go here</span> + next-sandbox:address:shared:sandbox-data ] <span class="muScenario">scenario</span> run-and-show-results [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊divide-with-remainder 11, 3 .</span> <span class="Constant"> . ┊3 .</span> <span class="Constant"> . ┊2 .</span> @@ -118,6 +126,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] + <span class="Comment"># sandbox title in reverse video</span> + screen-should-contain-in-color <span class="Constant">240/dark-grey</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + <span class="Constant"> . 0 .</span> + ] <span class="Comment"># run another command</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -125,18 +140,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊1 x.</span> <span class="Constant"> . ┊divide-with-remainder 11, 3 .</span> <span class="Constant"> . ┊3 .</span> <span class="Constant"> . ┊2 .</span> @@ -151,105 +166,113 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } do-run?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? <span class="CommentedCode">#? $log [F4 pressed]</span> - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[running... ]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[running... ]</span> screen<span class="Special"> <- </span>update-status screen, status, <span class="Constant">245/grey</span> error?:boolean, env, screen<span class="Special"> <- </span>run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> +<span class="CommentedCode">#? $print [render-all begin], 10/newline</span> screen<span class="Special"> <- </span>render-all screen, env +<span class="CommentedCode">#? $print [render-all end], 10/newline</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> error? - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ ]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ ]</span> screen<span class="Special"> <- </span>update-status screen, status, <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *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> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared: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 <span class="muControl">reply-if</span> errors-found? <span class="Comment"># check contents of right editor (sandbox)</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> +<span class="Constant"> <run-sandboxes-begin></span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> - sandbox-contents:address:array:character<span class="Special"> <- </span>editor-contents current-sandbox + sandbox-contents:address:shared:array:character<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> - data:address:address:array:character<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">data:offset</span> + new-sandbox:address:shared:sandbox-data<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> + data:address:address:shared:array:character<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">data:offset</span> *data<span class="Special"> <- </span>copy sandbox-contents <span class="Comment"># push to head of sandbox list</span> - dest:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> - next:address:address:sandbox-data<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">next-sandbox:offset</span> + dest:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + next:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *new-sandbox, <span class="Constant">next-sandbox:offset</span> *next<span class="Special"> <- </span>copy *dest *dest<span class="Special"> <- </span>copy new-sandbox + <span class="Comment"># update sandbox count</span> + sandbox-count:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *sandbox-count<span class="Special"> <- </span>add *sandbox-count, <span class="Constant">1</span> <span class="Comment"># clear sandbox editor</span> - init:address:address:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">data:offset</span> + init:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">data:offset</span> *init<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - top-of-screen:address:address:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</span> *top-of-screen<span class="Special"> <- </span>copy *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> + curr:address:shared: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> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - curr<span class="Special"> <- </span>update-sandbox curr + curr<span class="Special"> <- </span>update-sandbox curr, env, idx curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> +<span class="Constant"> <run-sandboxes-end></span> ] <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">recipe</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">recipe</span> update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared: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> - in:address:array:character<span class="Special"> <- </span>editor-contents recipes + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + in:address:shared:array:character<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> - fake-screen:address:address:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> + data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> + fake-screen:address:address:shared:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> *response, _, *fake-screen<span class="Special"> <- </span>run-interactive data ] -<span class="muRecipe">recipe</span> update-status screen:address:screen, msg:address:array:character, color:number<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe</span> update-status screen:address:shared:screen, msg:address:shared:array:character, color:number<span class="muRecipe"> -> </span>screen:address:shared: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">recipe</span> save-sandboxes env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> save-sandboxes env:address:shared: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:address:shared: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> - suffix:address:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> + curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + suffix:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - data:address:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> - filename:address:array:character<span class="Special"> <- </span>to-text idx + data:address:shared:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> + filename:address:shared:array:character<span class="Special"> <- </span>to-text idx save filename, data <span class="Delimiter">{</span> - expected-response:address:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> + expected-response:address:shared:array:character<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response filename<span class="Special"> <- </span>append filename, suffix save filename, expected-response @@ -260,24 +283,32 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe!</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">recipe!</span> render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [render sandbox side]</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> + current-sandbox:address:shared: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> - row:number, column:number, screen, current-sandbox<span class="Special"> <- </span>render screen, current-sandbox - clear-screen-from screen, row, column, left, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + <span class="Comment"># render sandbox editor</span> + render-from:number<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> + <span class="muControl">break-unless</span> render-current-sandbox? + row, column, screen, current-sandbox<span class="Special"> <- </span>render screen, current-sandbox + clear-screen-from screen, row, column, left, right + row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + <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> - row, screen<span class="Special"> <- </span>render-sandboxes screen, sandbox, left, right, row - clear-rest-of-screen screen, row, left, left, right + sandbox:address:shared: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">recipe</span> render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen, sandbox:address:sandbox-data [ +<span class="muRecipe">recipe</span> render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [render sandbox]</span> @@ -285,69 +316,86 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">reply-if</span> at-bottom?:boolean - <span class="Comment"># render sandbox menu</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - clear-line-delimited screen, left, right - print screen, <span class="Constant">120/x</span>, <span class="Constant">245/grey</span> - <span class="Comment"># save menu row so we can detect clicks to it later</span> - starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - *starting-row<span class="Special"> <- </span>copy row - <span class="Comment"># render sandbox contents</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - sandbox-data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row - code-ending-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> - *code-ending-row<span class="Special"> <- </span>copy row - <span class="Comment"># render sandbox warnings, screen or response, in that order</span> - response-starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> - sandbox-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> -<span class="Constant"> <render-sandbox-results></span> + hidden?:boolean<span class="Special"> <- </span>lesser-than idx, render-from <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 - <span class="muControl">break-if</span> empty-screen? - row, screen<span class="Special"> <- </span>render-screen screen, sandbox-screen, left, right, row + <span class="muControl">break-if</span> hidden? + <span class="Comment"># render sandbox menu</span> + row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + screen<span class="Special"> <- </span>move-cursor screen, row, left + print screen, idx, <span class="Constant">240/dark-grey</span> + clear-line-delimited screen, left, right + delete-icon:character<span class="Special"> <- </span>copy <span class="Constant">120/x</span> + print screen, delete-icon, <span class="Constant">245/grey</span> + <span class="Comment"># save menu row so we can detect clicks to it later</span> + starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + *starting-row<span class="Special"> <- </span>copy row + <span class="Comment"># render sandbox contents</span> + row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + screen<span class="Special"> <- </span>move-cursor screen, row, left + sandbox-data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row + code-ending-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + *code-ending-row<span class="Special"> <- </span>copy row + <span class="Comment"># render sandbox warnings, screen or response, in that order</span> + response-starting-row:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + sandbox-response:address:shared:array:character<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:shared: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 + <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> + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> empty-screen? + *response-starting-row<span class="Special"> <- </span>copy row +<span class="Constant"> <render-sandbox-response></span> + row, screen<span class="Special"> <- </span>render 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 + <span class="muControl">reply-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> <span class="Delimiter">}</span> + <span class="Comment"># if hidden, reset row attributes</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> empty-screen? - *response-starting-row<span class="Special"> <- </span>copy row -<span class="Constant"> <render-sandbox-response></span> - row, screen<span class="Special"> <- </span>render screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row + <span class="muControl">break-unless</span> hidden? + tmp:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> + tmp:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> + tmp:address:number<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + *tmp<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">}</span> -<span class="Constant"> +render-sandbox-end</span> - at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height - <span class="muControl">reply-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> <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> - row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row + next-sandbox:address:shared: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> + row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] <span class="Comment"># assumes programming environment has no sandboxes; restores them from previous session</span> -<span class="muRecipe">recipe</span> restore-sandboxes env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> restore-sandboxes env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>env:address:shared: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> - suffix:address:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> + suffix:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[.out]</span> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + curr:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> - filename:address:array:character<span class="Special"> <- </span>to-text idx - contents:address:array:character<span class="Special"> <- </span>restore filename + filename:address:shared:array:character<span class="Special"> <- </span>to-text idx + contents:address:shared:array:character<span class="Special"> <- </span>restore filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># create new sandbox for file</span> *curr<span class="Special"> <- </span>new <span class="Constant">sandbox-data:type</span> - data:address:address:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">data:offset</span> + data:address:address:shared:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">data:offset</span> *data<span class="Special"> <- </span>copy contents <span class="Comment"># restore expected output for sandbox if it exists</span> <span class="Delimiter">{</span> filename<span class="Special"> <- </span>append filename, suffix contents<span class="Special"> <- </span>restore filename <span class="muControl">break-unless</span> contents - expected-response:address:address:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">expected-response:offset</span> + expected-response:address:address:shared:array:character<span class="Special"> <- </span>get-address **curr, <span class="Constant">expected-response:offset</span> *expected-response<span class="Special"> <- </span>copy contents <span class="Delimiter">}</span> <span class="Constant"> +continue</span> @@ -355,23 +403,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } curr<span class="Special"> <- </span>get-address **curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> + <span class="Comment"># update sandbox count</span> + number-of-sandboxes:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *number-of-sandboxes<span class="Special"> <- </span>copy idx ] <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">recipe</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">recipe</span> render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> sandbox-screen <span class="Comment"># print 'screen:'</span> - header:address:array:character<span class="Special"> <- </span>new <span class="Constant">[screen:]</span> + header:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[screen:]</span> row<span class="Special"> <- </span>render screen, header, 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> + buf:address:shared: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> @@ -385,9 +436,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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> - print screen, <span class="Constant">32/space</span>, <span class="Constant">245/grey</span> - print screen, <span class="Constant">32/space</span>, <span class="Constant">245/grey</span> - print screen, <span class="Constant">46/full-stop</span>, <span class="Constant">245/grey</span> + space:character<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> + 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> @@ -408,13 +461,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print final '.'</span> - print screen, <span class="Constant">46/full-stop</span>, <span class="Constant">245/grey</span> + print screen, full-stop, <span class="Constant">245/grey</span> 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 <span class="muControl">break-if</span> line-done? - print screen, <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> <span class="Delimiter">}</span> @@ -427,24 +480,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">z:number <- 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>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> .z:number <- add 2, 2 ┊ x.</span> + <span class="Constant"> .z:number <- add 2, 2 ┊0 x.</span> <span class="Constant"> .reply z ┊foo .</span> <span class="Constant"> .] ┊4 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -458,14 +511,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen updates the result on the right</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> .z:number <- add 2, 3 ┊ x.</span> + <span class="Constant"> .z:number <- add 2, 3 ┊0 x.</span> <span class="Constant"> .reply z ┊foo .</span> <span class="Constant"> .] ┊5 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -477,23 +530,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that it prints a little toy screen</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> . ┊screen: .</span> <span class="Constant"> . ┊ .4 . .</span> @@ -506,11 +559,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> editor-contents editor:address:editor-data<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">recipe</span> editor-contents editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:address:shared:array:character [ <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:address:shared:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> + curr:address:shared:duplex-list:character<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 @@ -527,21 +580,447 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:address:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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>:address:array:character<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>:address:array:character + editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:address:shared:array:character<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">4</span>:array:character<span class="Special"> <- </span>copy *<span class="Constant">3</span>:address:shared:array:character ] memory-should-contain [ <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> ] ] + +<span class="Comment"># scrolling through sandboxes</span> + +<span class="muScenario">scenario</span> scrolling-down-past-bottom-of-sandbox-editor [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize sandbox side</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + assume-console [ + <span class="Comment"># create a sandbox</span> + press F4 + <span class="Comment"># switch to sandbox editor and type in 2 lines</span> + press ctrl-n + type <span class="Constant">[abc</span> +<span class="Constant">]</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + screen-should-contain [ + <span class="Constant"> . . # minor: F4 clears menu tooltip in very narrow screens</span> + <span class="Constant"> . ┊abc .</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + ] + <span class="Comment"># hit 'down' at bottom of sandbox editor</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'up'</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor displays again</span> + screen-should-contain [ + <span class="Constant"> . . # minor: F4 clears menu tooltip in very narrow screens</span> + <span class="Constant"> . ┊abc .</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + ] +] + +<span class="Comment"># down on sandbox side updates render-from when sandbox editor has cursor at bottom</span> +<span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> *sandbox-in-focus? + down?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65516/down-arrow</span> + <span class="muControl">break-unless</span> down? + sandbox-bottom:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">bottom:offset</span> + sandbox-cursor:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span> + sandbox-cursor-on-last-line?:boolean<span class="Special"> <- </span>equal sandbox-bottom, sandbox-cursor + <span class="muControl">break-unless</span> sandbox-cursor-on-last-line? + sandbox:address:shared: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:address:number<span class="Special"> <- </span>get-address *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 + <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> + <span class="Delimiter">}</span> + hide-screen screen + screen<span class="Special"> <- </span>render-sandbox-side screen, env + show-screen screen + <span class="muControl">jump</span> <span class="Constant">+finish-event:label</span> + <span class="Delimiter">}</span> +] + +<span class="Comment"># update-cursor takes render-from into account</span> +<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> + <span class="muControl">break-unless</span> scrolling? + cursor-column:number<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">reply</span> + <span class="Delimiter">}</span> +] + +<span class="Comment"># 'up' on sandbox side is like 'down': updates render-from when necessary</span> +<span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> *sandbox-in-focus? + up?:boolean<span class="Special"> <- </span>equal *k, <span class="Constant">65517/up-arrow</span> + <span class="muControl">break-unless</span> up? + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + at-beginning?:boolean<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> + hide-screen screen + screen<span class="Special"> <- </span>render-sandbox-side screen, env + show-screen screen + <span class="muControl">jump</span> <span class="Constant">+finish-event:label</span> + <span class="Delimiter">}</span> +] + +<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">recipe</span> previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data<span class="muRecipe"> -> </span>out:address:shared:sandbox-data [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + curr:address:shared:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + <span class="muControl">reply-unless</span> curr, <span class="Constant">0/nil</span> + next:address:shared:sandbox-data<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + <span class="Delimiter">{</span> + <span class="muControl">reply-unless</span> next, <span class="Constant">0/nil</span> + found?:boolean<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> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="muControl">reply</span> curr +] + +<span class="muScenario">scenario</span> scrolling-down-on-recipe-side [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize sandbox side and create a sandbox</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> +<span class="Constant">]</span> + <span class="Comment"># create a sandbox</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + assume-console [ + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># hit 'down' in recipe editor</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> + <span class="Constant"> .␣ ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> scrolling-through-multiple-sandboxes [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊␣ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] + <span class="Comment"># hit 'down'</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣ x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + ] + <span class="Comment"># hit 'down' again</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># just second sandbox displayed</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'down' again</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># no change</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'up'</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># back to displaying both sandboxes without editor</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + ] + <span class="Comment"># hit 'up' again</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + ] + <span class="Comment"># back to displaying both sandboxes as well as editor</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊␣ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] + <span class="Comment"># hit 'up' again</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># no change</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊␣ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] +] + +<span class="muScenario">scenario</span> scrolling-manages-sandbox-index-correctly [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create a sandbox</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'down' and 'up' a couple of times. sandbox index should be stable</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'up' again</span> + assume-console [ + press up-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># back to displaying both sandboxes as well as editor</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># hit 'down'</span> + assume-console [ + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> + <span class="Comment"># cursor moves to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x. # no change</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] </pre> </body> </html> diff --git a/html/edit/006-sandbox-edit.mu.html b/html/edit/006-sandbox-edit.mu.html index d902c4b7..a4830985 100644 --- a/html/edit/006-sandbox-edit.mu.html +++ b/html/edit/006-sandbox-edit.mu.html @@ -38,22 +38,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> 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>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> . reply 4 ┊ x.</span> + <span class="Constant"> . reply 4 ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -64,7 +64,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">3</span>, <span class="Constant">30</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -82,7 +82,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -103,7 +103,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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 <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:address:shared: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> @@ -112,35 +112,37 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } empty-sandbox-editor?:boolean<span class="Special"> <- </span>empty-editor? current-sandbox <span class="muControl">break-unless</span> empty-sandbox-editor? <span class="Comment"># don't clobber existing contents</span> <span class="Comment"># identify the sandbox to edit and remove it from the sandbox list</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>extract-sandbox env, click-row - text:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + sandbox:address:shared:sandbox-data<span class="Special"> <- </span>extract-sandbox env, click-row + <span class="muControl">break-unless</span> sandbox + text:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + *render-from<span class="Special"> <- </span>copy <span class="Constant">-1</span> hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> empty-editor? editor:address:editor-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">recipe</span> empty-editor? editor:address:shared:editor-data<span class="muRecipe"> -> </span>result:boolean [ <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:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + first:address:shared:duplex-list:character<span class="Special"> <- </span>next head result<span class="Special"> <- </span>not first ] -<span class="muRecipe">recipe</span> extract-sandbox env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>result:address:sandbox-data, env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> extract-sandbox env:address:shared:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>result:address:shared:sandbox-data, env:address:shared:programming-environment-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:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + sandbox:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *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 - assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> + in-editor?:boolean<span class="Special"> <- </span>lesser-than click-row, start + <span class="muControl">reply-if</span> in-editor?, <span class="Constant">0</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:address:shared:sandbox-data<span class="Special"> <- </span>get **sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox <span class="Comment"># if click-row < sandbox.next-sandbox.starting-row-on-screen, break</span> next-start:number<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> @@ -152,6 +154,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># snip sandbox out of its list</span> result<span class="Special"> <- </span>copy *sandbox *sandbox<span class="Special"> <- </span>copy next-sandbox + <span class="Comment"># update sandbox count</span> + sandbox-count:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *sandbox-count<span class="Special"> <- </span>subtract *sandbox-count, <span class="Constant">1</span> <span class="Comment"># position cursor in sandbox editor</span> sandbox-in-focus?:address:boolean<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox-in-focus?:offset</span> *sandbox-in-focus?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> @@ -161,20 +166,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> . ┊screen: .</span> <span class="Constant"> . ┊ .4 . .</span> @@ -190,7 +195,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">3</span>, <span class="Constant">70</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -200,6 +205,125 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ .</span> ] ] + +<span class="muScenario">scenario</span> editing-sandbox-after-scrolling-resets-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># edit the second sandbox</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">20</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊add 2, 2 .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> editing-sandbox-updates-sandbox-count [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># edit the second sandbox, then resave</span> + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">20</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># no change in contents</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># now try to scroll past end</span> + assume-console [ + press down-arrow + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># screen should show just final sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] </pre> </body> </html> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 6d289afa..b88de17f 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -37,9 +37,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> deleting-sandboxes [ 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="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <span class="Comment"># run a few commands</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -48,16 +48,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊1 x.</span> <span class="Constant"> . ┊divide-with-remainder 11, 3 .</span> <span class="Constant"> . ┊3 .</span> <span class="Constant"> . ┊2 .</span> @@ -69,13 +69,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">7</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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -87,7 +87,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -105,23 +105,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> was-delete? hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> delete-sandbox t:touch-event, env:address:programming-environment-data<span class="muRecipe"> -> </span>was-delete?:boolean, env:address:programming-environment-data [ +<span class="muRecipe">recipe</span> delete-sandbox t:touch-event, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>was-delete?:boolean, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> click-column:number<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> at-right?:boolean<span class="Special"> <- </span>equal click-column, right <span class="muControl">reply-unless</span> at-right?, <span class="Constant">0/false</span> click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - prev:address:address:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> - curr:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + prev:address:address:shared:sandbox-data<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox:offset</span> + curr:address:shared: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 <span class="Comment"># more sandboxes to check</span> @@ -129,9 +129,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } target-row:number<span class="Special"> <- </span>get *curr, <span class="Constant">starting-row-on-screen:offset</span> delete-curr?:boolean<span class="Special"> <- </span>equal target-row, click-row <span class="muControl">break-unless</span> delete-curr? - <span class="Comment"># delete this sandbox, rerender and stop</span> + <span class="Comment"># delete this sandbox</span> *prev<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> - <span class="muControl">reply</span> <span class="Constant">1/true</span> + <span class="Comment"># update sandbox count</span> + sandbox-count:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span> + *sandbox-count<span class="Special"> <- </span>subtract *sandbox-count, <span class="Constant">1</span> + <span class="Comment"># if it's the last sandbox and if it was the only sandbox rendered, reset scroll</span> + <span class="Delimiter">{</span> + <span class="muControl">break-if</span> *prev + render-from:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">render-from:offset</span> + reset-scroll?:boolean<span class="Special"> <- </span>equal *render-from, *sandbox-count + <span class="muControl">break-unless</span> reset-scroll? + *render-from<span class="Special"> <- </span>copy <span class="Constant">-1</span> + <span class="Delimiter">}</span> + <span class="muControl">reply</span> <span class="Constant">1/true</span> <span class="Comment"># force rerender</span> <span class="Delimiter">}</span> prev<span class="Special"> <- </span>get-address *curr, <span class="Constant">next-sandbox:offset</span> curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> @@ -139,6 +150,204 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="muControl">reply</span> <span class="Constant">0/false</span> ] + +<span class="muScenario">scenario</span> deleting-sandbox-after-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># delete the second sandbox</span> + assume-console [ + left-click <span class="Constant">6</span>, <span class="Constant">29</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> deleting-top-sandbox-after-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + ] + <span class="Comment"># delete the second sandbox</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">29</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> deleting-final-sandbox-after-scroll [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes and scroll to second</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] + <span class="Comment"># delete the second sandbox</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">29</span> + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># implicitly scroll up to first sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] + +<span class="muScenario">scenario</span> deleting-updates-sandbox-count [ + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> + assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span> + <span class="Comment"># initialize environment</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Comment"># create 2 sandboxes</span> + assume-console [ + press ctrl-n + type <span class="Constant">[add 2, 2]</span> + press F4 + type <span class="Constant">[add 1, 1]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊ .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊0 x.</span> + <span class="Constant"> . ┊add 1, 1 .</span> + <span class="Constant"> . ┊2 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊1 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + ] + <span class="Comment"># delete the second sandbox, then try to scroll down twice</span> + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">29</span> + press down-arrow + press down-arrow + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># shouldn't go past last sandbox</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 x.</span> + <span class="Constant"> . ┊add 2, 2 .</span> + <span class="Constant"> . ┊4 .</span> + <span class="Constant"> . ┊━━━━━━━━━━━━━━.</span> + <span class="Constant"> . ┊ .</span> + ] +] </pre> </body> </html> diff --git a/html/edit/008-sandbox-test.mu.html b/html/edit/008-sandbox-test.mu.html index bdf918e8..d5dbcfcb 100644 --- a/html/edit/008-sandbox-test.mu.html +++ b/html/edit/008-sandbox-test.mu.html @@ -38,22 +38,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> 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>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> . reply 4 ┊ x.</span> + <span class="Constant"> . reply 4 ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -64,7 +64,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">5</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># color toggles to green</span> screen-should-contain-in-color <span class="Constant">2/green</span>, [ @@ -79,13 +79,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># cursor should remain unmoved</span> run [ - print screen:address:screen, <span class="Constant">9251/␣/cursor</span> + <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . reply 4 ┊ x.</span> + <span class="Constant"> . reply 4 ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -100,7 +101,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># result turns red</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -123,38 +124,38 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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 <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:address:shared: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 <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:address:shared: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 save-sandboxes env hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env, <span class="Constant">1/clear</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:shared: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> + sandbox:address:shared: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 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:address:shared: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 @@ -170,10 +171,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> sandbox ] -<span class="muRecipe">recipe</span> toggle-expected-response sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe</span> toggle-expected-response sandbox:address:shared:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - expected-response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">expected-response:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if expected-response is set, reset</span> <span class="muControl">break-unless</span> *expected-response @@ -181,7 +182,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> sandbox/same-as-ingredient:<span class="Constant">0</span> <span class="Delimiter">}</span> <span class="Comment"># if not, current response is the expected response</span> - response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> + response:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> *expected-response<span class="Special"> <- </span>copy response ] @@ -189,7 +190,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-response></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-response - expected-response:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:address:shared:array:character<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 <span class="Delimiter">{</span> diff --git a/html/edit/009-sandbox-trace.mu.html b/html/edit/009-sandbox-trace.mu.html index 6d5603bd..868d68fc 100644 --- a/html/edit/009-sandbox-trace.mu.html +++ b/html/edit/009-sandbox-trace.mu.html @@ -39,22 +39,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> ]] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> 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>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> @@ -64,15 +64,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">4</span>, <span class="Constant">21</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">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">4</span>:character/cursor-icon<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor-icon ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -93,15 +94,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">4</span>, <span class="Constant">25</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">9251/␣/cursor</span> + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor-icon ] <span class="Comment"># trace hidden again</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> @@ -112,23 +113,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">40/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> <span class="muControl">reply</span> <span class="Constant">4</span> ]] <span class="Comment"># run it</span> - <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> 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>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> . reply 4 ┊foo .</span> <span class="Constant"> .] ┊4 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> @@ -139,14 +140,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">4</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># trace now printed above result</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . stash [abc] ┊ x.</span> + <span class="Constant"> . stash [abc] ┊0 x.</span> <span class="Constant"> . reply 4 ┊foo .</span> <span class="Constant"> .] ┊abc .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> @@ -156,18 +157,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muData">container</span> sandbox-data [ - trace:address:array:character + trace:address:shared:array:character display-trace?:boolean ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> - trace:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> - fake-screen:address:address:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> + data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> + trace:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> + fake-screen:address:address:shared:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> *response, _, *fake-screen, *trace<span class="Special"> <- </span>run-interactive data ] @@ -179,28 +180,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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 <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:address:shared: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 <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:address:shared: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:address:boolean<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">display-trace?:offset</span> *x<span class="Special"> <- </span>not *x hide-screen screen screen<span class="Special"> <- </span>render-sandbox-side screen, env, <span class="Constant">1/clear</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</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">recipe</span> find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>sandbox:address:shared: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> @@ -210,7 +211,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared: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 @@ -236,7 +237,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> display-trace?:boolean<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> <span class="muControl">break-unless</span> display-trace? - sandbox-trace:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">trace:offset</span> + sandbox-trace:address:shared:array:character<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> row, screen<span class="Special"> <- </span>render screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> diff --git a/html/edit/010-warnings.mu.html b/html/edit/010-warnings.mu.html index c675b386..a9b81c9e 100644 --- a/html/edit/010-warnings.mu.html +++ b/html/edit/010-warnings.mu.html @@ -37,23 +37,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## handling malformed programs</span> <span class="muData">container</span> programming-environment-data [ - recipe-warnings:address:array:character + recipe-warnings:address:shared:array:character ] <span class="Comment"># copy code from recipe editor, persist, load into mu, save any warnings</span> -<span class="muRecipe">recipe!</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">recipe!</span> update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -> </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [update recipes]</span> - recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:address:array:character<span class="Special"> <- </span>editor-contents recipes + recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + in:address:shared:array:character<span class="Special"> <- </span>editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in - recipe-warnings:address:address:array:character<span class="Special"> <- </span>get-address *env, <span class="Constant">recipe-warnings:offset</span> + recipe-warnings:address:address:shared:array:character<span class="Special"> <- </span>get-address *env, <span class="Constant">recipe-warnings:offset</span> *recipe-warnings<span class="Special"> <- </span>reload in <span class="Comment"># if recipe editor has errors, stop</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> *recipe-warnings - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found ]</span> update-status screen, status, <span class="Constant">1/red</span> errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="muControl">reply</span> @@ -63,35 +63,72 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> - recipe-warnings:address:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> + recipe-warnings:address:shared:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-warnings - status:address:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found]</span> + status:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found ]</span> update-status screen, status, <span class="Constant">1/red</span> <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant"><render-recipe-components-end></span> [ <span class="Delimiter">{</span> - recipe-warnings:address:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> + recipe-warnings:address:shared:array:character<span class="Special"> <- </span>get *env, <span class="Constant">recipe-warnings:offset</span> <span class="muControl">break-unless</span> recipe-warnings row, screen<span class="Special"> <- </span>render screen, recipe-warnings, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> ] +<span class="muData">container</span> programming-environment-data [ + warning-index:number <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> [ + warning-index:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">warning-index:offset</span> + *warning-index<span class="Special"> <- </span>copy <span class="Constant">-1</span> +] + +<span class="muRecipe">after</span> <span class="Constant"><run-sandboxes-begin></span> [ + warning-index:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">warning-index:offset</span> + *warning-index<span class="Special"> <- </span>copy <span class="Constant">-1</span> +] + +<span class="muRecipe">before</span> <span class="Constant"><run-sandboxes-end></span> [ + <span class="Delimiter">{</span> + sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal *warning-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> +] + +<span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ + <span class="Delimiter">{</span> + <span class="muControl">break-if</span> recipe-warnings + warning-index:number<span class="Special"> <- </span>get *env, <span class="Constant">warning-index:offset</span> + sandboxes-completed-successfully?:boolean<span class="Special"> <- </span>equal warning-index, <span class="Constant">-1</span> + <span class="muControl">break-if</span> sandboxes-completed-successfully? + status-template:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[errors found (_) ]</span> + warning-index-text:address:shared:array:character<span class="Special"> <- </span>to-text warning-index + status:address:shared:array:character<span class="Special"> <- </span>interpolate status-template, warning-index-text +<span class="CommentedCode">#? $print [update-status: sandbox warning], 10/newline</span> + update-status screen, status, <span class="Constant">1/red</span> +<span class="CommentedCode">#? $print [run sandboxes end], 10/newline</span> + <span class="Delimiter">}</span> +] + <span class="muData">container</span> sandbox-data [ - warnings:address:array:character + warnings:address:shared:array:character ] -<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -> </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="CommentedCode">#? $log [update sandbox]</span> - data:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> - warnings:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">warnings:offset</span> - trace:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> - fake-screen:address:address:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> + data:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> + response:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">response:offset</span> + warnings:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">warnings:offset</span> + trace:address:address:shared:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">trace:offset</span> + fake-screen:address:address:shared:screen<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">screen:offset</span> <span class="CommentedCode">#? $print [run-interactive], 10/newline</span> *response, *warnings, *fake-screen, *trace, completed?:boolean<span class="Special"> <- </span>run-interactive data <span class="Delimiter">{</span> @@ -100,13 +137,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *warnings<span class="Special"> <- </span>new <span class="Constant">[took too long!</span> <span class="Constant">]</span> <span class="Delimiter">}</span> + <span class="Delimiter">{</span> + <span class="muControl">break-unless</span> *warnings +<span class="CommentedCode">#? $print [setting warning-index to ], idx, 10/newline</span> + warning-index:address:number<span class="Special"> <- </span>get-address *env, <span class="Constant">warning-index:offset</span> + warning-not-set?:boolean<span class="Special"> <- </span>equal *warning-index, <span class="Constant">-1</span> + <span class="muControl">break-unless</span> warning-not-set? + *warning-index<span class="Special"> <- </span>copy idx + <span class="Delimiter">}</span> <span class="CommentedCode">#? $print [done with run-interactive], 10/newline</span> ] <span class="Comment"># make sure we render any trace</span> <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-trace-done></span> [ <span class="Delimiter">{</span> - sandbox-warnings:address:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">warnings:offset</span> + sandbox-warnings:address:shared:array:character<span class="Special"> <- </span>get *sandbox, <span class="Constant">warnings:offset</span> <span class="muControl">break-unless</span> sandbox-warnings *response-starting-row<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># no response</span> row, screen<span class="Special"> <- </span>render screen, sandbox-warnings, left, right, <span class="Constant">1/red</span>, row @@ -118,17 +163,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-warnings-in-get [ 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="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<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">]</span>] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -155,32 +200,84 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] +<span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox [ + 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="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">80</span> + <span class="Comment"># create invalid sandbox 1</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + <span class="Comment"># create invalid sandbox 0</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># status shows first sandbox with error</span> + screen-should-contain [ + <span class="Constant"> . errors found (0) run (F4) .</span> + ] +] + +<span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox-2 [ + 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="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + assume-console [ + left-click <span class="Constant">3</span>, <span class="Constant">80</span> + <span class="Comment"># create invalid sandbox 2</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + <span class="Comment"># create invalid sandbox 1</span> + type <span class="Constant">[get foo, x:offset]</span> + press F4 + <span class="Comment"># create valid sandbox 0</span> + type <span class="Constant">[add 2, 2]</span> + press F4 + ] + run [ + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + ] + <span class="Comment"># status shows first sandbox with error</span> + screen-should-contain [ + <span class="Constant"> . errors found (1) run (F4) .</span> + ] +] + <span class="muScenario">scenario</span> run-hides-warnings-from-past-sandboxes [ 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="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> press ctrl-k type <span class="Constant">[add 2, 2]</span> <span class="Comment"># valid code</span> - press F4 <span class="Comment"># error should disappear</span> + 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] + <span class="Comment"># error should disappear</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊add 2, 2 .</span> <span class="Constant"> . ┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -192,24 +289,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> + <span class="Constant">1</span>:address:shared:array:character<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">z <- add x, [a]</span> ]] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <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 ┊ x.</span> + <span class="Constant"> .load-ingredients ┊0 x.</span> <span class="Constant"> .z <- add x, [a] ┊foo 2 .</span> <span class="Constant"> .] ┊foo_2: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] .</span> @@ -221,14 +318,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># error should remain unchanged</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <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 ┊ x.</span> + <span class="Constant"> .load-ingredients ┊0 x.</span> <span class="Constant"> .z <- add x, [a] ┊foo 2 .</span> <span class="Constant"> .] ┊foo_2: 'add' requires number ingredients, but go↩.</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊t [a] .</span> @@ -241,24 +338,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:list:_elem -> n:number [</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe length l:address:shared:list:_elem -> n:number [</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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[x:address:list:number <- copy 0</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[x:address:shared:list:number <- 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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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> @@ -275,7 +372,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># still no errors</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -283,7 +380,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> @@ -300,17 +397,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-missing-type-warnings [ 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="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -326,18 +423,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo «</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span> - replace <span class="Constant">1</span>:address:array:character, <span class="Constant">171/«</span>, <span class="Constant">91</span> <span class="Comment"># '['</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + replace <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">171/«</span>, <span class="Constant">91</span> <span class="Comment"># '['</span> + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -354,28 +451,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-get-on-non-container-warnings [ 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="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</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:address:shared:point <- new point:type</span> +<span class="Constant"> get x:address:shared:point, 1:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> . x:address:point <- new point:type ┊ .</span> - <span class="Constant"> . get x:address:point, 1:offset ┊ .</span> + <span class="Constant"> . x:address:shared:point <- new point:type ┊ .</span> + <span class="Constant"> . get x:address:shared: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:address:shared:point ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -384,27 +481,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> run-shows-non-literal-get-argument-warnings [ 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="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</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"> y:address:shared:point <- new point:type</span> +<span class="Constant"> get *y:address:shared:point, x:number</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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"> . 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"> . y:address:shared:point <- new point:type ┊ .</span> + <span class="Constant"> . get *y:address:shared:point, x:number ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .foo: expected ingredient 1 of 'get' to have type ↩┊ .</span> <span class="Constant"> .'offset'; got x:number ┊ .</span> @@ -419,17 +516,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x:number <- copy y:number</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character 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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -446,7 +543,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -464,23 +561,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints error message in red</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊get 1234:number, 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> @@ -499,7 +596,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> ] screen-should-contain-in-color <span class="Constant">1/red</span>, [ - <span class="Constant"> . .</span> + <span class="Constant"> . errors found (0) .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -527,24 +624,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[get 1234:number, foo:offset]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># check that screen prints error message just once</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . ┊ x.</span> + <span class="Constant"> . ┊0 x.</span> <span class="Constant"> . ┊get 1234:number, 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> @@ -558,26 +655,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant"> {</span> <span class="Constant"> loop</span> <span class="Constant"> }</span> <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] screen-should-contain [ - <span class="Constant"> . run (F4) .</span> + <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo [ ┊ .</span> <span class="Constant"> . { ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . loop ┊ x.</span> + <span class="Constant"> . loop ┊0 x.</span> <span class="Constant"> . } ┊foo .</span> <span class="Constant"> .] ┊took too long! .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -589,7 +686,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a warning</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + <span class="Constant">1</span>:address:shared:array:character<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> @@ -597,40 +694,43 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } _, c:number<span class="Special"> <- </span>divide-with-remainder a, b <span class="muControl">reply</span> b ]] - <span class="Constant">2</span>:address:array:character<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>:address:array:character, <span class="Constant">2</span>:address:array:character + <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> + <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character <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:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data <span class="Comment"># screen prints error message</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .recipe foo \\\[ ┊ .</span> + <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 ┊ x.</span> + <span class="Constant"> .a:number <- next-ingredient ┊0 x.</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"> .reply b ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .] ┊ .</span> ] <span class="Comment"># click on the call in the sandbox</span> assume-console [ left-click <span class="Constant">4</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data ] <span class="Comment"># screen should expand trace</span> screen-should-contain [ - <span class="Constant"> . run (F4) .</span> - <span class="Constant"> .recipe foo \\\[ ┊ .</span> + <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 ┊ x.</span> + <span class="Constant"> .a:number <- next-ingredient ┊0 x.</span> <span class="Constant"> .b:number <- 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 ┊foo: divide by zero in '_, c:number <- divide-wi↩.</span> <span class="Constant"> .reply b ┊th-remainder a, b' .</span> + <span class="Constant"> .] ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> ] ] </pre> diff --git a/html/edit/011-editor-undo.mu.html b/html/edit/011-editor-undo.mu.html index 801ca648..d5d66d09 100644 --- a/html/edit/011-editor-undo.mu.html +++ b/html/edit/011-editor-undo.mu.html @@ -46,13 +46,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> insert-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character <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 + insert-from:address:shared:duplex-list:character + insert-until:address:shared:duplex-list:character tag:number <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> @@ -61,10 +61,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> move-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character tag:number <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> @@ -76,13 +76,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muData">container</span> delete-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared: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 + after-top-of-screen:address:shared:duplex-list:character + deleted-text:address:shared:duplex-list:character + delete-from:address:shared:duplex-list:character + delete-until:address:shared:duplex-list:character tag:number <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> @@ -91,8 +91,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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:address:shared:list:address:shared:operation + redo:address:shared:list:address:shared:operation ] <span class="Comment"># ctrl-z - undo operation</span> @@ -100,11 +100,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> undo?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">26/ctrl-z</span> <span class="muControl">break-unless</span> undo? - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo *undo<span class="Special"> <- </span>rest *undo - redo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> *redo<span class="Special"> <- </span>push op, *redo <span class="Constant"> <handle-undo></span> <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> @@ -116,11 +116,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> redo?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">25/ctrl-y</span> <span class="muControl">break-unless</span> redo? - redo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> <span class="muControl">break-unless</span> *redo - op:address:operation<span class="Special"> <- </span>first *redo + op:address:shared:operation<span class="Special"> <- </span>first *redo *redo<span class="Special"> <- </span>rest *redo - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> *undo<span class="Special"> <- </span>push op, *undo <span class="Constant"> <handle-redo></span> <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> @@ -132,19 +132,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># character should be gone</span> screen-should-contain [ @@ -158,7 +158,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -170,34 +170,34 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>copy *before-cursor + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor ] <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> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *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 + op:address:shared:operation<span class="Special"> <- </span>first *undo typing:address:insert-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> typing previous-coalesce-tag:number<span class="Special"> <- </span>get *typing, <span class="Constant">tag:offset</span> <span class="muControl">break-unless</span> previous-coalesce-tag - insert-until:address:address:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">insert-until:offset</span> + insert-until:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">insert-until:offset</span> *insert-until<span class="Special"> <- </span>next *before-cursor after-row:address:number<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-row:offset</span> *after-row<span class="Special"> <- </span>copy *cursor-row after-column:address:number<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy *cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <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:address:shared:duplex-list:character<span class="Special"> <- </span>next cursor-before + insert-to:address:shared:duplex-list:character<span class="Special"> <- </span>next insert-from + op:address:shared: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> @@ -207,15 +207,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>copy *before-cursor + top-before:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:address:shared:duplex-list:character<span class="Special"> <- </span>copy *before-cursor ] <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> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Comment"># never coalesce</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 *before-cursor - op:address:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + insert-from:address:shared:duplex-list:character<span class="Special"> <- </span>next cursor-before + insert-to:address:shared:duplex-list:character<span class="Special"> <- </span>next *before-cursor + op:address:shared: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 ] @@ -224,12 +224,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">recipe</span> add-operation editor:address:editor-data, op:address:operation<span class="muRecipe"> -> </span>editor:address:editor-data [ +<span class="muRecipe">recipe</span> add-operation editor:address:shared:editor-data, op:address:shared:operation<span class="muRecipe"> -> </span>editor:address:shared:editor-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> *undo<span class="Special"> <- </span>push op *undo - redo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> *redo<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span> ] @@ -238,14 +238,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> typing:address:insert-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> typing - 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:address:shared:duplex-list:character<span class="Special"> <- </span>get *typing, <span class="Constant">insert-from:offset</span> + end:address:shared:duplex-list:character<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<span class="Special"> <- </span>prev start remove-between *before-cursor, end *cursor-row<span class="Special"> <- </span>get *typing, <span class="Constant">before-row:offset</span> *cursor-column<span class="Special"> <- </span>get *typing, <span class="Constant">before-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *typing, <span class="Constant">before-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -253,19 +253,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing-multiple [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># all characters must be gone</span> screen-should-contain [ @@ -279,14 +279,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing-multiple-2 [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .012a .</span> @@ -298,7 +298,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -312,7 +312,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -325,15 +325,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-typing-enter [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . abc .</span> @@ -342,8 +342,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -353,10 +353,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -373,7 +373,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -388,14 +388,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-redo-typing [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -407,7 +407,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -421,7 +421,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -435,13 +435,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> typing:address:insert-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> typing - 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:address:shared: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> <span class="Comment"># assert insert-to matches next(*before-cursor)</span> insert-range *before-cursor, insert-from <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> *cursor-row<span class="Special"> <- </span>get *typing, <span class="Constant">after-row:offset</span> *cursor-column<span class="Special"> <- </span>get *typing, <span class="Constant">after-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *typing, <span class="Constant">after-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -449,14 +449,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-redo-typing-empty [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -468,7 +468,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -482,7 +482,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -495,21 +495,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-work-clears-redo-stack [ <span class="Comment"># create an editor with some text, do some work, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .0abc .</span> @@ -522,7 +522,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># nothing should happen</span> screen-should-contain [ @@ -537,9 +537,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-redo-typing-and-enter-and-tab [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ press tab @@ -550,7 +550,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . ab cd .</span> @@ -558,8 +558,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -569,11 +569,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -590,11 +590,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -610,11 +610,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -630,11 +630,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -650,11 +650,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -671,11 +671,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -694,24 +694,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-touch [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># click undone</span> memory-should-contain [ @@ -723,7 +723,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -737,19 +737,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">after</span> <span class="Constant"><move-cursor-begin></span> [ before-cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> before-cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + before-top-of-screen:address:shared:duplex-list:character<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> [ after-cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> after-cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - after-top-of-screen:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + after-top-of-screen:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen: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:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> *undo - op:address:operation<span class="Special"> <- </span>first *undo + op:address:shared:operation<span class="Special"> <- </span>first *undo move:address:move-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> move previous-coalesce-tag:number<span class="Special"> <- </span>get *move, <span class="Constant">tag:offset</span> @@ -759,11 +759,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *after-row<span class="Special"> <- </span>copy after-cursor-row after-column:address:number<span class="Special"> <- </span>get-address *move, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy after-cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *move, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *move, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <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:address:shared: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>, before-cursor-row, before-cursor-column, before-top-of-screen, after-cursor-row, after-cursor-column, after-top-of-screen, undo-coalesce-tag editor<span class="Special"> <- </span>add-operation editor, op <span class="Constant"> +done-adding-move-operation</span> @@ -774,7 +774,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } move:address:move-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> move <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *cursor-row<span class="Special"> <- </span>get *move, <span class="Constant">before-row:offset</span> *cursor-column<span class="Special"> <- </span>get *move, <span class="Constant">before-column:offset</span> *top<span class="Special"> <- </span>get *move, <span class="Constant">before-top-of-screen:offset</span> @@ -785,18 +785,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> <span class="Comment"># screen scrolls</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -813,9 +813,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moved back</span> memory-should-contain [ @@ -834,7 +834,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -847,25 +847,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-left-arrow [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -877,7 +877,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -891,19 +891,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-up-arrow [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -913,9 +913,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -927,7 +927,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -941,25 +941,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-down-arrow [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -971,7 +971,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -985,27 +985,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-f [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1020,27 +1020,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-page-down [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1055,28 +1055,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-b [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1091,28 +1091,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-page-up [ <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> + <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:address:editor-data + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1127,25 +1127,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-a [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1157,7 +1157,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1171,25 +1171,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-home [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1201,7 +1201,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1215,25 +1215,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-ctrl-e [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1245,7 +1245,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1259,25 +1259,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-end [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves back</span> memory-should-contain [ @@ -1289,7 +1289,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1303,17 +1303,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-separates-undo-insert-from-undo-cursor-move [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .adbc .</span> @@ -1329,9 +1329,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># last letter typed is deleted</span> screen-should-contain [ @@ -1349,9 +1349,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to screen; cursor moves</span> screen-should-contain [ @@ -1369,9 +1369,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen empty</span> screen-should-contain [ @@ -1389,9 +1389,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># first insert</span> screen-should-contain [ @@ -1409,9 +1409,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves</span> screen-should-contain [ @@ -1429,9 +1429,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># second insert</span> screen-should-contain [ @@ -1449,11 +1449,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-multiple-arrows-in-the-same-direction [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared:editor-data <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> @@ -1461,9 +1461,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1473,9 +1473,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># up-arrow is undone</span> memory-should-contain [ @@ -1487,9 +1487,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># both right-arrows are undone</span> memory-should-contain [ @@ -1503,24 +1503,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-redo-touch [ <span class="Comment"># create an editor with some text, click on a character, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data + <span class="Constant">3</span>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared:editor-data, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to left-click</span> memory-should-contain [ @@ -1532,7 +1532,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1550,7 +1550,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> *cursor-column<span class="Special"> <- </span>get *move, <span class="Constant">after-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *move, <span class="Constant">after-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -1560,24 +1560,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-backspace [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1587,10 +1587,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1606,10 +1606,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1624,38 +1624,38 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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:address:shared:duplex-list:character<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> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *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 + op:address:shared:operation<span class="Special"> <- </span>first *undo deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion 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> <span class="muControl">break-unless</span> coalesce? - delete-from:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-from:offset</span> + delete-from:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-from:offset</span> *delete-from<span class="Special"> <- </span>copy *before-cursor - backspaced-so-far:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> + backspaced-so-far:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> insert-range backspaced-cell, *backspaced-so-far *backspaced-so-far<span class="Special"> <- </span>copy backspaced-cell after-row:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-row:offset</span> *after-row<span class="Special"> <- </span>copy *cursor-row after-column:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy *cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <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:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<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> @@ -1666,17 +1666,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion - start2:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">data:offset</span> - anchor:address:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> + start2:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">data:offset</span> + anchor:address:shared:duplex-list:character<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:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">deleted-text:offset</span> + old-cursor:address:shared:duplex-list:character<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 *cursor-row<span class="Special"> <- </span>get *deletion, <span class="Constant">before-row:offset</span> *cursor-column<span class="Special"> <- </span>get *deletion, <span class="Constant">before-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *deletion, <span class="Constant">before-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -1685,13 +1685,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion - 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> + start:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> + end:address:shared:duplex-list:character<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-until: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> *cursor-column<span class="Special"> <- </span>get *deletion, <span class="Constant">after-column:offset</span> - top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> *top<span class="Special"> <- </span>get *deletion, <span class="Constant">after-top-of-screen:offset</span> <span class="Delimiter">}</span> ] @@ -1701,9 +1701,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-delete [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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> @@ -1713,15 +1713,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1731,10 +1731,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1750,10 +1750,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1769,10 +1769,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1788,11 +1788,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1808,11 +1808,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1828,11 +1828,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared: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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1846,37 +1846,37 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <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:address:shared:duplex-list:character<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> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *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 + op:address:shared:operation<span class="Special"> <- </span>first *undo deletion:address:delete-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> deletion 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> <span class="muControl">break-unless</span> coalesce? - delete-until:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-until:offset</span> + delete-until:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-until:offset</span> *delete-until<span class="Special"> <- </span>next *before-cursor - deleted-so-far:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> + deleted-so-far:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> *deleted-so-far<span class="Special"> <- </span>append *deleted-so-far, deleted-cell after-row:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-row:offset</span> *after-row<span class="Special"> <- </span>copy *cursor-row after-column:address:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-column:offset</span> *after-column<span class="Special"> <- </span>copy *cursor-column - after-top:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> + after-top:address:address:shared:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> *after-top<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> <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:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<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> @@ -1888,16 +1888,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-k [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1905,8 +1905,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1916,7 +1916,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1925,8 +1925,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1936,7 +1936,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -1946,8 +1946,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -1957,7 +1957,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1969,15 +1969,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <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:address:shared:duplex-list:character<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> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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 + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<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-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> @@ -1989,16 +1989,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u [ <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>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">1</span>:address:shared:array:character<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>:address:array:character, 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>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .c .</span> @@ -2006,8 +2006,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -2017,7 +2017,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2026,8 +2026,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -2037,7 +2037,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -2047,8 +2047,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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>:number<span class="Special"> <- </span>get *<span class="Constant">2</span>:address:shared: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:shared: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> @@ -2058,7 +2058,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2070,15 +2070,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <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:address:shared:duplex-list:character<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> - undo:address:address:list:address:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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 + top-after:address:shared:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + undo:address:address:shared:list:address:shared:operation<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + op:address:shared:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> + deleted-until:address:shared:duplex-list:character<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-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> @@ -2088,16 +2088,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u-2 [ <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>:address:array:character<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>:address:array:character, 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">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, <span class="Constant">2</span>:address:shared: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:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> |