about summary refs log tree commit diff stats
path: root/html/edit/005-sandbox.mu.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-26 23:47:23 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-26 23:47:23 -0800
commitd009e158803956c76adbf8f58a62884c3e7affb3 (patch)
treeb88198e28d15cd1fc064f5300365a190decc4c50 /html/edit/005-sandbox.mu.html
parent2da43c9462c7b7c1bb78d2f2826b3b97b4874973 (diff)
downloadmu-d009e158803956c76adbf8f58a62884c3e7affb3.tar.gz
2605
Diffstat (limited to 'html/edit/005-sandbox.mu.html')
-rw-r--r--html/edit/005-sandbox.mu.html729
1 files changed, 604 insertions, 125 deletions
diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html
index 0b3e3926..c079109e 100644
--- a/html/edit/005-sandbox.mu.html
+++ b/html/edit/005-sandbox.mu.html
@@ -43,10 +43,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 <span class="muRecipe">recipe!</span> main [
   <span class="Constant">local-scope</span>
   open-console
-  initial-recipe:address:array:character<span class="Special"> &lt;- </span>restore <span class="Constant">[recipes.mu]</span>
-  initial-sandbox:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  initial-recipe:address:shared:array:character<span class="Special"> &lt;- </span>restore <span class="Constant">[recipes.mu]</span>
+  initial-sandbox:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
   hide-screen <span class="Constant">0/screen</span>
-  env:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox
+  env:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox
   env<span class="Special"> &lt;- </span>restore-sandboxes env
   render-all <span class="Constant">0/screen</span>, env
   event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env
@@ -54,42 +54,50 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 ]
 
 <span class="muData">container</span> programming-environment-data [
-  sandbox:address:sandbox-data  <span class="Comment"># list of sandboxes, from top to bottom</span>
+  sandbox:address:shared:sandbox-data  <span class="Comment"># list of sandboxes, from top to bottom</span>
+  render-from:number
+  number-of-sandboxes:number
+]
+
+<span class="muRecipe">after</span> <span class="Constant">&lt;programming-environment-initialization&gt;</span> [
+  render-from:address:number<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">render-from:offset</span>
+  *render-from<span class="Special"> &lt;- </span>copy <span class="Constant">-1</span>
 ]
 
 <span class="muData">container</span> sandbox-data [
-  data:address:array:character
-  response:address:array:character
-  expected-response:address:array:character
+  data:address:shared:array:character
+  response:address:shared:array:character
+  expected-response:address:shared:array:character
   <span class="Comment"># coordinates to track clicks</span>
+  <span class="Comment"># constraint: will be 0 for sandboxes at positions before env.render-from</span>
   starting-row-on-screen:number
   code-ending-row-on-screen:number  <span class="Comment"># past end of code</span>
   response-starting-row-on-screen:number
-  screen:address:screen  <span class="Comment"># prints in the sandbox go here</span>
-  next-sandbox:address:sandbox-data
+  screen:address:shared:screen  <span class="Comment"># prints in the sandbox go here</span>
+  next-sandbox:address:shared:sandbox-data
 ]
 
 <span class="muScenario">scenario</span> run-and-show-results [
   trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
   assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span>
   <span class="Comment"># recipe editor is empty</span>
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
   <span class="Comment"># sandbox editor contains an instruction without storing outputs</span>
-  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span>
-  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
   <span class="Comment"># run the code in the editors</span>
   assume-console [
     press F4
   ]
   run [
-    event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
   ]
   <span class="Comment"># check that screen prints the results</span>
   screen-should-contain [
    <span class="Constant"> .                                                                                 run (F4)           .</span>
    <span class="Constant"> .                                                  ┊                                                 .</span>
 <span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
-   <span class="Constant"> .                                                  ┊                                                x.</span>
+   <span class="Constant"> .                                                  ┊0                                               x.</span>
    <span class="Constant"> .                                                  ┊divide-with-remainder 11, 3                      .</span>
    <span class="Constant"> .                                                  ┊3                                                .</span>
    <span class="Constant"> .                                                  ┊2                                                .</span>
@@ -118,6 +126,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
    <span class="Constant"> .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
    <span class="Constant"> .                                                  ┊                                                 .</span>
   ]
+  <span class="Comment"># sandbox title in reverse video</span>
+  screen-should-contain-in-color <span class="Constant">240/dark-grey</span>, [
+   <span class="Constant"> .                                                                                                    .</span>
+   <span class="Constant"> .                                                                                                    .</span>
+   <span class="Constant"> .                                                                                                    .</span>
+   <span class="Constant"> .                                                   0                                                .</span>
+  ]
   <span class="Comment"># run another command</span>
   assume-console [
     left-click <span class="Constant">1</span>, <span class="Constant">80</span>
@@ -125,18 +140,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     press F4
   ]
   run [
-    event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
   ]
   <span class="Comment"># check that screen prints the results</span>
   screen-should-contain [
    <span class="Constant"> .                                                                                 run (F4)           .</span>
    <span class="Constant"> .                                                  ┊                                                 .</span>
 <span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
-   <span class="Constant"> .                                                  ┊                                                x.</span>
+   <span class="Constant"> .                                                  ┊0                                               x.</span>
    <span class="Constant"> .                                                  ┊add 2, 2                                         .</span>
    <span class="Constant"> .                                                  ┊4                                                .</span>
    <span class="Constant"> .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
-   <span class="Constant"> .                                                  ┊                                                x.</span>
+   <span class="Constant"> .                                                  ┊1                                               x.</span>
    <span class="Constant"> .                                                  ┊divide-with-remainder 11, 3                      .</span>
    <span class="Constant"> .                                                  ┊3                                                .</span>
    <span class="Constant"> .                                                  ┊2                                                .</span>
@@ -151,105 +166,113 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     do-run?:boolean<span class="Special"> &lt;- </span>equal *k, <span class="Constant">65532/F4</span>
     <span class="muControl">break-unless</span> do-run?
 <span class="CommentedCode">#?     $log [F4 pressed]</span>
-    status:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[running...  ]</span>
+    status:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[running...       ]</span>
     screen<span class="Special"> &lt;- </span>update-status screen, status, <span class="Constant">245/grey</span>
     error?:boolean, env, screen<span class="Special"> &lt;- </span>run-sandboxes env, screen
     <span class="Comment"># F4 might update warnings and results on both sides</span>
+<span class="CommentedCode">#?     $print [render-all begin], 10/newline</span>
     screen<span class="Special"> &lt;- </span>render-all screen, env
+<span class="CommentedCode">#?     $print [render-all end], 10/newline</span>
     <span class="Delimiter">{</span>
       <span class="muControl">break-if</span> error?
-      status:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[            ]</span>
+      status:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[                 ]</span>
       screen<span class="Special"> &lt;- </span>update-status screen, status, <span class="Constant">245/grey</span>
     <span class="Delimiter">}</span>
-    screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?
+    screen<span class="Special"> &lt;- </span>update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env
     <span class="muControl">loop</span> <span class="Constant">+next-event:label</span>
   <span class="Delimiter">}</span>
 ]
 
