From dc5f112c3ea8aff1a389513fa6c33d88fab07420 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 25 Jun 2017 10:49:03 -0700 Subject: 3958 Improvement on fix 3957: rather than put a band-aid over a slow operation, eliminate the slowdown entirely. In this case it turns out we're unnecessarily saving files to disk when they could never be modified. Are we doing this on F4 as well?! --- html/edit/005-sandbox.mu.html | 1882 +++++++++++++++++----------------- html/edit/006-sandbox-copy.mu.html | 4 +- html/edit/007-sandbox-delete.mu.html | 2 +- html/edit/008-sandbox-edit.mu.html | 2 +- html/edit/009-sandbox-test.mu.html | 76 +- html/edit/010-sandbox-trace.mu.html | 4 +- html/edit/011-errors.mu.html | 6 +- 7 files changed, 991 insertions(+), 985 deletions(-) (limited to 'html/edit') diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 3adf365a..b68c4873 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -75,7 +75,7 @@ if ('onhashchange' in window) { 12 open-console 13 clear-screen 0/screen # non-scrolling app 14 env:&:environment <- new-programming-environment 0/filesystem, 0/screen - 15 env <- restore-sandboxes env, 0/filesystem + 15 env <- restore-sandboxes env, 0/filesystem 16 render-all 0/screen, env, render 17 event-loop 0/screen, 0/console, env, 0/filesystem 18 ] @@ -218,7 +218,7 @@ if ('onhashchange' in window) { 155 <run-sandboxes-begin> 156 current-sandbox:&:editor <- get *env, current-sandbox:offset 157 { - 158 ¦ sandbox-contents:text <- editor-contents current-sandbox + 158 ¦ sandbox-contents:text <- editor-contents current-sandbox 159 ¦ break-unless sandbox-contents 160 ¦ # if contents exist, first save them 161 ¦ # run them and turn them into a new sandbox @@ -263,7 +263,7 @@ if ('onhashchange' in window) { 200 local-scope 201 load-ingredients 202 recipes:&:editor <- get *env, recipes:offset - 203 in:text <- editor-contents recipes + 203 in:text <- editor-contents recipes 204 resources <- dump resources, [lesson/recipes.mu], in 205 reload in 206 errors-found? <- copy 0/false @@ -296,952 +296,958 @@ if ('onhashchange' in window) { 233 idx:num <- copy 0 234 { 235 ¦ break-unless curr - 236 ¦ data:text <- get *curr, data:offset - 237 ¦ filename:text <- append [lesson/], idx - 238 ¦ resources <- dump resources, filename, data - 239 ¦ <end-save-sandbox> - 240 ¦ idx <- add idx, 1 - 241 ¦ curr <- get *curr, next-sandbox:offset - 242 ¦ loop - 243 } - 244 ] - 245 - 246 def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [ - 247 local-scope - 248 load-ingredients - 249 trace 11, [app], [render sandbox side] - 250 old-top-idx:num <- save-top-idx screen - 251 current-sandbox:&:editor <- get *env, current-sandbox:offset - 252 row:num, column:num <- copy 1, 0 - 253 left:num <- get *current-sandbox, left:offset - 254 right:num <- get *current-sandbox, right:offset - 255 # render sandbox editor - 256 render-from:num <- get *env, render-from:offset - 257 { - 258 ¦ render-current-sandbox?:bool <- equal render-from, -1 - 259 ¦ break-unless render-current-sandbox? - 260 ¦ row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox - 261 ¦ clear-screen-from screen, row, column, left, right - 262 ¦ row <- add row, 1 - 263 } - 264 # render sandboxes - 265 draw-horizontal screen, row, left, right - 266 sandbox:&:sandbox <- get *env, sandbox:offset - 267 row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from - 268 clear-rest-of-screen screen, row, left, right - 269 # - 270 assert-no-scroll screen, old-top-idx - 271 ] - 272 - 273 def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ - 274 local-scope - 275 load-ingredients - 276 return-unless sandbox - 277 screen-height:num <- screen-height screen - 278 hidden?:bool <- lesser-than idx, render-from - 279 { - 280 ¦ break-if hidden? - 281 ¦ # render sandbox menu - 282 ¦ row <- add row, 1 - 283 ¦ at-bottom?:bool <- greater-or-equal row, screen-height - 284 ¦ return-if at-bottom? - 285 ¦ screen <- move-cursor screen, row, left - 286 ¦ screen <- render-sandbox-menu screen, idx, left, right - 287 ¦ # save menu row so we can detect clicks to it later - 288 ¦ *sandbox <- put *sandbox, starting-row-on-screen:offset, row - 289 ¦ # render sandbox contents - 290 ¦ row <- add row, 1 + 236 ¦ resources <- save-sandbox resources, curr, idx + 237 ¦ idx <- add idx, 1 + 238 ¦ curr <- get *curr, next-sandbox:offset + 239 ¦ loop + 240 } + 241 ] + 242 + 243 def save-sandbox resources:&:resources, sandbox:&:sandbox, sandbox-index:num -> resources:&:resources [ + 244 local-scope + 245 load-ingredients + 246 data:text <- get *sandbox, data:offset + 247 filename:text <- append [lesson/], sandbox-index + 248 resources <- dump resources, filename, data + 249 <end-save-sandbox> + 250 ] + 251 + 252 def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [ + 253 local-scope + 254 load-ingredients + 255 trace 11, [app], [render sandbox side] + 256 old-top-idx:num <- save-top-idx screen + 257 current-sandbox:&:editor <- get *env, current-sandbox:offset + 258 row:num, column:num <- copy 1, 0 + 259 left:num <- get *current-sandbox, left:offset + 260 right:num <- get *current-sandbox, right:offset + 261 # render sandbox editor + 262 render-from:num <- get *env, render-from:offset + 263 { + 264 ¦ render-current-sandbox?:bool <- equal render-from, -1 + 265 ¦ break-unless render-current-sandbox? + 266 ¦ row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox + 267 ¦ clear-screen-from screen, row, column, left, right + 268 ¦ row <- add row, 1 + 269 } + 270 # render sandboxes + 271 draw-horizontal screen, row, left, right + 272 sandbox:&:sandbox <- get *env, sandbox:offset + 273 row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from + 274 clear-rest-of-screen screen, row, left, right + 275 # + 276 assert-no-scroll screen, old-top-idx + 277 ] + 278 + 279 def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ + 280 local-scope + 281 load-ingredients + 282 return-unless sandbox + 283 screen-height:num <- screen-height screen + 284 hidden?:bool <- lesser-than idx, render-from + 285 { + 286 ¦ break-if hidden? + 287 ¦ # render sandbox menu + 288 ¦ row <- add row, 1 + 289 ¦ at-bottom?:bool <- greater-or-equal row, screen-height + 290 ¦ return-if at-bottom? 291 ¦ screen <- move-cursor screen, row, left - 292 ¦ sandbox-data:text <- get *sandbox, data:offset - 293 ¦ row, screen <- render-code screen, sandbox-data, left, right, row - 294 ¦ *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row - 295 ¦ # render sandbox warnings, screen or response, in that order - 296 ¦ sandbox-response:text <- get *sandbox, response:offset - 297 ¦ <render-sandbox-results> - 298 ¦ { - 299 ¦ ¦ sandbox-screen:&:screen <- get *sandbox, screen:offset - 300 ¦ ¦ empty-screen?:bool <- fake-screen-is-empty? sandbox-screen - 301 ¦ ¦ break-if empty-screen? - 302 ¦ ¦ row, screen <- render-screen screen, sandbox-screen, left, right, row - 303 ¦ } + 292 ¦ screen <- render-sandbox-menu screen, idx, left, right + 293 ¦ # save menu row so we can detect clicks to it later + 294 ¦ *sandbox <- put *sandbox, starting-row-on-screen:offset, row + 295 ¦ # render sandbox contents + 296 ¦ row <- add row, 1 + 297 ¦ screen <- move-cursor screen, row, left + 298 ¦ sandbox-data:text <- get *sandbox, data:offset + 299 ¦ row, screen <- render-code screen, sandbox-data, left, right, row + 300 ¦ *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row + 301 ¦ # render sandbox warnings, screen or response, in that order + 302 ¦ sandbox-response:text <- get *sandbox, response:offset + 303 ¦ <render-sandbox-results> 304 ¦ { - 305 ¦ ¦ break-unless empty-screen? - 306 ¦ ¦ <render-sandbox-response> - 307 ¦ ¦ row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row - 308 ¦ } - 309 ¦ +render-sandbox-end - 310 ¦ at-bottom?:bool <- greater-or-equal row, screen-height - 311 ¦ return-if at-bottom? - 312 ¦ # draw solid line after sandbox - 313 ¦ draw-horizontal screen, row, left, right - 314 } - 315 # if hidden, reset row attributes - 316 { - 317 ¦ break-unless hidden? - 318 ¦ *sandbox <- put *sandbox, starting-row-on-screen:offset, 0 - 319 ¦ *sandbox <- put *sandbox, code-ending-row-on-screen:offset, 0 - 320 ¦ <end-render-sandbox-reset-hidden> - 321 } - 322 # draw next sandbox - 323 next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset - 324 next-idx:num <- add idx, 1 - 325 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx - 326 ] - 327 - 328 def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [ - 329 local-scope - 330 load-ingredients - 331 move-cursor-to-column screen, left - 332 edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right - 333 print screen, sandbox-index, 232/dark-grey, 245/grey - 334 start-buttons:num <- subtract edit-button-left, 1 - 335 clear-line-until screen, start-buttons, 245/grey - 336 print screen, [edit], 232/black, 25/background-blue - 337 clear-line-until screen, edit-button-right, 25/background-blue - 338 print screen, [copy], 232/black, 58/background-green - 339 clear-line-until screen, copy-button-right, 58/background-green - 340 print screen, [to recipe], 232/black, 94/background-orange - 341 clear-line-until screen, recipe-button-right, 94/background-orange - 342 print screen, [delete], 232/black, 52/background-red - 343 clear-line-until screen, right, 52/background-red - 344 ] - 345 - 346 scenario skip-rendering-sandbox-menu-past-bottom-row [ - 347 trace-until 100/app # trace too long - 348 assume-screen 100/width, 6/height - 349 # recipe editor is empty - 350 assume-resources [ - 351 ¦ [lesson/0] <- [|add 2, 2|] - 352 ¦ [lesson/1] <- [|add 1, 1|] - 353 ] - 354 # create two sandboxes such that the top one just barely fills the screen - 355 env:&:environment <- new-programming-environment resources, screen, [] - 356 env <- restore-sandboxes env, resources - 357 run [ - 358 ¦ render-all screen, env, render + 305 ¦ ¦ sandbox-screen:&:screen <- get *sandbox, screen:offset + 306 ¦ ¦ empty-screen?:bool <- fake-screen-is-empty? sandbox-screen + 307 ¦ ¦ break-if empty-screen? + 308 ¦ ¦ row, screen <- render-screen screen, sandbox-screen, left, right, row + 309 ¦ } + 310 ¦ { + 311 ¦ ¦ break-unless empty-screen? + 312 ¦ ¦ <render-sandbox-response> + 313 ¦ ¦ row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row + 314 ¦ } + 315 ¦ +render-sandbox-end + 316 ¦ at-bottom?:bool <- greater-or-equal row, screen-height + 317 ¦ return-if at-bottom? + 318 ¦ # draw solid line after sandbox + 319 ¦ draw-horizontal screen, row, left, right + 320 } + 321 # if hidden, reset row attributes + 322 { + 323 ¦ break-unless hidden? + 324 ¦ *sandbox <- put *sandbox, starting-row-on-screen:offset, 0 + 325 ¦ *sandbox <- put *sandbox, code-ending-row-on-screen:offset, 0 + 326 ¦ <end-render-sandbox-reset-hidden> + 327 } + 328 # draw next sandbox + 329 next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset + 330 next-idx:num <- add idx, 1 + 331 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx + 332 ] + 333 + 334 def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [ + 335 local-scope + 336 load-ingredients + 337 move-cursor-to-column screen, left + 338 edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right + 339 print screen, sandbox-index, 232/dark-grey, 245/grey + 340 start-buttons:num <- subtract edit-button-left, 1 + 341 clear-line-until screen, start-buttons, 245/grey + 342 print screen, [edit], 232/black, 25/background-blue + 343 clear-line-until screen, edit-button-right, 25/background-blue + 344 print screen, [copy], 232/black, 58/background-green + 345 clear-line-until screen, copy-button-right, 58/background-green + 346 print screen, [to recipe], 232/black, 94/background-orange + 347 clear-line-until screen, recipe-button-right, 94/background-orange + 348 print screen, [delete], 232/black, 52/background-red + 349 clear-line-until screen, right, 52/background-red + 350 ] + 351 + 352 scenario skip-rendering-sandbox-menu-past-bottom-row [ + 353 trace-until 100/app # trace too long + 354 assume-screen 100/width, 6/height + 355 # recipe editor is empty + 356 assume-resources [ + 357 ¦ [lesson/0] <- [|add 2, 2|] + 358 ¦ [lesson/1] <- [|add 1, 1|] 359 ] - 360 screen-should-contain [ - 361 ¦ . run (F4) . - 362 ¦ . ╎ . - 363 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. - 364 ¦ . ╎0 edit copy to recipe delete . - 365 ¦ . ╎add 2, 2 . - 366 ¦ . ╎─────────────────────────────────────────────────. - 367 ] - 368 ] - 369 - 370 # divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons - 371 # delete-button-right == right - 372 # all left/right pairs are inclusive - 373 def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num [ - 374 local-scope - 375 load-ingredients - 376 start-buttons:num <- add left, 4/space-for-sandbox-index - 377 buttons-space:num <- subtract right, start-buttons - 378 button-width:num <- divide-with-remainder buttons-space, 4 # integer division - 379 buttons-wide-enough?:bool <- greater-or-equal button-width, 10 - 380 assert buttons-wide-enough?, [sandbox must be at least 40 or so characters wide] - 381 edit-button-left:num <- copy start-buttons - 382 copy-button-left:num <- add start-buttons, button-width - 383 edit-button-right:num <- subtract copy-button-left, 1 - 384 recipe-button-left:num <- add copy-button-left, button-width - 385 copy-button-right:num <- subtract recipe-button-left, 1 - 386 delete-button-left:num <- subtract right, button-width, -2 # because 'to recipe' is wider than 'delete' - 387 recipe-button-right:num <- subtract delete-button-left, 1 - 388 ] - 389 - 390 # print a text 's' to 'editor' in 'color' starting at 'row' - 391 # clear rest of last line, move cursor to next line - 392 # like 'render-code' but without syntax-based colorization - 393 def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [ - 394 local-scope - 395 load-ingredients - 396 return-unless s - 397 column:num <- copy left - 398 screen <- move-cursor screen, row, column - 399 screen-height:num <- screen-height screen - 400 i:num <- copy 0 - 401 len:num <- length *s - 402 { - 403 ¦ +next-character - 404 ¦ done?:bool <- greater-or-equal i, len - 405 ¦ break-if done? - 406 ¦ done? <- greater-or-equal row, screen-height - 407 ¦ break-if done? - 408 ¦ c:char <- index *s, i - 409 ¦ { - 410 ¦ ¦ # newline? move to left rather than 0 - 411 ¦ ¦ newline?:bool <- equal c, 10/newline - 412 ¦ ¦ break-unless newline? - 413 ¦ ¦ # clear rest of line in this window - 414 ¦ ¦ { - 415 ¦ ¦ ¦ done?:bool <- greater-than column, right - 416 ¦ ¦ ¦ break-if done? - 417 ¦ ¦ ¦ space:char <- copy 32/space - 418 ¦ ¦ ¦ print screen, space - 419 ¦ ¦ ¦ column <- add column, 1 - 420 ¦ ¦ ¦ loop - 421 ¦ ¦ } - 422 ¦ ¦ row <- add row, 1 - 423 ¦ ¦ column <- copy left - 424 ¦ ¦ screen <- move-cursor screen, row, column - 425 ¦ ¦ i <- add i, 1 - 426 ¦ ¦ loop +next-character - 427 ¦ } - 428 ¦ { - 429 ¦ ¦ # at right? wrap. - 430 ¦ ¦ at-right?:bool <- equal column, right - 431 ¦ ¦ break-unless at-right? - 432 ¦ ¦ # print wrap icon - 433 ¦ ¦ wrap-icon:char <- copy 8617/loop-back-to-left - 434 ¦ ¦ print screen, wrap-icon, 245/grey - 435 ¦ ¦ column <- copy left - 436 ¦ ¦ row <- add row, 1 - 437 ¦ ¦ screen <- move-cursor screen, row, column - 438 ¦ ¦ # don't increment i - 439 ¦ ¦ loop +next-character - 440 ¦ } - 441 ¦ i <- add i, 1 - 442 ¦ print screen, c, color - 443 ¦ column <- add column, 1 - 444 ¦ loop - 445 } - 446 was-at-left?:bool <- equal column, left - 447 clear-line-until screen, right - 448 { - 449 ¦ break-if was-at-left? - 450 ¦ row <- add row, 1 + 360 # create two sandboxes such that the top one just barely fills the screen + 361 env:&:environment <- new-programming-environment resources, screen, [] + 362 env <- restore-sandboxes env, resources + 363 run [ + 364 ¦ render-all screen, env, render + 365 ] + 366 screen-should-contain [ + 367 ¦ . run (F4) . + 368 ¦ . ╎ . + 369 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. + 370 ¦ . ╎0 edit copy to recipe delete . + 371 ¦ . ╎add 2, 2 . + 372 ¦ . ╎─────────────────────────────────────────────────. + 373 ] + 374 ] + 375 + 376 # divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons + 377 # delete-button-right == right + 378 # all left/right pairs are inclusive + 379 def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num [ + 380 local-scope + 381 load-ingredients + 382 start-buttons:num <- add left, 4/space-for-sandbox-index + 383 buttons-space:num <- subtract right, start-buttons + 384 button-width:num <- divide-with-remainder buttons-space, 4 # integer division + 385 buttons-wide-enough?:bool <- greater-or-equal button-width, 10 + 386 assert buttons-wide-enough?, [sandbox must be at least 40 or so characters wide] + 387 edit-button-left:num <- copy start-buttons + 388 copy-button-left:num <- add start-buttons, button-width + 389 edit-button-right:num <- subtract copy-button-left, 1 + 390 recipe-button-left:num <- add copy-button-left, button-width + 391 copy-button-right:num <- subtract recipe-button-left, 1 + 392 delete-button-left:num <- subtract right, button-width, -2 # because 'to recipe' is wider than 'delete' + 393 recipe-button-right:num <- subtract delete-button-left, 1 + 394 ] + 395 + 396 # print a text 's' to 'editor' in 'color' starting at 'row' + 397 # clear rest of last line, move cursor to next line + 398 # like 'render-code' but without syntax-based colorization + 399 def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [ + 400 local-scope + 401 load-ingredients + 402 return-unless s + 403 column:num <- copy left + 404 screen <- move-cursor screen, row, column + 405 screen-height:num <- screen-height screen + 406 i:num <- copy 0 + 407 len:num <- length *s + 408 { + 409 ¦ +next-character + 410 ¦ done?:bool <- greater-or-equal i, len + 411 ¦ break-if done? + 412 ¦ done? <- greater-or-equal row, screen-height + 413 ¦ break-if done? + 414 ¦ c:char <- index *s, i + 415 ¦ { + 416 ¦ ¦ # newline? move to left rather than 0 + 417 ¦ ¦ newline?:bool <- equal c, 10/newline + 418 ¦ ¦ break-unless newline? + 419 ¦ ¦ # clear rest of line in this window + 420 ¦ ¦ { + 421 ¦ ¦ ¦ done?:bool <- greater-than column, right + 422 ¦ ¦ ¦ break-if done? + 423 ¦ ¦ ¦ space:char <- copy 32/space + 424 ¦ ¦ ¦ print screen, space + 425 ¦ ¦ ¦ column <- add column, 1 + 426 ¦ ¦ ¦ loop + 427 ¦ ¦ } + 428 ¦ ¦ row <- add row, 1 + 429 ¦ ¦ column <- copy left + 430 ¦ ¦ screen <- move-cursor screen, row, column + 431 ¦ ¦ i <- add i, 1 + 432 ¦ ¦ loop +next-character + 433 ¦ } + 434 ¦ { + 435 ¦ ¦ # at right? wrap. + 436 ¦ ¦ at-right?:bool <- equal column, right + 437 ¦ ¦ break-unless at-right? + 438 ¦ ¦ # print wrap icon + 439 ¦ ¦ wrap-icon:char <- copy 8617/loop-back-to-left + 440 ¦ ¦ print screen, wrap-icon, 245/grey + 441 ¦ ¦ column <- copy left + 442 ¦ ¦ row <- add row, 1 + 443 ¦ ¦ screen <- move-cursor screen, row, column + 444 ¦ ¦ # don't increment i + 445 ¦ ¦ loop +next-character + 446 ¦ } + 447 ¦ i <- add i, 1 + 448 ¦ print screen, c, color + 449 ¦ column <- add column, 1 + 450 ¦ loop 451 } - 452 move-cursor screen, row, left - 453 ] - 454 - 455 scenario render-text-wraps-barely-long-lines [ - 456 local-scope - 457 assume-screen 5/width, 5/height - 458 run [ - 459 ¦ render-text screen, [abcde], 0/left, 4/right, 7/white, 1/row - 460 ] - 461 screen-should-contain [ - 462 ¦ . . - 463 ¦ .abcd↩. - 464 ¦ .e . - 465 ¦ . . + 452 was-at-left?:bool <- equal column, left + 453 clear-line-until screen, right + 454 { + 455 ¦ break-if was-at-left? + 456 ¦ row <- add row, 1 + 457 } + 458 move-cursor screen, row, left + 459 ] + 460 + 461 scenario render-text-wraps-barely-long-lines [ + 462 local-scope + 463 assume-screen 5/width, 5/height + 464 run [ + 465 ¦ render-text screen, [abcde], 0/left, 4/right, 7/white, 1/row 466 ] - 467 ] - 468 - 469 # assumes programming environment has no sandboxes; restores them from previous session - 470 def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [ - 471 local-scope - 472 load-ingredients - 473 # read all scenarios, pushing them to end of a list of scenarios - 474 idx:num <- copy 0 - 475 curr:&:sandbox <- copy 0 - 476 prev:&:sandbox <- copy 0 - 477 { - 478 ¦ filename:text <- append [lesson/], idx - 479 ¦ contents:text <- slurp resources, filename - 480 ¦ break-unless contents # stop at first error; assuming file didn't exist - 481 ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ # todo: handle empty sandbox - 482 ¦ # create new sandbox for file - 483 ¦ curr <- new sandbox:type - 484 ¦ *curr <- put *curr, data:offset, contents - 485 ¦ <end-restore-sandbox> - 486 ¦ { - 487 ¦ ¦ break-if idx - 488 ¦ ¦ *env <- put *env, sandbox:offset, curr - 489 ¦ } - 490 ¦ { - 491 ¦ ¦ break-unless idx - 492 ¦ ¦ *prev <- put *prev, next-sandbox:offset, curr - 493 ¦ } - 494 ¦ idx <- add idx, 1 - 495 ¦ prev <- copy curr - 496 ¦ loop - 497 } - 498 # update sandbox count - 499 *env <- put *env, number-of-sandboxes:offset, idx - 500 ] - 501 - 502 # print the fake sandbox screen to 'screen' with appropriate delimiters - 503 # leave cursor at start of next line - 504 def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [ - 505 local-scope - 506 load-ingredients - 507 return-unless sandbox-screen - 508 # print 'screen:' - 509 row <- render-text screen, [screen:], left, right, 245/grey, row - 510 screen <- move-cursor screen, row, left - 511 # start printing sandbox-screen - 512 column:num <- copy left - 513 s-width:num <- screen-width sandbox-screen - 514 s-height:num <- screen-height sandbox-screen - 515 buf:&:@:screen-cell <- get *sandbox-screen, data:offset - 516 stop-printing:num <- add left, s-width, 3 - 517 max-column:num <- min stop-printing, right - 518 i:num <- copy 0 - 519 len:num <- length *buf - 520 screen-height:num <- screen-height screen - 521 { - 522 ¦ done?:bool <- greater-or-equal i, len - 523 ¦ break-if done? - 524 ¦ done? <- greater-or-equal row, screen-height - 525 ¦ break-if done? - 526 ¦ column <- copy left - 527 ¦ screen <- move-cursor screen, row, column - 528 ¦ # initial leader for each row: two spaces and a '.' - 529 ¦ space:char <- copy 32/space - 530 ¦ print screen, space, 245/grey - 531 ¦ print screen, space, 245/grey - 532 ¦ full-stop:char <- copy 46/period - 533 ¦ print screen, full-stop, 245/grey - 534 ¦ column <- add left, 3 - 535 ¦ { - 536 ¦ ¦ # print row - 537 ¦ ¦ row-done?:bool <- greater-or-equal column, max-column - 538 ¦ ¦ break-if row-done? - 539 ¦ ¦ curr:screen-cell <- index *buf, i - 540 ¦ ¦ c:char <- get curr, contents:offset - 541 ¦ ¦ color:num <- get curr, color:offset - 542 ¦ ¦ { - 543 ¦ ¦ ¦ # damp whites down to grey - 544 ¦ ¦ ¦ white?:bool <- equal color, 7/white - 545 ¦ ¦ ¦ break-unless white? - 546 ¦ ¦ ¦ color <- copy 245/grey - 547 ¦ ¦ } - 548 ¦ ¦ print screen, c, color - 549 ¦ ¦ column <- add column, 1 - 550 ¦ ¦ i <- add i, 1 - 551 ¦ ¦ loop - 552 ¦ } - 553 ¦ # print final '.' - 554 ¦ print screen, full-stop, 245/grey - 555 ¦ column <- add column, 1 - 556 ¦ { - 557 ¦ ¦ # clear rest of current line - 558 ¦ ¦ line-done?:bool <- greater-than column, right - 559 ¦ ¦ break-if line-done? - 560 ¦ ¦ print screen, space - 561 ¦ ¦ column <- add column, 1 - 562 ¦ ¦ loop - 563 ¦ } - 564 ¦ row <- add row, 1 - 565 ¦ loop - 566 } - 567 ] - 568 - 569 scenario run-updates-results [ - 570 local-scope - 571 trace-until 100/app # trace too long - 572 assume-screen 100/width, 12/height - 573 # define a recipe (no indent for the 'add' line below so column numbers are more obvious) - 574 assume-resources [ - 575 ¦ [lesson/recipes.mu] <- [ - 576 ¦ ¦ || - 577 ¦ ¦ |recipe foo [| - 578 ¦ ¦ | local-scope| - 579 ¦ ¦ | z:num <- add 2, 2| - 580 ¦ ¦ | reply z| - 581 ¦ ¦ |]| - 582 ¦ ] - 583 ] - 584 # sandbox editor contains an instruction without storing outputs - 585 env:&:environment <- new-programming-environment resources, screen, [foo] # contents of sandbox editor - 586 render-all screen, env, render - 587 $clear-trace - 588 # run the code in the editors - 589 assume-console [ - 590 ¦ press F4 - 591 ] - 592 event-loop screen, console, env, resources - 593 screen-should-contain [ - 594 ¦ . run (F4) . - 595 ¦ . ╎ . - 596 ¦ .recipe foo [ ╎─────────────────────────────────────────────────. - 597 ¦ . local-scope ╎0 edit copy to recipe delete . - 598 ¦ . z:num <- add 2, 2 ╎foo . - 599 ¦ . reply z ╎4 . - 600 ¦ .] ╎─────────────────────────────────────────────────. + 467 screen-should-contain [ + 468 ¦ . . + 469 ¦ .abcd↩. + 470 ¦ .e . + 471 ¦ . . + 472 ] + 473 ] + 474 + 475 # assumes programming environment has no sandboxes; restores them from previous session + 476 def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [ + 477 local-scope + 478 load-ingredients + 479 # read all scenarios, pushing them to end of a list of scenarios + 480 idx:num <- copy 0 + 481 curr:&:sandbox <- copy 0 + 482 prev:&:sandbox <- copy 0 + 483 { + 484 ¦ filename:text <- append [lesson/], idx + 485 ¦ contents:text <- slurp resources, filename + 486 ¦ break-unless contents # stop at first error; assuming file didn't exist + 487 ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ # todo: handle empty sandbox + 488 ¦ # create new sandbox for file + 489 ¦ curr <- new sandbox:type + 490 ¦ *curr <- put *curr, data:offset, contents + 491 ¦ <end-restore-sandbox> + 492 ¦ { + 493 ¦ ¦ break-if idx + 494 ¦ ¦ *env <- put *env, sandbox:offset, curr + 495 ¦ } + 496 ¦ { + 497 ¦ ¦ break-unless idx + 498 ¦ ¦ *prev <- put *prev, next-sandbox:offset, curr + 499 ¦ } + 500 ¦ idx <- add idx, 1 + 501 ¦ prev <- copy curr + 502 ¦ loop + 503 } + 504 # update sandbox count + 505 *env <- put *env, number-of-sandboxes:offset, idx + 506 ] + 507 + 508 # print the fake sandbox screen to 'screen' with appropriate delimiters + 509 # leave cursor at start of next line + 510 def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [ + 511 local-scope + 512 load-ingredients + 513 return-unless sandbox-screen + 514 # print 'screen:' + 515 row <- render-text screen, [screen:], left, right, 245/grey, row + 516 screen <- move-cursor screen, row, left + 517 # start printing sandbox-screen + 518 column:num <- copy left + 519 s-width:num <- screen-width sandbox-screen + 520 s-height:num <- screen-height sandbox-screen + 521 buf:&:@:screen-cell <- get *sandbox-screen, data:offset + 522 stop-printing:num <- add left, s-width, 3 + 523 max-column:num <- min stop-printing, right + 524 i:num <- copy 0 + 525 len:num <- length *buf + 526 screen-height:num <- screen-height screen + 527 { + 528 ¦ done?:bool <- greater-or-equal i, len + 529 ¦ break-if done? + 530 ¦ done? <- greater-or-equal row, screen-height + 531 ¦ break-if done? + 532 ¦ column <- copy left + 533 ¦ screen <- move-cursor screen, row, column + 534 ¦ # initial leader for each row: two spaces and a '.' + 535 ¦ space:char <- copy 32/space + 536 ¦ print screen, space, 245/grey + 537 ¦ print screen, space, 245/grey + 538 ¦ full-stop:char <- copy 46/period + 539 ¦ print screen, full-stop, 245/grey + 540 ¦ column <- add left, 3 + 541 ¦ { + 542 ¦ ¦ # print row + 543 ¦ ¦ row-done?:bool <- greater-or-equal column, max-column + 544 ¦ ¦ break-if row-done? + 545 ¦ ¦ curr:screen-cell <- index *buf, i + 546 ¦ ¦ c:char <- get curr, contents:offset + 547 ¦ ¦ color:num <- get curr, color:offset + 548 ¦ ¦ { + 549 ¦ ¦ ¦ # damp whites down to grey + 550 ¦ ¦ ¦ white?:bool <- equal color, 7/white + 551 ¦ ¦ ¦ break-unless white? + 552 ¦ ¦ ¦ color <- copy 245/grey + 553 ¦ ¦ } + 554 ¦ ¦ print screen, c, color + 555 ¦ ¦ column <- add column, 1 + 556 ¦ ¦ i <- add i, 1 + 557 ¦ ¦ loop + 558 ¦ } + 559 ¦ # print final '.' + 560 ¦ print screen, full-stop, 245/grey + 561 ¦ column <- add column, 1 + 562 ¦ { + 563 ¦ ¦ # clear rest of current line + 564 ¦ ¦ line-done?:bool <- greater-than column, right + 565 ¦ ¦ break-if line-done? + 566 ¦ ¦ print screen, space + 567 ¦ ¦ column <- add column, 1 + 568 ¦ ¦ loop + 569 ¦ } + 570 ¦ row <- add row, 1 + 571 ¦ loop + 572 } + 573 ] + 574 + 575 scenario run-updates-results [ + 576 local-scope + 577 trace-until 100/app # trace too long + 578 assume-screen 100/width, 12/height + 579 # define a recipe (no indent for the 'add' line below so column numbers are more obvious) + 580 assume-resources [ + 581 ¦ [lesson/recipes.mu] <- [ + 582 ¦ ¦ || + 583 ¦ ¦ |recipe foo [| + 584 ¦ ¦ | local-scope| + 585 ¦ ¦ | z:num <- add 2, 2| + 586 ¦ ¦ | reply z| + 587 ¦ ¦ |]| + 588 ¦ ] + 589 ] + 590 # sandbox editor contains an instruction without storing outputs + 591 env:&:environment <- new-programming-environment resources, screen, [foo] # contents of sandbox editor + 592 render-all screen, env, render + 593 $clear-trace + 594 # run the code in the editors + 595 assume-console [ + 596 ¦ press F4 + 597 ] + 598 event-loop screen, console, env, resources + 599 screen-should-contain [ + 600 ¦ . run (F4) . 601 ¦ . ╎ . - 602 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . - 603 ¦ . ╎ . - 604 ] - 605 # no need to update editor - 606 trace-should-not-contain [ - 607 ¦ app: render recipes - 608 ] - 609 # make a change (incrementing one of the args to 'add'), then rerun - 610 assume-console [ - 611 ¦ left-click 4, 28 # one past the value of the second arg - 612 ¦ press backspace - 613 ¦ type [3] - 614 ¦ press F4 - 615 ] - 616 run [ - 617 ¦ event-loop screen, console, env, resources - 618 ] - 619 # check that screen updates the result on the right - 620 screen-should-contain [ - 621 ¦ . run (F4) . - 622 ¦ . ╎ . - 623 ¦ .recipe foo [ ╎─────────────────────────────────────────────────. - 624 ¦ . local-scope ╎0 edit copy to recipe delete . - 625 ¦ . z:num <- add 2, 3 ╎foo . - 626 ¦ . reply z ╎5 . - 627 ¦ .] ╎─────────────────────────────────────────────────. + 602 ¦ .recipe foo [ ╎─────────────────────────────────────────────────. + 603 ¦ . local-scope ╎0 edit copy to recipe delete . + 604 ¦ . z:num <- add 2, 2 ╎foo . + 605 ¦ . reply z ╎4 . + 606 ¦ .] ╎─────────────────────────────────────────────────. + 607 ¦ . ╎ . + 608 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . + 609 ¦ . ╎ . + 610 ] + 611 # no need to update editor + 612 trace-should-not-contain [ + 613 ¦ app: render recipes + 614 ] + 615 # make a change (incrementing one of the args to 'add'), then rerun + 616 assume-console [ + 617 ¦ left-click 4, 28 # one past the value of the second arg + 618 ¦ press backspace + 619 ¦ type [3] + 620 ¦ press F4 + 621 ] + 622 run [ + 623 ¦ event-loop screen, console, env, resources + 624 ] + 625 # check that screen updates the result on the right + 626 screen-should-contain [ + 627 ¦ . run (F4) . 628 ¦ . ╎ . - 629 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . - 630 ¦ . ╎ . - 631 ] - 632 ] - 633 - 634 scenario run-instruction-manages-screen-per-sandbox [ - 635 local-scope - 636 trace-until 100/app # trace too long - 637 assume-screen 100/width, 20/height - 638 # empty recipes - 639 assume-resources [ - 640 ] - 641 # sandbox editor contains an instruction - 642 env:&:environment <- new-programming-environment resources, screen, [print screen, 4] # contents of sandbox editor - 643 render-all screen, env, render - 644 # run the code in the editor - 645 assume-console [ - 646 ¦ press F4 - 647 ] - 648 run [ - 649 ¦ event-loop screen, console, env, resources - 650 ] - 651 # check that it prints a little toy screen - 652 screen-should-contain [ - 653 ¦ . run (F4) . - 654 ¦ . ╎ . - 655 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. - 656 ¦ . ╎0 edit copy to recipe delete . - 657 ¦ . ╎print screen, 4 . - 658 ¦ . ╎screen: . - 659 ¦ . ╎ .4 . . - 660 ¦ . ╎ . . . - 661 ¦ . ╎ . . . - 662 ¦ . ╎ . . . - 663 ¦ . ╎ . . . - 664 ¦ . ╎─────────────────────────────────────────────────. - 665 ¦ . ╎ . - 666 ] - 667 ] - 668 - 669 def editor-contents editor:&:editor -> result:text [ - 670 local-scope - 671 load-ingredients - 672 buf:&:buffer:char <- new-buffer 80 - 673 curr:&:duplex-list:char <- get *editor, data:offset - 674 # skip § sentinel - 675 assert curr, [editor without data is illegal; must have at least a sentinel] - 676 curr <- next curr - 677 return-unless curr, 0 - 678 { - 679 ¦ break-unless curr - 680 ¦ c:char <- get *curr, value:offset - 681 ¦ buf <- append buf, c - 682 ¦ curr <- next curr - 683 ¦ loop - 684 } - 685 result <- buffer-to-array buf - 686 ] - 687 - 688 scenario editor-provides-edited-contents [ - 689 local-scope - 690 assume-screen 10/width, 5/height - 691 e:&:editor <- new-editor [abc], 0/left, 10/right - 692 assume-console [ - 693 ¦ left-click 1, 2 - 694 ¦ type [def] - 695 ] - 696 run [ - 697 ¦ editor-event-loop screen, console, e - 698 ¦ s:text <- editor-contents e - 699 ¦ 1:@:char/raw <- copy *s - 700 ] - 701 memory-should-contain [ - 702 ¦ 1:array:character <- [abdefc] - 703 ] - 704 ] - 705 - 706 # keep the bottom of recipes from scrolling off the screen - 707 - 708 scenario scrolling-down-past-bottom-of-recipe-editor [ - 709 local-scope - 710 trace-until 100/app - 711 assume-screen 100/width, 10/height - 712 assume-resources [ - 713 ] - 714 env:&:environment <- new-programming-environment resources, screen, [] - 715 render-all screen, env, render - 716 assume-console [ - 717 ¦ press enter - 718 ¦ press down-arrow + 629 ¦ .recipe foo [ ╎─────────────────────────────────────────────────. + 630 ¦ . local-scope ╎0 edit copy to recipe delete . + 631 ¦ . z:num <- add 2, 3 ╎foo . + 632 ¦ . reply z ╎5 . + 633 ¦ .] ╎─────────────────────────────────────────────────. + 634 ¦ . ╎ . + 635 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . + 636 ¦ . ╎ . + 637 ] + 638 ] + 639 + 640 scenario run-instruction-manages-screen-per-sandbox [ + 641 local-scope + 642 trace-until 100/app # trace too long + 643 assume-screen 100/width, 20/height + 644 # empty recipes + 645 assume-resources [ + 646 ] + 647 # sandbox editor contains an instruction + 648 env:&:environment <- new-programming-environment resources, screen, [print screen, 4] # contents of sandbox editor + 649 render-all screen, env, render + 650 # run the code in the editor + 651 assume-console [ + 652 ¦ press F4 + 653 ] + 654 run [ + 655 ¦ event-loop screen, console, env, resources + 656 ] + 657 # check that it prints a little toy screen + 658 screen-should-contain [ + 659 ¦ . run (F4) . + 660 ¦ . ╎ . + 661 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. + 662 ¦ . ╎0 edit copy to recipe delete . + 663 ¦ . ╎print screen, 4 . + 664 ¦ . ╎screen: . + 665 ¦ . ╎ .4 . . + 666 ¦ . ╎ . . . + 667 ¦ . ╎ . . . + 668 ¦ . ╎ . . . + 669 ¦ . ╎ . . . + 670 ¦ . ╎─────────────────────────────────────────────────. + 671 ¦ . ╎ . + 672 ] + 673 ] + 674 + 675 def editor-contents editor:&:editor -> result:text [ + 676 local-scope + 677 load-ingredients + 678 buf:&:buffer:char <- new-buffer 80 + 679 curr:&:duplex-list:char <- get *editor, data:offset + 680 # skip § sentinel + 681 assert curr, [editor without data is illegal; must have at least a sentinel] + 682 curr <- next curr + 683 return-unless curr, 0 + 684 { + 685 ¦ break-unless curr + 686 ¦ c:char <- get *curr, value:offset + 687 ¦ buf <- append buf, c + 688 ¦ curr <- next curr + 689 ¦ loop + 690 } + 691 result <- buffer-to-array buf + 692 ] + 693 + 694 scenario editor-provides-edited-contents [ + 695 local-scope + 696 assume-screen 10/width, 5/height + 697 e:&:editor <- new-editor [abc], 0/left, 10/right + 698 assume-console [ + 699 ¦ left-click 1, 2 + 700 ¦ type [def] + 701 ] + 702 run [ + 703 ¦ editor-event-loop screen, console, e + 704 ¦ s:text <- editor-contents e + 705 ¦ 1:@:char/raw <- copy *s + 706 ] + 707 memory-should-contain [ + 708 ¦ 1:array:character <- [abdefc] + 709 ] + 710 ] + 711 + 712 # keep the bottom of recipes from scrolling off the screen + 713 + 714 scenario scrolling-down-past-bottom-of-recipe-editor [ + 715 local-scope + 716 trace-until 100/app + 717 assume-screen 100/width, 10/height + 718 assume-resources [ 719 ] - 720 event-loop screen, console, env, resources - 721 # no scroll - 722 screen-should-contain [ - 723 ¦ . run (F4) . - 724 ¦ . ╎ . - 725 ¦ . ╎─────────────────────────────────────────────────. - 726 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . - 727 ¦ . ╎ . - 728 ] - 729 ] - 730 - 731 scenario cursor-down-in-recipe-editor [ - 732 local-scope - 733 trace-until 100/app - 734 assume-screen 100/width, 10/height - 735 assume-resources [ - 736 ] - 737 env:&:environment <- new-programming-environment resources, screen, [] - 738 render-all screen, env, render - 739 assume-console [ - 740 ¦ press enter - 741 ¦ press up-arrow - 742 ¦ press down-arrow # while cursor isn't at bottom - 743 ] - 744 event-loop screen, console, env, resources - 745 cursor:char <- copy 9251/␣ - 746 print screen, cursor - 747 # cursor moves back to bottom - 748 screen-should-contain [ - 749 ¦ . run (F4) . - 750 ¦ . ╎ . - 751 ¦ .␣ ╎─────────────────────────────────────────────────. - 752 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . - 753 ¦ . ╎ . - 754 ] - 755 ] - 756 - 757 scenario scrolling-down-past-bottom-of-recipe-editor-2 [ - 758 local-scope - 759 trace-until 100/app - 760 assume-screen 100/width, 10/height - 761 assume-resources [ - 762 ] - 763 env:&:environment <- new-programming-environment resources, screen, [] - 764 render-all screen, env, render - 765 assume-console [ - 766 ¦ # add a line - 767 ¦ press enter - 768 ¦ # cursor back to top line - 769 ¦ press up-arrow - 770 ¦ # try to scroll - 771 ¦ press page-down # or ctrl-f - 772 ] - 773 event-loop screen, console, env, resources - 774 # no scroll, and cursor remains at top line - 775 screen-should-contain [ - 776 ¦ . run (F4) . - 777 ¦ . ╎ . - 778 ¦ . ╎─────────────────────────────────────────────────. - 779 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . - 780 ¦ . ╎ . - 781 ] - 782 ] - 783 - 784 scenario scrolling-down-past-bottom-of-recipe-editor-3 [ - 785 local-scope - 786 trace-until 100/app - 787 assume-screen 100/width, 10/height - 788 assume-resources [ - 789 ] - 790 env:&:environment <- new-programming-environment resources, screen, [ab - 791 cd] - 792 render-all screen, env, render - 793 assume-console [ - 794 ¦ # add a line - 795 ¦ press enter - 796 ¦ # switch to sandbox - 797 ¦ press ctrl-n - 798 ¦ # move cursor - 799 ¦ press down-arrow - 800 ] - 801 event-loop screen, console, env, resources - 802 cursor:char <- copy 9251/␣ - 803 print screen, cursor - 804 # no scroll on recipe side, cursor moves on sandbox side - 805 screen-should-contain [ - 806 ¦ . run (F4) . - 807 ¦ . ╎ab . - 808 ¦ . ╎␣d . - 809 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. - 810 ¦ . ╎ . - 811 ] - 812 ] - 813 - 814 # scrolling through sandboxes - 815 - 816 scenario scrolling-down-past-bottom-of-sandbox-editor [ - 817 local-scope - 818 trace-until 100/app # trace too long - 819 assume-screen 100/width, 10/height - 820 # initialize - 821 assume-resources [ - 822 ] - 823 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] - 824 render-all screen, env, render - 825 assume-console [ - 826 ¦ # create a sandbox - 827 ¦ press F4 + 720 env:&:environment <- new-programming-environment resources, screen, [] + 721 render-all screen, env, render + 722 assume-console [ + 723 ¦ press enter + 724 ¦ press down-arrow + 725 ] + 726 event-loop screen, console, env, resources + 727 # no scroll + 728 screen-should-contain [ + 729 ¦ . run (F4) . + 730 ¦ . ╎ . + 731 ¦ . ╎─────────────────────────────────────────────────. + 732 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . + 733 ¦ . ╎ . + 734 ] + 735 ] + 736 + 737 scenario cursor-down-in-recipe-editor [ + 738 local-scope + 739 trace-until 100/app + 740 assume-screen 100/width, 10/height + 741 assume-resources [ + 742 ] + 743 env:&:environment <- new-programming-environment resources, screen, [] + 744 render-all screen, env, render + 745 assume-console [ + 746 ¦ press enter + 747 ¦ press up-arrow + 748 ¦ press down-arrow # while cursor isn't at bottom + 749 ] + 750 event-loop screen, console, env, resources + 751 cursor:char <- copy 9251/␣ + 752 print screen, cursor + 753 # cursor moves back to bottom + 754 screen-should-contain [ + 755 ¦ . run (F4) . + 756 ¦ . ╎ . + 757 ¦ .␣ ╎─────────────────────────────────────────────────. + 758 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . + 759 ¦ . ╎ . + 760 ] + 761 ] + 762 + 763 scenario scrolling-down-past-bottom-of-recipe-editor-2 [ + 764 local-scope + 765 trace-until 100/app + 766 assume-screen 100/width, 10/height + 767 assume-resources [ + 768 ] + 769 env:&:environment <- new-programming-environment resources, screen, [] + 770 render-all screen, env, render + 771 assume-console [ + 772 ¦ # add a line + 773 ¦ press enter + 774 ¦ # cursor back to top line + 775 ¦ press up-arrow + 776 ¦ # try to scroll + 777 ¦ press page-down # or ctrl-f + 778 ] + 779 event-loop screen, console, env, resources + 780 # no scroll, and cursor remains at top line + 781 screen-should-contain [ + 782 ¦ . run (F4) . + 783 ¦ . ╎ . + 784 ¦ . ╎─────────────────────────────────────────────────. + 785 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎ . + 786 ¦ . ╎ . + 787 ] + 788 ] + 789 + 790 scenario scrolling-down-past-bottom-of-recipe-editor-3 [ + 791 local-scope + 792 trace-until 100/app + 793 assume-screen 100/width, 10/height + 794 assume-resources [ + 795 ] + 796 env:&:environment <- new-programming-environment resources, screen, [ab + 797 cd] + 798 render-all screen, env, render + 799 assume-console [ + 800 ¦ # add a line + 801 ¦ press enter + 802 ¦ # switch to sandbox + 803 ¦ press ctrl-n + 804 ¦ # move cursor + 805 ¦ press down-arrow + 806 ] + 807 event-loop screen, console, env, resources + 808 cursor:char <- copy 9251/␣ + 809 print screen, cursor + 810 # no scroll on recipe side, cursor moves on sandbox side + 811 screen-should-contain [ + 812 ¦ . run (F4) . + 813 ¦ . ╎ab . + 814 ¦ . ╎␣d . + 815 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. + 816 ¦ . ╎ . + 817 ] + 818 ] + 819 + 820 # scrolling through sandboxes + 821 + 822 scenario scrolling-down-past-bottom-of-sandbox-editor [ + 823 local-scope + 824 trace-until 100/app # trace too long + 825 assume-screen 100/width, 10/height + 826 # initialize + 827 assume-resources [ 828 ] - 829 event-loop screen, console, env, resources - 830 screen-should-contain [ - 831 ¦ . run (F4) . - 832 ¦ . ╎ . - 833 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. - 834 ¦ . ╎0 edit copy to recipe delete . - 835 ¦ . ╎add 2, 2 . - 836 ] - 837 # switch to sandbox window and hit 'page-down' - 838 assume-console [ - 839 ¦ press ctrl-n - 840 ¦ press page-down - 841 ] - 842 run [ - 843 ¦ event-loop screen, console, env, resources - 844 ¦ cursor:char <- copy 9251/␣ - 845 ¦ print screen, cursor - 846 ] - 847 # sandbox editor hidden; first sandbox displayed - 848 # cursor moves to first sandbox - 849 screen-should-contain [ - 850 ¦ . run (F4) . - 851 ¦ . ╎─────────────────────────────────────────────────. - 852 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎␣ edit copy to recipe delete . - 853 ¦ . ╎add 2, 2 . - 854 ¦ . ╎4 . - 855 ] - 856 # hit 'page-up' - 857 assume-console [ - 858 ¦ press page-up - 859 ] - 860 run [ - 861 ¦ event-loop screen, console, env, resources - 862 ¦ cursor:char <- copy 9251/␣ - 863 ¦ print screen, cursor - 864 ] - 865 # sandbox editor displays again, cursor is in editor - 866 screen-should-contain [ - 867 ¦ . run (F4) . - 868 ¦ . ╎␣ . - 869 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. - 870 ¦ . ╎0 edit copy to recipe delete . - 871 ¦ . ╎add 2, 2 . - 872 ] - 873 ] - 874 - 875 # page-down on sandbox side updates render-from to scroll sandboxes - 876 after <global-keypress> [ - 877 { - 878 ¦ break-unless sandbox-in-focus? - 879 ¦ page-down?:bool <- equal k, 65518/page-down - 880 ¦ break-unless page-down? - 881 ¦ sandbox:&:sandbox <- get *env, sandbox:offset - 882 ¦ break-unless sandbox - 883 ¦ # slide down if possible - 884 ¦ { - 885 ¦ ¦ render-from:num <- get *env, render-from:offset - 886 ¦ ¦ number-of-sandboxes:num <- get *env, number-of-sandboxes:offset - 887 ¦ ¦ max:num <- subtract number-of-sandboxes, 1 - 888 ¦ ¦ at-end?:bool <- greater-or-equal render-from, max - 889 ¦ ¦ loop-if at-end?, +next-event # render nothing - 890 ¦ ¦ render-from <- add render-from, 1 - 891 ¦ ¦ *env <- put *env, render-from:offset, render-from - 892 ¦ } - 893 ¦ screen <- render-sandbox-side screen, env, render - 894 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - 895 ¦ loop +next-event - 896 } - 897 ] - 898 - 899 # update-cursor takes render-from into account - 900 after <update-cursor-special-cases> [ - 901 { - 902 ¦ break-unless sandbox-in-focus? - 903 ¦ render-from:num <- get *env, render-from:offset - 904 ¦ scrolling?:bool <- greater-or-equal render-from, 0 - 905 ¦ break-unless scrolling? - 906 ¦ cursor-column:num <- get *current-sandbox, left:offset - 907 ¦ screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 - 908 ¦ return - 909 } - 910 ] - 911 - 912 # 'page-up' on sandbox side is like 'page-down': updates render-from when necessary - 913 after <global-keypress> [ - 914 { - 915 ¦ break-unless sandbox-in-focus? - 916 ¦ page-up?:bool <- equal k, 65519/page-up - 917 ¦ break-unless page-up? - 918 ¦ render-from:num <- get *env, render-from:offset - 919 ¦ at-beginning?:bool <- equal render-from, -1 - 920 ¦ break-if at-beginning? - 921 ¦ render-from <- subtract render-from, 1 - 922 ¦ *env <- put *env, render-from:offset, render-from - 923 ¦ screen <- render-sandbox-side screen, env, render - 924 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - 925 ¦ loop +next-event - 926 } - 927 ] - 928 - 929 # sandbox belonging to 'env' whose next-sandbox is 'in' - 930 # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox - 931 def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ - 932 local-scope - 933 load-ingredients - 934 curr:&:sandbox <- get *env, sandbox:offset - 935 return-unless curr, 0/nil - 936 next:&:sandbox <- get *curr, next-sandbox:offset - 937 { - 938 ¦ return-unless next, 0/nil - 939 ¦ found?:bool <- equal next, in - 940 ¦ break-if found? - 941 ¦ curr <- copy next - 942 ¦ next <- get *curr, next-sandbox:offset - 943 ¦ loop - 944 } - 945 return curr - 946 ] - 947 - 948 scenario scrolling-through-multiple-sandboxes [ - 949 local-scope - 950 trace-until 100/app # trace too long - 951 assume-screen 100/width, 10/height - 952 # initialize environment - 953 assume-resources [ - 954 ] - 955 env:&:environment <- new-programming-environment resources, screen, [] - 956 render-all screen, env, render - 957 # create 2 sandboxes - 958 assume-console [ - 959 ¦ press ctrl-n - 960 ¦ type [add 2, 2] - 961 ¦ press F4 - 962 ¦ type [add 1, 1] - 963 ¦ press F4 - 964 ] - 965 event-loop screen, console, env, resources - 966 cursor:char <- copy 9251/␣ - 967 print screen, cursor - 968 screen-should-contain [ - 969 ¦ . run (F4) . - 970 ¦ . ╎␣ . - 971 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. - 972 ¦ . ╎0 edit copy to recipe delete . - 973 ¦ . ╎add 1, 1 . - 974 ¦ . ╎2 . - 975 ¦ . ╎─────────────────────────────────────────────────. - 976 ¦ . ╎1 edit copy to recipe delete . - 977 ¦ . ╎add 2, 2 . - 978 ¦ . ╎4 . - 979 ] - 980 # hit 'page-down' - 981 assume-console [ - 982 ¦ press page-down - 983 ] - 984 run [ - 985 ¦ event-loop screen, console, env, resources - 986 ¦ cursor:char <- copy 9251/␣ - 987 ¦ print screen, cursor - 988 ] - 989 # sandbox editor hidden; first sandbox displayed - 990 # cursor moves to first sandbox - 991 screen-should-contain [ - 992 ¦ . run (F4) . - 993 ¦ . ╎─────────────────────────────────────────────────. - 994 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎␣ edit copy to recipe delete . - 995 ¦ . ╎add 1, 1 . - 996 ¦ . ╎2 . - 997 ¦ . ╎─────────────────────────────────────────────────. - 998 ¦ . ╎1 edit copy to recipe delete . - 999 ¦ . ╎add 2, 2 . -1000 ¦ . ╎4 . -1001 ] -1002 # hit 'page-down' again -1003 assume-console [ -1004 ¦ press page-down -1005 ] -1006 run [ -1007 ¦ event-loop screen, console, env, resources -1008 ] -1009 # just second sandbox displayed -1010 screen-should-contain [ -1011 ¦ . run (F4) . -1012 ¦ . ╎─────────────────────────────────────────────────. -1013 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy to recipe delete . -1014 ¦ . ╎add 2, 2 . -1015 ¦ . ╎4 . -1016 ¦ . ╎─────────────────────────────────────────────────. -1017 ¦ . ╎ . -1018 ] -1019 # hit 'page-down' again -1020 assume-console [ -1021 ¦ press page-down -1022 ] -1023 run [ -1024 ¦ event-loop screen, console, env, resources -1025 ] -1026 # no change -1027 screen-should-contain [ -1028 ¦ . run (F4) . -1029 ¦ . ╎─────────────────────────────────────────────────. -1030 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy to recipe delete . -1031 ¦ . ╎add 2, 2 . -1032 ¦ . ╎4 . -1033 ¦ . ╎─────────────────────────────────────────────────. -1034 ¦ . ╎ . -1035 ] -1036 # hit 'page-up' -1037 assume-console [ -1038 ¦ press page-up -1039 ] -1040 run [ -1041 ¦ event-loop screen, console, env, resources -1042 ] -1043 # back to displaying both sandboxes without editor -1044 screen-should-contain [ -1045 ¦ . run (F4) . -1046 ¦ . ╎─────────────────────────────────────────────────. -1047 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎0 edit copy to recipe delete . -1048 ¦ . ╎add 1, 1 . -1049 ¦ . ╎2 . -1050 ¦ . ╎─────────────────────────────────────────────────. -1051 ¦ . ╎1 edit copy to recipe delete . -1052 ¦ . ╎add 2, 2 . -1053 ¦ . ╎4 . -1054 ] -1055 # hit 'page-up' again -1056 assume-console [ -1057 ¦ press page-up -1058 ] -1059 run [ -1060 ¦ event-loop screen, console, env, resources -1061 ¦ cursor:char <- copy 9251/␣ -1062 ¦ print screen, cursor -1063 ] -1064 # back to displaying both sandboxes as well as editor -1065 screen-should-contain [ -1066 ¦ . run (F4) . -1067 ¦ . ╎␣ . -1068 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -1069 ¦ . ╎0 edit copy to recipe delete . -1070 ¦ . ╎add 1, 1 . -1071 ¦ . ╎2 . -1072 ¦ . ╎─────────────────────────────────────────────────. -1073 ¦ . ╎1 edit copy to recipe delete . -1074 ¦ . ╎add 2, 2 . -1075 ¦ . ╎4 . -1076 ] -1077 # hit 'page-up' again -1078 assume-console [ -1079 ¦ press page-up -1080 ] -1081 run [ -1082 ¦ event-loop screen, console, env, resources -1083 ¦ cursor:char <- copy 9251/␣ -1084 ¦ print screen, cursor -1085 ] -1086 # no change -1087 screen-should-contain [ -1088 ¦ . run (F4) . -1089 ¦ . ╎␣ . -1090 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -1091 ¦ . ╎0 edit copy to recipe delete . -1092 ¦ . ╎add 1, 1 . -1093 ¦ . ╎2 . -1094 ¦ . ╎─────────────────────────────────────────────────. -1095 ¦ . ╎1 edit copy to recipe delete . -1096 ¦ . ╎add 2, 2 . -1097 ¦ . ╎4 . -1098 ] -1099 ] -1100 -1101 scenario scrolling-manages-sandbox-index-correctly [ -1102 local-scope -1103 trace-until 100/app # trace too long -1104 assume-screen 100/width, 10/height -1105 # initialize environment -1106 assume-resources [ -1107 ] -1108 env:&:environment <- new-programming-environment resources, screen, [] -1109 render-all screen, env, render -1110 # create a sandbox -1111 assume-console [ -1112 ¦ press ctrl-n -1113 ¦ type [add 1, 1] -1114 ¦ press F4 -1115 ] -1116 event-loop screen, console, env, resources -1117 screen-should-contain [ -1118 ¦ . run (F4) . -1119 ¦ . ╎ . -1120 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -1121 ¦ . ╎0 edit copy to recipe delete . -1122 ¦ . ╎add 1, 1 . -1123 ¦ . ╎2 . -1124 ¦ . ╎─────────────────────────────────────────────────. + 829 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] + 830 render-all screen, env, render + 831 assume-console [ + 832 ¦ # create a sandbox + 833 ¦ press F4 + 834 ] + 835 event-loop screen, console, env, resources + 836 screen-should-contain [ + 837 ¦ . run (F4) . + 838 ¦ . ╎ . + 839 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. + 840 ¦ . ╎0 edit copy to recipe delete . + 841 ¦ . ╎add 2, 2 . + 842 ] + 843 # switch to sandbox window and hit 'page-down' + 844 assume-console [ + 845 ¦ press ctrl-n + 846 ¦ press page-down + 847 ] + 848 run [ + 849 ¦ event-loop screen, console, env, resources + 850 ¦ cursor:char <- copy 9251/␣ + 851 ¦ print screen, cursor + 852 ] + 853 # sandbox editor hidden; first sandbox displayed + 854 # cursor moves to first sandbox + 855 screen-should-contain [ + 856 ¦ . run (F4) . + 857 ¦ . ╎─────────────────────────────────────────────────. + 858 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎␣ edit copy to recipe delete . + 859 ¦ . ╎add 2, 2 . + 860 ¦ . ╎4 . + 861 ] + 862 # hit 'page-up' + 863 assume-console [ + 864 ¦ press page-up + 865 ] + 866 run [ + 867 ¦ event-loop screen, console, env, resources + 868 ¦ cursor:char <- copy 9251/␣ + 869 ¦ print screen, cursor + 870 ] + 871 # sandbox editor displays again, cursor is in editor + 872 screen-should-contain [ + 873 ¦ . run (F4) . + 874 ¦ . ╎␣ . + 875 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. + 876 ¦ . ╎0 edit copy to recipe delete . + 877 ¦ . ╎add 2, 2 . + 878 ] + 879 ] + 880 + 881 # page-down on sandbox side updates render-from to scroll sandboxes + 882 after <global-keypress> [ + 883 { + 884 ¦ break-unless sandbox-in-focus? + 885 ¦ page-down?:bool <- equal k, 65518/page-down + 886 ¦ break-unless page-down? + 887 ¦ sandbox:&:sandbox <- get *env, sandbox:offset + 888 ¦ break-unless sandbox + 889 ¦ # slide down if possible + 890 ¦ { + 891 ¦ ¦ render-from:num <- get *env, render-from:offset + 892 ¦ ¦ number-of-sandboxes:num <- get *env, number-of-sandboxes:offset + 893 ¦ ¦ max:num <- subtract number-of-sandboxes, 1 + 894 ¦ ¦ at-end?:bool <- greater-or-equal render-from, max + 895 ¦ ¦ loop-if at-end?, +next-event # render nothing + 896 ¦ ¦ render-from <- add render-from, 1 + 897 ¦ ¦ *env <- put *env, render-from:offset, render-from + 898 ¦ } + 899 ¦ screen <- render-sandbox-side screen, env, render + 900 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + 901 ¦ loop +next-event + 902 } + 903 ] + 904 + 905 # update-cursor takes render-from into account + 906 after <update-cursor-special-cases> [ + 907 { + 908 ¦ break-unless sandbox-in-focus? + 909 ¦ render-from:num <- get *env, render-from:offset + 910 ¦ scrolling?:bool <- greater-or-equal render-from, 0 + 911 ¦ break-unless scrolling? + 912 ¦ cursor-column:num <- get *current-sandbox, left:offset + 913 ¦ screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 + 914 ¦ return + 915 } + 916 ] + 917 + 918 # 'page-up' on sandbox side is like 'page-down': updates render-from when necessary + 919 after <global-keypress> [ + 920 { + 921 ¦ break-unless sandbox-in-focus? + 922 ¦ page-up?:bool <- equal k, 65519/page-up + 923 ¦ break-unless page-up? + 924 ¦ render-from:num <- get *env, render-from:offset + 925 ¦ at-beginning?:bool <- equal render-from, -1 + 926 ¦ break-if at-beginning? + 927 ¦ render-from <- subtract render-from, 1 + 928 ¦ *env <- put *env, render-from:offset, render-from + 929 ¦ screen <- render-sandbox-side screen, env, render + 930 ¦ screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + 931 ¦ loop +next-event + 932 } + 933 ] + 934 + 935 # sandbox belonging to 'env' whose next-sandbox is 'in' + 936 # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox + 937 def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ + 938 local-scope + 939 load-ingredients + 940 curr:&:sandbox <- get *env, sandbox:offset + 941 return-unless curr, 0/nil + 942 next:&:sandbox <- get *curr, next-sandbox:offset + 943 { + 944 ¦ return-unless next, 0/nil + 945 ¦ found?:bool <- equal next, in + 946 ¦ break-if found? + 947 ¦ curr <- copy next + 948 ¦ next <- get *curr, next-sandbox:offset + 949 ¦ loop + 950 } + 951 return curr + 952 ] + 953 + 954 scenario scrolling-through-multiple-sandboxes [ + 955 local-scope + 956 trace-until 100/app # trace too long + 957 assume-screen 100/width, 10/height + 958 # initialize environment + 959 assume-resources [ + 960 ] + 961 env:&:environment <- new-programming-environment resources, screen, [] + 962 render-all screen, env, render + 963 # create 2 sandboxes + 964 assume-console [ + 965 ¦ press ctrl-n + 966 ¦ type [add 2, 2] + 967 ¦ press F4 + 968 ¦ type [add 1, 1] + 969 ¦ press F4 + 970 ] + 971 event-loop screen, console, env, resources + 972 cursor:char <- copy 9251/␣ + 973 print screen, cursor + 974 screen-should-contain [ + 975 ¦ . run (F4) . + 976 ¦ . ╎␣ . + 977 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. + 978 ¦ . ╎0 edit copy to recipe delete . + 979 ¦ . ╎add 1, 1 . + 980 ¦ . ╎2 . + 981 ¦ . ╎─────────────────────────────────────────────────. + 982 ¦ . ╎1 edit copy to recipe delete . + 983 ¦ . ╎add 2, 2 . + 984 ¦ . ╎4 . + 985 ] + 986 # hit 'page-down' + 987 assume-console [ + 988 ¦ press page-down + 989 ] + 990 run [ + 991 ¦ event-loop screen, console, env, resources + 992 ¦ cursor:char <- copy 9251/␣ + 993 ¦ print screen, cursor + 994 ] + 995 # sandbox editor hidden; first sandbox displayed + 996 # cursor moves to first sandbox + 997 screen-should-contain [ + 998 ¦ . run (F4) . + 999 ¦ . ╎─────────────────────────────────────────────────. +1000 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎␣ edit copy to recipe delete . +1001 ¦ . ╎add 1, 1 . +1002 ¦ . ╎2 . +1003 ¦ . ╎─────────────────────────────────────────────────. +1004 ¦ . ╎1 edit copy to recipe delete . +1005 ¦ . ╎add 2, 2 . +1006 ¦ . ╎4 . +1007 ] +1008 # hit 'page-down' again +1009 assume-console [ +1010 ¦ press page-down +1011 ] +1012 run [ +1013 ¦ event-loop screen, console, env, resources +1014 ] +1015 # just second sandbox displayed +1016 screen-should-contain [ +1017 ¦ . run (F4) . +1018 ¦ . ╎─────────────────────────────────────────────────. +1019 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy to recipe delete . +1020 ¦ . ╎add 2, 2 . +1021 ¦ . ╎4 . +1022 ¦ . ╎─────────────────────────────────────────────────. +1023 ¦ . ╎ . +1024 ] +1025 # hit 'page-down' again +1026 assume-console [ +1027 ¦ press page-down +1028 ] +1029 run [ +1030 ¦ event-loop screen, console, env, resources +1031 ] +1032 # no change +1033 screen-should-contain [ +1034 ¦ . run (F4) . +1035 ¦ . ╎─────────────────────────────────────────────────. +1036 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎1 edit copy to recipe delete . +1037 ¦ . ╎add 2, 2 . +1038 ¦ . ╎4 . +1039 ¦ . ╎─────────────────────────────────────────────────. +1040 ¦ . ╎ . +1041 ] +1042 # hit 'page-up' +1043 assume-console [ +1044 ¦ press page-up +1045 ] +1046 run [ +1047 ¦ event-loop screen, console, env, resources +1048 ] +1049 # back to displaying both sandboxes without editor +1050 screen-should-contain [ +1051 ¦ . run (F4) . +1052 ¦ . ╎─────────────────────────────────────────────────. +1053 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎0 edit copy to recipe delete . +1054 ¦ . ╎add 1, 1 . +1055 ¦ . ╎2 . +1056 ¦ . ╎─────────────────────────────────────────────────. +1057 ¦ . ╎1 edit copy to recipe delete . +1058 ¦ . ╎add 2, 2 . +1059 ¦ . ╎4 . +1060 ] +1061 # hit 'page-up' again +1062 assume-console [ +1063 ¦ press page-up +1064 ] +1065 run [ +1066 ¦ event-loop screen, console, env, resources +1067 ¦ cursor:char <- copy 9251/␣ +1068 ¦ print screen, cursor +1069 ] +1070 # back to displaying both sandboxes as well as editor +1071 screen-should-contain [ +1072 ¦ . run (F4) . +1073 ¦ . ╎␣ . +1074 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +1075 ¦ . ╎0 edit copy to recipe delete . +1076 ¦ . ╎add 1, 1 . +1077 ¦ . ╎2 . +1078 ¦ . ╎─────────────────────────────────────────────────. +1079 ¦ . ╎1 edit copy to recipe delete . +1080 ¦ . ╎add 2, 2 . +1081 ¦ . ╎4 . +1082 ] +1083 # hit 'page-up' again +1084 assume-console [ +1085 ¦ press page-up +1086 ] +1087 run [ +1088 ¦ event-loop screen, console, env, resources +1089 ¦ cursor:char <- copy 9251/␣ +1090 ¦ print screen, cursor +1091 ] +1092 # no change +1093 screen-should-contain [ +1094 ¦ . run (F4) . +1095 ¦ . ╎␣ . +1096 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +1097 ¦ . ╎0 edit copy to recipe delete . +1098 ¦ . ╎add 1, 1 . +1099 ¦ . ╎2 . +1100 ¦ . ╎─────────────────────────────────────────────────. +1101 ¦ . ╎1 edit copy to recipe delete . +1102 ¦ . ╎add 2, 2 . +1103 ¦ . ╎4 . +1104 ] +1105 ] +1106 +1107 scenario scrolling-manages-sandbox-index-correctly [ +1108 local-scope +1109 trace-until 100/app # trace too long +1110 assume-screen 100/width, 10/height +1111 # initialize environment +1112 assume-resources [ +1113 ] +1114 env:&:environment <- new-programming-environment resources, screen, [] +1115 render-all screen, env, render +1116 # create a sandbox +1117 assume-console [ +1118 ¦ press ctrl-n +1119 ¦ type [add 1, 1] +1120 ¦ press F4 +1121 ] +1122 event-loop screen, console, env, resources +1123 screen-should-contain [ +1124 ¦ . run (F4) . 1125 ¦ . ╎ . -1126 ] -1127 # hit 'page-down' and 'page-up' a couple of times. sandbox index should be stable -1128 assume-console [ -1129 ¦ press page-down -1130 ] -1131 run [ -1132 ¦ event-loop screen, console, env, resources -1133 ] -1134 # sandbox editor hidden; first sandbox displayed -1135 # cursor moves to first sandbox -1136 screen-should-contain [ -1137 ¦ . run (F4) . -1138 ¦ . ╎─────────────────────────────────────────────────. -1139 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎0 edit copy to recipe delete . -1140 ¦ . ╎add 1, 1 . -1141 ¦ . ╎2 . -1142 ¦ . ╎─────────────────────────────────────────────────. -1143 ¦ . ╎ . -1144 ] -1145 # hit 'page-up' again -1146 assume-console [ -1147 ¦ press page-up -1148 ] -1149 run [ -1150 ¦ event-loop screen, console, env, resources -1151 ] -1152 # back to displaying both sandboxes as well as editor -1153 screen-should-contain [ -1154 ¦ . run (F4) . -1155 ¦ . ╎ . -1156 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. -1157 ¦ . ╎0 edit copy to recipe delete . -1158 ¦ . ╎add 1, 1 . -1159 ¦ . ╎2 . -1160 ¦ . ╎─────────────────────────────────────────────────. +1126 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +1127 ¦ . ╎0 edit copy to recipe delete . +1128 ¦ . ╎add 1, 1 . +1129 ¦ . ╎2 . +1130 ¦ . ╎─────────────────────────────────────────────────. +1131 ¦ . ╎ . +1132 ] +1133 # hit 'page-down' and 'page-up' a couple of times. sandbox index should be stable +1134 assume-console [ +1135 ¦ press page-down +1136 ] +1137 run [ +1138 ¦ event-loop screen, console, env, resources +1139 ] +1140 # sandbox editor hidden; first sandbox displayed +1141 # cursor moves to first sandbox +1142 screen-should-contain [ +1143 ¦ . run (F4) . +1144 ¦ . ╎─────────────────────────────────────────────────. +1145 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎0 edit copy to recipe delete . +1146 ¦ . ╎add 1, 1 . +1147 ¦ . ╎2 . +1148 ¦ . ╎─────────────────────────────────────────────────. +1149 ¦ . ╎ . +1150 ] +1151 # hit 'page-up' again +1152 assume-console [ +1153 ¦ press page-up +1154 ] +1155 run [ +1156 ¦ event-loop screen, console, env, resources +1157 ] +1158 # back to displaying both sandboxes as well as editor +1159 screen-should-contain [ +1160 ¦ . run (F4) . 1161 ¦ . ╎ . -1162 ] -1163 # hit 'page-down' -1164 assume-console [ -1165 ¦ press page-down -1166 ] -1167 run [ -1168 ¦ event-loop screen, console, env, resources -1169 ] -1170 # sandbox editor hidden; first sandbox displayed -1171 # cursor moves to first sandbox -1172 screen-should-contain [ -1173 ¦ . run (F4) . -1174 ¦ . ╎─────────────────────────────────────────────────. -1175 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎0 edit copy to recipe delete . -1176 ¦ . ╎add 1, 1 . -1177 ¦ . ╎2 . -1178 ¦ . ╎─────────────────────────────────────────────────. -1179 ¦ . ╎ . -1180 ] -1181 ] +1162 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. +1163 ¦ . ╎0 edit copy to recipe delete . +1164 ¦ . ╎add 1, 1 . +1165 ¦ . ╎2 . +1166 ¦ . ╎─────────────────────────────────────────────────. +1167 ¦ . ╎ . +1168 ] +1169 # hit 'page-down' +1170 assume-console [ +1171 ¦ press page-down +1172 ] +1173 run [ +1174 ¦ event-loop screen, console, env, resources +1175 ] +1176 # sandbox editor hidden; first sandbox displayed +1177 # cursor moves to first sandbox +1178 screen-should-contain [ +1179 ¦ . run (F4) . +1180 ¦ . ╎─────────────────────────────────────────────────. +1181 ¦ .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎0 edit copy to recipe delete . +1182 ¦ . ╎add 1, 1 . +1183 ¦ . ╎2 . +1184 ¦ . ╎─────────────────────────────────────────────────. +1185 ¦ . ╎ . +1186 ] +1187 ] diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index 61a889c5..d6a56d6c 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -210,7 +210,7 @@ if ('onhashchange' in window) { 148 assert first-sandbox, [!!] 149 sandbox-left-margin:num <- get *first-sandbox, left:offset 150 sandbox-right-margin:num <- get *first-sandbox, right:offset -151 _, _, copy-button-left:num, copy-button-right:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin +151 _, _, copy-button-left:num, copy-button-right:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin 152 copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right 153 return-unless copy-button-vertical-area?, 0/false 154 # finally, is sandbox editor empty? @@ -430,7 +430,7 @@ if ('onhashchange' in window) { 368 assert first-sandbox, [!!] 369 sandbox-left-margin:num <- get *first-sandbox, left:offset 370 sandbox-right-margin:num <- get *first-sandbox, right:offset -371 _, _, _, _, recipe-button-left:num, recipe-button-right:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin +371 _, _, _, _, recipe-button-left:num, recipe-button-right:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin 372 result <- within-range? click-column, recipe-button-left, recipe-button-right 373 ] 374 diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 0a41fc07..1d2aa139 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -153,7 +153,7 @@ if ('onhashchange' in window) { 91 assert first-sandbox, [!!] 92 sandbox-left-margin:num <- get *first-sandbox, left:offset 93 sandbox-right-margin:num <- get *first-sandbox, right:offset - 94 _, _, _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + 94 _, _, _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin 95 result <- within-range? click-column, delete-button-left, sandbox-right-margin 96 ] 97 diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index bfa85e12..22b0f407 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -193,7 +193,7 @@ if ('onhashchange' in window) { 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 +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? diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index d147fa92..f75f45f7 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -156,16 +156,16 @@ if ('onhashchange' in window) { 93 ] 94 95 # include expected response when saving or restoring a sandbox - 96 before <end-save-sandbox> [ + 96 before <end-save-sandbox> [ 97 { - 98 ¦ expected-response:text <- get *curr, expected-response:offset + 98 ¦ expected-response:text <- get *sandbox, expected-response:offset 99 ¦ break-unless expected-response 100 ¦ filename <- append filename, [.out] 101 ¦ resources <- dump resources, filename, expected-response 102 } 103 ] 104 -105 before <end-restore-sandbox> [ +105 before <end-restore-sandbox> [ 106 { 107 ¦ filename <- append filename, [.out] 108 ¦ contents <- slurp resources, filename @@ -189,43 +189,43 @@ 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, sandbox-index:num <- find-click-in-sandbox-output env, click-row 130 ¦ break-unless sandbox -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 +131 ¦ # toggle its expected-response, and save session +132 ¦ sandbox <- toggle-expected-response sandbox +133 ¦ save-sandbox resources, sandbox, sandbox-index +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, sandbox-index:num [ +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 sandbox-index <- copy 0 +150 { +151 ¦ next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset +152 ¦ break-unless next-sandbox +153 ¦ next-start:num <- get *next-sandbox, starting-row-on-screen:offset +154 ¦ found?:bool <- lesser-than click-row, next-start +155 ¦ break-if found? +156 ¦ sandbox <- copy next-sandbox +157 ¦ sandbox-index <- add sandbox-index, 1 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 +162 return-unless response-starting-row, 0/no-click-in-sandbox-output, 0/sandbox-index 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 +164 return-unless click-in-response?, 0/no-click-in-sandbox-output, 0/sandbox-index +165 return sandbox, sandbox-index 166 ] 167 168 def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ @@ -246,7 +246,7 @@ if ('onhashchange' in window) { 183 ] 184 185 # when rendering a sandbox, color it in red/green if expected response exists -186 after <render-sandbox-response> [ +186 after <render-sandbox-response> [ 187 { 188 ¦ break-unless sandbox-response 189 ¦ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row @@ -255,17 +255,17 @@ if ('onhashchange' in window) { 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 +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 +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> [ +205 before <end-render-sandbox-reset-hidden> [ 206 *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 207 ] diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 8578fa11..6a0b6435 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -304,13 +304,13 @@ if ('onhashchange' in window) { 241 ] 242 243 # when rendering a sandbox, dump its trace before response/warning if display-trace? property is set -244 after <render-sandbox-results> [ +244 after <render-sandbox-results> [ 245 { 246 ¦ display-trace?:bool <- get *sandbox, display-trace?:offset 247 ¦ break-unless display-trace? 248 ¦ sandbox-trace:text <- get *sandbox, trace:offset 249 ¦ break-unless sandbox-trace # nothing to print; move on -250 ¦ row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row +250 ¦ row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row 251 } 252 <render-sandbox-trace-done> 253 ] diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index b01219ba..0f726e99 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -72,7 +72,7 @@ if ('onhashchange' in window) { 9 local-scope 10 load-ingredients 11 recipes:&:editor <- get *env, recipes:offset - 12 in:text <- editor-contents recipes + 12 in:text <- editor-contents recipes 13 resources <- dump resources, [lesson/recipes.mu], in 14 recipe-errors:text <- reload in 15 *env <- put *env, recipe-errors:offset, recipe-errors @@ -94,7 +94,7 @@ if ('onhashchange' in window) { 31 ¦ left:num <- get *recipes, left:offset 32 ¦ right:num <- get *recipes, right:offset 33 ¦ row:num <- get *recipes, bottom:offset - 34 ¦ row, screen <- render-text screen, recipe-errors, left, right, 1/red, row + 34 ¦ row, screen <- render-text screen, recipe-errors, left, right, 1/red, row 35 ¦ # draw dotted line after recipes 36 ¦ draw-horizontal screen, row, left, right, 9480/horizontal-dotted 37 ¦ row <- add row, 1 @@ -170,7 +170,7 @@ if ('onhashchange' in window) { 107 ¦ sandbox-errors:text <- get *sandbox, errors:offset 108 ¦ break-unless sandbox-errors 109 ¦ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 # no response -110 ¦ row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row +110 ¦ row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row 111 ¦ # don't try to print anything more for this sandbox 112 ¦ jump +render-sandbox-end 113 } -- cgit 1.4.1-2-gfad0