diff options
Diffstat (limited to 'html/edit/004-programming-environment.mu.html')
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 199 |
1 files changed, 100 insertions, 99 deletions
diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index ca1057c4..c05d0127 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -41,22 +41,22 @@ 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:address:shared:array:character<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> + 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:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox render-all <span class="Constant">0/screen</span>, env event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> ] <span class="muData">container</span> programming-environment-data [ - recipes:address:shared:editor-data - current-sandbox:address:shared:editor-data + recipes:address:editor-data + current-sandbox:address:editor-data sandbox-in-focus?:boolean <span class="Comment"># false => cursor in recipes; true => cursor in current-sandbox</span> ] -<span class="muRecipe">def</span> new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character<span class="muRecipe"> -> </span>result:address:shared:programming-environment-data, screen:address:shared:screen [ +<span class="muRecipe">def</span> new-programming-environment screen:address:screen, initial-recipe-contents:address:array:character, initial-sandbox-contents:address:array:character<span class="muRecipe"> -> </span>result:address:programming-environment-data, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> width:number<span class="Special"> <- </span>screen-width screen @@ -73,21 +73,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment"># recipe editor on the left</span> - recipes:address:address:shared:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">recipes:offset</span> - *recipes<span class="Special"> <- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right + recipes:address:editor-data<span class="Special"> <- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right <span class="Comment"># sandbox editor on the right</span> - new-left:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - current-sandbox:address:address:shared:editor-data<span class="Special"> <- </span>get-address *result, <span class="Constant">current-sandbox:offset</span> - *current-sandbox<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, new-left, width/right + sandbox-left:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> + current-sandbox:address:editor-data<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, sandbox-left, width/right + *result<span class="Special"> <- </span>put *result, <span class="Constant">recipes:offset</span>, recipes + *result<span class="Special"> <- </span>put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox + *result<span class="Special"> <- </span>put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> <span class="Constant"> <programming-environment-initialization></span> ] -<span class="muRecipe">def</span> event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ +<span class="muRecipe">def</span> event-loop screen:address:screen, console:address:console, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, console:address:console, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:address:boolean<span class="Special"> <- </span>get-address *env, <span class="Constant">sandbox-in-focus?:offset</span> + recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Comment"># if we fall behind we'll stop updating the screen, but then we have to</span> <span class="Comment"># render the entire screen when we catch up.</span> <span class="Comment"># todo: test this</span> @@ -102,37 +103,38 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <handle-event></span> <span class="Comment"># check for global events that will trigger regardless of which editor has focus</span> <span class="Delimiter">{</span> - k:address:number<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> - <span class="muControl">break-unless</span> k + k:number, is-keycode?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + <span class="muControl">break-unless</span> is-keycode? <span class="Constant"> <global-keypress></span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - c:address:character<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">text:variant</span> - <span class="muControl">break-unless</span> c + c:character, is-unicode?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">text:variant</span> + <span class="muControl">break-unless</span> is-unicode? <span class="Constant"> <global-type></span> <span class="Delimiter">}</span> <span class="Comment"># 'touch' event - send to both sides, see what picks it up</span> <span class="Delimiter">{</span> - t:address:touch-event<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">touch:variant</span> - <span class="muControl">break-unless</span> t + t:touch-event, is-touch?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">touch:variant</span> + <span class="muControl">break-unless</span> is-touch? <span class="Comment"># ignore all but 'left-click' events for now</span> <span class="Comment"># todo: test this</span> - touch-type:number<span class="Special"> <- </span>get *t, <span class="Constant">type:offset</span> + touch-type:number<span class="Special"> <- </span>get t, <span class="Constant">type:offset</span> is-left-click?:boolean<span class="Special"> <- </span>equal touch-type, <span class="Constant">65513/mouse-left</span> <span class="muControl">loop-unless</span> is-left-click?, <span class="Constant">+next-event:label</span> <span class="Comment"># later exceptions for non-editor touches will go here</span> <span class="Constant"> <global-touch></span> <span class="Comment"># send to both editors</span> - _<span class="Special"> <- </span>move-cursor-in-editor screen, recipes, *t - *sandbox-in-focus?<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, *t - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env + _<span class="Special"> <- </span>move-cursor-in-editor screen, recipes, t + sandbox-in-focus?:boolean<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, t + *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> <span class="Comment"># 'resize' event - redraw editor</span> <span class="Comment"># todo: test this after supporting resize in assume-console</span> <span class="Delimiter">{</span> - r:address:resize-event<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">resize:variant</span> - <span class="muControl">break-unless</span> r + r:resize-event, is-resize?:boolean<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">resize:variant</span> + <span class="muControl">break-unless</span> is-resize? <span class="Comment"># if more events, we're still resizing; wait until we stop</span> more-events?:boolean<span class="Special"> <- </span>has-more-events? console <span class="Delimiter">{</span> @@ -150,8 +152,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if it's not global and not a touch event, send to appropriate editor</span> <span class="Delimiter">{</span> hide-screen screen + sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Delimiter">{</span> - <span class="muControl">break-if</span> *sandbox-in-focus? + <span class="muControl">break-if</span> sandbox-in-focus? screen, recipes, render?:boolean<span class="Special"> <- </span>handle-keyboard-event screen, recipes, e:event <span class="Comment"># refresh screen only if no more events</span> <span class="Comment"># if there are more events to process, wait for them to clear up, then make sure you render-all afterward.</span> @@ -179,7 +182,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> *sandbox-in-focus? + <span class="muControl">break-unless</span> sandbox-in-focus? screen, current-sandbox, render?:boolean<span class="Special"> <- </span>handle-keyboard-event screen, current-sandbox, e:event <span class="Comment"># refresh screen only if no more events</span> <span class="Comment"># if there are more events to process, wait for them to clear up, then make sure you render-all afterward.</span> @@ -207,48 +210,44 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Constant"> +finish-event</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> resize screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>env:address:shared:programming-environment-data, screen:address:shared:screen [ +<span class="muRecipe">def</span> resize screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>env:address:programming-environment-data, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> clear-screen screen <span class="Comment"># update screen dimensions</span> width:number<span class="Special"> <- </span>screen-width screen divider:number, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> <span class="Comment"># update recipe editor</span> - recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - right:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">right:offset</span> - *right<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> + recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + right:number<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> + *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">right:offset</span>, right <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> - cursor-row:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">cursor-row:offset</span> - *cursor-row<span class="Special"> <- </span>copy <span class="Constant">1</span> - cursor-column:address:number<span class="Special"> <- </span>get-address *recipes, <span class="Constant">cursor-column:offset</span> - *cursor-column<span class="Special"> <- </span>copy <span class="Constant">0</span> + *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> + *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">cursor-column:offset</span>, <span class="Constant">0</span> <span class="Comment"># update sandbox editor</span> - current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">left:offset</span> - right:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">right:offset</span> - *left<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - *right<span class="Special"> <- </span>subtract width, <span class="Constant">1</span> + current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + left:number<span class="Special"> <- </span>add divider, <span class="Constant">1</span> + *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">left:offset</span>, left + right:number<span class="Special"> <- </span>subtract width, <span class="Constant">1</span> + *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">right:offset</span>, right <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> - cursor-row:address:number<span class="Special"> <- </span>get-address *current-sandbox, <span class="Constant">cursor-row:offset</span> - *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 + *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> + *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">cursor-column:offset</span>, left ] <span class="muScenario">scenario</span> point-at-multiple-editors [ 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:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character <span class="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -256,11 +255,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># check cursor column in each</span> run [ - event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data - <span class="Constant">4</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">4</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -272,10 +271,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">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character - render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + render-all screen, <span class="Constant">3</span>:address:programming-environment-data <span class="Comment"># type one letter in each of them</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -284,11 +283,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[1]</span> ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data - <span class="Constant">4</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:address:shared:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:shared:programming-environment-data, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:shared:editor-data, <span class="Constant">cursor-column:offset</span> + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">4</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:number<span class="Special"> <- </span>get *<span class="Constant">4</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">6</span>:address:editor-data<span class="Special"> <- </span>get *<span class="Constant">3</span>:address:programming-environment-data, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:number<span class="Special"> <- </span>get *<span class="Constant">6</span>:address:editor-data, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . run (F4) . # this line has a different background, but we don't test that yet</span> @@ -303,7 +302,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># show the cursor at the right window</span> run [ <span class="Constant">8</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:shared:screen, <span class="Constant">8</span>:character/cursor + print screen:address:screen, <span class="Constant">8</span>:character/cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -317,10 +316,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">60/width</span>, <span class="Constant">10/height</span> run [ - <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character - render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + render-all screen, <span class="Constant">3</span>:address:programming-environment-data ] <span class="Comment"># divider isn't messed up</span> screen-should-contain [ @@ -335,16 +334,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character - render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + <span class="Constant">2</span>:address:array:character<span class="Special"> <- </span>new <span class="Constant">[def]</span> + <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character + render-all screen, <span class="Constant">3</span>:address:programming-environment-data <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ - event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data <span class="Constant">4</span>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + print screen:address:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># is cursor at the right place?</span> screen-should-contain [ @@ -358,9 +357,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[z]</span> ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + print screen:address:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># cursor should still be right</span> screen-should-contain [ @@ -375,11 +374,11 @@ 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">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:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:address:shared:array:character<span class="Special"> <- </span>new <span class="Constant">[abc</span> + <span class="Constant">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:shared:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character - render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data + <span class="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> <span class="Constant"> . ┊abc .</span> @@ -393,9 +392,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared: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>:character/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor + print screen:address:screen, <span class="Constant">4</span>:character/cursor ] <span class="Comment"># cursor moves to end of old line</span> screen-should-contain [ @@ -406,7 +405,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muRecipe">def</span> render-all screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen, env:address:shared:programming-environment-data [ +<span class="muRecipe">def</span> render-all screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> @@ -430,19 +429,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen<span class="Special"> <- </span>render-sandbox-side screen, env <span class="Constant"> <render-components-end></span> <span class="Comment">#</span> - recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment">#</span> show-screen screen ] -<span class="muRecipe">def</span> render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen, env:address:shared:programming-environment-data [ +<span class="muRecipe">def</span> render-recipes screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render recipes]</span> - recipes:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + recipes:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> <span class="Comment"># render recipes</span> left:number<span class="Special"> <- </span>get *recipes, <span class="Constant">left:offset</span> right:number<span class="Special"> <- </span>get *recipes, <span class="Constant">right:offset</span> @@ -457,10 +456,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># replaced in a later layer</span> -<span class="muRecipe">def</span> render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen, env:address:shared:programming-environment-data [ +<span class="muRecipe">def</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen, env:address:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:address:shared:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</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 @@ -472,7 +471,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color clear-screen-from screen, row, left, left, right ] -<span class="muRecipe">def</span> update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean, env:address:shared:programming-environment-data<span class="muRecipe"> -> </span>screen:address:shared:screen [ +<span class="muRecipe">def</span> update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean, env:address:programming-environment-data<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Constant"> <update-cursor-special-cases></span> @@ -491,7 +490,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># print a text 's' to 'editor' in 'color' starting at 'row'</span> <span class="Comment"># clear rest of last line, move cursor to next line</span> -<span class="muRecipe">def</span> render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ +<span class="muRecipe">def</span> render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s @@ -552,7 +551,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># like 'render' for texts, but with colorization for comments like in the editor</span> -<span class="muRecipe">def</span> render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:shared:screen [ +<span class="muRecipe">def</span> render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number<span class="muRecipe"> -> </span>row:number, screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s @@ -618,9 +617,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> - redraw-screen?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">12/ctrl-l</span> + redraw-screen?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">12/ctrl-l</span> <span class="muControl">break-unless</span> redraw-screen? - screen<span class="Special"> <- </span>render-all screen, env:address:shared:programming-environment-data + screen<span class="Special"> <- </span>render-all screen, env:address:programming-environment-data sync-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> @@ -631,17 +630,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> - switch-side?:boolean<span class="Special"> <- </span>equal *c, <span class="Constant">14/ctrl-n</span> + switch-side?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">14/ctrl-n</span> <span class="muControl">break-unless</span> switch-side? - *sandbox-in-focus?<span class="Special"> <- </span>not *sandbox-in-focus? - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env + sandbox-in-focus?:boolean<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus?<span class="Special"> <- </span>not sandbox-in-focus? + *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? + screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event:label</span> <span class="Delimiter">}</span> ] <span class="SalientComment">## helpers</span> -<span class="muRecipe">def</span> draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:shared:screen [ +<span class="muRecipe">def</span> draw-vertical screen:address:screen, col:number, y:number, bottom:number<span class="muRecipe"> -> </span>screen:address:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> style:character, style-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> |