diff options
Diffstat (limited to 'html/edit/005-sandbox.mu.html')
-rw-r--r-- | html/edit/005-sandbox.mu.html | 474 |
1 files changed, 237 insertions, 237 deletions
diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 735a45de..91e61166 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -45,11 +45,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:text <span class="Special"><-</span> restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text <span class="Special"><-</span> new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:&:environment<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 + env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env <span class="Special"><-</span> restore-sandboxes env render-all <span class="Constant">0/screen</span>, env, render event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ - *result<span class="Special"> <- </span>put *result, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> ] <span class="muData">container</span> sandbox [ @@ -82,7 +82,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -133,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># run another command</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 80</span> type <span class="Constant">[add 2, 2]</span> press F4 ] @@ -161,17 +161,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Comment"># F4? load all code and run all sandboxes.</span> <span class="Delimiter">{</span> - do-run?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65532/F4</span> + do-run?:bool <span class="Special"><-</span> equal k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? - screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> - error?:bool, env, screen<span class="Special"> <- </span>run-sandboxes env, screen + screen <span class="Special"><-</span> update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> + error?:bool, env, screen <span class="Special"><-</span> run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> - screen<span class="Special"> <- </span>render-all screen, env, render + screen <span class="Special"><-</span> render-all screen, env, render <span class="Delimiter">{</span> <span class="muControl">break-if</span> error? - screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> + screen <span class="Special"><-</span> update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> ] @@ -179,41 +179,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> run-sandboxes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - errors-found?:bool, env, screen<span class="Special"> <- </span>update-recipes env, screen + errors-found?:bool, env, screen <span class="Special"><-</span> update-recipes env, screen <span class="muControl">return-if</span> errors-found? <span class="Comment"># check contents of right editor (sandbox)</span> <span class="Constant"> <run-sandboxes-begin></span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> - sandbox-contents:text<span class="Special"> <- </span>editor-contents current-sandbox + sandbox-contents:text <span class="Special"><-</span> editor-contents current-sandbox <span class="muControl">break-unless</span> sandbox-contents <span class="Comment"># if contents exist, first save them</span> <span class="Comment"># run them and turn them into a new sandbox</span> - new-sandbox:&:sandbox<span class="Special"> <- </span>new <span class="Constant">sandbox:type</span> - *new-sandbox<span class="Special"> <- </span>put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents + new-sandbox:&:sandbox <span class="Special"><-</span> new <span class="Constant">sandbox:type</span> + *new-sandbox <span class="Special"><-</span> put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents <span class="Comment"># push to head of sandbox list</span> - dest:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - *new-sandbox<span class="Special"> <- </span>put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox:offset</span>, new-sandbox + dest:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + *new-sandbox <span class="Special"><-</span> put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox:offset</span>, new-sandbox <span class="Comment"># update sandbox count</span> - sandbox-count:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - sandbox-count<span class="Special"> <- </span>add sandbox-count, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count + sandbox-count:num <span class="Special"><-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count <span class="Special"><-</span> add sandbox-count,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count <span class="Comment"># clear sandbox editor</span> - init:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">data:offset</span>, init - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init + init:&:duplex-list:char <span class="Special"><-</span> push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">data:offset</span>, init + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init <span class="Delimiter">}</span> <span class="Comment"># save all sandboxes before running, just in case we die when running</span> save-sandboxes env <span class="Comment"># run all sandboxes</span> - curr:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - curr<span class="Special"> <- </span>update-sandbox curr, env, idx - curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> + curr <span class="Special"><-</span> update-sandbox curr, env, idx + curr <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Constant"> <run-sandboxes-end></span> @@ -224,46 +224,46 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> update-recipes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:text<span class="Special"> <- </span>editor-contents recipes + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + in:text <span class="Special"><-</span> editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in - errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</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">def!</span> update-sandbox sandbox:&:sandbox, env:&:environment, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:&:screen<span class="Special"> <- </span>run-sandboxed data - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + data:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:&:screen <span class="Special"><-</span> run-sandboxed data + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen ] <span class="muRecipe">def</span> update-status screen:&:screen, msg:text, color:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span> - screen<span class="Special"> <- </span>print screen, msg, color, <span class="Constant">238/grey/background</span> + screen <span class="Special"><-</span> move-cursor screen,<span class="Constant"> 0</span>,<span class="Constant"> 2</span> + screen <span class="Special"><-</span> print screen, msg, color, <span class="Constant">238/grey/background</span> ] <span class="muRecipe">def</span> save-sandboxes env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor <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>* <span class="Constant">>/dev/null</span> <span class="Constant">2</span>>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> - curr:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + $system <span class="Constant">[rm lesson/[0-9]</span>* <span class="Constant">>/dev/null</span> 2>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> + curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - data:text<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> - filename:text<span class="Special"> <- </span>to-text idx + data:text <span class="Special"><-</span> get *curr, <span class="Constant">data:offset</span> + filename:text <span class="Special"><-</span> to-text idx save filename, data <span class="Constant"> <end-save-sandbox></span> - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> + curr <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -271,24 +271,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> render-sandbox-side screen:&:screen, env:&:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -> </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - row:num, column:num<span class="Special"> <- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span> - left:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + row:num, column:num <span class="Special"><-</span> copy<span class="Constant"> 1</span>,<span class="Constant"> 0</span> + left:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">right:offset</span> <span class="Comment"># render sandbox editor</span> - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> <span class="Delimiter">{</span> - render-current-sandbox?:bool<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + render-current-sandbox?:bool <span class="Special"><-</span> equal render-from,<span class="Constant"> -1</span> <span class="muControl">break-unless</span> render-current-sandbox? - row, column, screen, current-sandbox<span class="Special"> <- </span>call render-editor, screen, current-sandbox + row, column, screen, current-sandbox <span class="Special"><-</span> call render-editor, screen, current-sandbox clear-screen-from screen, row, column, left, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Comment"># render sandboxes</span> draw-horizontal screen, row, left, right - sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - row, screen<span class="Special"> <- </span>render-sandboxes screen, sandbox, left, right, row, render-from + sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + row, screen <span class="Special"><-</span> render-sandboxes screen, sandbox, left, right, row, render-from clear-rest-of-screen screen, row, left, right ] @@ -296,40 +296,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox - screen-height:num<span class="Special"> <- </span>screen-height screen - at-bottom?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + screen-height:num <span class="Special"><-</span> screen-height screen + at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">return-if</span> at-bottom?:bool - hidden?:bool<span class="Special"> <- </span>lesser-than idx, render-from + hidden?:bool <span class="Special"><-</span> lesser-than idx, render-from <span class="Delimiter">{</span> <span class="muControl">break-if</span> hidden? <span class="Comment"># render sandbox menu</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - screen<span class="Special"> <- </span>render-sandbox-menu screen, idx, left, right + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, left + screen <span class="Special"><-</span> render-sandbox-menu screen, idx, left, right <span class="Comment"># save menu row so we can detect clicks to it later</span> - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, row + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, row <span class="Comment"># render sandbox contents</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - sandbox-data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, left + sandbox-data:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + row, screen <span class="Special"><-</span> render-code screen, sandbox-data, left, right, row + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row <span class="Comment"># render sandbox warnings, screen or response, in that order</span> - sandbox-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> + sandbox-response:text <span class="Special"><-</span> get *sandbox, <span class="Constant">response:offset</span> <span class="Constant"> <render-sandbox-results></span> <span class="Delimiter">{</span> - sandbox-screen:&:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> - empty-screen?:bool<span class="Special"> <- </span>fake-screen-is-empty? sandbox-screen + sandbox-screen:&:screen <span class="Special"><-</span> get *sandbox, <span class="Constant">screen:offset</span> + empty-screen?:bool <span class="Special"><-</span> fake-screen-is-empty? sandbox-screen <span class="muControl">break-if</span> empty-screen? - row, screen<span class="Special"> <- </span>render-screen screen, sandbox-screen, left, right, row + row, screen <span class="Special"><-</span> render-screen screen, sandbox-screen, left, right, row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> empty-screen? <span class="Constant"> <render-sandbox-response></span> - row, screen<span class="Special"> <- </span>render-text screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row + row, screen <span class="Special"><-</span> render-text screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> <span class="Constant"> +render-sandbox-end</span> - at-bottom?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">return-if</span> at-bottom? <span class="Comment"># draw solid line after sandbox</span> draw-horizontal screen, row, left, right @@ -337,33 +337,33 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if hidden, reset row attributes</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> hidden? - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, <span class="Constant">0</span> - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>,<span class="Constant"> 0</span> <span class="Constant"> <end-render-sandbox-reset-hidden></span> <span class="Delimiter">}</span> <span class="Comment"># draw next sandbox</span> - next-sandbox:&:sandbox<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> - next-idx:num<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx + next-sandbox:&:sandbox <span class="Special"><-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-idx:num <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> + row, screen <span class="Special"><-</span> render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] <span class="muRecipe">def</span> render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> move-cursor-to-column screen, left - edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num<span class="Special"> <- </span>sandbox-menu-columns left, right + edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <span class="Special"><-</span> sandbox-menu-columns left, right print screen, sandbox-index, <span class="Constant">232/dark-grey</span>, <span class="Constant">245/grey</span> - start-buttons:num<span class="Special"> <- </span>subtract edit-button-left, <span class="Constant">1</span> + start-buttons:num <span class="Special"><-</span> subtract edit-button-left,<span class="Constant"> 1</span> clear-line-until screen, start-buttons, <span class="Constant">245/grey</span> print screen, <span class="Constant">[edit]</span>, <span class="Constant">232/black</span>, <span class="Constant">94/background-orange</span> clear-line-until screen, edit-button-right, <span class="Constant">94/background-orange</span> - _, col:num<span class="Special"> <- </span>cursor-position screen - at-start-of-copy-button?:bool<span class="Special"> <- </span>equal col, copy-button-left + _, col:num <span class="Special"><-</span> cursor-position screen + at-start-of-copy-button?:bool <span class="Special"><-</span> equal col, copy-button-left assert at-start-of-copy-button?, <span class="Constant">[aaa]</span> print screen, <span class="Constant">[copy]</span>, <span class="Constant">232/black</span>, <span class="Constant">58/background-green</span> clear-line-until screen, copy-button-right, <span class="Constant">58/background-green</span> - _, col:num<span class="Special"> <- </span>cursor-position screen - at-start-of-delete-button?:bool<span class="Special"> <- </span>equal col, delete-button-left + _, col:num <span class="Special"><-</span> cursor-position screen + at-start-of-delete-button?:bool <span class="Special"><-</span> equal col, delete-button-left assert at-start-of-delete-button?, <span class="Constant">[bbb]</span> print screen, <span class="Constant">[delete]</span>, <span class="Constant">232/black</span>, <span class="Constant">52/background-red</span> clear-line-until screen, right, <span class="Constant">52/background-red</span> @@ -375,16 +375,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> sandbox-menu-columns left:num, right:num<span class="muRecipe"> -> </span>edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - start-buttons:num<span class="Special"> <- </span>add left, <span class="Constant">4/space-for-sandbox-index</span> - buttons-space:num<span class="Special"> <- </span>subtract right, start-buttons - button-width:num<span class="Special"> <- </span>divide-with-remainder buttons-space, <span class="Constant">3</span> <span class="Comment"># integer division</span> - buttons-wide-enough?:bool<span class="Special"> <- </span>greater-or-equal button-width, <span class="Constant">8</span> + start-buttons:num <span class="Special"><-</span> add left, <span class="Constant">4/space-for-sandbox-index</span> + buttons-space:num <span class="Special"><-</span> subtract right, start-buttons + button-width:num <span class="Special"><-</span> divide-with-remainder buttons-space,<span class="Constant"> 3</span> <span class="Comment"># integer division</span> + buttons-wide-enough?:bool <span class="Special"><-</span> greater-or-equal button-width,<span class="Constant"> 8</span> assert buttons-wide-enough?, <span class="Constant">[sandbox must be at least 30 or so characters wide]</span> - edit-button-left:num<span class="Special"> <- </span>copy start-buttons - copy-button-left:num<span class="Special"> <- </span>add start-buttons, button-width - edit-button-right:num<span class="Special"> <- </span>subtract copy-button-left, <span class="Constant">1</span> - delete-button-left:num<span class="Special"> <- </span>subtract right, button-width - copy-button-right:num<span class="Special"> <- </span>subtract delete-button-left, <span class="Constant">1</span> + edit-button-left:num <span class="Special"><-</span> copy start-buttons + copy-button-left:num <span class="Special"><-</span> add start-buttons, button-width + edit-button-right:num <span class="Special"><-</span> subtract copy-button-left,<span class="Constant"> 1</span> + delete-button-left:num <span class="Special"><-</span> subtract right, button-width + copy-button-right:num <span class="Special"><-</span> subtract delete-button-left,<span class="Constant"> 1</span> ] <span class="Comment"># print a text 's' to 'editor' in 'color' starting at 'row'</span> @@ -393,58 +393,58 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - column:num<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column - screen-height:num<span class="Special"> <- </span>screen-height screen - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> <- </span>length *s + column:num <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column + screen-height:num <span class="Special"><-</span> screen-height screen + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, len + done?:bool <span class="Special"><-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> <- </span>greater-or-equal row, screen-height + done? <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>index *s, i + c:char <span class="Special"><-</span> index *s, i <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special"><-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Comment"># retry i</span> <span class="Delimiter">}</span> - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-than column, right + done?:bool <span class="Special"><-</span> greater-than column, right <span class="muControl">break-if</span> done? - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> print screen, space - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:bool<span class="Special"> <- </span>equal column, left + was-at-left?:bool <span class="Special"><-</span> equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> move-cursor screen, row, left ] @@ -454,32 +454,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:&:sandbox<span class="Special"> <- </span>copy <span class="Constant">0</span> - prev:&:sandbox<span class="Special"> <- </span>copy <span class="Constant">0</span> + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + curr:&:sandbox <span class="Special"><-</span> copy<span class="Constant"> 0</span> + prev:&:sandbox <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - filename:text<span class="Special"> <- </span>to-text idx - contents:text<span class="Special"> <- </span>restore filename + filename:text <span class="Special"><-</span> to-text idx + contents:text <span class="Special"><-</span> restore filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># todo: handle empty sandbox</span> <span class="Comment"># create new sandbox for file</span> - curr<span class="Special"> <- </span>new <span class="Constant">sandbox:type</span> - *curr<span class="Special"> <- </span>put *curr, <span class="Constant">data:offset</span>, contents + curr <span class="Special"><-</span> new <span class="Constant">sandbox:type</span> + *curr <span class="Special"><-</span> put *curr, <span class="Constant">data:offset</span>, contents <span class="Constant"> <end-restore-sandbox></span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> idx - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox:offset</span>, curr + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox:offset</span>, curr <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> idx - *prev<span class="Special"> <- </span>put *prev, <span class="Constant">next-sandbox:offset</span>, curr + *prev <span class="Special"><-</span> put *prev, <span class="Constant">next-sandbox:offset</span>, curr <span class="Delimiter">}</span> - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - prev<span class="Special"> <- </span>copy curr + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> + prev <span class="Special"><-</span> copy curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># update sandbox count</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, idx + *env <span class="Special"><-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, idx ] <span class="Comment"># print the fake sandbox screen to 'screen' with appropriate delimiters</span> @@ -489,62 +489,62 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox-screen <span class="Comment"># print 'screen:'</span> - row<span class="Special"> <- </span>render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row - screen<span class="Special"> <- </span>move-cursor screen, row, left + row <span class="Special"><-</span> render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row + screen <span class="Special"><-</span> move-cursor screen, row, left <span class="Comment"># start printing sandbox-screen</span> - column:num<span class="Special"> <- </span>copy left - s-width:num<span class="Special"> <- </span>screen-width sandbox-screen - s-height:num<span class="Special"> <- </span>screen-height sandbox-screen - buf:&:@:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> - stop-printing:num<span class="Special"> <- </span>add left, s-width, <span class="Constant">3</span> - max-column:num<span class="Special"> <- </span>min stop-printing, right - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> <- </span>length *buf - screen-height:num<span class="Special"> <- </span>screen-height screen + column:num <span class="Special"><-</span> copy left + s-width:num <span class="Special"><-</span> screen-width sandbox-screen + s-height:num <span class="Special"><-</span> screen-height sandbox-screen + buf:&:@:screen-cell <span class="Special"><-</span> get *sandbox-screen, <span class="Constant">data:offset</span> + stop-printing:num <span class="Special"><-</span> add left, s-width,<span class="Constant"> 3</span> + max-column:num <span class="Special"><-</span> min stop-printing, right + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *buf + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, len + done?:bool <span class="Special"><-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> <- </span>greater-or-equal row, screen-height + done? <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="Comment"># initial leader for each row: two spaces and a '.'</span> - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> print screen, space, <span class="Constant">245/grey</span> print screen, space, <span class="Constant">245/grey</span> - full-stop:char<span class="Special"> <- </span>copy <span class="Constant">46/period</span> + full-stop:char <span class="Special"><-</span> copy <span class="Constant">46/period</span> print screen, full-stop, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>add left, <span class="Constant">3</span> + column <span class="Special"><-</span> add left,<span class="Constant"> 3</span> <span class="Delimiter">{</span> <span class="Comment"># print row</span> - row-done?:bool<span class="Special"> <- </span>greater-or-equal column, max-column + row-done?:bool <span class="Special"><-</span> greater-or-equal column, max-column <span class="muControl">break-if</span> row-done? - curr:screen-cell<span class="Special"> <- </span>index *buf, i - c:char<span class="Special"> <- </span>get curr, <span class="Constant">contents:offset</span> - color:num<span class="Special"> <- </span>get curr, <span class="Constant">color:offset</span> + curr:screen-cell <span class="Special"><-</span> index *buf, i + c:char <span class="Special"><-</span> get curr, <span class="Constant">contents:offset</span> + color:num <span class="Special"><-</span> get curr, <span class="Constant">color:offset</span> <span class="Delimiter">{</span> <span class="Comment"># damp whites down to grey</span> - white?:bool<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> + white?:bool <span class="Special"><-</span> equal color, <span class="Constant">7/white</span> <span class="muControl">break-unless</span> white? - color<span class="Special"> <- </span>copy <span class="Constant">245/grey</span> + color <span class="Special"><-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print final '.'</span> print screen, full-stop, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># clear rest of current line</span> - line-done?:bool<span class="Special"> <- </span>greater-than column, right + line-done?:bool <span class="Special"><-</span> greater-than column, right <span class="muControl">break-if</span> line-done? print screen, space - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -554,14 +554,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">z:num <- add 2, 2</span> <span class="Constant">reply z</span> <span class="Constant">]</span>] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -580,7 +580,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># make a change (incrementing one of the args to 'add'), then rerun</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">28</span> <span class="Comment"># one past the value of the second arg</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 28</span> <span class="Comment"># one past the value of the second arg</span> press backspace type <span class="Constant">[3]</span> press F4 @@ -608,7 +608,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> <span class="Comment"># right editor contains an instruction</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the code in the editor</span> assume-console [ press F4 @@ -637,37 +637,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> editor-contents editor:&:editor<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + buf:&:buffer <span class="Special"><-</span> new-buffer<span class="Constant"> 80</span> + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># skip § sentinel</span> assert curr, <span class="Constant">[editor without data is illegal; must have at least a sentinel]</span> - curr<span class="Special"> <- </span>next curr - <span class="muControl">return-unless</span> curr, <span class="Constant">0</span> + curr <span class="Special"><-</span> next curr + <span class="muControl">return-unless</span> curr,<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - buf<span class="Special"> <- </span>append buf, c - curr<span class="Special"> <- </span>next curr + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + buf <span class="Special"><-</span> append buf, c + curr <span class="Special"><-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - result<span class="Special"> <- </span>buffer-to-array buf + result <span class="Special"><-</span> buffer-to-array buf ] <span class="muScenario">scenario</span> editor-provides-edited-contents [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> type <span class="Constant">[def]</span> ] run [ editor-event-loop screen, console, e - s:text<span class="Special"> <- </span>editor-contents e - <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *s + s:text <span class="Special"><-</span> editor-contents e + 1:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s ] memory-should-contain [ - <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> + 1:array:character <span class="Special"><-</span> <span class="Constant">[abdefc]</span> ] ] @@ -677,7 +677,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter @@ -698,7 +698,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter @@ -706,7 +706,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press down-arrow <span class="Comment"># while cursor isn't at bottom</span> ] event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># cursor moves back to bottom</span> screen-should-contain [ @@ -726,28 +726,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><render-recipe-components-end></span> [ - *env<span class="Special"> <- </span>put *env, <span class="Constant">recipe-bottom:offset</span>, row + *env <span class="Special"><-</span> put *env, <span class="Constant">recipe-bottom:offset</span>, row ] <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - down-arrow?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> + down-arrow?:bool <span class="Special"><-</span> equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> down-arrow? - recipe-editor:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - recipe-cursor-row:num<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">cursor-row:offset</span> - recipe-editor-bottom:num<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">bottom:offset</span> - at-bottom-of-editor?:bool<span class="Special"> <- </span>greater-or-equal recipe-cursor-row, recipe-editor-bottom + recipe-editor:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + recipe-cursor-row:num <span class="Special"><-</span> get *recipe-editor, <span class="Constant">cursor-row:offset</span> + recipe-editor-bottom:num <span class="Special"><-</span> get *recipe-editor, <span class="Constant">bottom:offset</span> + at-bottom-of-editor?:bool <span class="Special"><-</span> greater-or-equal recipe-cursor-row, recipe-editor-bottom <span class="muControl">break-unless</span> at-bottom-of-editor? - more-to-scroll?:bool<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special"><-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:bool<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special"><-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -756,9 +756,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">6/ctrl-f</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:bool<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special"><-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -767,16 +767,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> more-to-scroll? env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipe-bottom:num<span class="Special"> <- </span>get *env, <span class="Constant">recipe-bottom:offset</span> - height:num<span class="Special"> <- </span>screen-height screen - result<span class="Special"> <- </span>greater-or-equal recipe-bottom, height + recipe-bottom:num <span class="Special"><-</span> get *env, <span class="Constant">recipe-bottom:offset</span> + height:num <span class="Special"><-</span> screen-height screen + result <span class="Special"><-</span> greater-or-equal recipe-bottom, height ] <span class="muScenario">scenario</span> scrolling-down-past-bottom-of-recipe-editor-2 [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ <span class="Comment"># add a line</span> @@ -801,7 +801,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> <span class="Constant">cd]</span> render-all screen, env, render assume-console [ @@ -813,7 +813,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press down-arrow ] event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># no scroll on recipe side, cursor moves on sandbox side</span> screen-should-contain [ @@ -832,7 +832,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ <span class="Comment"># create a sandbox</span> @@ -853,7 +853,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> @@ -871,7 +871,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor displays again, cursor is in editor</span> @@ -888,22 +888,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> sandbox <span class="Comment"># slide down if possible</span> <span class="Delimiter">{</span> - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - number-of-sandboxes:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - max:num<span class="Special"> <- </span>subtract number-of-sandboxes, <span class="Constant">1</span> - at-end?:bool<span class="Special"> <- </span>greater-or-equal render-from, max + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + number-of-sandboxes:num <span class="Special"><-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + max:num <span class="Special"><-</span> subtract number-of-sandboxes,<span class="Constant"> 1</span> + at-end?:bool <span class="Special"><-</span> greater-or-equal render-from, max <span class="muControl">jump-if</span> at-end?, <span class="Constant">+finish-event</span> <span class="Comment"># render nothing</span> - render-from<span class="Special"> <- </span>add render-from, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, render-from + render-from <span class="Special"><-</span> add render-from,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>, render-from <span class="Delimiter">}</span> hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render + screen <span class="Special"><-</span> render-sandbox-side screen, env, render show-screen screen <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> @@ -913,11 +913,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><update-cursor-special-cases></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - scrolling?:bool<span class="Special"> <- </span>greater-or-equal render-from, <span class="Constant">0</span> + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + scrolling?:bool <span class="Special"><-</span> greater-or-equal render-from,<span class="Constant"> 0</span> <span class="muControl">break-unless</span> scrolling? - cursor-column:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> + cursor-column:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + screen <span class="Special"><-</span> move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -926,15 +926,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-up?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool <span class="Special"><-</span> equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - at-beginning?:bool<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + at-beginning?:bool <span class="Special"><-</span> equal render-from,<span class="Constant"> -1</span> <span class="muControl">break-if</span> at-beginning? - render-from<span class="Special"> <- </span>subtract render-from, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, render-from + render-from <span class="Special"><-</span> subtract render-from,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>, render-from hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render + screen <span class="Special"><-</span> render-sandbox-side screen, env, render show-screen screen <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> @@ -945,15 +945,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> previous-sandbox env:&:environment, in:&:sandbox<span class="muRecipe"> -> </span>out:&:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">return-unless</span> curr, <span class="Constant">0/nil</span> - next:&:sandbox<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + next:&:sandbox <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">return-unless</span> next, <span class="Constant">0/nil</span> - found?:bool<span class="Special"> <- </span>equal next, in + found?:bool <span class="Special"><-</span> equal next, in <span class="muControl">break-if</span> found? - curr<span class="Special"> <- </span>copy next - next<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + curr <span class="Special"><-</span> copy next + next <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> curr @@ -964,10 +964,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side and create a sandbox</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">]</span> <span class="Comment"># create a sandbox</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ press F4 @@ -979,7 +979,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor moves down on recipe side</span> @@ -997,7 +997,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -1008,7 +1008,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -1028,7 +1028,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> @@ -1103,7 +1103,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> @@ -1125,7 +1125,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># no change</span> @@ -1148,7 +1148,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create a sandbox</span> assume-console [ |