about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
Diffstat (limited to 'edit')
-rw-r--r--edit/009-sandbox-test.mu52
1 files changed, 38 insertions, 14 deletions
diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu
index 5966617c..4893e1ea 100644
--- a/edit/009-sandbox-test.mu
+++ b/edit/009-sandbox-test.mu
@@ -3,7 +3,7 @@
 scenario sandbox-click-on-result-toggles-color-to-green [
   local-scope
   trace-until 100/app  # trace too long
-  assume-screen 100/width, 10/height
+  assume-screen 100/width, 20/height
   # basic recipe
   assume-resources [
     [lesson/recipes.mu] <- [
@@ -30,6 +30,7 @@ scenario sandbox-click-on-result-toggles-color-to-green [
     .                                                  ┊                                                 .
   ]
   # click on the '4' in the result
+  $clear-trace
   assume-console [
     left-click 5, 51
   ]
@@ -47,6 +48,8 @@ scenario sandbox-click-on-result-toggles-color-to-green [
     .                                                                                                    .
     .                                                                                                    .
   ]
+  # don't render entire sandbox side
+  check-trace-count-for-label-lesser-than 250, [print-character]  # say 5 sandbox lines
   # cursor should remain unmoved
   run [
     cursor:char <- copy 9251/␣
@@ -128,10 +131,19 @@ after <global-touch> [
     # identify the sandbox whose output is being clicked on
     sandbox:&:sandbox, sandbox-index:num <- find-click-in-sandbox-output env, click-row
     break-unless sandbox
-    # toggle its expected-response, and save session
+    # update it
     sandbox <- toggle-expected-response sandbox
+    # minimal update to disk
     save-sandbox resources, sandbox, sandbox-index
-    screen <- render-sandbox-side screen, env, render
+    # minimal update to screen
+    sandbox-right-margin:num <- get *current-sandbox, right:offset
+    row:num <- render-sandbox-response screen, sandbox, sandbox-left-margin, sandbox-right-margin
+    {
+      height:num <- screen-height screen
+      at-bottom?:bool <- greater-or-equal row, height
+      break-if at-bottom?
+      draw-horizontal screen, row, sandbox-left-margin, sandbox-right-margin
+    }
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     loop +next-event
   }
@@ -187,21 +199,33 @@ after <render-sandbox-response> [
   {
     break-unless sandbox-response
     *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row
-    expected-response:text <- get *sandbox, expected-response:offset
-    break-unless expected-response  # fall-through to print in grey
-    response-is-expected?:bool <- equal expected-response, sandbox-response
-    {
-      break-if response-is-expected?
-      row, screen <- render-text screen, sandbox-response, left, right, 1/red, row
-    }
-    {
-      break-unless response-is-expected?:bool
-      row, screen <- render-text screen, sandbox-response, left, right, 2/green, row
-    }
+    row <- render-sandbox-response screen, sandbox, left, right
     jump +render-sandbox-end
   }
 ]
 
+def render-sandbox-response screen:&:screen, sandbox:&:sandbox, left:num, right:num -> row:num, screen:&:screen [
+  local-scope
+  load-ingredients
+  sandbox-response:text <- get *sandbox, response:offset
+  expected-response:text <- get *sandbox, expected-response:offset
+  row:num <- get *sandbox response-starting-row-on-screen:offset
+  {
+    break-if expected-response
+    row <- render-text screen, sandbox-response, left, right, 245/grey, row
+    return
+  }
+  response-is-expected?:bool <- equal expected-response, sandbox-response
+  {
+    break-if response-is-expected?
+    row <- render-text screen, sandbox-response, left, right, 1/red, row
+  }
+  {
+    break-unless response-is-expected?:bool
+    row <- render-text screen, sandbox-response, left, right, 2/green, row
+  }
+]
+
 before <end-render-sandbox-reset-hidden> [
   *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0
 ]