From b2a2dc9593bd8a06977830f228ee86bb80c6a36e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 16 Apr 2017 15:16:22 -0700 Subject: 3825 --- html/edit/008-sandbox-edit.mu.html | 414 ++++++++++++++++++------------------- 1 file changed, 206 insertions(+), 208 deletions(-) (limited to 'html/edit/008-sandbox-edit.mu.html') diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index a6900448..56a9c009 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -169,221 +169,219 @@ if ('onhashchange' in window) { 107 after <global-touch> [ 108 # support 'edit' button 109 { -110 ¦ edit?:bool <- should-attempt-edit? click-row, click-column, env +110 ¦ edit?:bool <- should-attempt-edit? click-row, click-column, env 111 ¦ break-unless edit? -112 ¦ edit?, env <- try-edit-sandbox click-row, env +112 ¦ edit?, env <- try-edit-sandbox click-row, env 113 ¦ break-unless edit? -114 ¦ hide-screen screen -115 ¦ screen <- render-sandbox-side screen, env, render -116 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env -117 ¦ show-screen screen -118 ¦ loop +next-event -119 } -120 ] -121 -122 # some preconditions for attempting to edit a sandbox -123 def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [ -124 local-scope -125 load-ingredients -126 # are we below the sandbox editor? -127 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env -128 return-unless click-sandbox-area?, 0/false -129 # narrower, is the click in the columns spanning the 'edit' button? -130 first-sandbox:&:editor <- get *env, current-sandbox:offset -131 assert first-sandbox, [!!] -132 sandbox-left-margin:num <- get *first-sandbox, left:offset -133 sandbox-right-margin:num <- get *first-sandbox, right:offset -134 edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin -135 edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right -136 return-unless edit-button-vertical-area?, 0/false -137 # finally, is sandbox editor empty? -138 current-sandbox:&:editor <- get *env, current-sandbox:offset -139 result <- empty-editor? current-sandbox -140 ] -141 -142 def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [ -143 local-scope -144 load-ingredients -145 # identify the sandbox to edit, if the click was actually on the 'edit' button -146 sandbox:&:sandbox <- find-sandbox env, click-row -147 return-unless sandbox, 0/false -148 clicked-on-edit-button? <- copy 1/true -149 # 'edit' button = 'copy' button + 'delete' button -150 text:text <- get *sandbox, data:offset -151 current-sandbox:&:editor <- get *env, current-sandbox:offset -152 current-sandbox <- insert-text current-sandbox, text -153 env <- delete-sandbox env, sandbox -154 # reset scroll -155 *env <- put *env, render-from:offset, -1 -156 # position cursor in sandbox editor -157 *env <- put *env, sandbox-in-focus?:offset, 1/true -158 ] -159 -160 scenario sandbox-with-print-can-be-edited [ -161 local-scope -162 trace-until 100/app # trace too long -163 assume-screen 100/width, 20/height -164 # left editor is empty -165 assume-resources [ -166 ] -167 # right editor contains a print instruction -168 env:&:environment <- new-programming-environment resources, screen, [print screen, 4] -169 # run the sandbox -170 assume-console [ -171 ¦ press F4 -172 ] -173 event-loop screen, console, env, resources -174 screen-should-contain [ -175 ¦ . run (F4) . -176 ¦ . ╎ . -177 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -178 ¦ . ╎0 edit copy delete . -179 ¦ . ╎print screen, 4 . -180 ¦ . ╎screen: . -181 ¦ . ╎ .4 . . +114 ¦ screen <- render-sandbox-side screen, env, render +115 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +116 ¦ loop +next-event +117 } +118 ] +119 +120 # some preconditions for attempting to edit a sandbox +121 def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [ +122 local-scope +123 load-ingredients +124 # are we below the sandbox editor? +125 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env +126 return-unless click-sandbox-area?, 0/false +127 # narrower, is the click in the columns spanning the 'edit' button? +128 first-sandbox:&:editor <- get *env, current-sandbox:offset +129 assert first-sandbox, [!!] +130 sandbox-left-margin:num <- get *first-sandbox, left:offset +131 sandbox-right-margin:num <- get *first-sandbox, right:offset +132 edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin +133 edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right +134 return-unless edit-button-vertical-area?, 0/false +135 # finally, is sandbox editor empty? +136 current-sandbox:&:editor <- get *env, current-sandbox:offset +137 result <- empty-editor? current-sandbox +138 ] +139 +140 def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [ +141 local-scope +142 load-ingredients +143 # identify the sandbox to edit, if the click was actually on the 'edit' button +144 sandbox:&:sandbox <- find-sandbox env, click-row +145 return-unless sandbox, 0/false +146 clicked-on-edit-button? <- copy 1/true +147 # 'edit' button = 'copy' button + 'delete' button +148 text:text <- get *sandbox, data:offset +149 current-sandbox:&:editor <- get *env, current-sandbox:offset +150 current-sandbox <- insert-text current-sandbox, text +151 env <- delete-sandbox env, sandbox +152 # reset scroll +153 *env <- put *env, render-from:offset, -1 +154 # position cursor in sandbox editor +155 *env <- put *env, sandbox-in-focus?:offset, 1/true +156 ] +157 +158 scenario sandbox-with-print-can-be-edited [ +159 local-scope +160 trace-until 100/app # trace too long +161 assume-screen 100/width, 20/height +162 # left editor is empty +163 assume-resources [ +164 ] +165 # right editor contains a print instruction +166 env:&:environment <- new-programming-environment resources, screen, [print screen, 4] +167 # run the sandbox +168 assume-console [ +169 ¦ press F4 +170 ] +171 event-loop screen, console, env, resources +172 screen-should-contain [ +173 ¦ . run (F4) . +174 ¦ . ╎ . +175 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +176 ¦ . ╎0 edit copy delete . +177 ¦ . ╎print screen, 4 . +178 ¦ . ╎screen: . +179 ¦ . ╎ .4 . . +180 ¦ . ╎ . . . +181 ¦ . ╎ . . . 182 ¦ . ╎ . . . 183 ¦ . ╎ . . . -184 ¦ . ╎ . . . -185 ¦ . ╎ . . . -186 ¦ . ╎─────────────────────────────────────────────────. -187 ¦ . ╎ . -188 ] -189 # edit the sandbox -190 assume-console [ -191 ¦ left-click 3, 65 -192 ] -193 run [ -194 ¦ event-loop screen, console, env, resources -195 ] -196 screen-should-contain [ -197 ¦ . run (F4) . -198 ¦ . ╎print screen, 4 . -199 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -200 ¦ . ╎ . -201 ¦ . ╎ . -202 ] -203 ] -204 -205 scenario editing-sandbox-after-scrolling-resets-scroll [ -206 local-scope -207 trace-until 100/app # trace too long -208 assume-screen 100/width, 10/height -209 # initialize environment -210 assume-resources [ -211 ] -212 env:&:environment <- new-programming-environment resources, screen, [] -213 render-all screen, env, render -214 # create 2 sandboxes and scroll to second -215 assume-console [ -216 ¦ press ctrl-n -217 ¦ type [add 2, 2] +184 ¦ . ╎─────────────────────────────────────────────────. +185 ¦ . ╎ . +186 ] +187 # edit the sandbox +188 assume-console [ +189 ¦ left-click 3, 65 +190 ] +191 run [ +192 ¦ event-loop screen, console, env, resources +193 ] +194 screen-should-contain [ +195 ¦ . run (F4) . +196 ¦ . ╎print screen, 4 . +197 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +198 ¦ . ╎ . +199 ¦ . ╎ . +200 ] +201 ] +202 +203 scenario editing-sandbox-after-scrolling-resets-scroll [ +204 local-scope +205 trace-until 100/app # trace too long +206 assume-screen 100/width, 10/height +207 # initialize environment +208 assume-resources [ +209 ] +210 env:&:environment <- new-programming-environment resources, screen, [] +211 render-all screen, env, render +212 # create 2 sandboxes and scroll to second +213 assume-console [ +214 ¦ press ctrl-n +215 ¦ type [add 2, 2] +216 ¦ press F4 +217 ¦ type [add 1, 1] 218 ¦ press F4 -219 ¦ type [add 1, 1] -220 ¦ press F4 -221 ¦ press page-down -222 ¦ press page-down -223 ] -224 event-loop screen, console, env, resources -225 screen-should-contain [ -226 ¦ . run (F4) . -227 ¦ . ╎─────────────────────────────────────────────────. -228 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy delete . -229 ¦ . ╎add 2, 2 . -230 ¦ . ╎4 . -231 ¦ . ╎─────────────────────────────────────────────────. -232 ¦ . ╎ . -233 ] -234 # edit the second sandbox -235 assume-console [ -236 ¦ left-click 2, 55 -237 ] -238 run [ -239 ¦ event-loop screen, console, env, resources -240 ] -241 # second sandbox shows in editor; scroll resets to display first sandbox -242 screen-should-contain [ -243 ¦ . run (F4) . -244 ¦ . ╎add 2, 2 . -245 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -246 ¦ . ╎0 edit copy delete . -247 ¦ . ╎add 1, 1 . -248 ¦ . ╎2 . -249 ¦ . ╎─────────────────────────────────────────────────. -250 ¦ . ╎ . -251 ] -252 ] -253 -254 scenario editing-sandbox-updates-sandbox-count [ -255 local-scope -256 trace-until 100/app # trace too long -257 assume-screen 100/width, 10/height -258 # initialize environment -259 assume-resources [ -260 ] -261 env:&:environment <- new-programming-environment resources, screen, [] -262 render-all screen, env, render -263 # create 2 sandboxes -264 assume-console [ -265 ¦ press ctrl-n -266 ¦ type [add 2, 2] +219 ¦ press page-down +220 ¦ press page-down +221 ] +222 event-loop screen, console, env, resources +223 screen-should-contain [ +224 ¦ . run (F4) . +225 ¦ . ╎─────────────────────────────────────────────────. +226 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy delete . +227 ¦ . ╎add 2, 2 . +228 ¦ . ╎4 . +229 ¦ . ╎─────────────────────────────────────────────────. +230 ¦ . ╎ . +231 ] +232 # edit the second sandbox +233 assume-console [ +234 ¦ left-click 2, 55 +235 ] +236 run [ +237 ¦ event-loop screen, console, env, resources +238 ] +239 # second sandbox shows in editor; scroll resets to display first sandbox +240 screen-should-contain [ +241 ¦ . run (F4) . +242 ¦ . ╎add 2, 2 . +243 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +244 ¦ . ╎0 edit copy delete . +245 ¦ . ╎add 1, 1 . +246 ¦ . ╎2 . +247 ¦ . ╎─────────────────────────────────────────────────. +248 ¦ . ╎ . +249 ] +250 ] +251 +252 scenario editing-sandbox-updates-sandbox-count [ +253 local-scope +254 trace-until 100/app # trace too long +255 assume-screen 100/width, 10/height +256 # initialize environment +257 assume-resources [ +258 ] +259 env:&:environment <- new-programming-environment resources, screen, [] +260 render-all screen, env, render +261 # create 2 sandboxes +262 assume-console [ +263 ¦ press ctrl-n +264 ¦ type [add 2, 2] +265 ¦ press F4 +266 ¦ type [add 1, 1] 267 ¦ press F4 -268 ¦ type [add 1, 1] -269 ¦ press F4 -270 ] -271 event-loop screen, console, env, resources -272 screen-should-contain [ -273 ¦ . run (F4) . -274 ¦ . ╎ . -275 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -276 ¦ . ╎0 edit copy delete . -277 ¦ . ╎add 1, 1 . -278 ¦ . ╎2 . -279 ¦ . ╎─────────────────────────────────────────────────. -280 ¦ . ╎1 edit copy delete . -281 ¦ . ╎add 2, 2 . -282 ¦ . ╎4 . -283 ] -284 # edit the second sandbox, then resave -285 assume-console [ -286 ¦ left-click 3, 60 -287 ¦ press F4 -288 ] -289 run [ -290 ¦ event-loop screen, console, env, resources -291 ] -292 # no change in contents -293 screen-should-contain [ -294 ¦ . run (F4) . -295 ¦ . ╎ . -296 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -297 ¦ . ╎0 edit copy delete . -298 ¦ . ╎add 1, 1 . -299 ¦ . ╎2 . -300 ¦ . ╎─────────────────────────────────────────────────. -301 ¦ . ╎1 edit copy delete . -302 ¦ . ╎add 2, 2 . -303 ¦ . ╎4 . -304 ] -305 # now try to scroll past end -306 assume-console [ +268 ] +269 event-loop screen, console, env, resources +270 screen-should-contain [ +271 ¦ . run (F4) . +272 ¦ . ╎ . +273 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +274 ¦ . ╎0 edit copy delete . +275 ¦ . ╎add 1, 1 . +276 ¦ . ╎2 . +277 ¦ . ╎─────────────────────────────────────────────────. +278 ¦ . ╎1 edit copy delete . +279 ¦ . ╎add 2, 2 . +280 ¦ . ╎4 . +281 ] +282 # edit the second sandbox, then resave +283 assume-console [ +284 ¦ left-click 3, 60 +285 ¦ press F4 +286 ] +287 run [ +288 ¦ event-loop screen, console, env, resources +289 ] +290 # no change in contents +291 screen-should-contain [ +292 ¦ . run (F4) . +293 ¦ . ╎ . +294 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +295 ¦ . ╎0 edit copy delete . +296 ¦ . ╎add 1, 1 . +297 ¦ . ╎2 . +298 ¦ . ╎─────────────────────────────────────────────────. +299 ¦ . ╎1 edit copy delete . +300 ¦ . ╎add 2, 2 . +301 ¦ . ╎4 . +302 ] +303 # now try to scroll past end +304 assume-console [ +305 ¦ press page-down +306 ¦ press page-down 307 ¦ press page-down -308 ¦ press page-down -309 ¦ press page-down -310 ] -311 run [ -312 ¦ event-loop screen, console, env, resources -313 ] -314 # screen should show just final sandbox with the right index (1) -315 screen-should-contain [ -316 ¦ . run (F4) . -317 ¦ . ╎─────────────────────────────────────────────────. -318 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy delete . -319 ¦ . ╎add 2, 2 . -320 ¦ . ╎4 . -321 ¦ . ╎─────────────────────────────────────────────────. -322 ¦ . ╎ . -323 ] -324 ] +308 ] +309 run [ +310 ¦ event-loop screen, console, env, resources +311 ] +312 # screen should show just final sandbox with the right index (1) +313 screen-should-contain [ +314 ¦ . run (F4) . +315 ¦ . ╎─────────────────────────────────────────────────. +316 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy delete . +317 ¦ . ╎add 2, 2 . +318 ¦ . ╎4 . +319 ¦ . ╎─────────────────────────────────────────────────. +320 ¦ . ╎ . +321 ] +322 ] -- cgit 1.4.1-2-gfad0