From 6cb233fc43239c67caffadbd47e51594232e23bd Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 22 Jan 2016 08:59:38 -0800 Subject: 2586 - show first sandbox with error in status --- sandbox/004-programming-environment.mu | 3 ++ sandbox/005-sandbox.mu | 14 +++++--- sandbox/009-sandbox-trace.mu | 2 +- sandbox/010-warnings.mu | 61 ++++++++++++++++++++++++++++++---- 4 files changed, 67 insertions(+), 13 deletions(-) (limited to 'sandbox') 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 + ] 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 [ { 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 + 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 + ] # 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 [ 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 [ + warning-index:address:number <- get-address *result, warning-index:offset + *warning-index <- copy -1 +] + +after [ + warning-index:address:number <- get-address *env, warning-index:offset + *warning-index <- copy -1 +] + +before [ + { + sandboxes-completed-successfully?:boolean <- equal *warning-index, -1 + break-if sandboxes-completed-successfully? + errors-found? <- copy 1/true + } +] + +before [ + { + 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. -- cgit 1.4.1-2-gfad0