diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
commit | f344b250f6f062a1a1902bf69b23ebf9b565de0e (patch) | |
tree | 199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/edit/008-sandbox-edit.mu.html | |
parent | 897ae8c1855f830d8819759ea327d147f28a09bf (diff) | |
download | mu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz |
3395
Diffstat (limited to 'html/edit/008-sandbox-edit.mu.html')
-rw-r--r-- | html/edit/008-sandbox-edit.mu.html | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 18926f44..1fcf071f 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -47,8 +47,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -64,7 +64,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -81,7 +81,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -107,8 +107,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ press F4 ] - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -124,7 +124,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">68</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -141,7 +141,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[0]</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -157,7 +157,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'edit' button</span> <span class="Delimiter">{</span> - edit?:boolean<span class="Special"> <- </span>should-attempt-edit? click-row, click-column, env + edit?:bool<span class="Special"> <- </span>should-attempt-edit? click-row, click-column, env <span class="muControl">break-unless</span> edit? edit?, env<span class="Special"> <- </span>try-edit-sandbox click-row, env <span class="muControl">break-unless</span> edit? @@ -170,35 +170,35 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># some preconditions for attempting to edit a sandbox</span> -<span class="muRecipe">def</span> should-attempt-edit? click-row:number, click-column:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>result:boolean [ +<span class="muRecipe">def</span> should-attempt-edit? click-row:num, click-column:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:boolean<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'edit' button?</span> - first-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:number<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - edit-button-left:number, edit-button-right:number, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - edit-button-vertical-area?:boolean<span class="Special"> <- </span>within-range? click-column, edit-button-left, edit-button-right + sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> + edit-button-left:num, edit-button-right:num, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + edit-button-vertical-area?:bool<span class="Special"> <- </span>within-range? click-column, edit-button-left, edit-button-right <span class="muControl">reply-unless</span> edit-button-vertical-area?, <span class="Constant">0/false</span> <span class="Comment"># finally, is sandbox editor empty?</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> result<span class="Special"> <- </span>empty-editor? current-sandbox ] -<span class="muRecipe">def</span> try-edit-sandbox click-row:number, env:address:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-edit-button?:boolean, env:address:programming-environment-data [ +<span class="muRecipe">def</span> try-edit-sandbox click-row:num, env:&:programming-environment-data<span class="muRecipe"> -> </span>clicked-on-edit-button?:bool, env:&:programming-environment-data [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to edit, if the click was actually on the 'edit' button</span> - sandbox:address:sandbox-data<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox-data<span class="Special"> <- </span>find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> clicked-on-edit-button?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># 'edit' button = 'copy' button + 'delete' button</span> text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:address:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor-data<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text env<span class="Special"> <- </span>delete-sandbox env, sandbox <span class="Comment"># reset scroll</span> @@ -214,12 +214,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -240,7 +240,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">65</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -257,8 +257,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n @@ -269,7 +269,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down press page-down ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -284,7 +284,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">55</span> ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -305,8 +305,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># initialize environment</span> <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:address:programming-environment-data, render + <span class="Constant">3</span>:&:programming-environment-data<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + render-all screen, <span class="Constant">3</span>:&:programming-environment-data, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n @@ -315,7 +315,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color type <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -334,7 +334,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># no change in contents</span> screen-should-contain [ @@ -356,7 +356,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data + event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:programming-environment-data ] <span class="Comment"># screen should show just final sandbox with the right index (1)</span> screen-should-contain [ |