about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-22 08:59:38 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-22 08:59:38 -0800
commit6cb233fc43239c67caffadbd47e51594232e23bd (patch)
tree4a21f8ab2c8e988b1a838c6637d4be08e3f68bfd /sandbox
parent3151fb2387439475e12a354f2905a77ccb80ca19 (diff)
downloadmu-6cb233fc43239c67caffadbd47e51594232e23bd.tar.gz
2586 - show first sandbox with error in status
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/004-programming-environment.mu3
-rw-r--r--sandbox/005-sandbox.mu14
-rw-r--r--sandbox/009-sandbox-trace.mu2
-rw-r--r--sandbox/010-warnings.mu61
4 files changed, 67 insertions, 13 deletions
diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu
index b6c50fbf..81484f0f 100644
--- a/sandbox/004-programming-environment.mu
+++ b/sandbox/004-programming-environment.mu
@@ -36,6 +36,7 @@ recipe new-programming-environment screen:address:shared:screen, initial-sandbox
   # sandbox editor
   current-sandbox:address:address:shared:editor-data <- get-address *result, current-sandbox:offset
   *current-sandbox <- new-editor initial-sandbox-contents, screen, 0, width/right
+  <programming-environment-initialization>
 ]
 
 recipe event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [
@@ -159,7 +160,9 @@ recipe render-all screen:address:shared:screen, env:address:shared:programming-e
   # top menu
   trace 11, [app], [render top menu]
   width:number <- screen-width screen
+#?   $print [draw menu], 10/newline
   draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey
+#?   $print [draw menu end], 10/newline
   button-start:number <- subtract width, 20
   button-on-screen?:boolean <- greater-or-equal button-start, 0
   assert button-on-screen?, [screen too narrow for menu]
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index 2ad25dd4..19bce3d7 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -106,14 +106,15 @@ after <global-keypress> [
   {
     do-run?:boolean <- equal *k, 65532/F4
     break-unless do-run?
-    status:address:shared:array:character <- new [running...  ]
+    status:address:shared:array:character <- new [running...       ]
     screen <- update-status screen, status, 245/grey
     error?:boolean, env, screen <- run-sandboxes env, screen
     # F4 might update warnings and results on both sides
     screen <- render-all screen, env
     {
       break-if error?
-      status:address:shared:array:character <- new [            ]
+#?       $print [update-status: clearing], 10/newline
+      status:address:shared:array:character <- new [                 ]
       screen <- update-status screen, status, 245/grey
     }
     screen <- update-cursor screen, current-sandbox
@@ -127,6 +128,7 @@ recipe run-sandboxes env:address:shared:programming-environment-data, screen:add
   errors-found?:boolean, env, screen <- update-recipes env, screen
   reply-if errors-found?
   # check contents of editor
+  <run-sandboxes-begin>
   current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset
   {
     sandbox-contents:address:shared:array:character <- editor-contents current-sandbox
@@ -151,13 +153,15 @@ recipe run-sandboxes env:address:shared:programming-environment-data, screen:add
   save-sandboxes env
   # run all sandboxes
   curr:address:shared:sandbox-data <- get *env, sandbox:offset
+  idx:number <- copy 0
   {
     break-unless curr
-    curr <- update-sandbox curr, env
+    curr <- update-sandbox curr, env, idx
     curr <- get *curr, next-sandbox:offset
+    idx <- add idx, 1
     loop
   }
-  reply 0/no-errors-found, env/same-as-ingredient:0, screen/same-as-ingredient:1
+  <run-sandboxes-end>
 ]
 
 # load code from recipes.mu
@@ -171,7 +175,7 @@ recipe update-recipes env:address:shared:programming-environment-data, screen:ad
 ]
 
 # replaced in a later layer
-recipe update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [
+recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [
   local-scope
   load-ingredients
   data:address:shared:array:character <- get *sandbox, data:offset
diff --git a/sandbox/009-sandbox-trace.mu b/sandbox/009-sandbox-trace.mu
index 06a7cdec..8ca16327 100644
--- a/sandbox/009-sandbox-trace.mu
+++ b/sandbox/009-sandbox-trace.mu
@@ -119,7 +119,7 @@ container sandbox-data [
 ]
 
 # replaced in a later layer
-recipe! update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [
+recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [
   local-scope
   load-ingredients
   data:address:shared:array:character <- get *sandbox, data:offset
diff --git a/sandbox/010-warnings.mu b/sandbox/010-warnings.mu
index 16a6a92c..317a857a 100644
--- a/sandbox/010-warnings.mu
+++ b/sandbox/010-warnings.mu
@@ -14,8 +14,10 @@ recipe! update-recipes env:address:shared:programming-environment-data, screen:a
   # if recipe editor has errors, stop
   {
     break-unless *recipe-warnings
-    status:address:shared:array:character <- new [errors found]
+    status:address:shared:array:character <- new [errors found     ]
     update-status screen, status, 1/red
+    errors-found? <- copy 1/true
+    reply
   }
   errors-found? <- copy 0/false
 ]
@@ -25,8 +27,46 @@ before <render-components-end> [
   recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset
   {
     break-unless recipe-warnings
-    status:address:shared:array:character <- new [errors found]
+    status:address:shared:array:character <- new [errors found     ]
+    update-status screen, status, 1/red
+  }
+]
+
+container programming-environment-data [
+  warning-index:number  # index of first sandbox with an error (or -1 if none)
+]
+
+after <programming-environment-initialization> [
+  warning-index:address:number <- get-address *result, warning-index:offset
+  *warning-index <- copy -1
+]
+
+after <run-sandboxes-begin> [
+  warning-index:address:number <- get-address *env, warning-index:offset
+  *warning-index <- copy -1
+]
+
+before <run-sandboxes-end> [
+  {
+    sandboxes-completed-successfully?:boolean <- equal *warning-index, -1
+    break-if sandboxes-completed-successfully?
+    errors-found? <- copy 1/true
+  }
+]
+
+before <render-components-end> [
+  {
+    break-if recipe-warnings
+    warning-index:number <- get *env, warning-index:offset
+    sandboxes-completed-successfully?:boolean <- equal warning-index, -1
+    break-if sandboxes-completed-successfully?
+    status-template:address:shared:array:character <- new [errors found (_)    ]
+    warning-index-text:address:shared:array:character <- to-text warning-index
+    status:address:shared:array:character <- interpolate status-template, warning-index-text
+#?     $print [update-status: sandbox warning], 10/newline
     update-status screen, status, 1/red
+#?     $print [run sandboxes end], 10/newline
+    reply
   }
 ]
 
@@ -34,7 +74,7 @@ container sandbox-data [
   warnings:address:shared:array:character
 ]
 
-recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data -> sandbox:address:shared:sandbox-data [
+recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [
   local-scope
   load-ingredients
   data:address:shared:array:character <- get *sandbox, data:offset
@@ -55,6 +95,13 @@ recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:p
     *warnings <- new [took too long!
 ]
   }
+  {
+    break-unless *warnings
+#?     $print [setting warning-index to ], idx, 10/newline
+    warning-index:address:number <- get-address *env, warning-index:offset
+    *warning-index <- copy idx
+  }
+#?   $print [done with run-interactive], 10/newline
 ]
 
 # make sure we render any trace
@@ -86,7 +133,7 @@ scenario run-instruction-and-print-warnings [
     event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data
   ]
   screen-should-contain [
-    .                               run (F4)           .
+    .  errors found (0)             run (F4)           .
     .                                                  .
     .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
     .0                                                x.
@@ -97,7 +144,7 @@ scenario run-instruction-and-print-warnings [
     .                                                  .
   ]
   screen-should-contain-in-color 1/red, [
-    .                                                  .
+    .  errors found (0)                                .
     .                                                  .
     .                                                  .
     .                                                  .
@@ -127,7 +174,7 @@ scenario run-instruction-and-print-warnings-only-once [
   ]
   # check that screen prints error message just once
   screen-should-contain [
-    .                               run (F4)           .
+    .  errors found (0)             run (F4)           .
     .                                                  .
     .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
     .0                                                x.
@@ -156,7 +203,7 @@ loop
     event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data
   ]
   screen-should-contain [
-    .                               run (F4)           .
+    .  errors found (0)             run (F4)           .
     .                                                  .
     .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
     .0                                                x.