about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-06-12 09:44:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-06-12 09:44:27 -0700
commit4e7186faee27a32b92035b843ad24b5c61a3dc44 (patch)
tree86a55246b5b9347f8fcae1af3656f415a9579580 /edit
parent6dd675764158bca3ab9547f6c653bdf8ba277d43 (diff)
downloadmu-4e7186faee27a32b92035b843ad24b5c61a3dc44.tar.gz
3052 - make edit/ render functions higher-order
This required the fix of 3051 to first-class recipe support, and will
next enable us to keep the cursor from moving in response to resize
events.
Diffstat (limited to 'edit')
-rw-r--r--edit/004-programming-environment.mu38
-rw-r--r--edit/005-sandbox.mu28
-rw-r--r--edit/006-sandbox-copy.mu2
-rw-r--r--edit/007-sandbox-delete.mu10
-rw-r--r--edit/008-sandbox-edit.mu6
-rw-r--r--edit/009-sandbox-test.mu2
-rw-r--r--edit/010-sandbox-trace.mu2
7 files changed, 44 insertions, 44 deletions
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu
index 99584c56..e3bf3be3 100644
--- a/edit/004-programming-environment.mu
+++ b/edit/004-programming-environment.mu
@@ -10,7 +10,7 @@ def! main [
   initial-sandbox:address:array:character <- new []
   hide-screen 0/screen
   env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox
-  render-all 0/screen, env
+  render-all 0/screen, env, render
   event-loop 0/screen, 0/console, env
   # never gets here
 ]
@@ -111,7 +111,7 @@ def event-loop screen:address:screen, console:address:console, env:address:progr
       {
         break-if more-events?
         env, screen <- resize screen, env
-        screen <- render-all screen, env
+        screen <- render-all screen, env, render
         render-all-on-no-more-events? <- copy 0/false  # full render done
       }
       loop +next-event:label
@@ -136,14 +136,14 @@ def event-loop screen:address:screen, console:address:console, env:address:progr
           {
             break-unless render-all-on-no-more-events?
             # no more events, and we have to force render
-            screen <- render-all screen, env
+            screen <- render-all screen, env, render
             render-all-on-no-more-events? <- copy 0/false
             jump +finish-event:label
           }
           # no more events, no force render
           {
             break-unless render?
-            screen <- render-recipes screen, env
+            screen <- render-recipes screen, env, render
             jump +finish-event:label
           }
         }
@@ -164,14 +164,14 @@ def event-loop screen:address:screen, console:address:console, env:address:progr
           {
             break-unless render-all-on-no-more-events?
             # no more events, and we have to force render
-            screen <- render-all screen, env
+            screen <- render-all screen, env, render
             render-all-on-no-more-events? <- copy 0/false
             jump +finish-event:label
           }
           # no more events, no force render
           {
             break-unless render?
-            screen <- render-sandbox-side screen, env
+            screen <- render-sandbox-side screen, env, render
             jump +finish-event:label
           }
         }
