about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-01 22:27:45 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-01 22:27:45 -0700
commit66ba4e4b01d44e39836112b411a44cd74b7e01f3 (patch)
tree5b820126420325b1efd9316ce50572a02e1c5b6a
parent48e40252b005e3c37e3e5c087daf4f14657295f6 (diff)
downloadmu-66ba4e4b01d44e39836112b411a44cd74b7e01f3.tar.gz
1914 - save right after 'pinning' expected response
-rw-r--r--edit.mu42
1 files changed, 25 insertions, 17 deletions
diff --git a/edit.mu b/edit.mu
index e4a7f340..fedd9f9f 100644
--- a/edit.mu
+++ b/edit.mu
@@ -2774,7 +2774,6 @@ recipe run-sandboxes [
   local-scope
   env:address:programming-environment-data <- next-ingredient
   recipes:address:editor-data <- get *env, recipes:offset
-  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   # copy code from recipe editor, persist, load into mu, save any warnings
   in:address:array:character <- editor-contents recipes
   save [recipes.mu], in
@@ -2783,6 +2782,7 @@ recipe run-sandboxes [
   # if recipe editor has errors, stop
   reply-if *recipe-warnings
   # check contents of right editor (sandbox)
+  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   {
     sandbox-contents:address:array:character <- editor-contents current-sandbox
     break-unless sandbox-contents
@@ -2801,6 +2801,26 @@ recipe run-sandboxes [
     *init <- push-duplex 167/§, 0/tail
   }
   # save all sandboxes before running, just in case we die when running
+  save-sandboxes env
+  # run all sandboxes
+  curr:address:sandbox-data <- get *env, sandbox:offset
+  {
+    break-unless curr
+    data <- get-address *curr, data:offset
+    response:address:address:array:character <- get-address *curr, response:offset
+    warnings:address:address:array:character <- get-address *curr, warnings:offset
+    fake-screen:address:address:screen <- get-address *curr, screen:offset
+    *response, *warnings, *fake-screen <- run-interactive *data
+#?     $print *warnings, [ ], **warnings, 10/newline
+    curr <- get *curr, next-sandbox:offset
+    loop
+  }
+]
+
+recipe save-sandboxes [
+  local-scope
+  env:address:programming-environment-data <- next-ingredient
+  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   # first clear previous versions, in case we deleted some sandbox
   $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
   curr:address:sandbox-data <- get *env, sandbox:offset
@@ -2808,9 +2828,9 @@ recipe run-sandboxes [
   idx:number <- copy 0
   {
     break-unless curr
-    data <- get-address *curr, data:offset
+    data:address:array:character <- get *curr, data:offset
     filename:address:array:character <- integer-to-decimal-string idx
-    save filename, *data
+    save filename, data
     {
       expected-response:address:array:character <- get *curr, expected-response:offset
       break-unless expected-response
@@ -2821,19 +2841,6 @@ recipe run-sandboxes [
     curr <- get *curr, next-sandbox:offset
     loop
   }
-  # run all sandboxes
-  curr <- get *env, sandbox:offset
-  {
-    break-unless curr
-    data <- get-address *curr, data:offset
-    response:address:address:array:character <- get-address *curr, response:offset
-    warnings:address:address:array:character <- get-address *curr, warnings:offset
-    fake-screen:address:address:screen <- get-address *curr, screen:offset
-    *response, *warnings, *fake-screen <- run-interactive *data
-#?     $print *warnings, [ ], **warnings, 10/newline
-    curr <- get *curr, next-sandbox:offset
-    loop
-  }
 ]
 
 recipe render-sandbox-side [
@@ -3529,8 +3536,9 @@ after +global-touch [
     # identify the sandbox whose output is being clicked on
     sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row
     break-unless sandbox
-    # toggle its expected-response
+    # toggle its expected-response, and save session
     sandbox <- toggle-expected-response sandbox
+    save-sandboxes env
     screen <- render-sandbox-side screen, env, 1/clear
     # no change in cursor
     show-screen screen