From d2f0704962eb0e43f3db8b461dd6d48ee9297f73 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 25 Jun 2017 10:15:44 -0700 Subject: 3957 Marking sandbox responses as expected can take a long time if there are many sandboxes. Indicate when a click is being worked on. --- html/edit/009-sandbox-test.mu.html | 154 +++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 76 deletions(-) (limited to 'html/edit/009-sandbox-test.mu.html') diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index ecdd04c6..d147fa92 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -189,83 +189,85 @@ if ('onhashchange' in window) { 126 ¦ below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins 127 ¦ break-unless below-sandbox-editor? 128 ¦ # identify the sandbox whose output is being clicked on -129 ¦ sandbox:&:sandbox <- find-click-in-sandbox-output env, click-row +129 ¦ sandbox:&:sandbox <- find-click-in-sandbox-output env, click-row 130 ¦ break-unless sandbox -131 ¦ # toggle its expected-response, and save session -132 ¦ sandbox <- toggle-expected-response sandbox -133 ¦ save-sandboxes env, resources -134 ¦ screen <- render-sandbox-side screen, env, render -135 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env -136 ¦ loop +next-event -137 } -138 ] -139 -140 def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox [ -141 local-scope -142 load-ingredients -143 # assert click-row >= sandbox.starting-row-on-screen -144 sandbox:&:sandbox <- get *env, sandbox:offset -145 start:num <- get *sandbox, starting-row-on-screen:offset -146 clicked-on-sandboxes?:bool <- greater-or-equal click-row, start -147 assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] -148 # while click-row < sandbox.next-sandbox.starting-row-on-screen -149 { -150 ¦ next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset -151 ¦ break-unless next-sandbox -152 ¦ next-start:num <- get *next-sandbox, starting-row-on-screen:offset -153 ¦ found?:bool <- lesser-than click-row, next-start -154 ¦ break-if found? -155 ¦ sandbox <- copy next-sandbox -156 ¦ loop -157 } -158 # return sandbox if click is in its output region -159 response-starting-row:num <- get *sandbox, response-starting-row-on-screen:offset -160 return-unless response-starting-row, 0/no-click-in-sandbox-output -161 click-in-response?:bool <- greater-or-equal click-row, response-starting-row -162 return-unless click-in-response?, 0/no-click-in-sandbox-output -163 return sandbox -164 ] -165 -166 def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ -167 local-scope -168 load-ingredients -169 expected-response:text <- get *sandbox, expected-response:offset -170 { -171 ¦ # if expected-response is set, reset -172 ¦ break-unless expected-response -173 ¦ *sandbox <- put *sandbox, expected-response:offset, 0 -174 } -175 { -176 ¦ # if not, set expected response to the current response -177 ¦ break-if expected-response -178 ¦ response:text <- get *sandbox, response:offset -179 ¦ *sandbox <- put *sandbox, expected-response:offset, response -180 } -181 ] -182 -183 # when rendering a sandbox, color it in red/green if expected response exists -184 after <render-sandbox-response> [ -185 { -186 ¦ break-unless sandbox-response -187 ¦ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row -188 ¦ expected-response:text <- get *sandbox, expected-response:offset -189 ¦ break-unless expected-response # fall-through to print in grey -190 ¦ response-is-expected?:bool <- equal expected-response, sandbox-response -191 ¦ { -192 ¦ ¦ break-if response-is-expected? -193 ¦ ¦ row, screen <- render-text screen, sandbox-response, left, right, 1/red, row -194 ¦ } -195 ¦ { -196 ¦ ¦ break-unless response-is-expected?:bool -197 ¦ ¦ row, screen <- render-text screen, sandbox-response, left, right, 2/green, row -198 ¦ } -199 ¦ jump +render-sandbox-end -200 } -201 ] -202 -203 before <end-render-sandbox-reset-hidden> [ -204 *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 -205 ] +131 ¦ screen <- update-status screen, [updating... ], 245/grey +132 ¦ # toggle its expected-response, and save session +133 ¦ sandbox <- toggle-expected-response sandbox +134 ¦ save-sandboxes env, resources +135 ¦ screen <- render-sandbox-side screen, env, render +136 ¦ screen <- update-status screen, [ ], 245/grey +137 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +138 ¦ loop +next-event +139 } +140 ] +141 +142 def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox [ +143 local-scope +144 load-ingredients +145 # assert click-row >= sandbox.starting-row-on-screen +146 sandbox:&:sandbox <- get *env, sandbox:offset +147 start:num <- get *sandbox, starting-row-on-screen:offset +148 clicked-on-sandboxes?:bool <- greater-or-equal click-row, start +149 assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] +150 # while click-row < sandbox.next-sandbox.starting-row-on-screen +151 { +152 ¦ next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset +153 ¦ break-unless next-sandbox +154 ¦ next-start:num <- get *next-sandbox, starting-row-on-screen:offset +155 ¦ found?:bool <- lesser-than click-row, next-start +156 ¦ break-if found? +157 ¦ sandbox <- copy next-sandbox +158 ¦ loop +159 } +160 # return sandbox if click is in its output region +161 response-starting-row:num <- get *sandbox, response-starting-row-on-screen:offset +162 return-unless response-starting-row, 0/no-click-in-sandbox-output +163 click-in-response?:bool <- greater-or-equal click-row, response-starting-row +164 return-unless click-in-response?, 0/no-click-in-sandbox-output +165 return sandbox +166 ] +167 +168 def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ +169 local-scope +170 load-ingredients +171 expected-response:text <- get *sandbox, expected-response:offset +172 { +173 ¦ # if expected-response is set, reset +174 ¦ break-unless expected-response +175 ¦ *sandbox <- put *sandbox, expected-response:offset, 0 +176 } +177 { +178 ¦ # if not, set expected response to the current response +179 ¦ break-if expected-response +180 ¦ response:text <- get *sandbox, response:offset +181 ¦ *sandbox <- put *sandbox, expected-response:offset, response +182 } +183 ] +184 +185 # when rendering a sandbox, color it in red/green if expected response exists +186 after <render-sandbox-response> [ +187 { +188 ¦ break-unless sandbox-response +189 ¦ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row +190 ¦ expected-response:text <- get *sandbox, expected-response:offset +191 ¦ break-unless expected-response # fall-through to print in grey +192 ¦ response-is-expected?:bool <- equal expected-response, sandbox-response +193 ¦ { +194 ¦ ¦ break-if response-is-expected? +195 ¦ ¦ row, screen <- render-text screen, sandbox-response, left, right, 1/red, row +196 ¦ } +197 ¦ { +198 ¦ ¦ break-unless response-is-expected?:bool +199 ¦ ¦ row, screen <- render-text screen, sandbox-response, left, right, 2/green, row +200 ¦ } +201 ¦ jump +render-sandbox-end +202 } +203 ] +204 +205 before <end-render-sandbox-reset-hidden> [ +206 *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 +207 ] -- cgit 1.4.1-2-gfad0