diff options
Diffstat (limited to 'html/edit')
-rw-r--r-- | html/edit/001-editor.mu.html | 100 | ||||
-rw-r--r-- | html/edit/002-typing.mu.html | 237 | ||||
-rw-r--r-- | html/edit/003-shortcuts.mu.html | 842 | ||||
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 146 | ||||
-rw-r--r-- | html/edit/005-sandbox.mu.html | 169 | ||||
-rw-r--r-- | html/edit/006-sandbox-edit.mu.html | 61 | ||||
-rw-r--r-- | html/edit/007-sandbox-delete.mu.html | 22 | ||||
-rw-r--r-- | html/edit/008-sandbox-test.mu.html | 38 | ||||
-rw-r--r-- | html/edit/009-sandbox-trace.mu.html | 52 | ||||
-rw-r--r-- | html/edit/010-warnings.mu.html | 170 | ||||
-rw-r--r-- | html/edit/011-editor-undo.mu.html | 390 |
11 files changed, 1143 insertions, 1084 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index be568c9d..916e93c6 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } .muData { color: #ffff00; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> </style> @@ -37,9 +37,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># temporary main for this layer: just render the given string at the given</span> <span class="Comment"># screen dimensions, then stop</span> -<span class="muRecipe">recipe!</span> main [ +<span class="muRecipe">recipe!</span> main text:address:array:character [ <span class="Constant">local-scope</span> - text:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> open-console hide-screen <span class="Constant">0/screen</span> new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> @@ -52,7 +52,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> run [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> ] screen-should-contain [ <span class="Comment"># top line of screen reserved for menu</span> @@ -79,19 +79,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-column:number ] -<span class="Comment"># editor:address, screen <- new-editor s:address:array:character, screen:address, left:number, right:number</span> -<span class="Comment"># creates a new editor widget and renders its initial appearance to screen.</span> -<span class="Comment"># top/left/right constrain the screen area available to the new editor.</span> -<span class="Comment"># right is exclusive.</span> -<span class="muRecipe">recipe</span> new-editor [ +<span class="Comment"># creates a new editor widget and renders its initial appearance to screen</span> +<span class="Comment"># top/left/right constrain the screen area available to the new editor</span> +<span class="Comment"># right is exclusive</span> +<span class="muRecipe">recipe</span> new-editor s:address:array:character, screen:address:screen, left:number, right:number<span class="muRecipe"> -> </span>result:address:editor-data [ <span class="Constant">local-scope</span> - s:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> right<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> - result:address:editor-data<span class="Special"> <- </span>new <span class="Constant">editor-data:type</span> + result<span class="Special"> <- </span>new <span class="Constant">editor-data:type</span> <span class="Comment"># initialize screen-related fields</span> x:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">left:offset</span> *x<span class="Special"> <- </span>copy left @@ -102,11 +98,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<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> + init:address:address:duplex-list:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> *init<span class="Special"> <- </span>push-duplex <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - top-of-screen:address:address:duplex-list<span class="Special"> <- </span>get-address *result, <span class="Constant">top-of-screen:offset</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<span class="Special"> <- </span>copy *init - y:address:address:duplex-list<span class="Special"> <- </span>get-address *result, <span class="Constant">before-cursor:offset</span> + y:address:address: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> @@ -115,20 +111,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># initial render to screen, just for some old tests</span> _, _, screen, result<span class="Special"> <- </span>render screen, result <span class="Constant"> <editor-initialization></span> - <span class="muControl">reply</span> result ] -<span class="muRecipe">recipe</span> insert-text [ +<span class="muRecipe">recipe</span> insert-text editor:address:editor-data, text:address:array:character<span class="muRecipe"> -> </span>editor:address:editor-data [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - text:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># early exit if text is empty</span> <span class="muControl">reply-unless</span> text, editor/same-as-ingredient:<span class="Constant">0</span> len:number<span class="Special"> <- </span>length *text <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<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + curr:address: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? @@ -145,7 +139,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> editor-initializes-without-data [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ - <span class="Constant">1</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:address, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> + <span class="Constant">1</span>:address:editor-data<span class="Special"> <- </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 ] memory-should-contain [ @@ -165,22 +159,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="Comment"># last-row:number, last-column:number, screen, editor <- render screen:address, editor:address:editor-data</span> -<span class="Comment">#</span> <span class="Comment"># Assumes cursor should be at coordinates (cursor-row, cursor-column) and</span> <span class="Comment"># updates before-cursor to match. Might also move coordinates if they're</span> <span class="Comment"># outside text.</span> -<span class="muRecipe">recipe</span> render [ +<span class="muRecipe">recipe</span> render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> screen-height:number<span class="Special"> <- </span>screen-height screen right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> <span class="Comment"># traversing editor</span> - curr:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev-duplex</span> + curr:address:duplex-list:character<span class="Special"> <- </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-duplex</span> curr<span class="Special"> <- </span>next-duplex curr <span class="Comment"># traversing screen</span> <span class="Constant"> +render-loop-initialization</span> @@ -189,7 +180,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } column:number<span class="Special"> <- </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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address: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> @@ -251,7 +242,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># save first character off-screen</span> - bottom-of-screen:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">bottom-of-screen:offset</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<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> @@ -268,11 +259,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> ] -<span class="muRecipe">recipe</span> clear-line-delimited [ +<span class="muRecipe">recipe</span> clear-line-delimited screen:address:screen, column:number, right:number [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - column:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-than column, right <span class="muControl">break-if</span> done? @@ -282,13 +271,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> clear-screen-from [ +<span class="muRecipe">recipe</span> clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - column:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># if it's the real screen, use the optimized primitive</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> screen @@ -302,12 +287,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> clear-rest-of-screen [ +<span class="muRecipe">recipe</span> clear-rest-of-screen screen:address:screen, row:number, left:number, right:number [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> screen<span class="Special"> <- </span>move-cursor screen, row, left screen-height:number<span class="Special"> <- </span>screen-height screen @@ -326,7 +308,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } run [ s:address: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, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -340,7 +322,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor s:address:array:character, screen:address, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -354,7 +336,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } run [ s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:address:array:character, screen:address, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -368,7 +350,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -388,7 +370,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - new-editor s:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] <span class="Comment"># still wrap, even though the line would fit. We need room to click on the</span> <span class="Comment"># end of the line</span> @@ -410,7 +392,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> ] @@ -433,7 +415,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } s:address: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, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -462,12 +444,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } color<span class="Special"> <- </span>get-color color, c ] -<span class="Comment"># color <- get-color color:number, c:character</span> <span class="Comment"># so far the previous color is all the information we need; that may change</span> -<span class="muRecipe">recipe</span> get-color [ +<span class="muRecipe">recipe</span> get-color color:number, c:character<span class="muRecipe"> -> </span>color:number [ <span class="Constant">local-scope</span> - color:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - c:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> color-is-white?:boolean<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> <span class="Comment"># if color is white and next character is '#', switch color to blue</span> <span class="Delimiter">{</span> @@ -516,7 +496,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } s:address: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, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + new-editor s:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 787e3a4e..c1f1128f 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } +.muData { color: #ffff00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } +.muScenario { color: #00af00; } --> </style> @@ -37,27 +37,25 @@ 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 [ +<span class="muRecipe">recipe!</span> main text:address:array:character [ <span class="Constant">local-scope</span> - text:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</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-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 [ +<span class="muRecipe">recipe</span> editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="Comment"># looping over each (keyboard or touch) event as it occurs</span> <span class="Constant"> +next-event</span> cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - e:event, console:address, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console + e:event, console:address: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> @@ -82,11 +80,9 @@ 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 [ +<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 [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - t:touch-event<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> editor, <span class="Constant">0/false</span> click-row:number<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> <span class="muControl">reply-unless</span> click-row, <span class="Constant">0/false</span> <span class="Comment"># ignore clicks on 'menu'</span> @@ -106,24 +102,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> <span class="Constant">1/true</span> ] -<span class="Comment"># editor <- snap-cursor screen:address, editor:address:editor-data, target-row:number, target-column:number</span> -<span class="Comment">#</span> <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 [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - target-row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - target-column:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="muControl">reply-unless</span> editor, <span class="Constant">1/top</span>, editor/same-as-ingredient:<span class="Constant">1</span> + <span class="Constant">load-ingredients</span> + <span class="muControl">reply-unless</span> editor left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> screen-height:number<span class="Special"> <- </span>screen-height screen <span class="Comment"># count newlines until screen row</span> - curr:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:address:duplex-list<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev-duplex</span> + curr:address:duplex-list:character<span class="Special"> <- </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-duplex</span> curr<span class="Special"> <- </span>next-duplex curr row:number<span class="Special"> <- </span>copy <span class="Constant">1/top</span> column:number<span class="Special"> <- </span>copy left @@ -131,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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address: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 @@ -195,23 +186,20 @@ 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> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">1</span> ] -<span class="Comment"># screen, editor, go-render?:boolean <- handle-keyboard-event screen:address, editor:address:editor-data, e:event</span> <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 [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - e:event<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="muControl">reply-unless</span> editor, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span> + <span class="Constant">load-ingredients</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-unless</span> editor screen-width:number<span class="Special"> <- </span>screen-width screen screen-height:number<span class="Special"> <- </span>screen-height screen left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - before-cursor:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address: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 @@ -225,27 +213,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> <handle-special-character></span> <span class="Comment"># ignore any other special characters</span> regular-character?:boolean<span class="Special"> <- </span>greater-or-equal *c, <span class="Constant">32/space</span> - <span class="muControl">reply-unless</span> regular-character?, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-unless</span> regular-character? <span class="Comment"># otherwise type it in</span> <span class="Constant"> <insert-character-begin></span> editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, *c, screen <span class="Constant"> <insert-character-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># special key to modify the text or move the cursor</span> k:address:number<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> assert k, <span class="Constant">[event was of unknown type; neither keyboard nor mouse]</span> <span class="Comment"># handlers for each special key will go here</span> <span class="Constant"> <handle-special-key></span> - <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> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> ] -<span class="muRecipe">recipe</span> insert-at-cursor [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - c:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - before-cursor:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</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> insert-duplex c, *before-cursor *before-cursor<span class="Special"> <- </span>next-duplex *before-cursor cursor-row:address:number<span class="Special"> <- </span>get-address *editor, <span class="Constant">cursor-row:offset</span> @@ -260,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<span class="Special"> <- </span>next-duplex *before-cursor + next:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -272,20 +260,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-if</span> overflow? move-cursor screen, save-row, save-column print-character screen, c - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">2</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># not at right margin? print the character and rest of line</span> <span class="muControl">break-unless</span> next at-right?:boolean<span class="Special"> <- </span>greater-or-equal *cursor-column, screen-width <span class="muControl">break-if</span> at-right? - curr:address:duplex-list<span class="Special"> <- </span>copy *before-cursor + curr:address: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> <span class="Comment"># hit right margin? give up and let caller render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> at-right?:boolean<span class="Special"> <- </span>greater-than curr-column, right - <span class="muControl">reply-if</span> at-right?, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">2</span>, <span class="Constant">1/go-render</span> + <span class="muControl">reply-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> @@ -296,16 +286,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } curr<span class="Special"> <- </span>next-duplex curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">2</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">2</span>, <span class="Constant">1/go-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> ] <span class="Comment"># helper for tests</span> -<span class="muRecipe">recipe</span> editor-render [ +<span class="muRecipe">recipe</span> editor-render screen:address:screen, editor:address:editor-data<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> row:number, column:number<span class="Special"> <- </span>render screen, editor @@ -319,11 +310,11 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console <span class="Constant">[]</span> run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -336,14 +327,14 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -363,13 +354,13 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -384,13 +375,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -405,13 +396,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -426,7 +417,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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="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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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"> $clear-trace</span> assume-console [ @@ -434,7 +425,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">3</span>, <span class="Constant">8</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -454,7 +445,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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"> $clear-trace</span> assume-console [ @@ -462,7 +453,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } left-click <span class="Constant">0</span>, <span class="Constant">3</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -476,14 +467,14 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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"> $clear-trace</span> assume-console [ type <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -497,7 +488,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> @@ -507,7 +498,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -521,7 +512,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -529,7 +520,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -544,7 +535,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -552,7 +543,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -567,7 +558,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -575,7 +566,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -590,7 +581,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -598,7 +589,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -614,7 +605,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -622,7 +613,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[ef]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -637,13 +628,13 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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 assume-console [ type <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -658,14 +649,14 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="Comment"># type a letter</span> assume-console [ type <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># no wrap yet</span> screen-should-contain [ @@ -680,7 +671,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># now wrap</span> screen-should-contain [ @@ -697,7 +688,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="Comment"># type more text at the start</span> assume-console [ @@ -705,7 +696,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -740,20 +731,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">2</span>, <span class="Constant">1/go-render</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="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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> 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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -773,13 +765,13 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> 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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -799,13 +791,13 @@ 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, <span class="Constant">2/left</span>, <span class="Constant">7/right</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> 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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -836,13 +828,13 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -860,17 +852,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> <insert-enter-begin></span> editor<span class="Special"> <- </span>insert-new-line-and-indent editor, screen <span class="Constant"> <insert-enter-end></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> + 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> insert-new-line-and-indent [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address: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 @@ -884,13 +876,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } below-screen?:boolean<span class="Special"> <- </span>greater-or-equal *cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> *cursor-row<span class="Special"> <- </span>subtract *cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> <span class="Delimiter">}</span> <span class="Comment"># indent if necessary</span> indent?:boolean<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> - <span class="muControl">reply-unless</span> indent?, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span> - d:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-previous-line:address:duplex-list<span class="Special"> <- </span>prev-duplex *before-cursor + <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-duplex *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> @@ -900,19 +893,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } i<span class="Special"> <- </span>add i, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span> ] <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 [ +<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="Constant">local-scope</span> - curr:address:duplex-list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - start:address:duplex-list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="muControl">reply-unless</span> curr, result + <span class="muControl">reply-unless</span> curr at-start?:boolean<span class="Special"> <- </span>equal curr, start - <span class="muControl">reply-if</span> at-start?, result + <span class="muControl">reply-if</span> at-start? <span class="Delimiter">{</span> curr<span class="Special"> <- </span>prev-duplex curr <span class="muControl">break-unless</span> curr @@ -934,19 +925,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> result ] <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, <span class="Constant">1/left</span>, <span class="Constant">10/right</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> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -960,7 +950,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> assume-console [ press enter ] @@ -972,7 +962,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># line should be fully cleared</span> screen-should-contain [ @@ -989,7 +979,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> @@ -997,7 +987,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1013,7 +1003,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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> @@ -1022,7 +1012,7 @@ 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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1039,7 +1029,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> paste-start? indent?:address:boolean<span class="Special"> <- </span>get-address *editor, <span class="Constant">indent?:offset</span> *indent?<span class="Special"> <- </span>copy <span class="Constant">0/false</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> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -1049,18 +1040,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> paste-end? indent?:address:boolean<span class="Special"> <- </span>get-address *editor, <span class="Constant">indent?:offset</span> *indent?<span class="Special"> <- </span>copy <span class="Constant">1/true</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> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] <span class="SalientComment">## helpers</span> -<span class="muRecipe">recipe</span> draw-horizontal [ +<span class="muRecipe">recipe</span> draw-horizontal screen:address:screen, row:number, x:number, right:number [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - x:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 82273ba7..023f8448 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -13,14 +13,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } .Special { color: #ff6060; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> </style> @@ -43,12 +43,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> assume-console [ press tab ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -65,7 +65,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen editor, screen, go-render?:boolean<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen <span class="Constant"> <insert-character-end></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> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -74,7 +75,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -82,7 +83,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -104,46 +105,48 @@ 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<span class="Special"> <- </span>delete-before-cursor editor, screen + editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character<span class="Special"> <- </span>delete-before-cursor editor, screen <span class="Constant"> <backspace-character-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="Comment"># editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list <- delete-before-cursor editor:address:editor-data, screen</span> <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 [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - before-cursor:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</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> <span class="Comment"># if at start of text (before-cursor at § sentinel), return</span> - prev:address:duplex-list<span class="Special"> <- </span>prev-duplex *before-cursor - <span class="muControl">reply-unless</span> prev, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> + prev:address:duplex-list:character<span class="Special"> <- </span>prev-duplex *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<span class="Special"> <- </span>copy *before-cursor + backspaced-cell:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor remove-duplex *before-cursor <span class="Comment"># will also neatly trim next/prev pointers in backspaced-cell/*before-cursor</span> *before-cursor<span class="Special"> <- </span>copy prev - <span class="muControl">reply-if</span> scroll?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/go-render</span>, backspaced-cell + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply-if</span> scroll? screen-width:number<span class="Special"> <- </span>screen-width screen cursor-row:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> cursor-column:number<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># did we just backspace over a newline?</span> same-row?:boolean<span class="Special"> <- </span>equal cursor-row, original-row - <span class="muControl">reply-unless</span> same-row?, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span>, backspaced-cell + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <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<span class="Special"> <- </span>next-duplex *before-cursor + curr:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:boolean<span class="Special"> <- </span>greater-or-equal curr-column, screen-width - <span class="muControl">reply-if</span> at-right?, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span>, backspaced-cell + at-right?:boolean<span class="Special"> <- </span>greater-or-equal curr-column, right + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> @@ -156,13 +159,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> screen<span class="Special"> <- </span>print-character screen, <span class="Constant">32/space</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span>, backspaced-cell + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] -<span class="muRecipe">recipe</span> move-cursor-coordinates-left [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - before-cursor:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + <span class="Constant">load-ingredients</span> + before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> cursor-row: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> @@ -172,7 +175,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-if</span> at-left-margin? trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[decrementing cursor column]</span> *cursor-column<span class="Special"> <- </span>subtract *cursor-column, <span class="Constant">1</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># if at left margin, we must move to previous row:</span> top-of-screen?:boolean<span class="Special"> <- </span>equal *cursor-row, <span class="Constant">1</span> <span class="Comment"># exclude menu bar</span> @@ -193,28 +197,26 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + d:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> end-of-line:number<span class="Special"> <- </span>previous-line-length before-cursor, d *cursor-column<span class="Special"> <- </span>add left, end-of-line - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># case 2: if previous-character was not newline, we're just at a wrapped line</span> trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[wrapping to previous line]</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> *cursor-column<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> <span class="Comment"># leave room for wrap icon</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, go-render? ] <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 [ +<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="Constant">local-scope</span> - curr:address:duplex-list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - start:address:duplex-list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> result:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="muControl">reply-unless</span> curr, result + <span class="muControl">reply-unless</span> curr at-start?:boolean<span class="Special"> <- </span>equal curr, start - <span class="muControl">reply-if</span> at-start?, result + <span class="muControl">reply-if</span> at-start? <span class="Delimiter">{</span> curr<span class="Special"> <- </span>prev-duplex curr <span class="muControl">break-unless</span> curr @@ -226,7 +228,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } result<span class="Special"> <- </span>add result, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> result ] <span class="muScenario">scenario</span> editor-clears-last-line-on-backspace [ @@ -234,13 +235,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> 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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -256,19 +257,77 @@ 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">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"> $clear-trace</span> + <span class="Comment"># position the cursor at the start of the second and hit backspace</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">0</span> + press backspace + ] + run [ + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + ] + <span class="Comment"># resulting single line should wrap correctly</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> .abc defgh↩.</span> + <span class="Constant"> .i jkl .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> + <span class="Constant"> . .</span> + ] +] + +<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="Comment"># confirm that it wraps</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> .abc def↩ .</span> + <span class="Constant"> . ghij .</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈ .</span> + ] +<span class="Constant"> $clear-trace</span> + <span class="Comment"># position the cursor somewhere in the middle of the top screen line and hit backspace</span> + assume-console [ + left-click <span class="Constant">1</span>, <span class="Constant">4</span> + press backspace + ] + run [ + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + ] + <span class="Comment"># resulting single line should wrap correctly and not overflow its bounds</span> + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> .abcdef ↩ .</span> + <span class="Constant"> .ghij .</span> + <span class="Constant"> .┈┈┈┈┈┈┈┈ .</span> + <span class="Constant"> . .</span> + ] +] + <span class="Comment"># delete - delete character at cursor</span> <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ press delete ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -282,7 +341,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press delete ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -298,25 +357,26 @@ 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<span class="Special"> <- </span>delete-at-cursor editor, screen + editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character<span class="Special"> <- </span>delete-at-cursor editor, screen <span class="Constant"> <delete-character-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> delete-at-cursor [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - before-cursor:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - candidate:address:duplex-list<span class="Special"> <- </span>next-duplex *before-cursor - <span class="muControl">reply-unless</span> candidate, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> - currc:character<span class="Special"> <- </span>get *candidate, <span class="Constant">value:offset</span> - remove-duplex candidate + <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> + deleted-cell:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> + remove-duplex deleted-cell deleted-newline?:boolean<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> - <span class="muControl">reply-if</span> deleted-newline?, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span>, candidate/deleted-cell + 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<span class="Special"> <- </span>next-duplex *before-cursor <span class="Comment"># refresh after remove-duplex above</span> + curr:address:duplex-list:character<span class="Special"> <- </span>next-duplex *before-cursor <span class="Comment"># refresh after remove-duplex 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 @@ -325,7 +385,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> at-right?:boolean<span class="Special"> <- </span>greater-or-equal curr-column, screen-width - <span class="muControl">reply-if</span> at-right?, editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span>, candidate/deleted-cell + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> currc:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> @@ -338,7 +399,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> screen<span class="Special"> <- </span>print-character screen, <span class="Constant">32/space</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span>, candidate/deleted-cell + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] <span class="Comment"># right arrow</span> @@ -346,7 +407,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -354,7 +415,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -370,7 +431,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<span class="Special"> <- </span>next-duplex *before-cursor + next-cursor:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -379,15 +440,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>move-cursor screen, *cursor-row, *cursor-column undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">2/right-arrow</span> <span class="Constant"> <move-cursor-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-cursor-coordinates-right [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen-height:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - before-cursor:address:duplex-list<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> + <span class="Constant">load-ingredients</span> + before-cursor:address:duplex-list:character<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> cursor-row: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> @@ -400,10 +460,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *cursor-row<span class="Special"> <- </span>add *cursor-row, <span class="Constant">1</span> *cursor-column<span class="Special"> <- </span>copy left below-screen?:boolean<span class="Special"> <- </span>greater-or-equal *cursor-row, screen-height <span class="Comment"># must be equal</span> - <span class="muControl">reply-unless</span> below-screen?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-unless</span> below-screen? <span class="Constant"> <scroll-down></span> *cursor-row<span class="Special"> <- </span>subtract *cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/go-render</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="Comment"># if the line wraps, move cursor to start of next row</span> <span class="Delimiter">{</span> @@ -412,7 +474,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<span class="Special"> <- </span>next-duplex before-cursor + next:address:duplex-list:character<span class="Special"> <- </span>next-duplex 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> @@ -423,18 +485,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply-unless</span> below-screen?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> <span class="Constant"> <scroll-down></span> *cursor-row<span class="Special"> <- </span>subtract *cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/go-render</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="Comment"># otherwise move cursor one character right</span> *cursor-column<span class="Special"> <- </span>add *cursor-column, <span class="Constant">1</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> @@ -445,7 +508,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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -453,7 +516,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -469,7 +532,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">1/left</span>, <span class="Constant">10/right</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 assume-console [ press right-arrow @@ -479,7 +542,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -493,7 +556,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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"> $clear-trace</span> assume-console [ @@ -501,7 +564,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -523,7 +586,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> @@ -532,7 +595,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -545,7 +608,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -559,7 +622,7 @@ 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, <span class="Constant">1/left</span>, <span class="Constant">6/right</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"> $clear-trace</span> assume-console [ @@ -567,7 +630,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -589,7 +652,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> @@ -599,7 +662,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># new character should be in next line</span> screen-should-contain [ @@ -619,7 +682,7 @@ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -628,7 +691,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -645,14 +708,15 @@ 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<span class="Special"> <- </span>prev-duplex *before-cursor - <span class="muControl">reply-unless</span> prev, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</span> + prev:address:duplex-list:character<span class="Special"> <- </span>prev-duplex *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> editor, go-render?<span class="Special"> <- </span>move-cursor-coordinates-left editor *before-cursor<span class="Special"> <- </span>copy prev undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">1/left-arrow</span> <span class="Constant"> <move-cursor-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -661,7 +725,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># position cursor at start of second line (so there's no previous newline)</span> @@ -670,7 +734,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press left-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -687,7 +751,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># position cursor further down (so there's a newline before the character at</span> @@ -698,7 +762,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -715,7 +779,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># position cursor at start of text, press left-arrow, then type a character</span> @@ -725,7 +789,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># left-arrow should have had no effect</span> screen-should-contain [ @@ -744,7 +808,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> @@ -754,7 +818,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -770,7 +834,7 @@ d] 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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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"> $clear-trace</span> screen-should-contain [ @@ -786,7 +850,7 @@ d] press left-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -805,7 +869,7 @@ d] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -813,7 +877,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -826,7 +890,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -845,16 +909,16 @@ d] editor, go-render?<span class="Special"> <- </span>move-to-previous-line editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">3/up-arrow</span> <span class="Constant"> <move-cursor-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-previous-line [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address: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> @@ -864,21 +928,23 @@ 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<span class="Special"> <- </span>copy *before-cursor + curr:address:duplex-list:character<span class="Special"> <- </span>copy *before-cursor <span class="Delimiter">{</span> - old:address:duplex-list<span class="Special"> <- </span>copy curr + old:address:duplex-list:character<span class="Special"> <- </span>copy curr c2:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> at-newline?:boolean<span class="Special"> <- </span>equal c2, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr:address:duplex-list<span class="Special"> <- </span>before-previous-line curr, editor + curr:address:duplex-list:character<span class="Special"> <- </span>before-previous-line curr, editor no-motion?:boolean<span class="Special"> <- </span>equal curr, old - <span class="muControl">reply-if</span> no-motion?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-if</span> no-motion? <span class="Delimiter">}</span> <span class="Delimiter">{</span> old<span class="Special"> <- </span>copy curr curr<span class="Special"> <- </span>before-previous-line curr, editor no-motion?:boolean<span class="Special"> <- </span>equal curr, old - <span class="muControl">reply-if</span> no-motion?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-if</span> no-motion? <span class="Delimiter">}</span> *before-cursor<span class="Special"> <- </span>copy curr *cursor-row<span class="Special"> <- </span>subtract *cursor-row, <span class="Constant">1</span> @@ -888,7 +954,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<span class="Special"> <- </span>next-duplex *before-cursor + curr:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -898,13 +964,15 @@ d] *cursor-column<span class="Special"> <- </span>add *cursor-column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># if cursor already at top, scroll up</span> <span class="muControl">break-unless</span> already-at-top? <span class="Constant"> <scroll-up></span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/go-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -912,7 +980,7 @@ d] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -920,7 +988,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -933,7 +1001,7 @@ d] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -948,7 +1016,7 @@ d] 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 [ 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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -956,7 +1024,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -969,7 +1037,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -986,7 +1054,7 @@ def] <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># click on the third line and hit up-arrow, so you end up just after a newline</span> @@ -995,7 +1063,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1008,7 +1076,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1025,7 +1093,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> @@ -1033,7 +1101,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1047,7 +1115,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1066,17 +1134,16 @@ def] editor, go-render?<span class="Special"> <- </span>move-to-next-line editor, screen-height undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">4/down-arrow</span> <span class="Constant"> <move-cursor-end></span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, go-render? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-next-line [ +<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="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen-height:number<span class="Special"> <- </span><span class="Constant">next-ingredient</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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:address:address: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> @@ -1086,7 +1153,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<span class="Special"> <- </span>before-start-of-next-line *before-cursor, max + next-line:address: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> @@ -1094,7 +1161,8 @@ def] <span class="muControl">break-unless</span> no-motion? scroll?:boolean<span class="Special"> <- </span>greater-than *cursor-row, <span class="Constant">1</span> <span class="muControl">break-if</span> scroll?, <span class="Constant">+try-to-scroll:label</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> *cursor-row<span class="Special"> <- </span>add *cursor-row, <span class="Constant">1</span> *before-cursor<span class="Special"> <- </span>copy next-line @@ -1103,7 +1171,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<span class="Special"> <- </span>next-duplex *before-cursor + curr:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -1113,18 +1181,19 @@ def] *cursor-column<span class="Special"> <- </span>add *cursor-column, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Constant"> +try-to-scroll</span> <span class="Constant"> <scroll-down></span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/go-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> ] <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> assume-console [ @@ -1132,7 +1201,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1145,7 +1214,7 @@ def] type <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1156,78 +1225,13 @@ 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">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, <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"> $clear-trace</span> - <span class="Comment"># try to move down past end of text</span> - assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> - press down-arrow - ] - run [ - editor-event-loop screen:address, console:address, <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> - ] - <span class="Comment"># screen should scroll, moving cursor to end of text</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> - ] - assume-console [ - type <span class="Constant">[0]</span> - ] - run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data - ] - screen-should-contain [ - <span class="Constant"> . .</span> - <span class="Constant"> .de0 .</span> -<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> - <span class="Constant"> . .</span> - ] - <span class="Comment"># try to move down again</span> -<span class="Constant"> $clear-trace</span> - assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> - press down-arrow - ] - run [ - editor-event-loop screen:address, console:address, <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> - ] - <span class="Comment"># screen stops scrolling because cursor is already at top</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> - ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> - assume-console [ - type <span class="Constant">[1]</span> - ] - run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data - ] - screen-should-contain [ - <span class="Constant"> . .</span> - <span class="Constant"> .de01 .</span> -<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> - <span class="Constant"> . .</span> - ] -] - <span class="Comment"># ctrl-a/home - move cursor to start of line</span> <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> @@ -1236,7 +1240,7 @@ def] press ctrl-a ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1256,7 +1260,8 @@ def] move-to-start-of-line editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></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">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -1268,20 +1273,21 @@ def] move-to-start-of-line editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></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">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-start-of-line [ +<span class="muRecipe">recipe</span> move-to-start-of-line editor:address:editor-data [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># update cursor column</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> cursor-column: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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - init:address:duplex-list<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> + init:address: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 @@ -1299,7 +1305,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> @@ -1308,7 +1314,7 @@ def] press ctrl-a ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1324,7 +1330,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on second line, press 'home'</span> assume-console [ @@ -1332,7 +1338,7 @@ def] press home ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1348,7 +1354,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> @@ -1357,7 +1363,7 @@ def] press home ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1375,7 +1381,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> @@ -1384,7 +1390,7 @@ def] press ctrl-e ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1399,7 +1405,7 @@ def] type <span class="Constant">[z]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1425,7 +1431,8 @@ def] move-to-end-of-line editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></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">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -1437,18 +1444,19 @@ def] move-to-end-of-line editor undo-coalesce-tag:number<span class="Special"> <- </span>copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></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">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> move-to-end-of-line [ +<span class="muRecipe">recipe</span> move-to-end-of-line editor:address:editor-data [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - before-cursor:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</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> 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<span class="Special"> <- </span>next-duplex *before-cursor + next:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -1463,7 +1471,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> @@ -1472,7 +1480,7 @@ def] press ctrl-e ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1488,7 +1496,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> @@ -1497,7 +1505,7 @@ def] press end ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1513,7 +1521,7 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> @@ -1522,7 +1530,7 @@ def] press end ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1540,14 +1548,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1564,20 +1572,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<span class="Special"> <- </span>delete-to-start-of-line editor + deleted-cells:address:duplex-list:character<span class="Special"> <- </span>delete-to-start-of-line editor <span class="Constant"> <delete-to-start-of-line-end></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> + 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 [ +<span class="muRecipe">recipe</span> delete-to-start-of-line editor:address:editor-data<span class="muRecipe"> -> </span>result:address:duplex-list:character [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - init:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - before-cursor:address:address:duplex-list<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor:offset</span> - start:address:duplex-list<span class="Special"> <- </span>copy *before-cursor - end:address:duplex-list<span class="Special"> <- </span>next-duplex *before-cursor + 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-duplex *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? @@ -1589,28 +1598,27 @@ def] <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result:address:duplex-list<span class="Special"> <- </span>next-duplex start + result:address:duplex-list:character<span class="Special"> <- </span>next-duplex start remove-duplex-between start, end <span class="Comment"># adjust cursor</span> - *before-cursor<span class="Special"> <- </span>prev-duplex end + *before-cursor<span class="Special"> <- </span>copy start left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> 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="muControl">reply</span> result ] <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1626,14 +1634,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1649,14 +1657,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1674,14 +1682,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1698,18 +1706,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<span class="Special"> <- </span>delete-to-end-of-line editor + deleted-cells:address:duplex-list:character<span class="Special"> <- </span>delete-to-end-of-line editor <span class="Constant"> <delete-to-end-of-line-end></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> + 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 [ +<span class="muRecipe">recipe</span> delete-to-end-of-line editor:address:editor-data<span class="muRecipe"> -> </span>result:address:duplex-list:character [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - start:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - end:address:duplex-list<span class="Special"> <- </span>next-duplex start + 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-duplex 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? @@ -1720,23 +1729,22 @@ def] <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result:address:duplex-list<span class="Special"> <- </span>next-duplex start + result<span class="Special"> <- </span>next-duplex start remove-duplex-between start, end - <span class="muControl">reply</span> result ] <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1752,14 +1760,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes just last character</span> screen-should-contain [ @@ -1775,14 +1783,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1798,14 +1806,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes just the final character</span> screen-should-contain [ @@ -1821,14 +1829,14 @@ def] 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1850,7 +1858,7 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1863,7 +1871,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -1876,29 +1884,25 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address: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<span class="Special"> <- </span>copy *top-of-screen + old-top:address: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 - <span class="Comment"># Hack: this reply doesn't match one of the locations of <scroll-down>,</span> - <span class="Comment"># directly within insert-at-cursor. However, I'm unable to trigger the</span> - <span class="Comment"># error.. If necessary create a duplicate copy of <scroll-down> with the</span> - <span class="Comment"># right 'reply-if'.</span> - <span class="muControl">reply-if</span> no-movement?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-if</span> no-movement? ] <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 [ +<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="Constant">local-scope</span> - original:address:duplex-list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - max:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> count:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:address:duplex-list<span class="Special"> <- </span>copy original + curr:address: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> @@ -1931,7 +1935,7 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -1944,7 +1948,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -1963,14 +1967,14 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line containing a wrap icon</span> screen-should-contain [ @@ -1984,7 +1988,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2002,14 +2006,14 @@ def] <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -2032,14 +2036,14 @@ def] <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> type [ ] ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -2063,14 +2067,14 @@ def] <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -2095,14 +2099,14 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -2119,6 +2123,71 @@ 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">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"> $clear-trace</span> + <span class="Comment"># try to move down past end of text</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">0</span> + 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> + ] + <span class="Comment"># screen should scroll, moving cursor to end of text</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> + ] + assume-console [ + type <span class="Constant">[0]</span> + ] + run [ + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> .de0 .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> + <span class="Constant"> . .</span> + ] + <span class="Comment"># try to move down again</span> +<span class="Constant"> $clear-trace</span> + assume-console [ + left-click <span class="Constant">2</span>, <span class="Constant">0</span> + 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> + ] + <span class="Comment"># screen stops scrolling because cursor is already at top</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> + ] + check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + assume-console [ + type <span class="Constant">[1]</span> + ] + run [ + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data + ] + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> .de01 .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> + <span class="Constant"> . .</span> + ] +] + <span class="muScenario">scenario</span> editor-combines-page-and-line-scroll [ <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> @@ -2130,7 +2199,7 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="Comment"># scroll down one page and one line</span> assume-console [ press page-down @@ -2138,7 +2207,7 @@ def] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen scrolls down 3 lines</span> screen-should-contain [ @@ -2159,7 +2228,7 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2172,7 +2241,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2185,33 +2254,33 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list<span class="Special"> <- </span>copy *top-of-screen + 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<span class="Special"> <- </span>before-previous-line *top-of-screen, editor no-movement?:boolean<span class="Special"> <- </span>equal old-top, *top-of-screen - <span class="muControl">reply-if</span> no-movement?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + <span class="muControl">reply-if</span> no-movement? ] <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 [ +<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="Constant">local-scope</span> - curr:address:duplex-list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> c:character<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> <span class="Comment"># compute max, number of characters to skip</span> <span class="Comment"># 1 + len%(width-1)</span> <span class="Comment"># except rotate second term to vary from 1 to width-1 rather than 0 to width-2</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> left:number<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> max-line-length:number<span class="Special"> <- </span>subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> - sentinel:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + sentinel:address:duplex-list:character<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> len:number<span class="Special"> <- </span>previous-line-length curr, sentinel <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<span class="Special"> <- </span>prev-duplex curr + prev:address:duplex-list:character<span class="Special"> <- </span>prev-duplex curr <span class="muControl">reply-unless</span> prev, curr <span class="muControl">reply</span> prev <span class="Delimiter">}</span> @@ -2227,7 +2296,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<span class="Special"> <- </span>prev-duplex curr + prev:address:duplex-list:character<span class="Special"> <- </span>prev-duplex 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> @@ -2245,7 +2314,7 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2257,7 +2326,7 @@ def] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2270,7 +2339,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2289,13 +2358,13 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="Comment"># position cursor at top of second page</span> assume-console [ press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2309,7 +2378,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2324,7 +2393,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2339,7 +2408,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2362,7 +2431,7 @@ def] <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, <span class="Constant">0/left</span>, <span class="Constant">6/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcde↩ .</span> @@ -2374,7 +2443,7 @@ def] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2387,7 +2456,7 @@ def] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2408,12 +2477,12 @@ def] 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, <span class="Constant">0/left</span>, <span class="Constant">6/right</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> assume-console [ press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2425,7 +2494,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2437,7 +2506,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2456,13 +2525,13 @@ e] <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </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="Comment"># position cursor at top of second page</span> assume-console [ press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2475,7 +2544,7 @@ e] press left-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -2500,7 +2569,7 @@ e] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2515,7 +2584,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2529,7 +2598,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen remains unchanged</span> screen-should-contain [ @@ -2548,7 +2617,7 @@ e] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2560,7 +2629,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2575,15 +2644,15 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list<span class="Special"> <- </span>copy *top-of-screen + 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 <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> <span class="Constant"> <move-cursor-end></span> no-movement?:boolean<span class="Special"> <- </span>equal *top-of-screen, old-top - <span class="muControl">reply-if</span> no-movement?, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</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> + go-render?<span class="Special"> <- </span>not no-movement? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -2591,28 +2660,28 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list<span class="Special"> <- </span>copy *top-of-screen + 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 <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> <span class="Constant"> <move-cursor-end></span> no-movement?:boolean<span class="Special"> <- </span>equal *top-of-screen, old-top - <span class="muControl">reply-if</span> no-movement?, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</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> + go-render?<span class="Special"> <- </span>not no-movement? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] <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 [ +<span class="muRecipe">recipe</span> page-down editor:address:editor-data<span class="muRecipe"> -> </span>editor:address:editor-data [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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<span class="Special"> <- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> - <span class="muControl">reply-unless</span> bottom-of-screen, editor/same-as-ingredient:<span class="Constant">0</span> + bottom-of-screen:address: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<span class="Special"> <- </span>get-address *editor, <span class="Constant">before-cursor: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<span class="Special"> <- </span>prev-duplex bottom-of-screen <span class="Comment"># keep one line in common with previous page</span> <span class="Delimiter">{</span> @@ -2623,16 +2692,15 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</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<span class="Special"> <- </span>copy *before-cursor - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span> ] <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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 screen-should-contain [ <span class="Constant"> . .</span> @@ -2645,7 +2713,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen remains unmodified</span> screen-should-contain [ @@ -2664,7 +2732,7 @@ e] <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">4/right</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="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2677,7 +2745,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2695,7 +2763,7 @@ e] <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">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, <span class="Constant">0/left</span>, <span class="Constant">4/right</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="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2708,7 +2776,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2727,7 +2795,7 @@ e] <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:address:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2739,7 +2807,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2753,7 +2821,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2768,15 +2836,15 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list<span class="Special"> <- </span>copy *top-of-screen + 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 <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> <span class="Constant"> <move-cursor-end></span> no-movement?:boolean<span class="Special"> <- </span>equal *top-of-screen, old-top - <span class="muControl">reply-if</span> no-movement?, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</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> + go-render?<span class="Special"> <- </span>not no-movement? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] @@ -2784,36 +2852,34 @@ 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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> - old-top:address:duplex-list<span class="Special"> <- </span>copy *top-of-screen + 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 <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> <span class="Constant"> <move-cursor-end></span> no-movement?:boolean<span class="Special"> <- </span>equal *top-of-screen, old-top <span class="Comment"># don't bother re-rendering if nothing changed. todo: test this</span> - <span class="muControl">reply-if</span> no-movement?, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">0/no-more-render</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> + go-render?<span class="Special"> <- </span>not no-movement? + <span class="muControl">reply</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> page-up [ +<span class="muRecipe">recipe</span> page-up editor:address:editor-data, screen-height:number<span class="muRecipe"> -> </span>editor:address:editor-data [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen-height:number<span class="Special"> <- </span><span class="Constant">next-ingredient</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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top-of-screen:address:address: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<span class="Special"> <- </span>before-previous-line *top-of-screen, editor + prev:address: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> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> editor/same-as-ingredient:<span class="Constant">0</span> ] <span class="muScenario">scenario</span> editor-can-scroll-up-multiple-pages [ @@ -2828,7 +2894,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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2841,7 +2907,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows third page</span> screen-should-contain [ @@ -2855,7 +2921,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows second page</span> screen-should-contain [ @@ -2869,7 +2935,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2895,7 +2961,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, <span class="Constant">0/left</span>, <span class="Constant">4/right</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="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2912,7 +2978,7 @@ e] press down-arrow ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2928,7 +2994,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -2948,7 +3014,7 @@ e] <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">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, <span class="Constant">0/left</span>, <span class="Constant">4/right</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="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2961,7 +3027,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2975,7 +3041,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -2998,7 +3064,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, <span class="Constant">0/left</span>, <span class="Constant">4/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axx .</span> @@ -3009,7 +3075,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3021,7 +3087,7 @@ e] press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3034,7 +3100,7 @@ e] press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3056,7 +3122,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, <span class="Constant">0/left</span>, <span class="Constant">4/right</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> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axy .</span> @@ -3067,7 +3133,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3079,7 +3145,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3092,7 +3158,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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 406c19a9..172b1dcc 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -13,16 +13,16 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } +.muData { color: #ffff00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } +.muScenario { color: #00af00; } --> </style> @@ -46,7 +46,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } initial-sandbox:address: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<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 <span class="Comment"># never gets here</span> @@ -58,15 +57,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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 [ +<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 [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - initial-recipe-contents:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - initial-sandbox-contents:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> width:number<span class="Special"> <- </span>screen-width screen height:number<span class="Special"> <- </span>screen-height screen <span class="Comment"># top menu</span> - result:address:programming-environment-data<span class="Special"> <- </span>new <span class="Constant">programming-environment-data:type</span> + result<span class="Special"> <- </span>new <span class="Constant">programming-environment-data:type</span> draw-horizontal screen, <span class="Constant">0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> button-start:number<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> button-on-screen?:boolean<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> @@ -84,15 +81,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, new-left, width/right -<span class="Constant"> +programming-environment-initialization</span> - <span class="muControl">reply</span> result ] -<span class="muRecipe">recipe</span> event-loop [ +<span class="muRecipe">recipe</span> event-loop screen:address:screen, console:address:console, env:address:programming-environment-data [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> sandbox-in-focus?:address:boolean<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox-in-focus?:offset</span> @@ -222,10 +215,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> resize [ +<span class="muRecipe">recipe</span> resize screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> @@ -249,16 +241,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *cursor-row<span class="Special"> <- </span>copy <span class="Constant">1</span> cursor-column:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">cursor-column:offset</span> *cursor-column<span class="Special"> <- </span>copy *left - <span class="muControl">reply</span> env/same-as-ingredient:<span class="Constant">1</span> ] <span class="muScenario">scenario</span> point-at-multiple-editors [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -266,7 +257,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># check cursor column in each</span> run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + 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> @@ -279,12 +270,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> edit-multiple-editors [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># type one letter in each of them</span> assume-console [ @@ -294,7 +285,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + 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> @@ -312,7 +303,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># show the cursor at the right window</span> run [ - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -323,12 +314,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> multiple-editors-cover-only-their-own-areas [ - $close-trace <span class="Comment"># trace too long</span> + 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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># divider isn't messed up</span> @@ -342,17 +333,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] <span class="Comment"># is cursor at the right place?</span> screen-should-contain [ @@ -366,8 +357,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[z]</span> ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] <span class="Comment"># cursor should still be right</span> screen-should-contain [ @@ -379,13 +370,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> backspace-in-sandbox-editor-joins-lines [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <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">def]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -400,8 +391,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] <span class="Comment"># cursor moves to end of old line</span> screen-should-contain [ @@ -412,10 +403,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> render-all [ +<span class="muRecipe">recipe</span> render-all screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> hide-screen screen <span class="Comment"># top menu</span> @@ -444,13 +434,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus? <span class="Comment">#</span> show-screen screen - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> render-recipes [ +<span class="muRecipe">recipe</span> render-recipes screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> <span class="Comment"># render recipes</span> @@ -464,33 +452,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> clear-screen-from screen, row, left, left, right - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe</span> render-sandbox-side [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> left:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> row:number, column:number, screen, current-sandbox<span class="Special"> <- </span>render screen, current-sandbox clear-line-delimited screen, column, right row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - <span class="Comment"># draw solid line after recipes (you'll see why in later layers)</span> + <span class="Comment"># draw solid line after code (you'll see why in later layers)</span> draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal</span> row<span class="Special"> <- </span>add row, <span class="Constant">1</span> clear-screen-from screen, row, left, left, right - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> update-cursor [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - recipes:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - current-sandbox:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - sandbox-in-focus?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</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> @@ -502,21 +484,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-column:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">}</span> screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="Comment"># row, screen <- render-string screen:address, s:address:array:character, left:number, right:number, color:number, row:number</span> <span class="Comment"># print a string '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-string [ +<span class="muRecipe">recipe</span> render-string 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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - s:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - color:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="muControl">reply-unless</span> s, row/same-as-ingredient:<span class="Constant">5</span>, screen/same-as-ingredient:<span class="Constant">0</span> + <span class="Constant">load-ingredients</span> + <span class="muControl">reply-unless</span> s column:number<span class="Special"> <- </span>copy left screen<span class="Special"> <- </span>move-cursor screen, row, column screen-height:number<span class="Special"> <- </span>screen-height screen @@ -568,20 +543,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-if</span> was-at-left? row<span class="Special"> <- </span>add row, <span class="Constant">1</span> <span class="Delimiter">}</span> - move-cursor row, left - <span class="muControl">reply</span> row/same-as-ingredient:<span class="Constant">5</span>, screen/same-as-ingredient:<span class="Constant">0</span> + move-cursor screen, row, left ] -<span class="Comment"># row, screen <- render-code-string screen:address, s:address:array:character, left:number, right:number, row:number</span> <span class="Comment"># like 'render-string' but with colorization for comments like in the editor</span> -<span class="muRecipe">recipe</span> render-code-string [ +<span class="muRecipe">recipe</span> render-code-string screen:address:screen, s:address:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - s:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="muControl">reply-unless</span> s, row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> + <span class="Constant">load-ingredients</span> + <span class="muControl">reply-unless</span> s color:number<span class="Special"> <- </span>copy <span class="Constant">7/white</span> column:number<span class="Special"> <- </span>copy left screen<span class="Special"> <- </span>move-cursor screen, row, column @@ -635,8 +604,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-if</span> was-at-left? row<span class="Special"> <- </span>add row, <span class="Constant">1</span> <span class="Delimiter">}</span> - move-cursor row, left - <span class="muControl">reply</span> row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> + move-cursor screen, row, left ] <span class="Comment"># ctrl-l - redraw screen (just in case it printed junk somehow)</span> @@ -667,12 +635,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># ctrl-x - maximize/unmaximize the side with focus</span> <span class="muScenario">scenario</span> maximize-side [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 screen<span class="Special"> <- </span>render-all screen, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -685,7 +653,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-x ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># only left side visible</span> screen-should-contain [ @@ -699,7 +667,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-x ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -733,11 +701,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> maximize [ +<span class="muRecipe">recipe</span> maximize screen:address:screen, console:address:console, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, console:address:console [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> hide-screen screen <span class="Comment"># maximize one of the sides</span> maximized?:address:boolean<span class="Special"> <- </span>get-address *env, <span class="Constant">maximized?:offset</span> @@ -760,7 +726,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } screen<span class="Special"> <- </span>render-sandbox-side screen, env <span class="Delimiter">}</span> show-screen screen - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">1</span> ] <span class="Comment"># when maximized, wait for any event and simply unmaximize</span> @@ -794,12 +759,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## helpers</span> -<span class="muRecipe">recipe</span> draw-vertical [ +<span class="muRecipe">recipe</span> draw-vertical screen:address:screen, col:number, y:number, bottom:number [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - col:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - y:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - bottom:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 7115ca00..3fdab8a0 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.muScenario { color: #00af00; } -.muData { color: #ffff00; } -.Special { color: #ff6060; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } +.Special { color: #ff6060; } +.muData { color: #ffff00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } +.muScenario { color: #00af00; } --> </style> @@ -39,6 +39,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># (non-editable) sandboxes below the editor, showing the result and a maybe</span> <span class="Comment"># few other things.</span> +<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> + 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<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 + <span class="Comment"># never gets here</span> +] + <span class="muData">container</span> programming-environment-data [ sandbox:address:sandbox-data <span class="Comment"># list of sandboxes, from top to bottom</span> ] @@ -56,19 +69,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> run-and-show-results [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <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="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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ @@ -111,7 +124,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ @@ -131,8 +144,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="Comment"># hook into event-loop recipe: read non-unicode keypress from k, process it if</span> -<span class="Comment"># necessary, then go to next level</span> <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Comment"># F4? load all code and run all sandboxes.</span> <span class="Delimiter">{</span> @@ -153,12 +164,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> run-sandboxes [ +<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="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - stop?:boolean, env, screen<span class="Special"> <- </span>update-recipes env, screen - <span class="muControl">reply-if</span> stop?, <span class="Constant">1/errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</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="Delimiter">{</span> @@ -175,9 +185,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *next<span class="Special"> <- </span>copy *dest *dest<span class="Special"> <- </span>copy new-sandbox <span class="Comment"># clear sandbox editor</span> - init:address:address:duplex-list<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">data:offset</span> + init:address:address:duplex-list:character<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">data:offset</span> *init<span class="Special"> <- </span>push-duplex <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - top-of-screen:address:address:duplex-list<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</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<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> @@ -186,49 +196,45 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } curr:address: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 - update-sandbox curr + curr<span class="Special"> <- </span>update-sandbox curr curr<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> <span class="Constant">0/no-errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span> + errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] <span class="Comment"># copy code from recipe editor, persist, load into mu</span> -<span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe</span> update-recipes [ +<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="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</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 - save <span class="Constant">[recipes.mu]</span>, in + save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in - <span class="muControl">reply</span> <span class="Constant">0/no-errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span> + 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 [ +<span class="muRecipe">recipe</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ <span class="Constant">local-scope</span> - sandbox:address:sandbox-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> *response, _, *fake-screen<span class="Special"> <- </span>run-interactive data ] -<span class="muRecipe">recipe</span> update-status [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - msg:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - color:number<span class="Special"> <- </span><span class="Constant">next-ingredient</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-string screen, msg, color, <span class="Constant">238/grey/background</span> - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> save-sandboxes [ +<span class="muRecipe">recipe</span> save-sandboxes env:address:programming-environment-data [ <span class="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> <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> @@ -252,10 +258,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe!</span> render-sandbox-side [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> left:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> @@ -267,20 +272,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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 - <span class="muControl">reply</span> screen/same-as-ingredient:<span class="Constant">0</span> ] -<span class="muRecipe">recipe</span> render-sandboxes [ +<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 [ <span class="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - sandbox:address:sandbox-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="muControl">reply-unless</span> sandbox, row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> + <span class="Constant">load-ingredients</span> + <span class="muControl">reply-unless</span> sandbox screen-height:number<span class="Special"> <- </span>screen-height screen at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row, screen-height - <span class="muControl">reply-if</span> at-bottom?:boolean, row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> + <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 @@ -301,7 +301,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } sandbox-response:address: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<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</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 @@ -314,19 +314,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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?, row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> + <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 - <span class="muControl">reply</span> row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> ] <span class="Comment"># assumes programming environment has no sandboxes; restores them from previous session</span> -<span class="muRecipe">recipe</span> restore-sandboxes [ +<span class="muRecipe">recipe</span> restore-sandboxes env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data [ <span class="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> idx:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -352,29 +351,23 @@ 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="muControl">reply</span> env/same-as-ingredient:<span class="Constant">0</span> ] -<span class="Comment"># row, screen <- render-screen screen:address, sandbox-screen:address, left:number, right:number, row:number</span> <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 [ +<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="Constant">local-scope</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - s:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="muControl">reply-unless</span> s, row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</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> row<span class="Special"> <- </span>render-string 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 s</span> + <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 s - s-height:number<span class="Special"> <- </span>screen-height s - buf:address:array:screen-cell<span class="Special"> <- </span>get *s, <span class="Constant">data:offset</span> + s-width:number<span class="Special"> <- </span>screen-width sandbox-screen + s-height:number<span class="Special"> <- </span>screen-height sandbox-screen + buf:address:array:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> stop-printing:number<span class="Special"> <- </span>add left, s-width, <span class="Constant">3</span> max-column:number<span class="Special"> <- </span>min stop-printing, right i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -424,36 +417,33 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } row<span class="Special"> <- </span>add row, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> row/same-as-ingredient:<span class="Constant">4</span>, screen/same-as-ingredient:<span class="Constant">0</span> ] <span class="muScenario">scenario</span> run-updates-results [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">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">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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the code in the editors</span> assume-console [ press F4 ] - run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - ] - <span class="Comment"># check that screen prints the results</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address: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"> .] ┊foo .</span> - <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> - <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .reply z ┊foo .</span> + <span class="Constant"> .] ┊4 .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] <span class="Comment"># make a change (incrementing one of the args to 'add'), then rerun</span> @@ -464,7 +454,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># check that screen updates the result on the right</span> screen-should-contain [ @@ -472,27 +462,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> .z:number <- add 2, 3 ┊ x.</span> - <span class="Constant"> .] ┊foo .</span> - <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊5 .</span> - <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .reply z ┊foo .</span> + <span class="Constant"> .] ┊5 .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] ] <span class="muScenario">scenario</span> run-instruction-manages-screen-per-sandbox [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">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="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:address, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the code in the editor</span> assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># check that it prints a little toy screen</span> screen-should-contain [ @@ -500,7 +490,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ x.</span> - <span class="Constant"> . ┊print-integer screen:address, 4 .</span> + <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> . ┊screen: .</span> <span class="Constant"> . ┊ .4 . .</span> <span class="Constant"> . ┊ . . .</span> @@ -512,11 +502,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -<span class="muRecipe">recipe</span> editor-contents [ +<span class="muRecipe">recipe</span> editor-contents editor:address:editor-data<span class="muRecipe"> -> </span>result:address:array:character [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + curr:address: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-duplex curr @@ -528,20 +518,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } curr<span class="Special"> <- </span>next-duplex curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - result:address:array:character<span class="Special"> <- </span>buffer-to-array buf - <span class="muControl">reply</span> result + result<span class="Special"> <- </span>buffer-to-array buf ] <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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> 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, console:address, <span class="Constant">2</span>:address:editor-data + 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 ] diff --git a/html/edit/006-sandbox-edit.mu.html b/html/edit/006-sandbox-edit.mu.html index e5c2d430..a1e3bb2f 100644 --- a/html/edit/006-sandbox-edit.mu.html +++ b/html/edit/006-sandbox-edit.mu.html @@ -13,14 +13,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } .Special { color: #ff6060; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> </style> @@ -35,25 +35,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## editing sandboxes after they've been created</span> <span class="muScenario">scenario</span> clicking-on-a-sandbox-moves-it-to-editor [ - $close-trace <span class="Comment"># trace too long</span> + 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">recipe foo [</span> -<span class="Constant"> add 2, 2</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> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + <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 screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . add 2, 2 ┊ x.</span> + <span class="Constant"> . reply 4 ┊ x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -64,14 +64,14 @@ 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, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . add 2, 2 ┊ .</span> + <span class="Constant"> . reply 4 ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> @@ -82,13 +82,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[0]</span> ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊0foo .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . add 2, 2 ┊ .</span> + <span class="Constant"> . reply 4 ┊ .</span> <span class="Constant"> .] ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> @@ -97,8 +97,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ - <span class="Comment"># right side of screen and below sandbox editor? pop appropriate sandbox</span> - <span class="Comment"># contents back into sandbox editor provided it's empty</span> + <span class="Comment"># below sandbox editor? pop appropriate sandbox contents back into sandbox editor</span> <span class="Delimiter">{</span> sandbox-left-margin:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> click-column:number<span class="Special"> <- </span>get *t, <span class="Constant">column:offset</span> @@ -111,7 +110,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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? empty-sandbox-editor?:boolean<span class="Special"> <- </span>empty-editor? current-sandbox - <span class="muControl">break-unless</span> empty-sandbox-editor? <span class="Comment"># make the user hit F4 before editing a new sandbox</span> + <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> @@ -124,19 +123,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> empty-editor? [ +<span class="muRecipe">recipe</span> empty-editor? editor:address:editor-data<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - head:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - first:address:duplex-list<span class="Special"> <- </span>next-duplex head - result:boolean<span class="Special"> <- </span>not first - <span class="muControl">reply</span> result + <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-duplex head + result<span class="Special"> <- </span>not first ] -<span class="muRecipe">recipe</span> extract-sandbox [ +<span class="muRecipe">recipe</span> extract-sandbox env:address:programming-environment-data, click-row:number<span class="muRecipe"> -> </span>result:address:sandbox-data [ <span class="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - click-row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</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> start:number<span class="Special"> <- </span>get **sandbox, <span class="Constant">starting-row-on-screen:offset</span> @@ -153,7 +150,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip sandbox out of its list</span> - result:address:sandbox-data<span class="Special"> <- </span>copy *sandbox + result<span class="Special"> <- </span>copy *sandbox *sandbox<span class="Special"> <- </span>copy next-sandbox <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> @@ -162,26 +159,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> sandbox-with-print-can-be-edited [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">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="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:address, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the sandbox</span> assume-console [ press F4 ] - run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - ] + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address: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"> . ┊print-integer screen:address, 4 .</span> + <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> . ┊screen: .</span> <span class="Constant"> . ┊ .4 . .</span> <span class="Constant"> . ┊ . . .</span> @@ -196,11 +191,11 @@ 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, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ┊print-integer screen:address, 4 .</span> + <span class="Constant"> . ┊print-integer screen, 4 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> . ┊ .</span> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 5f3cdfcf..f563b266 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -13,14 +13,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } .Special { color: #ff6060; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> </style> @@ -35,11 +35,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## deleting sandboxes</span> <span class="muScenario">scenario</span> deleting-sandboxes [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run a few commands</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> @@ -48,9 +48,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[add 2, 2]</span> press F4 ] - run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - ] + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -71,7 +69,7 @@ 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, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -89,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, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -113,11 +111,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="Comment"># was-deleted?:boolean <- delete-sandbox t:touch-event, env:address:programming-environment-data</span> -<span class="muRecipe">recipe</span> delete-sandbox [ +<span class="muRecipe">recipe</span> delete-sandbox t:touch-event, env:address:programming-environment-data<span class="muRecipe"> -> </span>was-delete?:boolean [ <span class="Constant">local-scope</span> - t:touch-event<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> right:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> diff --git a/html/edit/008-sandbox-test.mu.html b/html/edit/008-sandbox-test.mu.html index 0cdd6a08..08b62ddc 100644 --- a/html/edit/008-sandbox-test.mu.html +++ b/html/edit/008-sandbox-test.mu.html @@ -13,14 +13,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } .Special { color: #ff6060; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> </style> @@ -35,25 +35,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## clicking on sandbox results to 'fix' them and turn sandboxes into tests</span> <span class="muScenario">scenario</span> sandbox-click-on-result-toggles-color-to-green [ - $close-trace <span class="Comment"># trace too long</span> + 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">recipe foo [</span> -<span class="Constant"> add 2, 2</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> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + <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 screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . add 2, 2 ┊ x.</span> + <span class="Constant"> . reply 4 ┊ 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, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># color toggles to green</span> screen-should-contain-in-color <span class="Constant">2/green</span>, [ @@ -79,19 +79,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># cursor should remain unmoved</span> run [ - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> .␣ ┊ .</span> <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━.</span> - <span class="Constant"> . add 2, 2 ┊ x.</span> + <span class="Constant"> . reply 4 ┊ x.</span> <span class="Constant"> .] ┊foo .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] - <span class="Comment"># now change the second arg of the 'add'</span> + <span class="Comment"># now change the result</span> <span class="Comment"># then rerun</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">11</span> <span class="Comment"># cursor to end of line</span> @@ -100,7 +100,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># result turns red</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -109,7 +109,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"> . 5 .</span> + <span class="Constant"> . 3 .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> ] @@ -117,7 +117,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># clicks on sandbox responses save it as 'expected'</span> <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ - <span class="Comment"># right side of screen? check if it's inside the output of any sandbox</span> + <span class="Comment"># check if it's inside the output of any sandbox</span> <span class="Delimiter">{</span> sandbox-left-margin:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> click-column:number<span class="Special"> <- </span>get *t, <span class="Constant">column:offset</span> @@ -144,10 +144,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> find-click-in-sandbox-output [ +<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="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - click-row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> sandbox:address:sandbox-data<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> start:number<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> @@ -171,9 +170,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> sandbox ] -<span class="muRecipe">recipe</span> toggle-expected-response [ +<span class="muRecipe">recipe</span> toggle-expected-response sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ <span class="Constant">local-scope</span> - sandbox:address:sandbox-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> <span class="Delimiter">{</span> <span class="Comment"># if expected-response is set, reset</span> @@ -184,7 +183,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> *expected-response<span class="Special"> <- </span>copy response - <span class="muControl">reply</span> sandbox/same-as-ingredient:<span class="Constant">0</span> ] <span class="Comment"># when rendering a sandbox, color it in red/green if expected response exists</span> diff --git a/html/edit/009-sandbox-trace.mu.html b/html/edit/009-sandbox-trace.mu.html index b73fbee6..071f62af 100644 --- a/html/edit/009-sandbox-trace.mu.html +++ b/html/edit/009-sandbox-trace.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } .muData { color: #ffff00; } .Special { color: #ff6060; } -.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> </style> @@ -36,7 +36,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## clicking on the code typed into a sandbox toggles its trace</span> <span class="muScenario">scenario</span> sandbox-click-on-code-toggles-app-trace [ - $close-trace <span class="Comment"># trace too long</span> + 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> @@ -48,8 +48,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + <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 screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -59,13 +59,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] - <span class="Comment"># click on the 'foo' line in the sandbox</span> + <span class="Comment"># click on the code in the sandbox</span> assume-console [ left-click <span class="Constant">4</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> screen-should-contain [ @@ -93,8 +93,8 @@ 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, console:address, <span class="Constant">3</span>:address:programming-environment-data - print-character screen:address, <span class="Constant">9251/␣/cursor</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + print-character screen:address:screen, <span class="Constant">9251/␣/cursor</span> ] <span class="Comment"># trace hidden again</span> screen-should-contain [ @@ -109,45 +109,45 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> sandbox-shows-app-trace-and-result [ - $close-trace <span class="Comment"># trace too long</span> + 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">recipe foo [</span> <span class="Constant"> stash [abc]</span> - add <span class="Constant">2</span>, <span class="Constant">2</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> assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + <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 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"> . add 2, 2 ┊foo .</span> + <span class="Constant"> . reply 4 ┊foo .</span> <span class="Constant"> .] ┊4 .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] - <span class="Comment"># click on the 'foo' line in the sandbox</span> + <span class="Comment"># click on the code in the sandbox</span> assume-console [ left-click <span class="Constant">4</span>, <span class="Constant">21</span> ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] - <span class="Comment"># trace now printed</span> + <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"> . add 2, 2 ┊foo .</span> + <span class="Constant"> . reply 4 ┊foo .</span> <span class="Constant"> .] ┊abc .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━.</span> @@ -161,9 +161,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">recipe!</span> update-sandbox [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ <span class="Constant">local-scope</span> - sandbox:address:sandbox-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> @@ -173,7 +173,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># clicks on sandbox code toggle its display-trace? flag</span> <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ - <span class="Comment"># right side of screen? check if it's inside the code of any sandbox</span> + <span class="Comment"># check if it's inside the code of any sandbox</span> <span class="Delimiter">{</span> sandbox-left-margin:number<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> click-column:number<span class="Special"> <- </span>get *t, <span class="Constant">column:offset</span> @@ -200,12 +200,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">recipe</span> find-click-in-sandbox-code [ +<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="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - click-row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</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<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> @@ -241,6 +240,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> sandbox-trace <span class="Comment"># nothing to print; move on</span> row, screen<span class="Special"> <- </span>render-string, screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> +<span class="Constant"> <render-sandbox-trace-done></span> ] </pre> </body> diff --git a/html/edit/010-warnings.mu.html b/html/edit/010-warnings.mu.html index ca9008b7..335bfb42 100644 --- a/html/edit/010-warnings.mu.html +++ b/html/edit/010-warnings.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } +.muData { color: #ffff00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } +.muScenario { color: #00af00; } --> </style> @@ -40,10 +40,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="Comment"># copy code from recipe editor, persist, load into mu, save any warnings</span> -<span class="muRecipe">recipe!</span> update-recipes [ +<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="Constant">local-scope</span> - env:address:programming-environment-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</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 save <span class="Constant">[recipes.mu]</span>, in @@ -54,9 +53,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">break-unless</span> *recipe-warnings status:address: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="muControl">reply</span> <span class="Constant">1/errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span> + errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + <span class="muControl">reply</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> <span class="Constant">0/no-errors-found</span>, env/same-as-ingredient:<span class="Constant">0</span>, screen/same-as-ingredient:<span class="Constant">1</span> + errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> ] <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ @@ -81,9 +81,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } warnings:address:array:character ] -<span class="muRecipe">recipe!</span> update-sandbox [ +<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -> </span>sandbox:address:sandbox-data [ <span class="Constant">local-scope</span> - sandbox:address:sandbox-data<span class="Special"> <- </span><span class="Constant">next-ingredient</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> warnings:address:address:array:character<span class="Special"> <- </span>get-address *sandbox, <span class="Constant">warnings:offset</span> @@ -98,30 +98,32 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">}</span> ] -<span class="muRecipe">after</span> <span class="Constant"><render-sandbox-results></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> <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-string screen, sandbox-warnings, left, right, <span class="Constant">1/red</span>, row + <span class="Comment"># don't try to print anything more for this sandbox</span> <span class="muControl">jump</span> <span class="Constant">+render-sandbox-end:label</span> <span class="Delimiter">}</span> ] <span class="muScenario">scenario</span> run-shows-warnings-in-get [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Constant">1</span>:address: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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -129,7 +131,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . get 123:number, foo:offset ┊ .</span> <span class="Constant"> .] ┊ .</span> - <span class="Constant"> .unknown element foo in container number ┊ .</span> + <span class="Constant"> .foo: unknown element foo in container number ┊ .</span> + <span class="Constant"> .foo: first ingredient of 'get' should be a contai↩┊ .</span> + <span class="Constant"> .ner, but got 123:number ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -139,25 +143,27 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . .</span> - <span class="Constant"> .unknown element foo in container number .</span> + <span class="Constant"> .foo: unknown element foo in container number .</span> + <span class="Constant"> .foo: first ingredient of 'get' should be a contai .</span> + <span class="Constant"> .ner, but got 123:number .</span> <span class="Constant"> . .</span> ] ] <span class="muScenario">scenario</span> run-shows-missing-type-warnings [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Constant">1</span>:address: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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -165,14 +171,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . x <- copy 0 ┊ .</span> <span class="Constant"> .] ┊ .</span> - <span class="Constant"> .missing type in 'x <- copy 0' ┊ .</span> - <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> - <span class="Constant"> . ┊ .</span> + <span class="Constant"> .foo: missing type for x in 'x <- copy 0' ┊ .</span> ] ] <span class="muScenario">scenario</span> run-shows-unbalanced-bracket-warnings [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <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> @@ -181,12 +185,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">]</span> string-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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -201,7 +205,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muScenario">scenario</span> run-shows-get-on-non-container-warnings [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> @@ -209,28 +213,29 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> get x:address: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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ - <span class="Constant"> . run (F4) .</span> - <span class="Constant"> . ┊ .</span> + <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 ┊ x.</span> - <span class="Constant"> . get x:address:point, 1:offset ┊foo .</span> - <span class="Constant"> .] ┊foo: first ingredient of 'get' should be a conta↩.</span> - <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊iner, but got x:address:point .</span> - <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> . x:address:point <- new point:type ┊ .</span> + <span class="Constant"> . get x:address: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"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] ] <span class="muScenario">scenario</span> run-shows-non-literal-get-argument-warnings [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> @@ -239,12 +244,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> get *y:address: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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -256,13 +261,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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> + <span class="Constant"> .foo: second ingredient of 'get' should have type ↩┊ .</span> + <span class="Constant"> .'offset', but got x:number ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] ] <span class="muScenario">scenario</span> run-shows-warnings-everytime [ - $close-trace <span class="Comment"># trace too long</span> + 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> @@ -270,12 +277,12 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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 assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -283,7 +290,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . x:number <- copy y:number ┊ .</span> <span class="Constant"> .] ┊ .</span> - <span class="Constant"> .use before set: y in foo ┊ .</span> + <span class="Constant"> .foo: use before set: y ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] @@ -292,7 +299,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -300,26 +307,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . x:number <- copy y:number ┊ .</span> <span class="Constant"> .] ┊ .</span> - <span class="Constant"> .use before set: y in foo ┊ .</span> + <span class="Constant"> .foo: use before set: y ┊ .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .</span> <span class="Constant"> . ┊ .</span> ] ] <span class="muScenario">scenario</span> run-instruction-and-print-warnings [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <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="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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># check that screen prints error message in red</span> screen-should-contain [ @@ -329,6 +336,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ 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> + <span class="Constant"> . ┊ but got 1234:number .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] @@ -349,6 +358,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . .</span> <span class="Constant"> . .</span> <span class="Constant"> . unknown element foo in container number .</span> + <span class="Constant"> . first ingredient of 'get' should be a container, .</span> + <span class="Constant"> . but got 1234:number .</span> <span class="Constant"> . .</span> ] screen-should-contain-in-color <span class="Constant">245/grey</span>, [ @@ -358,26 +369,28 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ x.</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="muScenario">scenario</span> run-instruction-and-print-warnings-only-once [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <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="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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># check that screen prints error message just once</span> screen-should-contain [ @@ -387,13 +400,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ 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> + <span class="Constant"> . ┊ but got 1234:number .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> <span class="Constant"> . ┊ .</span> ] ] <span class="muScenario">scenario</span> sandbox-can-handle-infinite-loop [ - $close-trace <span class="Comment"># trace too long</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">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> @@ -403,13 +418,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + <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="Comment"># run the sandbox</span> assume-console [ press F4 ] run [ - event-loop screen:address, console:address, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -422,6 +437,55 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant"> . ┊ .</span> ] ] + +<span class="muScenario">scenario</span> sandbox-with-warnings-shows-trace [ + 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">local-scope</span> +<span class="Constant">a:number <- next-ingredient</span> +<span class="Constant">b:number <- next-ingredient</span> +<span class="Constant">stash [dividing by]</span>, b +_, 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="Comment"># run</span> + assume-console [ + press F4 + ] + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address: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"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .a:number <- next-ingredient ┊ 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="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 + ] + <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"> .local-scope ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> + <span class="Constant"> .a:number <- next-ingredient ┊ 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> + ] +] </pre> </body> </html> diff --git a/html/edit/011-editor-undo.mu.html b/html/edit/011-editor-undo.mu.html index 37417b7f..b50f0063 100644 --- a/html/edit/011-editor-undo.mu.html +++ b/html/edit/011-editor-undo.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } +.muData { color: #ffff00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } +.muScenario { color: #00af00; } --> </style> @@ -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<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:list:address: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 *undo<span class="Special"> <- </span>rest *undo - redo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:list:address: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<span class="Special"> <- </span>get-address *editor, <span class="Constant">redo:offset</span> + redo:address:address:list:address: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 *redo<span class="Special"> <- </span>rest *redo - undo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:list:address: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> @@ -133,18 +133,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console [ type <span class="Constant">[0]</span> ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -170,12 +170,12 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:address:duplex-list<span class="Special"> <- </span>copy *before-cursor + 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 ] <span class="muRecipe">before</span> <span class="Constant"><insert-character-end></span> [ - top-after:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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> <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 @@ -184,19 +184,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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<span class="Special"> <- </span>get-address *typing, <span class="Constant">insert-until:offset</span> + insert-until:address:address:duplex-list:character<span class="Special"> <- </span>get-address *typing, <span class="Constant">insert-until:offset</span> *insert-until<span class="Special"> <- </span>next-duplex *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:number<span class="Special"> <- </span>get-address *typing, <span class="Constant">after-top-of-screen:offset</span> + 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<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<span class="Special"> <- </span>next-duplex cursor-before - insert-to:address:duplex-list<span class="Special"> <- </span>next-duplex insert-from + insert-from:address:duplex-list:character<span class="Special"> <- </span>next-duplex cursor-before + insert-to:address:duplex-list:character<span class="Special"> <- </span>next-duplex insert-from op:address: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 @@ -207,14 +207,14 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:address:duplex-list<span class="Special"> <- </span>copy *before-cursor + 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 ] <span class="muRecipe">before</span> <span class="Constant"><insert-enter-end></span> [ - top-after:address:duplex-list<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-after:address: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<span class="Special"> <- </span>next-duplex cursor-before - insert-to:address:duplex-list<span class="Special"> <- </span>next-duplex *before-cursor + insert-from:address:duplex-list:character<span class="Special"> <- </span>next-duplex cursor-before + insert-to:address:duplex-list:character<span class="Special"> <- </span>next-duplex *before-cursor op:address: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,10 +224,9 @@ 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 [ +<span class="muRecipe">recipe</span> add-operation editor:address:editor-data, op:address:operation<span class="muRecipe"> -> </span>editor:address:editor-data [ <span class="Constant">local-scope</span> - editor:address:editor-data<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - op:address:operation<span class="Special"> <- </span><span class="Constant">next-ingredient</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<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> @@ -239,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<span class="Special"> <- </span>get *typing, <span class="Constant">insert-from:offset</span> - end:address:duplex-list<span class="Special"> <- </span>get *typing, <span class="Constant">insert-until:offset</span> + 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> <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-duplex start remove-duplex-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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address: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> ] @@ -255,18 +254,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console [ type <span class="Constant">[012]</span> ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># all characters must be gone</span> screen-should-contain [ @@ -281,13 +280,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># type some characters</span> assume-console [ type <span class="Constant">[012]</span> ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .012a .</span> @@ -299,7 +298,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -313,7 +312,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -327,14 +326,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . abc .</span> @@ -354,7 +353,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> @@ -374,7 +373,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -390,13 +389,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console [ type <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -408,7 +407,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -422,7 +421,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -436,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<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: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-duplex(*before-cursor)</span> insert-duplex-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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address: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> ] @@ -451,13 +450,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console [ type <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -469,7 +468,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -483,7 +482,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -499,18 +498,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console [ type <span class="Constant">[1]</span> press ctrl-z ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># do some more work</span> assume-console [ type <span class="Constant">[0]</span> ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .0abc .</span> @@ -523,7 +522,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># nothing should happen</span> screen-should-contain [ @@ -539,7 +538,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ @@ -551,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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . ab cd .</span> @@ -570,7 +569,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -591,7 +590,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -611,7 +610,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -631,7 +630,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -651,7 +650,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -672,7 +671,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -698,19 +697,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -724,7 +723,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -738,17 +737,17 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + before-top-of-screen:address: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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + after-top-of-screen:address: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<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</span> + undo:address:address:list:address: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 move:address:move-operation<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> @@ -760,7 +759,7 @@ 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:number<span class="Special"> <- </span>get-address *move, <span class="Constant">after-top-of-screen:offset</span> + 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<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> @@ -775,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<span class="Special"> <- </span>get-address *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address: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> @@ -789,13 +788,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">5/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + 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> <span class="Comment"># screen scrolls</span> @@ -814,7 +813,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -835,7 +834,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -851,20 +850,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -878,7 +877,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -895,14 +894,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + 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> memory-should-contain [ @@ -914,7 +913,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -928,7 +927,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -945,20 +944,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -972,7 +971,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -992,19 +991,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># scroll the page</span> assume-console [ press ctrl-f ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1027,19 +1026,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># scroll the page</span> assume-console [ press page-down ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1062,20 +1061,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># scroll the page down and up</span> assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1098,20 +1097,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># scroll the page down and up</span> assume-console [ press page-down press page-up ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1131,20 +1130,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1158,7 +1157,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1175,20 +1174,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1202,7 +1201,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1219,20 +1218,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1246,7 +1245,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1263,20 +1262,20 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1290,7 +1289,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1305,14 +1304,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 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, console:address, <span class="Constant">2</span>:address:editor-data + 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> screen-should-contain [ @@ -1330,7 +1329,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1350,7 +1349,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1370,7 +1369,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1390,7 +1389,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1410,7 +1409,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1430,7 +1429,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1453,7 +1452,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># move the cursor</span> assume-console [ @@ -1462,7 +1461,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press right-arrow press up-arrow ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> memory-should-contain [ @@ -1474,7 +1473,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1488,7 +1487,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1507,19 +1506,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Constant">1</span>:address: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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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 assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press ctrl-z ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data <span class="Comment"># redo</span> assume-console [ press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> ] @@ -1533,7 +1532,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1551,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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address: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> ] @@ -1562,7 +1561,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># insert some text and hit backspace</span> assume-console [ @@ -1570,7 +1569,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press backspace press backspace ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1588,7 +1587,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> @@ -1607,7 +1606,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> @@ -1625,13 +1624,13 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address: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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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> <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 @@ -1641,22 +1640,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-from:offset</span> + delete-from:address:address: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<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> + backspaced-so-far:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> insert-duplex-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:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> + 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<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<span class="Special"> <- </span>next-duplex *before-cursor + deleted-until:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -1667,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<span class="Special"> <- </span>get-address *editor, <span class="Constant">data:offset</span> - anchor:address:duplex-list<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> + 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> <span class="muControl">break-unless</span> anchor - deleted:address:duplex-list<span class="Special"> <- </span>get *deletion, <span class="Constant">deleted-text:offset</span> - old-cursor:address:duplex-list<span class="Special"> <- </span>last-duplex deleted + 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-duplex deleted insert-duplex-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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address: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> ] @@ -1686,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<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-from:offset</span> - end:address:duplex-list<span class="Special"> <- </span>get *deletion, <span class="Constant">delete-until:offset</span> + 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> remove-duplex-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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top:address:address: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> ] @@ -1703,7 +1702,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ @@ -1714,7 +1713,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press delete press delete ] - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .af .</span> @@ -1732,7 +1731,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> @@ -1751,7 +1750,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> @@ -1770,7 +1769,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + 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> @@ -1789,7 +1788,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -1809,7 +1808,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -1829,7 +1828,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address: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> @@ -1847,13 +1846,13 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address: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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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> <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 @@ -1863,21 +1862,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-until:offset</span> + delete-until:address:address:duplex-list:character<span class="Special"> <- </span>get-address *deletion, <span class="Constant">delete-until:offset</span> *delete-until<span class="Special"> <- </span>next-duplex *before-cursor - deleted-so-far:address:address:duplex-list<span class="Special"> <- </span>get-address *deletion, <span class="Constant">deleted-text:offset</span> + 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<span class="Special"> <- </span>append-duplex *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:number<span class="Special"> <- </span>get-address *deletion, <span class="Constant">after-top-of-screen:offset</span> + 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<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<span class="Special"> <- </span>next-duplex *before-cursor + deleted-until:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -1891,14 +1890,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1917,7 +1916,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1937,7 +1936,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -1958,7 +1957,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1970,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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address: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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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<span class="Special"> <- </span>next-duplex *before-cursor + deleted-until:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> @@ -1992,14 +1991,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 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">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, <span class="Constant">0/left</span>, <span class="Constant">10/right</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="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, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .c .</span> @@ -2018,7 +2017,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-z ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2038,7 +2037,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } press ctrl-y ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -2059,7 +2058,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } type <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:address, console:address, <span class="Constant">2</span>:address:editor-data + editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2071,21 +2070,42 @@ 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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:address: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<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - undo:address:address:list<span class="Special"> <- </span>get-address *editor, <span class="Constant">undo:offset</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<span class="Special"> <- </span>next-duplex *before-cursor + deleted-until:address:duplex-list:character<span class="Special"> <- </span>next-duplex *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> <span class="Delimiter">}</span> ] +<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="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 + screen-should-contain [ + <span class="Constant"> . .</span> + <span class="Constant"> .abc .</span> +<span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> + <span class="Constant"> . .</span> + ] +] + <span class="Comment"># todo:</span> <span class="Comment"># operations for recipe side and each sandbox-data</span> <span class="Comment"># undo delete sandbox as a separate primitive on the status bar</span> |