-<span class="muRecipe">recipe</span> run-sandboxes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -&gt; </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [
+<span class="muRecipe">recipe</span> run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -&gt; </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   errors-found?:boolean, env, screen<span class="Special"> &lt;- </span>update-recipes env, screen
   <span class="muControl">reply-if</span> errors-found?
   <span class="Comment"># check contents of right editor (sandbox)</span>
-  current-sandbox:address:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span>
+<span class="Constant">  &lt;run-sandboxes-begin&gt;</span>
+  current-sandbox:address:shared:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span>
   <span class="Delimiter">{</span>
-    sandbox-contents:address:array:character<span class="Special"> &lt;- </span>editor-contents current-sandbox
+    sandbox-contents:address:shared:array:character<span class="Special"> &lt;- </span>editor-contents current-sandbox
     <span class="muControl">break-unless</span> sandbox-contents
     <span class="Comment"># if contents exist, first save them</span>
     <span class="Comment"># run them and turn them into a new sandbox-data</span>
-    new-sandbox:address:sandbox-data<span class="Special"> &lt;- </span>new <span class="Constant">sandbox-data:type</span>
-    data:address:address:array:character<span class="Special"> &lt;- </span>get-address *new-sandbox, <span class="Constant">data:offset</span>
+    new-sandbox:address:shared:sandbox-data<span class="Special"> &lt;- </span>new <span class="Constant">sandbox-data:type</span>
+    data:address:address:shared:array:character<span class="Special"> &lt;- </span>get-address *new-sandbox, <span class="Constant">data:offset</span>
     *data<span class="Special"> &lt;- </span>copy sandbox-contents
     <span class="Comment"># push to head of sandbox list</span>
-    dest:address:address:sandbox-data<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">sandbox:offset</span>
-    next:address:address:sandbox-data<span class="Special"> &lt;- </span>get-address *new-sandbox, <span class="Constant">next-sandbox:offset</span>
+    dest:address:address:shared:sandbox-data<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">sandbox:offset</span>
+    next:address:address:shared:sandbox-data<span class="Special"> &lt;- </span>get-address *new-sandbox, <span class="Constant">next-sandbox:offset</span>
     *next<span class="Special"> &lt;- </span>copy *dest
     *dest<span class="Special"> &lt;- </span>copy new-sandbox
+    <span class="Comment"># update sandbox count</span>
+    sandbox-count:address:number<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span>
+    *sandbox-count<span class="Special"> &lt;- </span>add *sandbox-count, <span class="Constant">1</span>
     <span class="Comment"># clear sandbox editor</span>
-    init:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *current-sandbox, <span class="Constant">data:offset</span>
+    init:address:address:shared:duplex-list:character<span class="Special"> &lt;- </span>get-address *current-sandbox, <span class="Constant">data:offset</span>
     *init<span class="Special"> &lt;- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span>
-    top-of-screen:address:address:duplex-list:character<span class="Special"> &lt;- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</span>
+    top-of-screen:address:address:shared:duplex-list:character<span class="Special"> &lt;- </span>get-address *current-sandbox, <span class="Constant">top-of-screen:offset</span>
     *top-of-screen<span class="Special"> &lt;- </span>copy *init
   <span class="Delimiter">}</span>
   <span class="Comment"># save all sandboxes before running, just in case we die when running</span>
   save-sandboxes env
   <span class="Comment"># run all sandboxes</span>
-  curr:address:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
+  curr:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
+  idx:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   <span class="Delimiter">{</span>
     <span class="muControl">break-unless</span> curr
-    curr<span class="Special"> &lt;- </span>update-sandbox curr
+    curr<span class="Special"> &lt;- </span>update-sandbox curr, env, idx
     curr<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span>
+    idx<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span>
     <span class="muControl">loop</span>
   <span class="Delimiter">}</span>
-  errors-found?<span class="Special"> &lt;- </span>copy <span class="Constant">0/false</span>
+<span class="Constant">  &lt;run-sandboxes-end&gt;</span>
 ]
 
 <span class="Comment"># copy code from recipe editor, persist, load into mu</span>
 <span class="Comment"># replaced in a later layer (whereupon errors-found? will actually be set)</span>
