about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-05 12:17:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-05 12:17:27 -0700
commitae244ebddc9f0c2952b2d79b3d6203f4431f9f53 (patch)
tree851874353edd9e5d8209f347d8d32c2fc8102dbf /edit
parenta90faae99043042ec5e2d0de21b7dbe0eba29e3a (diff)
downloadmu-ae244ebddc9f0c2952b2d79b3d6203f4431f9f53.tar.gz
2157 - edit/ now contains real layers
To run just until say layer 6, say this:

  $ ./mu test edit/00[0-6]*

The layers are not perfect yet; there might be a few things (like the
warning fields) that need to move to a later layer.
Diffstat (limited to 'edit')
-rw-r--r--edit/001-editor.mu1
-rw-r--r--edit/004-programming-environment.mu19
-rw-r--r--edit/005-sandbox.mu56
-rw-r--r--edit/006-sandbox-edit.mu46
4 files changed, 74 insertions, 48 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu
index 8909a574..819351e7 100644
--- a/edit/001-editor.mu
+++ b/edit/001-editor.mu
@@ -7,6 +7,7 @@ scenario editor-initially-prints-string-to-screen [
     new-editor 1:address:array:character, screen:address, 0/left, 10/right
   ]
   screen-should-contain [
+    # top line of screen reserved for menu
     .          .
     .abc       .
     .          .
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu
index 9698572f..892ac8f2 100644
--- a/edit/004-programming-environment.mu
+++ b/edit/004-programming-environment.mu
@@ -20,7 +20,6 @@ container programming-environment-data [
   recipes:address:editor-data
   recipe-warnings:address:array:character
   current-sandbox:address:editor-data
-  sandbox:address:sandbox-data  # list of sandboxes, from top to bottom
   sandbox-in-focus?:boolean  # false => cursor in recipes; true => cursor in current-sandbox
 ]
 
@@ -449,6 +448,24 @@ recipe render-recipes [
   reply screen/same-as-ingredient:0
 ]
 
+# replaced in a later layer
+recipe render-sandbox-side [
+  local-scope
+  screen:address <- next-ingredient
+  env:address:programming-environment-data <- next-ingredient
+  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
+  left:number <- get *current-sandbox, left:offset
+  right:number <- get *current-sandbox, right:offset
+  row:number, column:number, screen, current-sandbox <- render screen, current-sandbox
+  clear-line-delimited screen, column, right
+  row <- add row, 1
+  # draw solid line after recipes (you'll see why in later layers)
+  draw-horizontal screen, row, left, right, 9473/horizontal
+  row <- add row, 1
+  clear-screen-from screen, row, left, left, right
+  reply screen/same-as-ingredient:0
+]
+
 recipe update-cursor [
   local-scope
   screen:address <- next-ingredient
diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu
index 239112ce..10a3fffb 100644
--- a/edit/005-sandbox.mu
+++ b/edit/005-sandbox.mu
@@ -1,4 +1,12 @@
 ## running code from the editor and creating sandboxes
+#
+# Running code in the sandbox editor prepends its contents to a list of
+# (non-editable) sandboxes below the editor, showing the result and a maybe
+# few other things.
+
+container programming-environment-data [
+  sandbox:address:sandbox-data  # list of sandboxes, from top to bottom
+]
 
 container sandbox-data [
   data:address:array:character
@@ -211,7 +219,7 @@ recipe save-sandboxes [
   }
 ]
 
-recipe render-sandbox-side [
+recipe! render-sandbox-side [
   local-scope
   screen:address <- next-ingredient
   env:address:programming-environment-data <- next-ingredient
@@ -567,52 +575,6 @@ scenario run-instruction-manages-screen-per-sandbox [
   ]
 ]
 
-scenario sandbox-with-print-can-be-edited [
-  $close-trace  # trace too long
-  assume-screen 100/width, 20/height
-  # left editor is empty
-  1:address:array:character <- new []
-  # right editor contains an instruction
-  2:address:array:character <- new [print-integer screen:address, 4]
-  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
-  # run the sandbox
-  assume-console [
-    press F4
-  ]
-  run [
-    event-loop screen:address, console:address, 3:address:programming-environment-data
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊                                                 .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
-    .                                                  ┊                                                x.
-    .                                                  ┊print-integer screen:address, 4                  .
-    .                                                  ┊screen:                                          .
-    .                                                  ┊  .4                             .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊  .                              .               .
-    .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
-    .                                                  ┊                                                 .
-  ]
-  # edit the sandbox
-  assume-console [
-    left-click 3, 70
-  ]
-  run [
-    event-loop screen:address, console:address, 3:address:programming-environment-data
-  ]
-  screen-should-contain [
-    .                                                                                 run (F4)           .
-    .                                                  ┊print-integer screen:address, 4                  .
-    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
-    .                                                  ┊                                                 .
-    .                                                  ┊                                                 .
-  ]
-]
-
 scenario sandbox-can-handle-infinite-loop [
   $close-trace  # trace too long
   assume-screen 100/width, 20/height
diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu
index acd597c7..e43e09b2 100644
--- a/edit/006-sandbox-edit.mu
+++ b/edit/006-sandbox-edit.mu
@@ -126,3 +126,49 @@ recipe extract-sandbox [
   *sandbox-in-focus? <- copy 1/true
   reply result
 ]
+
+scenario sandbox-with-print-can-be-edited [
+  $close-trace  # trace too long
+  assume-screen 100/width, 20/height
+  # left editor is empty
+  1:address:array:character <- new []
+  # right editor contains an instruction
+  2:address:array:character <- new [print-integer screen:address, 4]
+  3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  # run the sandbox
+  assume-console [
+    press F4
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                x.
+    .                                                  ┊print-integer screen:address, 4                  .
+    .                                                  ┊screen:                                          .
+    .                                                  ┊  .4                             .               .
+    .                                                  ┊  .                              .               .
+    .                                                  ┊  .                              .               .
+    .                                                  ┊  .                              .               .
+    .                                                  ┊  .                              .               .
+    .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+  ]
+  # edit the sandbox
+  assume-console [
+    left-click 3, 70
+  ]
+  run [
+    event-loop screen:address, console:address, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊print-integer screen:address, 4                  .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]