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