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