-<span class="muRecipe">recipe</span> update-recipes env:address:programming-environment-data, screen:address:screen<span class="muRecipe"> -&gt; </span>errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [
+<span class="muRecipe">recipe</span> update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen<span class="muRecipe"> -&gt; </span>errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  recipes:address:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span>
-  in:address:array:character<span class="Special"> &lt;- </span>editor-contents recipes
+  recipes:address:shared:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">recipes:offset</span>
+  in:address:shared:array:character<span class="Special"> &lt;- </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"> &lt;- </span>copy <span class="Constant">0/false</span>
 ]
 
 <span class="Comment"># replaced in a later layer</span>
-<span class="muRecipe">recipe</span> update-sandbox sandbox:address:sandbox-data<span class="muRecipe"> -&gt; </span>sandbox:address:sandbox-data [
+<span class="muRecipe">recipe!</span> update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number<span class="muRecipe"> -&gt; </span>sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  data:address:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span>
-  response:address:address:array:character<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">response:offset</span>
-  fake-screen:address:address:screen<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">screen:offset</span>
+  data:address:shared:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span>
+  response:address:address:shared:array:character<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">response:offset</span>
+  fake-screen:address:address:shared:screen<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">screen:offset</span>
   *response, _, *fake-screen<span class="Special"> &lt;- </span>run-interactive data
 ]
 
