about summary refs log tree commit diff stats
path: root/sandbox/009-sandbox-test.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-25 14:50:16 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-25 14:50:16 -0700
commit67160f82f285e4422927346c4ab0b5dd164b8544 (patch)
tree57b1cc8ea27e6765fdd508fc522b61610781c147 /sandbox/009-sandbox-test.mu
parente3c9e1536154e0dee2c15b556a2a6b9f6524e114 (diff)
downloadmu-67160f82f285e4422927346c4ab0b5dd164b8544.tar.gz
3960
Don't refresh entire sandbox side when toggling the expected result for
a single sandbox.
Diffstat (limited to 'sandbox/009-sandbox-test.mu')
-rw-r--r--sandbox/009-sandbox-test.mu50
1 files changed, 37 insertions, 13 deletions
diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu
index 65381a2b..2bd3aac9 100644
--- a/sandbox/009-sandbox-test.mu
+++ b/sandbox/009-sandbox-test.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, 21
   ]
@@ -46,6 +47,8 @@ scenario sandbox-click-on-result-toggles-color-to-green [
     .4                                                 .
     .                                                  .
   ]
+  # 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/␣
@@ -130,10 +133,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, current-sandbox, env
     loop +next-event
   }
@@ -189,21 +201,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
 ]