@@ -241,7 +241,7 @@ scenario edit-multiple-editors [
   1:address:array:character <- new [abc]
   2:address:array:character <- new [def]
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # type one letter in each of them
   assume-console [
     left-click 1, 1
@@ -286,7 +286,7 @@ scenario multiple-editors-cover-only-their-own-areas [
     1:address:array:character <- new [abc]
     2:address:array:character <- new [def]
     3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-    render-all screen, 3:address:programming-environment-data
+    render-all screen, 3:address:programming-environment-data, render
   ]
   # divider isn't messed up
   screen-should-contain [
@@ -304,7 +304,7 @@ scenario editor-in-focus-keeps-cursor [
   1:address:array:character <- new [abc]
   2:address:array:character <- new [def]
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # initialize programming environment and highlight cursor
   assume-console []
   run [
@@ -338,14 +338,14 @@ scenario editor-in-focus-keeps-cursor [
 ]
 
 scenario backspace-in-sandbox-editor-joins-lines [
-  trace-until 100/app  # trace too long
+#?   trace-until 100/app  # trace too long
   assume-screen 30/width, 5/height
   # initialize sandbox side with two lines
   1:address:array:character <- new []
   2:address:array:character <- new [abc
 def]
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   screen-should-contain [
     .           run (F4)           .
     .               ┊abc           .
@@ -372,7 +372,7 @@ def]
   ]
 ]
 
-def render-all screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [
+def render-all screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [
   local-scope
   load-ingredients
   trace 10, [app], [render all]
@@ -392,8 +392,8 @@ def render-all screen:address:screen, env:address:programming-environment-data -
   height:number <- screen-height screen
   draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted
   #
-  screen <- render-recipes screen, env
-  screen <- render-sandbox-side screen, env
+  screen <- render-recipes screen, env, render-editor
+  screen <- render-sandbox-side screen, env, render-editor
   <render-components-end>
   #
   recipes:address:editor-data <- get *env, recipes:offset
@@ -404,7 +404,7 @@ def render-all screen:address:screen, env:address:programming-environment-data -
   show-screen screen
 ]
 
-def render-recipes screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [
+def render-recipes screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [
   local-scope
   load-ingredients
   trace 11, [app], [render recipes]
@@ -412,7 +412,7 @@ def render-recipes screen:address:screen, env:address:programming-environment-da
   # render recipes
   left:number <- get *recipes, left:offset
   right:number <- get *recipes, right:offset
-  row:number, column:number, screen <- render screen, recipes
+  row:number, column:number, screen <- call render-editor, screen, recipes
   clear-line-until screen, right
   row <- add row, 1
   <render-recipe-components-end>
@@ -423,13 +423,13 @@ def render-recipes screen:address:screen, env:address:programming-environment-da
 ]
 
 # replaced in a later layer
-def render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [
+def render-sandbox-side screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [
   local-scope
   load-ingredients
   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
+  row:number, column:number, screen, current-sandbox <- call render-editor, screen, current-sandbox
   clear-line-until screen, right
   row <- add row, 1
   # draw solid line after code (you'll see why in later layers)
@@ -586,7 +586,7 @@ after <global-type> [
   {
     redraw-screen?:boolean <- equal c, 12/ctrl-l
     break-unless redraw-screen?
-    screen <- render-all screen, env:address:programming-environment-data
+    screen <- render-all screen, env:address:programming-environment-data, render
     sync-screen screen
     loop +next-event:label
   }
diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu
index fadf0d68..0091eb1f 100644
--- a/edit/005-sandbox.mu
+++ b/edit/005-sandbox.mu
@@ -15,7 +15,7 @@ def! main [
   hide-screen 0/screen
   env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox
   env <- restore-sandboxes env
-  render-all 0/screen, env
+  render-all 0/screen, env, render
   event-loop 0/screen, 0/console, env
   # never gets here
 ]
@@ -132,7 +132,7 @@ after <global-keypress> [
     screen <- update-status screen, [running...       ], 245/grey
     error?:boolean, env, screen <- run-sandboxes env, screen
     # F4 might update warnings and results on both sides
-    screen <- render-all screen, env
+    screen <- render-all screen, env, render
     {
       break-if error?
       screen <- update-status screen, [                 ], 245/grey
@@ -234,7 +234,7 @@ def save-sandboxes env:address:programming-environment-data [
   }
 ]
 
-def! render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [
+def! render-sandbox-side screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [
   local-scope
   load-ingredients
   trace 11, [app], [render sandbox side]
@@ -247,7 +247,7 @@ def! render-sandbox-side screen:address:screen, env:address:programming-environm
   {
     render-current-sandbox?:boolean <- equal render-from, -1
     break-unless render-current-sandbox?
-    row, column, screen, current-sandbox <- render screen, current-sandbox
+    row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox
     clear-screen-from screen, row, column, left, right
     row <- add row, 1
   }
@@ -583,7 +583,7 @@ scenario scrolling-down-past-bottom-of-recipe-editor [
   trace-until 100/app
   assume-screen 100/width, 10/height
   env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], []
-  render-all screen, env
+  render-all screen, env, render
   assume-console [
     press enter
     press down-arrow
@@ -604,7 +604,7 @@ scenario cursor-down-in-recipe-editor [
   trace-until 100/app
   assume-screen 100/width, 10/height
   env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], []
-  render-all screen, env
+  render-all screen, env, render
   assume-console [
     press enter
     press up-arrow
@@ -682,7 +682,7 @@ scenario scrolling-down-past-bottom-of-recipe-editor-2 [
   trace-until 100/app
   assume-screen 100/width, 10/height
   env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], []
-  render-all screen, env
+  render-all screen, env, render
   assume-console [
     # add a line
     press enter
@@ -708,7 +708,7 @@ scenario scrolling-down-past-bottom-of-recipe-editor-3 [
   assume-screen 100/width, 10/height
   env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [ab
 cd]
-  render-all screen, env
+  render-all screen, env, render
   assume-console [
     # add a line
     press enter
@@ -739,7 +739,7 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [
   1:address:array:character <- new []
   2:address:array:character <- new [add 2, 2]
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   assume-console [
     # create a sandbox
     press F4
@@ -809,7 +809,7 @@ after <global-keypress> [
       *env <- put *env, render-from:offset, render-from
     }
     hide-screen screen
-    screen <- render-sandbox-side screen, env
+    screen <- render-sandbox-side screen, env, render
     show-screen screen
     jump +finish-event:label
   }
@@ -840,7 +840,7 @@ after <global-keypress> [
     render-from <- subtract render-from, 1
     *env <- put *env, render-from:offset, render-from
     hide-screen screen
-    screen <- render-sandbox-side screen, env
+    screen <- render-sandbox-side screen, env, render
     show-screen screen
     jump +finish-event:label
   }
@@ -874,7 +874,7 @@ scenario scrolling-down-on-recipe-side [
   # create a sandbox
   2:address:array:character <- new [add 2, 2]
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   assume-console [
     press F4
   ]
@@ -905,7 +905,7 @@ scenario scrolling-through-multiple-sandboxes [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes
   assume-console [
     press ctrl-n
@@ -1057,7 +1057,7 @@ scenario scrolling-manages-sandbox-index-correctly [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create a sandbox
   assume-console [
     press ctrl-n
diff --git a/edit/006-sandbox-copy.mu b/edit/006-sandbox-copy.mu
index d74e0caf..a5a98d4d 100644
--- a/edit/006-sandbox-copy.mu
+++ b/edit/006-sandbox-copy.mu
@@ -133,7 +133,7 @@ after <global-touch> [
     copy?, env <- try-copy-sandbox click-row, env
     break-unless copy?
     hide-screen screen
-    screen <- render-sandbox-side screen, env
+    screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     show-screen screen
     loop +next-event:label
diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu
index 83e6282e..def5c0c5 100644
--- a/edit/007-sandbox-delete.mu
+++ b/edit/007-sandbox-delete.mu
@@ -72,7 +72,7 @@ after <global-touch> [
     delete?, env <- try-delete-sandbox click-row, env
     break-unless delete?
     hide-screen screen
-    screen <- render-sandbox-side screen, env
+    screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     show-screen screen
     loop +next-event:label
@@ -154,7 +154,7 @@ scenario deleting-sandbox-after-scroll [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes and scroll to second
   assume-console [
     press ctrl-n
@@ -200,7 +200,7 @@ scenario deleting-top-sandbox-after-scroll [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes and scroll to second
   assume-console [
     press ctrl-n
@@ -246,7 +246,7 @@ scenario deleting-final-sandbox-after-scroll [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes and scroll to second
   assume-console [
     press ctrl-n
@@ -294,7 +294,7 @@ scenario deleting-updates-sandbox-count [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes
   assume-console [
     press ctrl-n
diff --git a/edit/008-sandbox-edit.mu b/edit/008-sandbox-edit.mu
index df897a6e..b208c277 100644
--- a/edit/008-sandbox-edit.mu
+++ b/edit/008-sandbox-edit.mu
@@ -128,7 +128,7 @@ after <global-touch> [
     edit?, env <- try-edit-sandbox click-row, env
     break-unless edit?
     hide-screen screen
-    screen <- render-sandbox-side screen, env
+    screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     show-screen screen
     loop +next-event:label
@@ -224,7 +224,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes and scroll to second
   assume-console [
     press ctrl-n
@@ -272,7 +272,7 @@ scenario editing-sandbox-updates-sandbox-count [
   1:address:array:character <- new []
   2:address:array:character <- new []
   3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
-  render-all screen, 3:address:programming-environment-data
+  render-all screen, 3:address:programming-environment-data, render
   # create 2 sandboxes
   assume-console [
     press ctrl-n
diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu
index edefcf45..16c85c45 100644
--- a/edit/009-sandbox-test.mu
+++ b/edit/009-sandbox-test.mu
@@ -130,7 +130,7 @@ after <global-touch> [
     sandbox <- toggle-expected-response sandbox
     save-sandboxes env
     hide-screen screen
-    screen <- render-sandbox-side screen, env, 1/clear
+    screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     # no change in cursor
     show-screen screen
diff --git a/edit/010-sandbox-trace.mu b/edit/010-sandbox-trace.mu
index 3451cc4b..ab21e24c 100644
--- a/edit/010-sandbox-trace.mu
+++ b/edit/010-sandbox-trace.mu
@@ -201,7 +201,7 @@ after <global-touch> [
     x <- not x
     *sandbox <- put *sandbox, display-trace?:offset, x
     hide-screen screen
-    screen <- render-sandbox-side screen, env, 1/clear
+    screen <- render-sandbox-side screen, env, render
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     # no change in cursor
     show-screen screen