-<span class="muRecipe">recipe</span> update-status screen:address:screen, msg:address:array:character, color:number<span class="muRecipe"> -&gt; </span>screen:address:screen [
+<span class="muRecipe">recipe</span> update-status screen:address:shared:screen, msg:address:shared:array:character, color:number<span class="muRecipe"> -&gt; </span>screen:address:shared:screen [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   screen<span class="Special"> &lt;- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span>
   screen<span class="Special"> &lt;- </span>print screen, msg, color, <span class="Constant">238/grey/background</span>
 ]
 
-<span class="muRecipe">recipe</span> save-sandboxes env:address:programming-environment-data [
+<span class="muRecipe">recipe</span> save-sandboxes env:address:shared:programming-environment-data [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  current-sandbox:address:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span>
+  current-sandbox:address:shared:editor-data<span class="Special"> &lt;- </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>* &gt;/dev/null <span class="Constant">2</span>&gt;/dev/null]  <span class="Comment"># some shells can't handle '&gt;&amp;'</span>
-  curr:address:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
-  suffix:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[.out]</span>
+  curr:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
+  suffix:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[.out]</span>
   idx:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   <span class="Delimiter">{</span>
     <span class="muControl">break-unless</span> curr
-    data:address:array:character<span class="Special"> &lt;- </span>get *curr, <span class="Constant">data:offset</span>
-    filename:address:array:character<span class="Special"> &lt;- </span>to-text idx
+    data:address:shared:array:character<span class="Special"> &lt;- </span>get *curr, <span class="Constant">data:offset</span>
+    filename:address:shared:array:character<span class="Special"> &lt;- </span>to-text idx
     save filename, data
     <span class="Delimiter">{</span>
-      expected-response:address:array:character<span class="Special"> &lt;- </span>get *curr, <span class="Constant">expected-response:offset</span>
+      expected-response:address:shared:array:character<span class="Special"> &lt;- </span>get *curr, <span class="Constant">expected-response:offset</span>
       <span class="muControl">break-unless</span> expected-response
       filename<span class="Special"> &lt;- </span>append filename, suffix
       save filename, expected-response
@@ -260,24 +283,32 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   <span class="Delimiter">}</span>
 ]
 
-<span class="muRecipe">recipe!</span> render-sandbox-side screen:address:screen, env:address:programming-environment-data<span class="muRecipe"> -&gt; </span>screen:address:screen [
+<span class="muRecipe">recipe!</span> render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data<span class="muRecipe"> -&gt; </span>screen:address:shared:screen [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
 <span class="CommentedCode">#?   $log [render sandbox side]</span>
   trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span>
-  current-sandbox:address:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span>
+  current-sandbox:address:shared:editor-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">current-sandbox:offset</span>
+  row:number, column:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span>
   left:number<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span>
   right:number<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">right:offset</span>
-  row:number, column:number, screen, current-sandbox<span class="Special"> &lt;- </span>render screen, current-sandbox
-  clear-screen-from screen, row, column, left, right
-  row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
+  <span class="Comment"># render sandbox editor</span>
+  render-from:number<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span>
+  <span class="Delimiter">{</span>
+    render-current-sandbox?:boolean<span class="Special"> &lt;- </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"> &lt;- </span>render screen, current-sandbox
+    clear-screen-from screen, row, column, left, right
+    row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
+  <span class="Delimiter">}</span>
+  <span class="Comment"># render sandboxes</span>
   draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span>
-  sandbox:address:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
-  row, screen<span class="Special"> &lt;- </span>render-sandboxes screen, sandbox, left, right, row
-  clear-rest-of-screen screen, row, left, left, right
+  sandbox:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
+  row, screen<span class="Special"> &lt;- </span>render-sandboxes screen, sandbox, left, right, row, render-from
+  clear-rest-of-screen screen, row, left, right
 ]
 
-<span class="muRecipe">recipe</span> render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number<span class="muRecipe"> -&gt; </span>row:number, screen:address:screen, sandbox:address:sandbox-data [
+<span class="muRecipe">recipe</span> render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number<span class="muRecipe"> -&gt; </span>row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
 <span class="CommentedCode">#?   $log [render sandbox]</span>
@@ -285,69 +316,86 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   screen-height:number<span class="Special"> &lt;- </span>screen-height screen
   at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal row, screen-height
   <span class="muControl">reply-if</span> at-bottom?:boolean
-  <span class="Comment"># render sandbox menu</span>
-  row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
-  screen<span class="Special"> &lt;- </span>move-cursor screen, row, left
-  clear-line-delimited screen, left, right
-  print screen, <span class="Constant">120/x</span>, <span class="Constant">245/grey</span>
-  <span class="Comment"># save menu row so we can detect clicks to it later</span>
-  starting-row:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span>
-  *starting-row<span class="Special"> &lt;- </span>copy row
-  <span class="Comment"># render sandbox contents</span>
-  row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
-  screen<span class="Special"> &lt;- </span>move-cursor screen, row, left
-  sandbox-data:address:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span>
-  row, screen<span class="Special"> &lt;- </span>render-code screen, sandbox-data, left, right, row
-  code-ending-row:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>
-  *code-ending-row<span class="Special"> &lt;- </span>copy row
-  <span class="Comment"># render sandbox warnings, screen or response, in that order</span>
-  response-starting-row:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>
-  sandbox-response:address:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">response:offset</span>
-<span class="Constant">  &lt;render-sandbox-results&gt;</span>
+  hidden?:boolean<span class="Special"> &lt;- </span>lesser-than idx, render-from
   <span class="Delimiter">{</span>
-    sandbox-screen:address:screen<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">screen:offset</span>
-    empty-screen?:boolean<span class="Special"> &lt;- </span>fake-screen-is-empty? sandbox-screen
-    <span class="muControl">break-if</span> empty-screen?
-    row, screen<span class="Special"> &lt;- </span>render-screen screen, sandbox-screen, left, right, row
+    <span class="muControl">break-if</span> hidden?
+    <span class="Comment"># render sandbox menu</span>
+    row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
+    screen<span class="Special"> &lt;- </span>move-cursor screen, row, left
+    print screen, idx, <span class="Constant">240/dark-grey</span>
+    clear-line-delimited screen, left, right
+    delete-icon:character<span class="Special"> &lt;- </span>copy <span class="Constant">120/x</span>
+    print screen, delete-icon, <span class="Constant">245/grey</span>
+    <span class="Comment"># save menu row so we can detect clicks to it later</span>
+    starting-row:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span>
+    *starting-row<span class="Special"> &lt;- </span>copy row
+    <span class="Comment"># render sandbox contents</span>
+    row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
+    screen<span class="Special"> &lt;- </span>move-cursor screen, row, left
+    sandbox-data:address:shared:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">data:offset</span>
+    row, screen<span class="Special"> &lt;- </span>render-code screen, sandbox-data, left, right, row
+    code-ending-row:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>
+    *code-ending-row<span class="Special"> &lt;- </span>copy row
+    <span class="Comment"># render sandbox warnings, screen or response, in that order</span>
+    response-starting-row:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>
+    sandbox-response:address:shared:array:character<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">response:offset</span>
+<span class="Constant">    &lt;render-sandbox-results&gt;</span>
+    <span class="Delimiter">{</span>
+      sandbox-screen:address:shared:screen<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">screen:offset</span>
+      empty-screen?:boolean<span class="Special"> &lt;- </span>fake-screen-is-empty? sandbox-screen
+      <span class="muControl">break-if</span> empty-screen?
+      row, screen<span class="Special"> &lt;- </span>render-screen screen, sandbox-screen, left, right, row
+    <span class="Delimiter">}</span>
+    <span class="Delimiter">{</span>
+      <span class="muControl">break-unless</span> empty-screen?
+      *response-starting-row<span class="Special"> &lt;- </span>copy row
+<span class="Constant">      &lt;render-sandbox-response&gt;</span>
+      row, screen<span class="Special"> &lt;- </span>render screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row
+    <span class="Delimiter">}</span>
+<span class="Constant">    +render-sandbox-end</span>
+    at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal row, screen-height
+    <span class="muControl">reply-if</span> at-bottom?
+    <span class="Comment"># draw solid line after sandbox</span>
+    draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span>
   <span class="Delimiter">}</span>
+  <span class="Comment"># if hidden, reset row attributes</span>
   <span class="Delimiter">{</span>
-    <span class="muControl">break-unless</span> empty-screen?
-    *response-starting-row<span class="Special"> &lt;- </span>copy row
-<span class="Constant">    &lt;render-sandbox-response&gt;</span>
-    row, screen<span class="Special"> &lt;- </span>render screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row
+    <span class="muControl">break-unless</span> hidden?
+    tmp:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">starting-row-on-screen:offset</span>
+    *tmp<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+    tmp:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>
+    *tmp<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+    tmp:address:number<span class="Special"> &lt;- </span>get-address *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>
+    *tmp<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   <span class="Delimiter">}</span>
-<span class="Constant">  +render-sandbox-end</span>
-  at-bottom?:boolean<span class="Special"> &lt;- </span>greater-or-equal row, screen-height
-  <span class="muControl">reply-if</span> at-bottom?
-  <span class="Comment"># draw solid line after sandbox</span>
-  draw-horizontal screen, row, left, right, <span class="Constant">9473/horizontal-double</span>
   <span class="Comment"># draw next sandbox</span>
-  next-sandbox:address:sandbox-data<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span>
-  row, screen<span class="Special"> &lt;- </span>render-sandboxes screen, next-sandbox, left, right, row
+  next-sandbox:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span>
+  next-idx:number<span class="Special"> &lt;- </span>add idx, <span class="Constant">1</span>
+  row, screen<span class="Special"> &lt;- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx
 ]
 
 <span class="Comment"># assumes programming environment has no sandboxes; restores them from previous session</span>
-<span class="muRecipe">recipe</span> restore-sandboxes env:address:programming-environment-data<span class="muRecipe"> -&gt; </span>env:address:programming-environment-data [
+<span class="muRecipe">recipe</span> restore-sandboxes env:address:shared:programming-environment-data<span class="muRecipe"> -&gt; </span>env:address:shared:programming-environment-data [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span>
-  suffix:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[.out]</span>
+  suffix:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[.out]</span>
   idx:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  curr:address:address:sandbox-data<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">sandbox:offset</span>
+  curr:address:address:shared:sandbox-data<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">sandbox:offset</span>
   <span class="Delimiter">{</span>
-    filename:address:array:character<span class="Special"> &lt;- </span>to-text idx
-    contents:address:array:character<span class="Special"> &lt;- </span>restore filename
+    filename:address:shared:array:character<span class="Special"> &lt;- </span>to-text idx
+    contents:address:shared:array:character<span class="Special"> &lt;- </span>restore filename
     <span class="muControl">break-unless</span> contents  <span class="Comment"># stop at first error; assuming file didn't exist</span>
     <span class="Comment"># create new sandbox for file</span>
     *curr<span class="Special"> &lt;- </span>new <span class="Constant">sandbox-data:type</span>
-    data:address:address:array:character<span class="Special"> &lt;- </span>get-address **curr, <span class="Constant">data:offset</span>
+    data:address:address:shared:array:character<span class="Special"> &lt;- </span>get-address **curr, <span class="Constant">data:offset</span>
     *data<span class="Special"> &lt;- </span>copy contents
     <span class="Comment"># restore expected output for sandbox if it exists</span>
     <span class="Delimiter">{</span>
       filename<span class="Special"> &lt;- </span>append filename, suffix
       contents<span class="Special"> &lt;- </span>restore filename
       <span class="muControl">break-unless</span> contents
-      expected-response:address:address:array:character<span class="Special"> &lt;- </span>get-address **curr, <span class="Constant">expected-response:offset</span>
+      expected-response:address:address:shared:array:character<span class="Special"> &lt;- </span>get-address **curr, <span class="Constant">expected-response:offset</span>
       *expected-response<span class="Special"> &lt;- </span>copy contents
     <span class="Delimiter">}</span>
 <span class="Constant">    +continue</span>
@@ -355,23 +403,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     curr<span class="Special"> &lt;- </span>get-address **curr, <span class="Constant">next-sandbox:offset</span>
     <span class="muControl">loop</span>
   <span class="Delimiter">}</span>
+  <span class="Comment"># update sandbox count</span>
+  number-of-sandboxes:address:number<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">number-of-sandboxes:offset</span>
+  *number-of-sandboxes<span class="Special"> &lt;- </span>copy idx
 ]
 
 <span class="Comment"># print the fake sandbox screen to 'screen' with appropriate delimiters</span>
 <span class="Comment"># leave cursor at start of next line</span>
-<span class="muRecipe">recipe</span> render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number<span class="muRecipe"> -&gt; </span>row:number, screen:address:screen [
+<span class="muRecipe">recipe</span> render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number<span class="muRecipe"> -&gt; </span>row:number, screen:address:shared:screen [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
   <span class="muControl">reply-unless</span> sandbox-screen
   <span class="Comment"># print 'screen:'</span>
-  header:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[screen:]</span>
+  header:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[screen:]</span>
   row<span class="Special"> &lt;- </span>render screen, header, left, right, <span class="Constant">245/grey</span>, row
   screen<span class="Special"> &lt;- </span>move-cursor screen, row, left
   <span class="Comment"># start printing sandbox-screen</span>
   column:number<span class="Special"> &lt;- </span>copy left
   s-width:number<span class="Special"> &lt;- </span>screen-width sandbox-screen
   s-height:number<span class="Special"> &lt;- </span>screen-height sandbox-screen
-  buf:address:array:screen-cell<span class="Special"> &lt;- </span>get *sandbox-screen, <span class="Constant">data:offset</span>
+  buf:address:shared:array:screen-cell<span class="Special"> &lt;- </span>get *sandbox-screen, <span class="Constant">data:offset</span>
   stop-printing:number<span class="Special"> &lt;- </span>add left, s-width, <span class="Constant">3</span>
   max-column:number<span class="Special"> &lt;- </span>min stop-printing, right
   i:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
@@ -385,9 +436,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     column<span class="Special"> &lt;- </span>copy left
     screen<span class="Special"> &lt;- </span>move-cursor screen, row, column
     <span class="Comment"># initial leader for each row: two spaces and a '.'</span>
-    print screen, <span class="Constant">32/space</span>, <span class="Constant">245/grey</span>
-    print screen, <span class="Constant">32/space</span>, <span class="Constant">245/grey</span>
-    print screen, <span class="Constant">46/full-stop</span>, <span class="Constant">245/grey</span>
+    space:character<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span>
+    print screen, space, <span class="Constant">245/grey</span>
+    print screen, space, <span class="Constant">245/grey</span>
+    full-stop:character<span class="Special"> &lt;- </span>copy <span class="Constant">46/period</span>
+    print screen, full-stop, <span class="Constant">245/grey</span>
     column<span class="Special"> &lt;- </span>add left, <span class="Constant">3</span>
     <span class="Delimiter">{</span>
       <span class="Comment"># print row</span>
@@ -408,13 +461,13 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
       <span class="muControl">loop</span>
     <span class="Delimiter">}</span>
     <span class="Comment"># print final '.'</span>
-    print screen, <span class="Constant">46/full-stop</span>, <span class="Constant">245/grey</span>
+    print screen, full-stop, <span class="Constant">245/grey</span>
     column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span>
     <span class="Delimiter">{</span>
       <span class="Comment"># clear rest of current line</span>
       line-done?:boolean<span class="Special"> &lt;- </span>greater-than column, right
       <span class="muControl">break-if</span> line-done?
-      print screen, <span class="Constant">32/space</span>
+      print screen, space
       column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span>
       <span class="muControl">loop</span>
     <span class="Delimiter">}</span>
@@ -427,24 +480,24 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
   assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span>
   <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span>
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
 <span class="Constant">recipe foo [</span>
 <span class="Constant">z:number &lt;- add 2, 2</span>
 <span class="Constant">reply z</span>
 <span class="Constant">]</span>]
   <span class="Comment"># sandbox editor contains an instruction without storing outputs</span>
-  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
-  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[foo]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
   <span class="Comment"># run the code in the editors</span>
   assume-console [
     press F4
   ]
-  event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data
+  event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
   screen-should-contain [
    <span class="Constant"> .                                                                                 run (F4)           .</span>
    <span class="Constant"> .                                                  ┊                                                 .</span>
    <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
-   <span class="Constant"> .z:number &lt;- add 2, 2                              ┊                                                x.</span>
+   <span class="Constant"> .z:number &lt;- add 2, 2                              ┊0                                               x.</span>
    <span class="Constant"> .reply z                                           ┊foo                                              .</span>
    <span class="Constant"> .]                                                 ┊4                                                .</span>
 <span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
@@ -458,14 +511,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
     press F4
   ]
   run [
-    event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
   ]
   <span class="Comment"># check that screen updates the result on the right</span>
   screen-should-contain [
    <span class="Constant"> .                                                                                 run (F4)           .</span>
    <span class="Constant"> .                                                  ┊                                                 .</span>
    <span class="Constant"> .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
-   <span class="Constant"> .z:number &lt;- add 2, 3                              ┊                                                x.</span>
+   <span class="Constant"> .z:number &lt;- add 2, 3                              ┊0                                               x.</span>
    <span class="Constant"> .reply z                                           ┊foo                                              .</span>
    <span class="Constant"> .]                                                 ┊5                                                .</span>
 <span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
@@ -477,23 +530,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
   assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span>
   <span class="Comment"># left editor is empty</span>
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
   <span class="Comment"># right editor contains an instruction</span>
-  <span class="Constant">2</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[print-integer screen, 4]</span>
-  <span class="Constant">3</span>:address:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:screen, <span class="Constant">1</span>:address:array:character, <span class="Constant">2</span>:address:array:character
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[print-integer screen, 4]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
   <span class="Comment"># run the code in the editor</span>
   assume-console [
     press F4
   ]
   run [
-    event-loop screen:address:screen, console:address:console, <span class="Constant">3</span>:address:programming-environment-data
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
   ]
   <span class="Comment"># check that it prints a little toy screen</span>
   screen-should-contain [
    <span class="Constant"> .                                                                                 run (F4)           .</span>
    <span class="Constant"> .                                                  ┊                                                 .</span>
 <span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span>
-   <span class="Constant"> .                                                  ┊                                                x.</span>
+   <span class="Constant"> .                                                  ┊0                                               x.</span>
    <span class="Constant"> .                                                  ┊print-integer screen, 4                          .</span>
    <span class="Constant"> .                                                  ┊screen:                                          .</span>
    <span class="Constant"> .                                                  ┊  .4                             .               .</span>
@@ -506,11 +559,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
   ]
 ]
 
-<span class="muRecipe">recipe</span> editor-contents editor:address:editor-data<span class="muRecipe"> -&gt; </span>result:address:array:character [
+<span class="muRecipe">recipe</span> editor-contents editor:address:shared:editor-data<span class="muRecipe"> -&gt; </span>result:address:shared:array:character [
   <span class="Constant">local-scope</span>
   <span class="Constant">load-ingredients</span>
-  buf:address:buffer<span class="Special"> &lt;- </span>new-buffer <span class="Constant">80</span>
-  curr:address:duplex-list:character<span class="Special"> &lt;- </span>get *editor, <span class="Constant">data:offset</span>
+  buf:address:shared:buffer<span class="Special"> &lt;- </span>new-buffer <span class="Constant">80</span>
+  curr:address:shared:duplex-list:character<span class="Special"> &lt;- </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"> &lt;- </span>next curr
@@ -527,21 +580,447 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 
 <span class="muScenario">scenario</span> editor-provides-edited-contents [
   assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span>
-  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc]</span>
-  <span class="Constant">2</span>:address:editor-data<span class="Special"> &lt;- </span>new-editor <span class="Constant">1</span>:address:array:character, screen:address:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[abc]</span>
+  <span class="Constant">2</span>:address:shared:editor-data<span class="Special"> &lt;- </span>new-editor <span class="Constant">1</span>:address:shared:array:character, screen:address:shared:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span>
   assume-console [
     left-click <span class="Constant">1</span>, <span class="Constant">2</span>
     type <span class="Constant">[def]</span>
   ]
   run [
-    editor-event-loop screen:address:screen, console:address:console, <span class="Constant">2</span>:address:editor-data
-    <span class="Constant">3</span>:address:array:character<span class="Special"> &lt;- </span>editor-contents <span class="Constant">2</span>:address:editor-data
-    <span class="Constant">4</span>:array:character<span class="Special"> &lt;- </span>copy *<span class="Constant">3</span>:address:array:character
+    editor-event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">2</span>:address:shared:editor-data
+    <span class="Constant">3</span>:address:shared:array:character<span class="Special"> &lt;- </span>editor-contents <span class="Constant">2</span>:address:shared:editor-data
+    <span class="Constant">4</span>:array:character<span class="Special"> &lt;- </span>copy *<span class="Constant">3</span>:address:shared:array:character
   ]
   memory-should-contain [
     <span class="Constant">4</span>:array:character<span class="Special"> &lt;- </span><span class="Constant">[abdefc]</span>
   ]
 ]
+
+<span class="Comment"># scrolling through sandboxes</span>
+
+<span class="muScenario">scenario</span> scrolling-down-past-bottom-of-sandbox-editor [
+  trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
+  assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span>
+  <span class="Comment"># initialize sandbox side</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[add 2, 2]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
+  render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data
+  assume-console [
+    <span class="Comment"># create a sandbox</span>
+    press F4
+    <span class="Comment"># switch to sandbox editor and type in 2 lines</span>
+    press ctrl-n
+    type <span class="Constant">[abc</span>
+<span class="Constant">]</span>
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  screen-should-contain [
+   <span class="Constant"> .                              .  # minor: F4 clears menu tooltip in very narrow screens</span>
+   <span class="Constant"> .               ┊abc           .</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+  ]
+  <span class="Comment"># hit 'down' at bottom of sandbox editor</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  <span class="Comment"># sandbox editor hidden; first sandbox displayed</span>
+  <span class="Comment"># cursor moves to first sandbox</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+  <span class="Comment"># hit 'up'</span>
+  assume-console [
+    press up-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  <span class="Comment"># sandbox editor displays again</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .  # minor: F4 clears menu tooltip in very narrow screens</span>
+   <span class="Constant"> .               ┊abc           .</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+  ]
+]
+
+<span class="Comment"># down on sandbox side updates render-from when sandbox editor has cursor at bottom</span>
+<span class="muRecipe">after</span> <span class="Constant">&lt;global-keypress&gt;</span> [
+  <span class="Delimiter">{</span>
+    <span class="muControl">break-unless</span> *sandbox-in-focus?
+    down?:boolean<span class="Special"> &lt;- </span>equal *k, <span class="Constant">65516/down-arrow</span>
+    <span class="muControl">break-unless</span> down?
+    sandbox-bottom:number<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">bottom:offset</span>
+    sandbox-cursor:number<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span>
+    sandbox-cursor-on-last-line?:boolean<span class="Special"> &lt;- </span>equal sandbox-bottom, sandbox-cursor
+    <span class="muControl">break-unless</span> sandbox-cursor-on-last-line?
+    sandbox:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
+    <span class="muControl">break-unless</span> sandbox
+    <span class="Comment"># slide down if possible</span>
+    <span class="Delimiter">{</span>
+      render-from:address:number<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">render-from:offset</span>
+      number-of-sandboxes:number<span class="Special"> &lt;- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span>
+      max:number<span class="Special"> &lt;- </span>subtract number-of-sandboxes, <span class="Constant">1</span>
+      at-end?:boolean<span class="Special"> &lt;- </span>greater-or-equal *render-from, max
+      <span class="muControl">jump-if</span> at-end?, <span class="Constant">+finish-event:label</span>  <span class="Comment"># render nothing</span>
+      *render-from<span class="Special"> &lt;- </span>add *render-from, <span class="Constant">1</span>
+    <span class="Delimiter">}</span>
+    hide-screen screen
+    screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env
+    show-screen screen
+    <span class="muControl">jump</span> <span class="Constant">+finish-event:label</span>
+  <span class="Delimiter">}</span>
+]
+
+<span class="Comment"># update-cursor takes render-from into account</span>
+<span class="muRecipe">after</span> <span class="Constant">&lt;update-cursor-special-cases&gt;</span> [
+  <span class="Delimiter">{</span>
+    <span class="muControl">break-unless</span> sandbox-in-focus?
+    render-from:number<span class="Special"> &lt;- </span>get *env, <span class="Constant">render-from:offset</span>
+    scrolling?:boolean<span class="Special"> &lt;- </span>greater-or-equal render-from, <span class="Constant">0</span>
+    <span class="muControl">break-unless</span> scrolling?
+    cursor-column:number<span class="Special"> &lt;- </span>get *current-sandbox, <span class="Constant">left:offset</span>
+    screen<span class="Special"> &lt;- </span>move-cursor screen, <span class="Constant">2/row</span>, cursor-column  <span class="Comment"># highlighted sandbox will always start at row 2</span>
+    <span class="muControl">reply</span>
+  <span class="Delimiter">}</span>
+]
+
+<span class="Comment"># 'up' on sandbox side is like 'down': updates render-from when necessary</span>
+<span class="muRecipe">after</span> <span class="Constant">&lt;global-keypress&gt;</span> [
+  <span class="Delimiter">{</span>
+    <span class="muControl">break-unless</span> *sandbox-in-focus?
+    up?:boolean<span class="Special"> &lt;- </span>equal *k, <span class="Constant">65517/up-arrow</span>
+    <span class="muControl">break-unless</span> up?
+    render-from:address:number<span class="Special"> &lt;- </span>get-address *env, <span class="Constant">render-from:offset</span>
+    at-beginning?:boolean<span class="Special"> &lt;- </span>equal *render-from, <span class="Constant">-1</span>
+    <span class="muControl">break-if</span> at-beginning?
+    *render-from<span class="Special"> &lt;- </span>subtract *render-from, <span class="Constant">1</span>
+    hide-screen screen
+    screen<span class="Special"> &lt;- </span>render-sandbox-side screen, env
+    show-screen screen
+    <span class="muControl">jump</span> <span class="Constant">+finish-event:label</span>
+  <span class="Delimiter">}</span>
+]
+
+<span class="Comment"># sandbox belonging to 'env' whose next-sandbox is 'in'</span>
+<span class="Comment"># return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox</span>
+<span class="muRecipe">recipe</span> previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data<span class="muRecipe"> -&gt; </span>out:address:shared:sandbox-data [
+  <span class="Constant">local-scope</span>
+  <span class="Constant">load-ingredients</span>
+  curr:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *env, <span class="Constant">sandbox:offset</span>
+  <span class="muControl">reply-unless</span> curr, <span class="Constant">0/nil</span>
+  next:address:shared:sandbox-data<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span>
+  <span class="Delimiter">{</span>
+    <span class="muControl">reply-unless</span> next, <span class="Constant">0/nil</span>
+    found?:boolean<span class="Special"> &lt;- </span>equal next, in
+    <span class="muControl">break-if</span> found?
+    curr<span class="Special"> &lt;- </span>copy next
+    next<span class="Special"> &lt;- </span>get *curr, <span class="Constant">next-sandbox:offset</span>
+    <span class="muControl">loop</span>
+  <span class="Delimiter">}</span>
+  <span class="muControl">reply</span> curr
+]
+
+<span class="muScenario">scenario</span> scrolling-down-on-recipe-side [
+  trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
+  assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span>
+  <span class="Comment"># initialize sandbox side and create a sandbox</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ </span>
+<span class="Constant">]</span>
+  <span class="Comment"># create a sandbox</span>
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[add 2, 2]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
+  render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># hit 'down' in recipe editor</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  <span class="Comment"># sandbox editor hidden; first sandbox displayed</span>
+  <span class="Comment"># cursor moves to first sandbox</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊              .</span>
+   <span class="Constant"> .␣              ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+]
+
+<span class="muScenario">scenario</span> scrolling-through-multiple-sandboxes [
+  trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
+  assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span>
+  <span class="Comment"># initialize environment</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
+  render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data
+  <span class="Comment"># create 2 sandboxes</span>
+  assume-console [
+    press ctrl-n
+    type <span class="Constant">[add 2, 2]</span>
+    press F4
+    type <span class="Constant">[add 1, 1]</span>
+    press F4
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊␣             .</span>
+<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+  ]
+  <span class="Comment"># hit 'down'</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  <span class="Comment"># sandbox editor hidden; first sandbox displayed</span>
+  <span class="Comment"># cursor moves to first sandbox</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊␣            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+  ]
+  <span class="Comment"># hit 'down' again</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># just second sandbox displayed</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+  <span class="Comment"># hit 'down' again</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># no change</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+  <span class="Comment"># hit 'up'</span>
+  assume-console [
+    press up-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># back to displaying both sandboxes without editor</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+  ]
+  <span class="Comment"># hit 'up' again</span>
+  assume-console [
+    press up-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+    <span class="Constant">4</span>:character/cursor<span class="Special"> &lt;- </span>copy <span class="Constant">9251/␣</span>
+    print screen:address:shared:screen, <span class="Constant">4</span>:character/cursor
+  ]
+  <span class="Comment"># back to displaying both sandboxes as well as editor</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊␣             .</span>
+<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+  ]
+  <span class="Comment"># hit 'up' again</span>
+  assume-console [
+    press up-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># no change</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊␣             .</span>
+<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊1            x.</span>
+   <span class="Constant"> .               ┊add 2, 2      .</span>
+   <span class="Constant"> .               ┊4             .</span>
+  ]
+]
+
+<span class="muScenario">scenario</span> scrolling-manages-sandbox-index-correctly [
+  trace-until <span class="Constant">100/app</span>  <span class="Comment"># trace too long</span>
+  assume-screen <span class="Constant">30/width</span>, <span class="Constant">10/height</span>
+  <span class="Comment"># initialize environment</span>
+  <span class="Constant">1</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">2</span>:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[]</span>
+  <span class="Constant">3</span>:address:shared:programming-environment-data<span class="Special"> &lt;- </span>new-programming-environment screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:character, <span class="Constant">2</span>:address:shared:array:character
+  render-all screen, <span class="Constant">3</span>:address:shared:programming-environment-data
+  <span class="Comment"># create a sandbox</span>
+  assume-console [
+    press ctrl-n
+    type <span class="Constant">[add 1, 1]</span>
+    press F4
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊              .</span>
+<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+  <span class="Comment"># hit 'down' and 'up' a couple of times. sandbox index should be stable</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># sandbox editor hidden; first sandbox displayed</span>
+  <span class="Comment"># cursor moves to first sandbox</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+  <span class="Comment"># hit 'up' again</span>
+  assume-console [
+    press up-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># back to displaying both sandboxes as well as editor</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊              .</span>
+<span class="Constant">    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊0            x.</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+  <span class="Comment"># hit 'down'</span>
+  assume-console [
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, <span class="Constant">3</span>:address:shared:programming-environment-data
+  ]
+  <span class="Comment"># sandbox editor hidden; first sandbox displayed</span>
+  <span class="Comment"># cursor moves to first sandbox</span>
+  screen-should-contain [
+   <span class="Constant"> .                              .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0            x.  # no change</span>
+   <span class="Constant"> .               ┊add 1, 1      .</span>
+   <span class="Constant"> .               ┊2             .</span>
+   <span class="Constant"> .               ┊━━━━━━━━━━━━━━.</span>
+   <span class="Constant"> .               ┊              .</span>
+  ]
+]
 </pre>
 </body>
 </html>