From b301e0c0e6b54dceecbe4ee1ef8f610411015c30 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 27 Jan 2018 00:28:51 -0800 Subject: 4200 Forgot to set up exuberant_ctags_rc as .ctags on new laptop. --- html/edit/003-shortcuts.mu.html | 1138 +++++++++++++++++++-------------------- 1 file changed, 569 insertions(+), 569 deletions(-) (limited to 'html/edit/003-shortcuts.mu.html') diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 4e2c3c8c..4b335115 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -70,14 +70,14 @@ if ('onhashchange' in window) { 9 assume-screen 10/width, 5/height 10 s:text <- new [ab 11 cd] - 12 e:&:editor <- new-editor s, 0/left, 5/right - 13 editor-render screen, e + 12 e:&:editor <- new-editor s, 0/left, 5/right + 13 editor-render screen, e 14 $clear-trace 15 assume-console [ 16 press tab 17 ] 18 run [ - 19 editor-event-loop screen, console, e + 19 editor-event-loop screen, console, e 20 ] 21 screen-should-contain [ 22 . . @@ -91,14 +91,14 @@ if ('onhashchange' in window) { 30 scenario editor-inserts-two-spaces-and-wraps-line-on-tab [ 31 local-scope 32 assume-screen 10/width, 5/height - 33 e:&:editor <- new-editor [abcd], 0/left, 5/right - 34 editor-render screen, e + 33 e:&:editor <- new-editor [abcd], 0/left, 5/right + 34 editor-render screen, e 35 $clear-trace 36 assume-console [ 37 press tab 38 ] 39 run [ - 40 editor-event-loop screen, console, e + 40 editor-event-loop screen, console, e 41 ] 42 screen-should-contain [ 43 . . @@ -109,15 +109,15 @@ if ('onhashchange' in window) { 48 check-trace-count-for-label-greater-than 10, [print-character] 49 ] 50 - 51 after <handle-special-character> [ + 51 after <handle-special-character> [ 52 { 53 tab?:bool <- equal c, 9/tab 54 break-unless tab? 55 <begin-insert-character> 56 # todo: decompose insert-at-cursor into editor update and screen update, 57 # so that 'tab' doesn't render the current line multiple times - 58 insert-at-cursor editor, 32/space, screen - 59 go-render? <- insert-at-cursor editor, 32/space, screen + 58 insert-at-cursor editor, 32/space, screen + 59 go-render? <- insert-at-cursor editor, 32/space, screen 60 <end-insert-character> 61 return 62 } @@ -128,15 +128,15 @@ if ('onhashchange' in window) { 67 scenario editor-handles-backspace-key [ 68 local-scope 69 assume-screen 10/width, 5/height - 70 e:&:editor <- new-editor [abc], 0/left, 10/right - 71 editor-render screen, e + 70 e:&:editor <- new-editor [abc], 0/left, 10/right + 71 editor-render screen, e 72 $clear-trace 73 assume-console [ 74 left-click 1, 1 75 press backspace 76 ] 77 run [ - 78 editor-event-loop screen, console, e + 78 editor-event-loop screen, console, e 79 4:num/raw <- get *e, cursor-row:offset 80 5:num/raw <- get *e, cursor-column:offset 81 ] @@ -153,13 +153,13 @@ if ('onhashchange' in window) { 92 check-trace-count-for-label 3, [print-character] # length of original line to overwrite 93 ] 94 - 95 after <handle-special-character> [ + 95 after <handle-special-character> [ 96 { 97 delete-previous-character?:bool <- equal c, 8/backspace 98 break-unless delete-previous-character? - 99 <begin-backspace-character> - 100 go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen - 101 <end-backspace-character> + 99 <begin-backspace-character> + 100 go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen + 101 <end-backspace-character> 102 return 103 } 104 ] @@ -167,23 +167,23 @@ if ('onhashchange' in window) { 106 # return values: 107 # go-render? - whether caller needs to update the screen 108 # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. - 109 def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ + 109 def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ 110 local-scope 111 load-inputs - 112 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 113 data:&:duplex-list:char <- get *editor, data:offset + 112 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 113 data:&:duplex-list:char <- get *editor, data:offset 114 # if at start of text (before-cursor at § sentinel), return - 115 prev:&:duplex-list:char <- prev before-cursor - 116 return-unless prev, 0/no-more-render, 0/nothing-deleted + 115 prev:&:duplex-list:char <- prev before-cursor + 116 return-unless prev, 0/no-more-render, 0/nothing-deleted 117 trace 10, [app], [delete-before-cursor] 118 original-row:num <- get *editor, cursor-row:offset - 119 scroll?:bool <- move-cursor-coordinates-left editor - 120 backspaced-cell:&:duplex-list:char <- copy before-cursor + 119 scroll?:bool <- move-cursor-coordinates-left editor + 120 backspaced-cell:&:duplex-list:char <- copy before-cursor 121 data <- remove before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/before-cursor - 122 before-cursor <- copy prev + 122 before-cursor <- copy prev 123 *editor <- put *editor, before-cursor:offset, before-cursor 124 return-if scroll?, 1/go-render - 125 screen-width:num <- screen-width screen + 125 screen-width:num <- screen-width screen 126 cursor-row:num <- get *editor, cursor-row:offset 127 cursor-column:num <- get *editor, cursor-column:offset 128 # did we just backspace over a newline? @@ -191,8 +191,8 @@ if ('onhashchange' in window) { 130 return-unless same-row?, 1/go-render 131 left:num <- get *editor, left:offset 132 right:num <- get *editor, right:offset - 133 curr:&:duplex-list:char <- next before-cursor - 134 screen <- move-cursor screen, cursor-row, cursor-column + 133 curr:&:duplex-list:char <- next before-cursor + 134 screen <- move-cursor screen, cursor-row, cursor-column 135 curr-column:num <- copy cursor-column 136 { 137 # hit right margin? give up and let caller render @@ -203,22 +203,22 @@ if ('onhashchange' in window) { 142 currc:char <- get *curr, value:offset 143 at-newline?:bool <- equal currc, 10/newline 144 break-if at-newline? - 145 screen <- print screen, currc + 145 screen <- print screen, currc 146 curr-column <- add curr-column, 1 - 147 curr <- next curr + 147 curr <- next curr 148 loop 149 } 150 # we're guaranteed not to be at the right margin 151 space:char <- copy 32/space - 152 screen <- print screen, space + 152 screen <- print screen, space 153 go-render? <- copy 0/false 154 ] 155 - 156 def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:editor [ + 156 def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:editor [ 157 local-scope 158 load-inputs 159 go-render?:bool <- copy 0/false - 160 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 160 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 161 cursor-row:num <- get *editor, cursor-row:offset 162 cursor-column:num <- get *editor, cursor-column:offset 163 left:num <- get *editor, left:offset @@ -250,8 +250,8 @@ if ('onhashchange' in window) { 189 break-unless previous-character-is-newline? 190 # compute length of previous line 191 trace 10, [app], [switching to previous line] - 192 d:&:duplex-list:char <- get *editor, data:offset - 193 end-of-line:num <- previous-line-length before-cursor, d + 192 d:&:duplex-list:char <- get *editor, data:offset + 193 end-of-line:num <- previous-line-length before-cursor, d 194 right:num <- get *editor, right:offset 195 width:num <- subtract right, left 196 wrap?:bool <- greater-than end-of-line, width @@ -277,7 +277,7 @@ if ('onhashchange' in window) { 216 217 # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts 218 # the length of the previous line before the 'curr' pointer. - 219 def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ + 219 def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ 220 local-scope 221 load-inputs 222 result:num <- copy 0 @@ -285,7 +285,7 @@ if ('onhashchange' in window) { 224 at-start?:bool <- equal curr, start 225 return-if at-start? 226 { - 227 curr <- prev curr + 227 curr <- prev curr 228 break-unless curr 229 at-start?:bool <- equal curr, start 230 break-if at-start? @@ -302,13 +302,13 @@ if ('onhashchange' in window) { 241 assume-screen 10/width, 5/height 242 s:text <- new [ab 243 cd] - 244 e:&:editor <- new-editor s, 0/left, 10/right + 244 e:&:editor <- new-editor s, 0/left, 10/right 245 assume-console [ 246 left-click 2, 0 247 press backspace 248 ] 249 run [ - 250 editor-event-loop screen, console, e + 250 editor-event-loop screen, console, e 251 4:num/raw <- get *e, cursor-row:offset 252 5:num/raw <- get *e, cursor-column:offset 253 ] @@ -330,8 +330,8 @@ if ('onhashchange' in window) { 269 # initialize editor with two long-ish but non-wrapping lines 270 s:text <- new [abc def 271 ghi jkl] - 272 e:&:editor <- new-editor s, 0/left, 10/right - 273 editor-render screen, e + 272 e:&:editor <- new-editor s, 0/left, 10/right + 273 editor-render screen, e 274 $clear-trace 275 # position the cursor at the start of the second and hit backspace 276 assume-console [ @@ -339,7 +339,7 @@ if ('onhashchange' in window) { 278 press backspace 279 ] 280 run [ - 281 editor-event-loop screen, console, e + 281 editor-event-loop screen, console, e 282 ] 283 # resulting single line should wrap correctly 284 screen-should-contain [ @@ -355,8 +355,8 @@ if ('onhashchange' in window) { 294 local-scope 295 assume-screen 10/width, 5/height 296 # initialize editor in part of the screen with a long line - 297 e:&:editor <- new-editor [abc def ghij], 0/left, 8/right - 298 editor-render screen, e + 297 e:&:editor <- new-editor [abc def ghij], 0/left, 8/right + 298 editor-render screen, e 299 # confirm that it wraps 300 screen-should-contain [ 301 . . @@ -371,7 +371,7 @@ if ('onhashchange' in window) { 310 press backspace 311 ] 312 run [ - 313 editor-event-loop screen, console, e + 313 editor-event-loop screen, console, e 314 ] 315 # resulting single line should wrap correctly and not overflow its bounds 316 screen-should-contain [ @@ -388,14 +388,14 @@ if ('onhashchange' in window) { 327 scenario editor-handles-delete-key [ 328 local-scope 329 assume-screen 10/width, 5/height - 330 e:&:editor <- new-editor [abc], 0/left, 10/right - 331 editor-render screen, e + 330 e:&:editor <- new-editor [abc], 0/left, 10/right + 331 editor-render screen, e 332 $clear-trace 333 assume-console [ 334 press delete 335 ] 336 run [ - 337 editor-event-loop screen, console, e + 337 editor-event-loop screen, console, e 338 ] 339 screen-should-contain [ 340 . . @@ -409,7 +409,7 @@ if ('onhashchange' in window) { 348 press delete 349 ] 350 run [ - 351 editor-event-loop screen, console, e + 351 editor-event-loop screen, console, e 352 ] 353 screen-should-contain [ 354 . . @@ -420,51 +420,51 @@ if ('onhashchange' in window) { 359 check-trace-count-for-label 2, [print-character] # new length to overwrite 360 ] 361 - 362 after <handle-special-key> [ + 362 after <handle-special-key> [ 363 { 364 delete-next-character?:bool <- equal k, 65522/delete 365 break-unless delete-next-character? - 366 <begin-delete-character> - 367 go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen - 368 <end-delete-character> + 366 <begin-delete-character> + 367 go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen + 368 <end-delete-character> 369 return 370 } 371 ] 372 - 373 def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ + 373 def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ 374 local-scope 375 load-inputs - 376 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 377 data:&:duplex-list:char <- get *editor, data:offset - 378 deleted-cell:&:duplex-list:char <- next before-cursor + 376 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 377 data:&:duplex-list:char <- get *editor, data:offset + 378 deleted-cell:&:duplex-list:char <- next before-cursor 379 return-unless deleted-cell, 0/don't-render 380 currc:char <- get *deleted-cell, value:offset 381 data <- remove deleted-cell, data 382 deleted-newline?:bool <- equal currc, 10/newline 383 return-if deleted-newline?, 1/go-render 384 # wasn't a newline? render rest of line - 385 curr:&:duplex-list:char <- next before-cursor # refresh after remove above + 385 curr:&:duplex-list:char <- next before-cursor # refresh after remove above 386 cursor-row:num <- get *editor, cursor-row:offset 387 cursor-column:num <- get *editor, cursor-column:offset - 388 screen <- move-cursor screen, cursor-row, cursor-column + 388 screen <- move-cursor screen, cursor-row, cursor-column 389 curr-column:num <- copy cursor-column - 390 screen-width:num <- screen-width screen + 390 screen-width:num <- screen-width screen 391 { 392 # hit right margin? give up and let caller render - 393 at-right?:bool <- greater-or-equal curr-column, screen-width + 393 at-right?:bool <- greater-or-equal curr-column, screen-width 394 return-if at-right?, 1/go-render 395 break-unless curr 396 currc:char <- get *curr, value:offset 397 at-newline?:bool <- equal currc, 10/newline 398 break-if at-newline? - 399 screen <- print screen, currc + 399 screen <- print screen, currc 400 curr-column <- add curr-column, 1 - 401 curr <- next curr + 401 curr <- next curr 402 loop 403 } 404 # we're guaranteed not to be at the right margin 405 space:char <- copy 32/space - 406 screen <- print screen, space + 406 screen <- print screen, space 407 go-render? <- copy 0/false 408 ] 409 @@ -473,15 +473,15 @@ if ('onhashchange' in window) { 412 scenario editor-moves-cursor-right-with-key [ 413 local-scope 414 assume-screen 10/width, 5/height - 415 e:&:editor <- new-editor [abc], 0/left, 10/right - 416 editor-render screen, e + 415 e:&:editor <- new-editor [abc], 0/left, 10/right + 416 editor-render screen, e 417 $clear-trace 418 assume-console [ 419 press right-arrow 420 type [0] 421 ] 422 run [ - 423 editor-event-loop screen, console, e + 423 editor-event-loop screen, console, e 424 ] 425 screen-should-contain [ 426 . . @@ -492,29 +492,29 @@ if ('onhashchange' in window) { 431 check-trace-count-for-label 3, [print-character] # 0 and following characters 432 ] 433 - 434 after <handle-special-key> [ + 434 after <handle-special-key> [ 435 { 436 move-to-next-character?:bool <- equal k, 65514/right-arrow 437 break-unless move-to-next-character? 438 # if not at end of text - 439 next-cursor:&:duplex-list:char <- next before-cursor + 439 next-cursor:&:duplex-list:char <- next before-cursor 440 break-unless next-cursor 441 # scan to next character 442 <begin-move-cursor> 443 before-cursor <- copy next-cursor 444 *editor <- put *editor, before-cursor:offset, before-cursor - 445 go-render?:bool <- move-cursor-coordinates-right editor, screen-height - 446 screen <- move-cursor screen, cursor-row, cursor-column + 445 go-render?:bool <- move-cursor-coordinates-right editor, screen-height + 446 screen <- move-cursor screen, cursor-row, cursor-column 447 undo-coalesce-tag:num <- copy 2/right-arrow 448 <end-move-cursor> 449 return 450 } 451 ] 452 - 453 def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ + 453 def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 454 local-scope 455 load-inputs - 456 before-cursor:&:duplex-list:char <- get *editor before-cursor:offset + 456 before-cursor:&:duplex-list:char <- get *editor before-cursor:offset 457 cursor-row:num <- get *editor, cursor-row:offset 458 cursor-column:num <- get *editor, cursor-column:offset 459 left:num <- get *editor, left:offset @@ -528,7 +528,7 @@ if ('onhashchange' in window) { 467 *editor <- put *editor, cursor-row:offset, cursor-row 468 cursor-column <- copy left 469 *editor <- put *editor, cursor-column:offset, cursor-column - 470 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal + 470 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal 471 return-unless below-screen?, 0/don't-render 472 <scroll-down> 473 cursor-row <- subtract cursor-row, 1 # bring back into screen range @@ -542,8 +542,8 @@ if ('onhashchange' in window) { 481 at-wrap?:bool <- equal cursor-column, wrap-column 482 break-unless at-wrap? 483 # and if next character isn't newline - 484 next:&:duplex-list:char <- next before-cursor - 485 break-unless next + 484 next:&:duplex-list:char <- next before-cursor + 485 break-unless next 486 next-character:char <- get *next, value:offset 487 newline?:bool <- equal next-character, 10/newline 488 break-if newline? @@ -551,7 +551,7 @@ if ('onhashchange' in window) { 490 *editor <- put *editor, cursor-row:offset, cursor-row 491 cursor-column <- copy left 492 *editor <- put *editor, cursor-column:offset, cursor-column - 493 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal + 493 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal 494 return-unless below-screen?, 0/no-more-render 495 <scroll-down> 496 cursor-row <- subtract cursor-row, 1 # bring back into screen range @@ -569,8 +569,8 @@ if ('onhashchange' in window) { 508 assume-screen 10/width, 5/height 509 s:text <- new [abc 510 d] - 511 e:&:editor <- new-editor s, 0/left, 10/right - 512 editor-render screen, e + 511 e:&:editor <- new-editor s, 0/left, 10/right + 512 editor-render screen, e 513 $clear-trace 514 # type right-arrow a few times to get to start of second line 515 assume-console [ @@ -580,7 +580,7 @@ if ('onhashchange' in window) { 519 press right-arrow # next line 520 ] 521 run [ - 522 editor-event-loop screen, console, e + 522 editor-event-loop screen, console, e 523 ] 524 check-trace-count-for-label 0, [print-character] 525 # type something and ensure it goes where it should @@ -588,7 +588,7 @@ if ('onhashchange' in window) { 527 type [0] 528 ] 529 run [ - 530 editor-event-loop screen, console, e + 530 editor-event-loop screen, console, e 531 ] 532 screen-should-contain [ 533 . . @@ -605,8 +605,8 @@ if ('onhashchange' in window) { 544 assume-screen 10/width, 5/height 545 s:text <- new [abc 546 d] - 547 e:&:editor <- new-editor s, 1/left, 10/right - 548 editor-render screen, e + 547 e:&:editor <- new-editor s, 1/left, 10/right + 548 editor-render screen, e 549 assume-console [ 550 press right-arrow 551 press right-arrow @@ -615,7 +615,7 @@ if ('onhashchange' in window) { 554 type [0] 555 ] 556 run [ - 557 editor-event-loop screen, console, e + 557 editor-event-loop screen, console, e 558 ] 559 screen-should-contain [ 560 . . @@ -629,15 +629,15 @@ if ('onhashchange' in window) { 568 scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ 569 local-scope 570 assume-screen 10/width, 5/height - 571 e:&:editor <- new-editor [abcdef], 0/left, 5/right - 572 editor-render screen, e + 571 e:&:editor <- new-editor [abcdef], 0/left, 5/right + 572 editor-render screen, e 573 $clear-trace 574 assume-console [ 575 left-click 1, 3 576 press right-arrow 577 ] 578 run [ - 579 editor-event-loop screen, console, e + 579 editor-event-loop screen, console, e 580 3:num/raw <- get *e, cursor-row:offset 581 4:num/raw <- get *e, cursor-column:offset 582 ] @@ -659,8 +659,8 @@ if ('onhashchange' in window) { 598 local-scope 599 assume-screen 10/width, 5/height 600 # line just barely wrapping - 601 e:&:editor <- new-editor [abcde], 0/left, 5/right - 602 editor-render screen, e + 601 e:&:editor <- new-editor [abcde], 0/left, 5/right + 602 editor-render screen, e 603 $clear-trace 604 # position cursor at last character before wrap and hit right-arrow 605 assume-console [ @@ -668,7 +668,7 @@ if ('onhashchange' in window) { 607 press right-arrow 608 ] 609 run [ - 610 editor-event-loop screen, console, e + 610 editor-event-loop screen, console, e 611 3:num/raw <- get *e, cursor-row:offset 612 4:num/raw <- get *e, cursor-column:offset 613 ] @@ -681,7 +681,7 @@ if ('onhashchange' in window) { 620 press right-arrow 621 ] 622 run [ - 623 editor-event-loop screen, console, e + 623 editor-event-loop screen, console, e 624 3:num/raw <- get *e, cursor-row:offset 625 4:num/raw <- get *e, cursor-column:offset 626 ] @@ -695,15 +695,15 @@ if ('onhashchange' in window) { 634 scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ 635 local-scope 636 assume-screen 10/width, 5/height - 637 e:&:editor <- new-editor [abcdef], 1/left, 6/right - 638 editor-render screen, e + 637 e:&:editor <- new-editor [abcdef], 1/left, 6/right + 638 editor-render screen, e 639 $clear-trace 640 assume-console [ 641 left-click 1, 4 642 press right-arrow 643 ] 644 run [ - 645 editor-event-loop screen, console, e + 645 editor-event-loop screen, console, e 646 3:num/raw <- get *e, cursor-row:offset 647 4:num/raw <- get *e, cursor-column:offset 648 ] @@ -726,8 +726,8 @@ if ('onhashchange' in window) { 665 assume-screen 10/width, 5/height 666 s:text <- new [abc 667 d] - 668 e:&:editor <- new-editor s, 0/left, 10/right - 669 editor-render screen, e + 668 e:&:editor <- new-editor s, 0/left, 10/right + 669 editor-render screen, e 670 $clear-trace 671 # move to end of line, press right-arrow, type a character 672 assume-console [ @@ -736,7 +736,7 @@ if ('onhashchange' in window) { 675 type [0] 676 ] 677 run [ - 678 editor-event-loop screen, console, e + 678 editor-event-loop screen, console, e 679 ] 680 # new character should be in next line 681 screen-should-contain [ @@ -756,8 +756,8 @@ if ('onhashchange' in window) { 695 scenario editor-moves-cursor-left-with-key [ 696 local-scope 697 assume-screen 10/width, 5/height - 698 e:&:editor <- new-editor [abc], 0/left, 10/right - 699 editor-render screen, e + 698 e:&:editor <- new-editor [abc], 0/left, 10/right + 699 editor-render screen, e 700 $clear-trace 701 assume-console [ 702 left-click 1, 2 @@ -765,7 +765,7 @@ if ('onhashchange' in window) { 704 type [0] 705 ] 706 run [ - 707 editor-event-loop screen, console, e + 707 editor-event-loop screen, console, e 708 ] 709 screen-should-contain [ 710 . . @@ -776,17 +776,17 @@ if ('onhashchange' in window) { 715 check-trace-count-for-label 3, [print-character] 716 ] 717 - 718 after <handle-special-key> [ + 718 after <handle-special-key> [ 719 { 720 move-to-previous-character?:bool <- equal k, 65515/left-arrow 721 break-unless move-to-previous-character? 722 trace 10, [app], [left arrow] 723 # if not at start of text (before-cursor at § sentinel) - 724 prev:&:duplex-list:char <- prev before-cursor - 725 return-unless prev, 0/don't-render + 724 prev:&:duplex-list:char <- prev before-cursor + 725 return-unless prev, 0/don't-render 726 <begin-move-cursor> - 727 go-render? <- move-cursor-coordinates-left editor - 728 before-cursor <- copy prev + 727 go-render? <- move-cursor-coordinates-left editor + 728 before-cursor <- copy prev 729 *editor <- put *editor, before-cursor:offset, before-cursor 730 undo-coalesce-tag:num <- copy 1/left-arrow 731 <end-move-cursor> @@ -800,8 +800,8 @@ if ('onhashchange' in window) { 739 # initialize editor with two lines 740 s:text <- new [abc 741 d] - 742 e:&:editor <- new-editor s, 0/left, 10/right - 743 editor-render screen, e + 742 e:&:editor <- new-editor s, 0/left, 10/right + 743 editor-render screen, e 744 $clear-trace 745 # position cursor at start of second line (so there's no previous newline) 746 assume-console [ @@ -809,7 +809,7 @@ if ('onhashchange' in window) { 748 press left-arrow 749 ] 750 run [ - 751 editor-event-loop screen, console, e + 751 editor-event-loop screen, console, e 752 3:num/raw <- get *e, cursor-row:offset 753 4:num/raw <- get *e, cursor-column:offset 754 ] @@ -827,8 +827,8 @@ if ('onhashchange' in window) { 766 s:text <- new [abc 767 def 768 g] - 769 e:&:editor <- new-editor s:text, 0/left, 10/right - 770 editor-render screen, e + 769 e:&:editor <- new-editor s:text, 0/left, 10/right + 770 editor-render screen, e 771 $clear-trace 772 # position cursor further down (so there's a newline before the character at 773 # the cursor) @@ -838,7 +838,7 @@ if ('onhashchange' in window) { 777 type [0] 778 ] 779 run [ - 780 editor-event-loop screen, console, e + 780 editor-event-loop screen, console, e 781 ] 782 screen-should-contain [ 783 . . @@ -856,8 +856,8 @@ if ('onhashchange' in window) { 795 s:text <- new [abc 796 def 797 g] - 798 e:&:editor <- new-editor s, 0/left, 10/right - 799 editor-render screen, e + 798 e:&:editor <- new-editor s, 0/left, 10/right + 799 editor-render screen, e 800 $clear-trace 801 # position cursor at start of text, press left-arrow, then type a character 802 assume-console [ @@ -866,7 +866,7 @@ if ('onhashchange' in window) { 805 type [0] 806 ] 807 run [ - 808 editor-event-loop screen, console, e + 808 editor-event-loop screen, console, e 809 ] 810 # left-arrow should have had no effect 811 screen-should-contain [ @@ -886,8 +886,8 @@ if ('onhashchange' in window) { 825 s:text <- new [abc 826 827 d] - 828 e:&:editor <- new-editor s, 0/left, 10/right - 829 editor-render screen, e:&:editor + 828 e:&:editor <- new-editor s, 0/left, 10/right + 829 editor-render screen, e:&:editor 830 $clear-trace 831 # position cursor right after empty line 832 assume-console [ @@ -896,7 +896,7 @@ if ('onhashchange' in window) { 835 type [0] 836 ] 837 run [ - 838 editor-event-loop screen, console, e + 838 editor-event-loop screen, console, e 839 ] 840 screen-should-contain [ 841 . . @@ -912,8 +912,8 @@ if ('onhashchange' in window) { 851 local-scope 852 assume-screen 10/width, 5/height 853 # initialize editor with a wrapping line - 854 e:&:editor <- new-editor [abcdef], 0/left, 5/right - 855 editor-render screen, e + 854 e:&:editor <- new-editor [abcdef], 0/left, 5/right + 855 editor-render screen, e 856 $clear-trace 857 screen-should-contain [ 858 . . @@ -928,7 +928,7 @@ if ('onhashchange' in window) { 867 press left-arrow 868 ] 869 run [ - 870 editor-event-loop screen, console, e + 870 editor-event-loop screen, console, e 871 3:num/raw <- get *e, cursor-row:offset 872 4:num/raw <- get *e, cursor-column:offset 873 ] @@ -945,8 +945,8 @@ if ('onhashchange' in window) { 884 # initialize editor with a wrapping line followed by a second line 885 s:text <- new [abcdef 886 g] - 887 e:&:editor <- new-editor s, 0/left, 5/right - 888 editor-render screen, e + 887 e:&:editor <- new-editor s, 0/left, 5/right + 888 editor-render screen, e 889 $clear-trace 890 screen-should-contain [ 891 . . @@ -961,7 +961,7 @@ if ('onhashchange' in window) { 900 press left-arrow 901 ] 902 run [ - 903 editor-event-loop screen, console, e + 903 editor-event-loop screen, console, e 904 3:num/raw <- get *e, cursor-row:offset 905 4:num/raw <- get *e, cursor-column:offset 906 ] @@ -978,8 +978,8 @@ if ('onhashchange' in window) { 917 # initialize editor with a line on the verge of wrapping, followed by a second line 918 s:text <- new [abcd 919 e] - 920 e:&:editor <- new-editor s, 0/left, 5/right - 921 editor-render screen, e + 920 e:&:editor <- new-editor s, 0/left, 5/right + 921 editor-render screen, e 922 $clear-trace 923 screen-should-contain [ 924 . . @@ -994,7 +994,7 @@ if ('onhashchange' in window) { 933 press left-arrow 934 ] 935 run [ - 936 editor-event-loop screen, console, e + 936 editor-event-loop screen, console, e 937 3:num/raw <- get *e, cursor-row:offset 938 4:num/raw <- get *e, cursor-column:offset 939 ] @@ -1014,15 +1014,15 @@ if ('onhashchange' in window) { 953 assume-screen 10/width, 5/height 954 s:text <- new [abc 955 def] - 956 e:&:editor <- new-editor s, 0/left, 10/right - 957 editor-render screen, e + 956 e:&:editor <- new-editor s, 0/left, 10/right + 957 editor-render screen, e 958 $clear-trace 959 assume-console [ 960 left-click 2, 1 961 press up-arrow 962 ] 963 run [ - 964 editor-event-loop screen, console, e + 964 editor-event-loop screen, console, e 965 3:num/raw <- get *e, cursor-row:offset 966 4:num/raw <- get *e, cursor-column:offset 967 ] @@ -1035,7 +1035,7 @@ if ('onhashchange' in window) { 974 type [0] 975 ] 976 run [ - 977 editor-event-loop screen, console, e + 977 editor-event-loop screen, console, e 978 ] 979 screen-should-contain [ 980 . . @@ -1046,25 +1046,25 @@ if ('onhashchange' in window) { 985 ] 986 ] 987 - 988 after <handle-special-key> [ + 988 after <handle-special-key> [ 989 { 990 move-to-previous-line?:bool <- equal k, 65517/up-arrow 991 break-unless move-to-previous-line? 992 <begin-move-cursor> - 993 go-render? <- move-to-previous-line editor + 993 go-render? <- move-to-previous-line editor 994 undo-coalesce-tag:num <- copy 3/up-arrow 995 <end-move-cursor> 996 return 997 } 998 ] 999 -1000 def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [ +1000 def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [ 1001 local-scope 1002 load-inputs 1003 go-render?:bool <- copy 0/false 1004 cursor-row:num <- get *editor, cursor-row:offset 1005 cursor-column:num <- get *editor, cursor-column:offset -1006 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1006 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1007 left:num <- get *editor, left:offset 1008 right:num <- get *editor, right:offset 1009 already-at-top?:bool <- lesser-or-equal cursor-row, 1/top @@ -1074,17 +1074,17 @@ if ('onhashchange' in window) { 1013 # if not at start of screen line, move to start of screen line (previous newline) 1014 # then scan back another line 1015 # if either step fails, give up without modifying cursor or coordinates -1016 curr:&:duplex-list:char <- copy before-cursor -1017 old:&:duplex-list:char <- copy curr +1016 curr:&:duplex-list:char <- copy before-cursor +1017 old:&:duplex-list:char <- copy curr 1018 { 1019 at-left?:bool <- equal cursor-column, left 1020 break-if at-left? -1021 curr <- before-previous-screen-line curr, editor +1021 curr <- before-previous-screen-line curr, editor 1022 no-motion?:bool <- equal curr, old 1023 return-if no-motion? 1024 } 1025 { -1026 curr <- before-previous-screen-line curr, editor +1026 curr <- before-previous-screen-line curr, editor 1027 no-motion?:bool <- equal curr, old 1028 return-if no-motion? 1029 } @@ -1099,7 +1099,7 @@ if ('onhashchange' in window) { 1038 { 1039 done?:bool <- greater-or-equal cursor-column, target-column 1040 break-if done? -1041 curr:&:duplex-list:char <- next before-cursor +1041 curr:&:duplex-list:char <- next before-cursor 1042 break-unless curr 1043 currc:char <- get *curr, value:offset 1044 at-newline?:bool <- equal currc, 10/newline @@ -1126,15 +1126,15 @@ if ('onhashchange' in window) { 1065 assume-screen 10/width, 5/height 1066 s:text <- new [ab 1067 def] -1068 e:&:editor <- new-editor s, 0/left, 10/right -1069 editor-render screen, e +1068 e:&:editor <- new-editor s, 0/left, 10/right +1069 editor-render screen, e 1070 $clear-trace 1071 assume-console [ 1072 left-click 2, 3 1073 press up-arrow 1074 ] 1075 run [ -1076 editor-event-loop screen, console, e +1076 editor-event-loop screen, console, e 1077 3:num/raw <- get *e, cursor-row:offset 1078 4:num/raw <- get *e, cursor-column:offset 1079 ] @@ -1147,7 +1147,7 @@ if ('onhashchange' in window) { 1086 type [0] 1087 ] 1088 run [ -1089 editor-event-loop screen, console, e +1089 editor-event-loop screen, console, e 1090 ] 1091 screen-should-contain [ 1092 . . @@ -1163,15 +1163,15 @@ if ('onhashchange' in window) { 1102 assume-screen 10/width, 5/height 1103 s:text <- new [ 1104 def] -1105 e:&:editor <- new-editor s, 0/left, 10/right -1106 editor-render screen, e +1105 e:&:editor <- new-editor s, 0/left, 10/right +1106 editor-render screen, e 1107 $clear-trace 1108 assume-console [ 1109 left-click 2, 3 1110 press up-arrow 1111 ] 1112 run [ -1113 editor-event-loop screen, console, e +1113 editor-event-loop screen, console, e 1114 3:num/raw <- get *e, cursor-row:offset 1115 4:num/raw <- get *e, cursor-column:offset 1116 ] @@ -1184,7 +1184,7 @@ if ('onhashchange' in window) { 1123 type [0] 1124 ] 1125 run [ -1126 editor-event-loop screen, console, e +1126 editor-event-loop screen, console, e 1127 ] 1128 screen-should-contain [ 1129 . . @@ -1202,8 +1202,8 @@ if ('onhashchange' in window) { 1141 s:text <- new [abc 1142 def 1143 ghi] -1144 e:&:editor <- new-editor s, 0/left, 10/right -1145 editor-render screen, e +1144 e:&:editor <- new-editor s, 0/left, 10/right +1145 editor-render screen, e 1146 $clear-trace 1147 # click on the third line and hit up-arrow, so you end up just after a newline 1148 assume-console [ @@ -1211,7 +1211,7 @@ if ('onhashchange' in window) { 1150 press up-arrow 1151 ] 1152 run [ -1153 editor-event-loop screen, console, e +1153 editor-event-loop screen, console, e 1154 3:num/raw <- get *e, cursor-row:offset 1155 4:num/raw <- get *e, cursor-column:offset 1156 ] @@ -1224,7 +1224,7 @@ if ('onhashchange' in window) { 1163 type [0] 1164 ] 1165 run [ -1166 editor-event-loop screen, console, e +1166 editor-event-loop screen, console, e 1167 ] 1168 screen-should-contain [ 1169 . . @@ -1242,8 +1242,8 @@ if ('onhashchange' in window) { 1181 s:text <- new [abc 1182 def 1183 ghi] -1184 e:&:editor <- new-editor s, 1/left, 10/right -1185 editor-render screen, e +1184 e:&:editor <- new-editor s, 1/left, 10/right +1185 editor-render screen, e 1186 $clear-trace 1187 # click on the third line and hit up-arrow, so you end up just after a newline 1188 assume-console [ @@ -1251,7 +1251,7 @@ if ('onhashchange' in window) { 1190 press up-arrow 1191 ] 1192 run [ -1193 editor-event-loop screen, console, e +1193 editor-event-loop screen, console, e 1194 3:num/raw <- get *e, cursor-row:offset 1195 4:num/raw <- get *e, cursor-column:offset 1196 ] @@ -1264,7 +1264,7 @@ if ('onhashchange' in window) { 1203 type [0] 1204 ] 1205 run [ -1206 editor-event-loop screen, console, e +1206 editor-event-loop screen, console, e 1207 ] 1208 screen-should-contain [ 1209 . . @@ -1278,8 +1278,8 @@ if ('onhashchange' in window) { 1217 scenario editor-moves-to-top-line-in-presence-of-wrapped-line [ 1218 local-scope 1219 assume-screen 10/width, 5/height -1220 e:&:editor <- new-editor [abcde], 0/left, 5/right -1221 editor-render screen, e +1220 e:&:editor <- new-editor [abcde], 0/left, 5/right +1221 editor-render screen, e 1222 screen-should-contain [ 1223 . . 1224 .abcd↩ . @@ -1292,7 +1292,7 @@ if ('onhashchange' in window) { 1231 press up-arrow 1232 ] 1233 run [ -1234 editor-event-loop screen, console, e +1234 editor-event-loop screen, console, e 1235 3:num/raw <- get *e, cursor-row:offset 1236 4:num/raw <- get *e, cursor-column:offset 1237 ] @@ -1305,7 +1305,7 @@ if ('onhashchange' in window) { 1244 type [0] 1245 ] 1246 run [ -1247 editor-event-loop screen, console, e +1247 editor-event-loop screen, console, e 1248 ] 1249 screen-should-contain [ 1250 . . @@ -1320,8 +1320,8 @@ if ('onhashchange' in window) { 1259 assume-screen 10/width, 5/height 1260 s:text <- new [abc 1261 defgh] -1262 e:&:editor <- new-editor s, 0/left, 5/right -1263 editor-render screen, e +1262 e:&:editor <- new-editor s, 0/left, 5/right +1263 editor-render screen, e 1264 screen-should-contain [ 1265 . . 1266 .abc . @@ -1336,7 +1336,7 @@ if ('onhashchange' in window) { 1275 press up-arrow 1276 ] 1277 run [ -1278 editor-event-loop screen, console, e +1278 editor-event-loop screen, console, e 1279 3:num/raw <- get *e, cursor-row:offset 1280 4:num/raw <- get *e, cursor-column:offset 1281 ] @@ -1349,7 +1349,7 @@ if ('onhashchange' in window) { 1288 type [0] 1289 ] 1290 run [ -1291 editor-event-loop screen, console, e +1291 editor-event-loop screen, console, e 1292 ] 1293 screen-should-contain [ 1294 . . @@ -1367,15 +1367,15 @@ if ('onhashchange' in window) { 1306 assume-screen 10/width, 5/height 1307 s:text <- new [abc 1308 def] -1309 e:&:editor <- new-editor s, 0/left, 10/right -1310 editor-render screen, e +1309 e:&:editor <- new-editor s, 0/left, 10/right +1310 editor-render screen, e 1311 $clear-trace 1312 # cursor starts out at (1, 0) 1313 assume-console [ 1314 press down-arrow 1315 ] 1316 run [ -1317 editor-event-loop screen, console, e +1317 editor-event-loop screen, console, e 1318 3:num/raw <- get *e, cursor-row:offset 1319 4:num/raw <- get *e, cursor-column:offset 1320 ] @@ -1389,7 +1389,7 @@ if ('onhashchange' in window) { 1328 type [0] 1329 ] 1330 run [ -1331 editor-event-loop screen, console, e +1331 editor-event-loop screen, console, e 1332 ] 1333 screen-should-contain [ 1334 . . @@ -1400,27 +1400,27 @@ if ('onhashchange' in window) { 1339 ] 1340 ] 1341 -1342 after <handle-special-key> [ +1342 after <handle-special-key> [ 1343 { 1344 move-to-next-line?:bool <- equal k, 65516/down-arrow 1345 break-unless move-to-next-line? 1346 <begin-move-cursor> -1347 go-render? <- move-to-next-line editor, screen-height +1347 go-render? <- move-to-next-line editor, screen-height 1348 undo-coalesce-tag:num <- copy 4/down-arrow 1349 <end-move-cursor> 1350 return 1351 } 1352 ] 1353 -1354 def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ +1354 def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 1355 local-scope 1356 load-inputs 1357 cursor-row:num <- get *editor, cursor-row:offset 1358 cursor-column:num <- get *editor, cursor-column:offset -1359 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1359 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1360 left:num <- get *editor, left:offset 1361 right:num <- get *editor, right:offset -1362 last-line:num <- subtract screen-height, 1 +1362 last-line:num <- subtract screen-height, 1 1363 bottom:num <- get *editor, bottom:offset 1364 at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line 1365 { @@ -1434,9 +1434,9 @@ if ('onhashchange' in window) { 1373 jump +try-to-scroll 1374 } 1375 } -1376 next:&:duplex-list:char <- next before-cursor +1376 next:&:duplex-list:char <- next before-cursor 1377 { -1378 break-if next +1378 break-if next 1379 { 1380 break-if at-bottom-of-screen? 1381 return 0/don't-render @@ -1453,19 +1453,19 @@ if ('onhashchange' in window) { 1392 target-column:num <- copy cursor-column 1393 # scan to start of next line 1394 { -1395 next:&:duplex-list:char <- next before-cursor -1396 break-unless next +1395 next:&:duplex-list:char <- next before-cursor +1396 break-unless next 1397 done?:bool <- greater-or-equal cursor-column, right 1398 break-if done? 1399 cursor-column <- add cursor-column, 1 -1400 before-cursor <- copy next +1400 before-cursor <- copy next 1401 c:char <- get *next, value:offset 1402 at-newline?:bool <- equal c, 10/newline 1403 break-if at-newline? 1404 loop 1405 } 1406 { -1407 break-if next +1407 break-if next 1408 { 1409 break-if at-bottom-of-screen? 1410 return 0/don't-render @@ -1478,15 +1478,15 @@ if ('onhashchange' in window) { 1417 cursor-row <- add cursor-row, 1 1418 cursor-column <- copy left 1419 { -1420 next:&:duplex-list:char <- next before-cursor -1421 break-unless next +1420 next:&:duplex-list:char <- next before-cursor +1421 break-unless next 1422 c:char <- get *next, value:offset 1423 at-newline?:bool <- equal c, 10/newline 1424 break-if at-newline? 1425 done?:bool <- greater-or-equal cursor-column, target-column 1426 break-if done? 1427 cursor-column <- add cursor-column, 1 -1428 before-cursor <- copy next +1428 before-cursor <- copy next 1429 loop 1430 } 1431 *editor <- put *editor, before-cursor:offset, before-cursor @@ -1506,8 +1506,8 @@ if ('onhashchange' in window) { 1445 s:text <- new [abcde 1446 fg 1447 hi] -1448 e:&:editor <- new-editor s, 0/left, 10/right -1449 editor-render screen, e +1448 e:&:editor <- new-editor s, 0/left, 10/right +1449 editor-render screen, e 1450 $clear-trace 1451 # move to end of first line, then press down 1452 assume-console [ @@ -1515,7 +1515,7 @@ if ('onhashchange' in window) { 1454 press down-arrow 1455 ] 1456 run [ -1457 editor-event-loop screen, console, e +1457 editor-event-loop screen, console, e 1458 3:num/raw <- get *e, cursor-row:offset 1459 4:num/raw <- get *e, cursor-column:offset 1460 ] @@ -1529,7 +1529,7 @@ if ('onhashchange' in window) { 1468 type [0] 1469 ] 1470 run [ -1471 editor-event-loop screen, console, e +1471 editor-event-loop screen, console, e 1472 ] 1473 screen-should-contain [ 1474 . . @@ -1543,8 +1543,8 @@ if ('onhashchange' in window) { 1482 scenario editor-moves-down-within-wrapped-line [ 1483 local-scope 1484 assume-screen 10/width, 5/height -1485 e:&:editor <- new-editor [abcdefghijklmno], 0/left, 10/right -1486 editor-render screen, e +1485 e:&:editor <- new-editor [abcdefghijklmno], 0/left, 10/right +1486 editor-render screen, e 1487 screen-should-contain [ 1488 . . 1489 .abcdefghi↩. @@ -1558,7 +1558,7 @@ if ('onhashchange' in window) { 1497 press down-arrow 1498 ] 1499 run [ -1500 editor-event-loop screen, console, e +1500 editor-event-loop screen, console, e 1501 3:num/raw <- get *e, cursor-row:offset 1502 4:num/raw <- get *e, cursor-column:offset 1503 ] @@ -1576,8 +1576,8 @@ if ('onhashchange' in window) { 1515 assume-screen 10/width, 5/height 1516 s:text <- new [123 1517 456] -1518 e:&:editor <- new-editor s, 0/left, 10/right -1519 editor-render screen, e +1518 e:&:editor <- new-editor s, 0/left, 10/right +1519 editor-render screen, e 1520 $clear-trace 1521 # start on second line, press ctrl-a 1522 assume-console [ @@ -1585,7 +1585,7 @@ if ('onhashchange' in window) { 1524 press ctrl-a 1525 ] 1526 run [ -1527 editor-event-loop screen, console, e +1527 editor-event-loop screen, console, e 1528 4:num/raw <- get *e, cursor-row:offset 1529 5:num/raw <- get *e, cursor-column:offset 1530 ] @@ -1597,24 +1597,24 @@ if ('onhashchange' in window) { 1536 check-trace-count-for-label 0, [print-character] 1537 ] 1538 -1539 after <handle-special-character> [ +1539 after <handle-special-character> [ 1540 { 1541 move-to-start-of-line?:bool <- equal c, 1/ctrl-a 1542 break-unless move-to-start-of-line? 1543 <begin-move-cursor> -1544 move-to-start-of-screen-line editor +1544 move-to-start-of-screen-line editor 1545 undo-coalesce-tag:num <- copy 0/never 1546 <end-move-cursor> 1547 return 0/don't-render 1548 } 1549 ] 1550 -1551 after <handle-special-key> [ +1551 after <handle-special-key> [ 1552 { 1553 move-to-start-of-line?:bool <- equal k, 65521/home 1554 break-unless move-to-start-of-line? 1555 <begin-move-cursor> -1556 move-to-start-of-screen-line editor +1556 move-to-start-of-screen-line editor 1557 undo-coalesce-tag:num <- copy 0/never 1558 <end-move-cursor> 1559 return 0/don't-render @@ -1623,20 +1623,20 @@ if ('onhashchange' in window) { 1562 1563 # handles wrapped lines 1564 # precondition: cursor-column should be in a consistent state -1565 def move-to-start-of-screen-line editor:&:editor -> editor:&:editor [ +1565 def move-to-start-of-screen-line editor:&:editor -> editor:&:editor [ 1566 local-scope 1567 load-inputs 1568 # update cursor column 1569 left:num <- get *editor, left:offset 1570 col:num <- get *editor, cursor-column:offset 1571 # update before-cursor -1572 curr:&:duplex-list:char <- get *editor, before-cursor:offset +1572 curr:&:duplex-list:char <- get *editor, before-cursor:offset 1573 # while not at start of line, move 1574 { 1575 done?:bool <- equal col, left 1576 break-if done? 1577 assert curr, [move-to-start-of-line tried to move before start of text] -1578 curr <- prev curr +1578 curr <- prev curr 1579 col <- subtract col, 1 1580 loop 1581 } @@ -1649,8 +1649,8 @@ if ('onhashchange' in window) { 1588 assume-screen 10/width, 5/height 1589 s:text <- new [123 1590 456] -1591 e:&:editor <- new-editor s, 0/left, 10/right -1592 editor-render screen, e +1591 e:&:editor <- new-editor s, 0/left, 10/right +1592 editor-render screen, e 1593 $clear-trace 1594 # start on first line (no newline before), press ctrl-a 1595 assume-console [ @@ -1658,7 +1658,7 @@ if ('onhashchange' in window) { 1597 press ctrl-a 1598 ] 1599 run [ -1600 editor-event-loop screen, console, e +1600 editor-event-loop screen, console, e 1601 4:num/raw <- get *e, cursor-row:offset 1602 5:num/raw <- get *e, cursor-column:offset 1603 ] @@ -1675,7 +1675,7 @@ if ('onhashchange' in window) { 1614 assume-screen 10/width, 5/height 1615 s:text <- new [123 1616 456] -1617 e:&:editor <- new-editor s, 0/left, 10/right +1617 e:&:editor <- new-editor s, 0/left, 10/right 1618 $clear-trace 1619 # start on second line, press 'home' 1620 assume-console [ @@ -1683,7 +1683,7 @@ if ('onhashchange' in window) { 1622 press home 1623 ] 1624 run [ -1625 editor-event-loop screen, console, e +1625 editor-event-loop screen, console, e 1626 3:num/raw <- get *e, cursor-row:offset 1627 4:num/raw <- get *e, cursor-column:offset 1628 ] @@ -1700,8 +1700,8 @@ if ('onhashchange' in window) { 1639 assume-screen 10/width, 5/height 1640 s:text <- new [123 1641 456] -1642 e:&:editor <- new-editor s, 0/left, 10/right -1643 editor-render screen, e +1642 e:&:editor <- new-editor s, 0/left, 10/right +1643 editor-render screen, e 1644 $clear-trace 1645 # start on first line (no newline before), press 'home' 1646 assume-console [ @@ -1709,7 +1709,7 @@ if ('onhashchange' in window) { 1648 press home 1649 ] 1650 run [ -1651 editor-event-loop screen, console, e +1651 editor-event-loop screen, console, e 1652 3:num/raw <- get *e, cursor-row:offset 1653 4:num/raw <- get *e, cursor-column:offset 1654 ] @@ -1724,8 +1724,8 @@ if ('onhashchange' in window) { 1663 scenario editor-moves-to-start-of-screen-line-with-ctrl-a [ 1664 local-scope 1665 assume-screen 10/width, 5/height -1666 e:&:editor <- new-editor [123456], 0/left, 5/right -1667 editor-render screen, e +1666 e:&:editor <- new-editor [123456], 0/left, 5/right +1667 editor-render screen, e 1668 screen-should-contain [ 1669 . . 1670 .1234↩ . @@ -1741,7 +1741,7 @@ if ('onhashchange' in window) { 1680 press up-arrow 1681 ] 1682 run [ -1683 editor-event-loop screen, console, e +1683 editor-event-loop screen, console, e 1684 4:num/raw <- get *e, cursor-row:offset 1685 5:num/raw <- get *e, cursor-column:offset 1686 ] @@ -1756,7 +1756,7 @@ if ('onhashchange' in window) { 1695 type [a] 1696 ] 1697 run [ -1698 editor-event-loop screen, console, e +1698 editor-event-loop screen, console, e 1699 4:num/raw <- get *e, cursor-row:offset 1700 5:num/raw <- get *e, cursor-column:offset 1701 ] @@ -1780,8 +1780,8 @@ if ('onhashchange' in window) { 1719 assume-screen 10/width, 5/height 1720 s:text <- new [123 1721 456] -1722 e:&:editor <- new-editor s, 0/left, 10/right -1723 editor-render screen, e +1722 e:&:editor <- new-editor s, 0/left, 10/right +1723 editor-render screen, e 1724 $clear-trace 1725 # start on first line, press ctrl-e 1726 assume-console [ @@ -1789,7 +1789,7 @@ if ('onhashchange' in window) { 1728 press ctrl-e 1729 ] 1730 run [ -1731 editor-event-loop screen, console, e +1731 editor-event-loop screen, console, e 1732 4:num/raw <- get *e, cursor-row:offset 1733 5:num/raw <- get *e, cursor-column:offset 1734 ] @@ -1804,7 +1804,7 @@ if ('onhashchange' in window) { 1743 type [z] 1744 ] 1745 run [ -1746 editor-event-loop screen, console, e +1746 editor-event-loop screen, console, e 1747 4:num/raw <- get *e, cursor-row:offset 1748 5:num/raw <- get *e, cursor-column:offset 1749 ] @@ -1822,40 +1822,40 @@ if ('onhashchange' in window) { 1761 check-trace-count-for-label 1, [print-character] 1762 ] 1763 -1764 after <handle-special-character> [ +1764 after <handle-special-character> [ 1765 { 1766 move-to-end-of-line?:bool <- equal c, 5/ctrl-e 1767 break-unless move-to-end-of-line? 1768 <begin-move-cursor> -1769 move-to-end-of-line editor +1769 move-to-end-of-line editor 1770 undo-coalesce-tag:num <- copy 0/never 1771 <end-move-cursor> 1772 return 0/don't-render 1773 } 1774 ] 1775 -1776 after <handle-special-key> [ +1776 after <handle-special-key> [ 1777 { 1778 move-to-end-of-line?:bool <- equal k, 65520/end 1779 break-unless move-to-end-of-line? 1780 <begin-move-cursor> -1781 move-to-end-of-line editor +1781 move-to-end-of-line editor 1782 undo-coalesce-tag:num <- copy 0/never 1783 <end-move-cursor> 1784 return 0/don't-render 1785 } 1786 ] 1787 -1788 def move-to-end-of-line editor:&:editor -> editor:&:editor [ +1788 def move-to-end-of-line editor:&:editor -> editor:&:editor [ 1789 local-scope 1790 load-inputs -1791 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1791 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1792 cursor-column:num <- get *editor, cursor-column:offset 1793 right:num <- get *editor, right:offset 1794 # while not at end of line, move 1795 { -1796 next:&:duplex-list:char <- next before-cursor -1797 break-unless next # end of text +1796 next:&:duplex-list:char <- next before-cursor +1797 break-unless next # end of text 1798 nextc:char <- get *next, value:offset 1799 at-end-of-line?:bool <- equal nextc, 10/newline 1800 break-if at-end-of-line? @@ -1863,7 +1863,7 @@ if ('onhashchange' in window) { 1802 at-right?:bool <- equal cursor-column, right 1803 break-if at-right? 1804 *editor <- put *editor, cursor-column:offset, cursor-column -1805 before-cursor <- copy next +1805 before-cursor <- copy next 1806 *editor <- put *editor, before-cursor:offset, before-cursor 1807 loop 1808 } @@ -1874,8 +1874,8 @@ if ('onhashchange' in window) { 1813 assume-screen 10/width, 5/height 1814 s:text <- new [123 1815 456] -1816 e:&:editor <- new-editor s, 0/left, 10/right -1817 editor-render screen, e +1816 e:&:editor <- new-editor s, 0/left, 10/right +1817 editor-render screen, e 1818 $clear-trace 1819 # start on second line (no newline after), press ctrl-e 1820 assume-console [ @@ -1883,7 +1883,7 @@ if ('onhashchange' in window) { 1822 press ctrl-e 1823 ] 1824 run [ -1825 editor-event-loop screen, console, e +1825 editor-event-loop screen, console, e 1826 4:num/raw <- get *e, cursor-row:offset 1827 5:num/raw <- get *e, cursor-column:offset 1828 ] @@ -1900,8 +1900,8 @@ if ('onhashchange' in window) { 1839 assume-screen 10/width, 5/height 1840 s:text <- new [123 1841 456] -1842 e:&:editor <- new-editor s, 0/left, 10/right -1843 editor-render screen, e +1842 e:&:editor <- new-editor s, 0/left, 10/right +1843 editor-render screen, e 1844 $clear-trace 1845 # start on first line, press 'end' 1846 assume-console [ @@ -1909,7 +1909,7 @@ if ('onhashchange' in window) { 1848 press end 1849 ] 1850 run [ -1851 editor-event-loop screen, console, e +1851 editor-event-loop screen, console, e 1852 3:num/raw <- get *e, cursor-row:offset 1853 4:num/raw <- get *e, cursor-column:offset 1854 ] @@ -1926,8 +1926,8 @@ if ('onhashchange' in window) { 1865 assume-screen 10/width, 5/height 1866 s:text <- new [123 1867 456] -1868 e:&:editor <- new-editor s, 0/left, 10/right -1869 editor-render screen, e +1868 e:&:editor <- new-editor s, 0/left, 10/right +1869 editor-render screen, e 1870 $clear-trace 1871 # start on second line (no newline after), press 'end' 1872 assume-console [ @@ -1935,7 +1935,7 @@ if ('onhashchange' in window) { 1874 press end 1875 ] 1876 run [ -1877 editor-event-loop screen, console, e +1877 editor-event-loop screen, console, e 1878 3:num/raw <- get *e, cursor-row:offset 1879 4:num/raw <- get *e, cursor-column:offset 1880 ] @@ -1952,8 +1952,8 @@ if ('onhashchange' in window) { 1891 assume-screen 10/width, 5/height 1892 s:text <- new [123456 1893 789] -1894 e:&:editor <- new-editor s, 0/left, 5/right -1895 editor-render screen, e +1894 e:&:editor <- new-editor s, 0/left, 5/right +1895 editor-render screen, e 1896 $clear-trace 1897 # start on first line, press 'end' 1898 assume-console [ @@ -1961,7 +1961,7 @@ if ('onhashchange' in window) { 1900 press end 1901 ] 1902 run [ -1903 editor-event-loop screen, console, e +1903 editor-event-loop screen, console, e 1904 10:num/raw <- get *e, cursor-row:offset 1905 11:num/raw <- get *e, cursor-column:offset 1906 ] @@ -1977,7 +1977,7 @@ if ('onhashchange' in window) { 1916 type [a] 1917 ] 1918 run [ -1919 editor-event-loop screen, console, e +1919 editor-event-loop screen, console, e 1920 ] 1921 screen-should-contain [ 1922 . . @@ -1995,8 +1995,8 @@ if ('onhashchange' in window) { 1934 assume-screen 10/width, 5/height 1935 s:text <- new [123 1936 456] -1937 e:&:editor <- new-editor s, 0/left, 10/right -1938 editor-render screen, e +1937 e:&:editor <- new-editor s, 0/left, 10/right +1938 editor-render screen, e 1939 $clear-trace 1940 # start on second line, press ctrl-u 1941 assume-console [ @@ -2004,7 +2004,7 @@ if ('onhashchange' in window) { 1943 press ctrl-u 1944 ] 1945 run [ -1946 editor-event-loop screen, console, e +1946 editor-event-loop screen, console, e 1947 ] 1948 # cursor deletes to start of line 1949 screen-should-contain [ @@ -2017,32 +2017,32 @@ if ('onhashchange' in window) { 1956 check-trace-count-for-label 10, [print-character] 1957 ] 1958 -1959 after <handle-special-character> [ +1959 after <handle-special-character> [ 1960 { 1961 delete-to-start-of-line?:bool <- equal c, 21/ctrl-u 1962 break-unless delete-to-start-of-line? -1963 <begin-delete-to-start-of-line> -1964 deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor -1965 <end-delete-to-start-of-line> -1966 go-render?:bool <- minimal-render-for-ctrl-u screen, editor, deleted-cells +1963 <begin-delete-to-start-of-line> +1964 deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor +1965 <end-delete-to-start-of-line> +1966 go-render?:bool <- minimal-render-for-ctrl-u screen, editor, deleted-cells 1967 return 1968 } 1969 ] 1970 -1971 def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ +1971 def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ 1972 local-scope 1973 load-inputs 1974 curr-column:num <- get *editor, cursor-column:offset 1975 # accumulate the current line as text and render it -1976 buf:&:buffer:char <- new-buffer 30 # accumulator for the text we need to render -1977 curr:&:duplex-list:char <- get *editor, before-cursor:offset +1976 buf:&:buffer:char <- new-buffer 30 # accumulator for the text we need to render +1977 curr:&:duplex-list:char <- get *editor, before-cursor:offset 1978 i:num <- copy curr-column 1979 right:num <- get *editor, right:offset 1980 { 1981 # if we have a wrapped line, give up and render the whole screen 1982 wrap?:bool <- greater-or-equal i, right 1983 return-if wrap?, 1/go-render -1984 curr <- next curr +1984 curr <- next curr 1985 break-unless curr 1986 c:char <- get *curr, value:offset 1987 b:bool <- equal c, 10 @@ -2058,22 +2058,22 @@ if ('onhashchange' in window) { 1997 end:num <- subtract right, left 1998 wrap?:bool <- greater-or-equal old-row-len, end 1999 return-if wrap?, 1/go-render -2000 curr-line:text <- buffer-to-array buf +2000 curr-line:text <- buffer-to-array buf 2001 curr-row:num <- get *editor, cursor-row:offset -2002 render-code screen, curr-line, curr-column, right, curr-row +2002 render-code screen, curr-line, curr-column, right, curr-row 2003 return 0/dont-render 2004 ] 2005 -2006 def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ +2006 def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ 2007 local-scope 2008 load-inputs 2009 # compute range to delete -2010 init:&:duplex-list:char <- get *editor, data:offset -2011 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2010 init:&:duplex-list:char <- get *editor, data:offset +2011 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2012 update-top-of-screen?:bool <- copy 0/false -2013 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -2014 start:&:duplex-list:char <- copy before-cursor -2015 end:&:duplex-list:char <- next before-cursor +2013 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +2014 start:&:duplex-list:char <- copy before-cursor +2015 end:&:duplex-list:char <- next before-cursor 2016 { 2017 at-start-of-text?:bool <- equal start, init 2018 break-if at-start-of-text? @@ -2083,13 +2083,13 @@ if ('onhashchange' in window) { 2022 # if we went past top-of-screen, make a note to update it as well 2023 at-top-of-screen?:bool <- equal start, top-of-screen 2024 update-top-of-screen?:bool <- or update-top-of-screen?, at-top-of-screen? -2025 start <- prev start +2025 start <- prev start 2026 assert start, [delete-to-start-of-line tried to move before start of text] 2027 loop 2028 } 2029 # snip it out -2030 result:&:duplex-list:char <- next start -2031 remove-between start, end +2030 result:&:duplex-list:char <- next start +2031 remove-between start, end 2032 # update top-of-screen if it's just been invalidated 2033 { 2034 break-unless update-top-of-screen? @@ -2120,21 +2120,21 @@ if ('onhashchange' in window) { 2059 put *editor, cursor-row:offset, cursor-row 2060 ] 2061 -2062 def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [ +2062 def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [ 2063 local-scope 2064 load-inputs 2065 return-unless s 2066 color:num <- copy 7/white 2067 column:num <- copy left -2068 screen <- move-cursor screen, row, column -2069 screen-height:num <- screen-height screen +2068 screen <- move-cursor screen, row, column +2069 screen-height:num <- screen-height screen 2070 i:num <- copy 0 2071 len:num <- length *s 2072 { 2073 +next-character 2074 done?:bool <- greater-or-equal i, len 2075 break-if done? -2076 done? <- greater-or-equal row, screen-height +2076 done? <- greater-or-equal row, screen-height 2077 break-if done? 2078 c:char <- index *s, i 2079 <character-c-received> @@ -2147,13 +2147,13 @@ if ('onhashchange' in window) { 2086 done?:bool <- greater-than column, right 2087 break-if done? 2088 space:char <- copy 32/space -2089 print screen, space +2089 print screen, space 2090 column <- add column, 1 2091 loop 2092 } 2093 row <- add row, 1 2094 column <- copy left -2095 screen <- move-cursor screen, row, column +2095 screen <- move-cursor screen, row, column 2096 i <- add i, 1 2097 loop +next-character 2098 } @@ -2163,25 +2163,25 @@ if ('onhashchange' in window) { 2102 break-unless at-right? 2103 # print wrap icon 2104 wrap-icon:char <- copy 8617/loop-back-to-left -2105 print screen, wrap-icon, 245/grey +2105 print screen, wrap-icon, 245/grey 2106 column <- copy left 2107 row <- add row, 1 -2108 screen <- move-cursor screen, row, column +2108 screen <- move-cursor screen, row, column 2109 # don't increment i 2110 loop +next-character 2111 } 2112 i <- add i, 1 -2113 print screen, c, color +2113 print screen, c, color 2114 column <- add column, 1 2115 loop 2116 } 2117 was-at-left?:bool <- equal column, left -2118 clear-line-until screen, right +2118 clear-line-until screen, right 2119 { 2120 break-if was-at-left? 2121 row <- add row, 1 2122 } -2123 move-cursor screen, row, left +2123 move-cursor screen, row, left 2124 ] 2125 2126 scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ @@ -2189,8 +2189,8 @@ if ('onhashchange' in window) { 2128 assume-screen 10/width, 5/height 2129 s:text <- new [123 2130 456] -2131 e:&:editor <- new-editor s, 0/left, 10/right -2132 editor-render screen, e +2131 e:&:editor <- new-editor s, 0/left, 10/right +2132 editor-render screen, e 2133 $clear-trace 2134 # start on first line (no newline before), press ctrl-u 2135 assume-console [ @@ -2198,7 +2198,7 @@ if ('onhashchange' in window) { 2137 press ctrl-u 2138 ] 2139 run [ -2140 editor-event-loop screen, console, e +2140 editor-event-loop screen, console, e 2141 ] 2142 # cursor deletes to start of line 2143 screen-should-contain [ @@ -2216,8 +2216,8 @@ if ('onhashchange' in window) { 2155 assume-screen 10/width, 5/height 2156 s:text <- new [123 2157 456] -2158 e:&:editor <- new-editor s, 0/left, 10/right -2159 editor-render screen, e +2158 e:&:editor <- new-editor s, 0/left, 10/right +2159 editor-render screen, e 2160 $clear-trace 2161 # start past end of line, press ctrl-u 2162 assume-console [ @@ -2225,7 +2225,7 @@ if ('onhashchange' in window) { 2164 press ctrl-u 2165 ] 2166 run [ -2167 editor-event-loop screen, console, e +2167 editor-event-loop screen, console, e 2168 ] 2169 # cursor deletes to start of line 2170 screen-should-contain [ @@ -2243,8 +2243,8 @@ if ('onhashchange' in window) { 2182 assume-screen 10/width, 5/height 2183 s:text <- new [123 2184 456] -2185 e:&:editor <- new-editor s, 0/left, 10/right -2186 editor-render screen, e +2185 e:&:editor <- new-editor s, 0/left, 10/right +2186 editor-render screen, e 2187 $clear-trace 2188 # start past end of final line, press ctrl-u 2189 assume-console [ @@ -2252,7 +2252,7 @@ if ('onhashchange' in window) { 2191 press ctrl-u 2192 ] 2193 run [ -2194 editor-event-loop screen, console, e +2194 editor-event-loop screen, console, e 2195 ] 2196 # cursor deletes to start of line 2197 screen-should-contain [ @@ -2271,8 +2271,8 @@ if ('onhashchange' in window) { 2210 # first line starts out wrapping 2211 s:text <- new [123456 2212 789] -2213 e:&:editor <- new-editor s, 0/left, 5/right -2214 editor-render screen, e +2213 e:&:editor <- new-editor s, 0/left, 5/right +2214 editor-render screen, e 2215 screen-should-contain [ 2216 . . 2217 .1234↩ . @@ -2288,7 +2288,7 @@ if ('onhashchange' in window) { 2227 press ctrl-u 2228 ] 2229 run [ -2230 editor-event-loop screen, console, e +2230 editor-event-loop screen, console, e 2231 ] 2232 # entire screen needs to be refreshed 2233 screen-should-contain [ @@ -2310,8 +2310,8 @@ if ('onhashchange' in window) { 2249 2 2250 345678 2251 9] -2252 e:&:editor <- new-editor s, 0/left, 5/right -2253 editor-render screen, e +2252 e:&:editor <- new-editor s, 0/left, 5/right +2253 editor-render screen, e 2254 screen-should-contain [ 2255 . . 2256 .1 . @@ -2328,7 +2328,7 @@ if ('onhashchange' in window) { 2267 press ctrl-u 2268 ] 2269 run [ -2270 editor-event-loop screen, console, e +2270 editor-event-loop screen, console, e 2271 10:num/raw <- get *e, cursor-row:offset 2272 11:num/raw <- get *e, cursor-column:offset 2273 ] @@ -2357,12 +2357,12 @@ if ('onhashchange' in window) { 2296 2 2297 3456789abcd 2298 e] -2299 e:&:editor <- new-editor s, 0/left, 5/right -2300 editor-render screen, e +2299 e:&:editor <- new-editor s, 0/left, 5/right +2300 editor-render screen, e 2301 assume-console [ 2302 left-click 4, 1 # on '8' 2303 ] -2304 editor-event-loop screen, console, e +2304 editor-event-loop screen, console, e 2305 screen-should-contain [ 2306 . . 2307 .1 . @@ -2379,7 +2379,7 @@ if ('onhashchange' in window) { 2318 press ctrl-u 2319 ] 2320 run [ -2321 editor-event-loop screen, console, e +2321 editor-event-loop screen, console, e 2322 10:num/raw <- get *e, cursor-row:offset 2323 11:num/raw <- get *e, cursor-column:offset 2324 ] @@ -2406,8 +2406,8 @@ if ('onhashchange' in window) { 2345 # first line starts out wrapping 2346 s:text <- new [1234567 2347 89] -2348 e:&:editor <- new-editor s, 0/left, 5/right -2349 editor-render screen, e +2348 e:&:editor <- new-editor s, 0/left, 5/right +2349 editor-render screen, e 2350 screen-should-contain [ 2351 . . 2352 .1234↩ . @@ -2422,7 +2422,7 @@ if ('onhashchange' in window) { 2361 press ctrl-u 2362 ] 2363 run [ -2364 editor-event-loop screen, console, e +2364 editor-event-loop screen, console, e 2365 10:num/raw <- get *e, cursor-row:offset 2366 11:num/raw <- get *e, cursor-column:offset 2367 ] @@ -2449,14 +2449,14 @@ if ('onhashchange' in window) { 2388 2 2389 345678 2390 9] -2391 e:&:editor <- new-editor s, 0/left, 5/right -2392 editor-render screen, e +2391 e:&:editor <- new-editor s, 0/left, 5/right +2392 editor-render screen, e 2393 # position the '78' line at the top of the screen 2394 assume-console [ 2395 left-click 4, 1 # on '8' 2396 press ctrl-t 2397 ] -2398 editor-event-loop screen, console, e +2398 editor-event-loop screen, console, e 2399 screen-should-contain [ 2400 . . 2401 .78 . @@ -2469,7 +2469,7 @@ if ('onhashchange' in window) { 2408 press ctrl-u 2409 ] 2410 run [ -2411 editor-event-loop screen, console, e +2411 editor-event-loop screen, console, e 2412 10:num/raw <- get *e, cursor-row:offset 2413 11:num/raw <- get *e, cursor-column:offset 2414 ] @@ -2490,7 +2490,7 @@ if ('onhashchange' in window) { 2429 press up-arrow 2430 ] 2431 run [ -2432 editor-event-loop screen, console, e +2432 editor-event-loop screen, console, e 2433 ] 2434 screen-should-contain [ 2435 . . @@ -2511,15 +2511,15 @@ if ('onhashchange' in window) { 2450 2 2451 3456789abcd 2452 e] -2453 e:&:editor <- new-editor s, 0/left, 5/right -2454 editor-render screen, e +2453 e:&:editor <- new-editor s, 0/left, 5/right +2454 editor-render screen, e 2455 # position the 'bcd' line at the top of the screen 2456 assume-console [ 2457 left-click 4, 1 # on '8' 2458 press ctrl-t 2459 press ctrl-s # now on 'c' 2460 ] -2461 editor-event-loop screen, console, e +2461 editor-event-loop screen, console, e 2462 screen-should-contain [ 2463 . . 2464 .bcd . @@ -2532,7 +2532,7 @@ if ('onhashchange' in window) { 2471 press ctrl-u 2472 ] 2473 run [ -2474 editor-event-loop screen, console, e +2474 editor-event-loop screen, console, e 2475 10:num/raw <- get *e, cursor-row:offset 2476 11:num/raw <- get *e, cursor-column:offset 2477 ] @@ -2553,7 +2553,7 @@ if ('onhashchange' in window) { 2492 press up-arrow 2493 ] 2494 run [ -2495 editor-event-loop screen, console, e +2495 editor-event-loop screen, console, e 2496 ] 2497 screen-should-contain [ 2498 . . @@ -2572,8 +2572,8 @@ if ('onhashchange' in window) { 2511 assume-screen 10/width, 5/height 2512 s:text <- new [123 2513 456] -2514 e:&:editor <- new-editor s, 0/left, 10/right -2515 editor-render screen, e +2514 e:&:editor <- new-editor s, 0/left, 10/right +2515 editor-render screen, e 2516 $clear-trace 2517 # start on first line, press ctrl-k 2518 assume-console [ @@ -2581,7 +2581,7 @@ if ('onhashchange' in window) { 2520 press ctrl-k 2521 ] 2522 run [ -2523 editor-event-loop screen, console, e +2523 editor-event-loop screen, console, e 2524 ] 2525 # cursor deletes to end of line 2526 screen-should-contain [ @@ -2594,20 +2594,20 @@ if ('onhashchange' in window) { 2533 check-trace-count-for-label 9, [print-character] 2534 ] 2535 -2536 after <handle-special-character> [ +2536 after <handle-special-character> [ 2537 { 2538 delete-to-end-of-line?:bool <- equal c, 11/ctrl-k 2539 break-unless delete-to-end-of-line? -2540 <begin-delete-to-end-of-line> -2541 deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor -2542 <end-delete-to-end-of-line> +2540 <begin-delete-to-end-of-line> +2541 deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor +2542 <end-delete-to-end-of-line> 2543 # checks if we can do a minimal render and if we can it will do a minimal render -2544 go-render?:bool <- minimal-render-for-ctrl-k screen, editor, deleted-cells +2544 go-render?:bool <- minimal-render-for-ctrl-k screen, editor, deleted-cells 2545 return 2546 } 2547 ] 2548 -2549 def minimal-render-for-ctrl-k screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ +2549 def minimal-render-for-ctrl-k screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ 2550 local-scope 2551 load-inputs 2552 # if we deleted nothing, there's nothing to render @@ -2621,28 +2621,28 @@ if ('onhashchange' in window) { 2560 end:num <- subtract right, left 2561 wrap?:bool <- greater-or-equal old-row-len, end 2562 return-if wrap?, 1/go-render -2563 clear-line-until screen, right +2563 clear-line-until screen, right 2564 return 0/dont-render 2565 ] 2566 -2567 def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ +2567 def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ 2568 local-scope 2569 load-inputs 2570 # compute range to delete -2571 start:&:duplex-list:char <- get *editor, before-cursor:offset -2572 end:&:duplex-list:char <- next start +2571 start:&:duplex-list:char <- get *editor, before-cursor:offset +2572 end:&:duplex-list:char <- next start 2573 { 2574 at-end-of-text?:bool <- equal end, 0/null 2575 break-if at-end-of-text? 2576 curr:char <- get *end, value:offset 2577 at-end-of-line?:bool <- equal curr, 10/newline 2578 break-if at-end-of-line? -2579 end <- next end +2579 end <- next end 2580 loop 2581 } 2582 # snip it out -2583 result <- next start -2584 remove-between start, end +2583 result <- next start +2584 remove-between start, end 2585 ] 2586 2587 scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ @@ -2650,8 +2650,8 @@ if ('onhashchange' in window) { 2589 assume-screen 10/width, 5/height 2590 s:text <- new [123 2591 456] -2592 e:&:editor <- new-editor s, 0/left, 10/right -2593 editor-render screen, e +2592 e:&:editor <- new-editor s, 0/left, 10/right +2593 editor-render screen, e 2594 $clear-trace 2595 # start on second line (no newline after), press ctrl-k 2596 assume-console [ @@ -2659,7 +2659,7 @@ if ('onhashchange' in window) { 2598 press ctrl-k 2599 ] 2600 run [ -2601 editor-event-loop screen, console, e +2601 editor-event-loop screen, console, e 2602 ] 2603 # cursor deletes to end of line 2604 screen-should-contain [ @@ -2677,8 +2677,8 @@ if ('onhashchange' in window) { 2616 assume-screen 10/width, 5/height 2617 s:text <- new [123 2618 456] -2619 e:&:editor <- new-editor s, 0/left, 10/right -2620 editor-render screen, e +2619 e:&:editor <- new-editor s, 0/left, 10/right +2620 editor-render screen, e 2621 $clear-trace 2622 # start at end of line 2623 assume-console [ @@ -2686,7 +2686,7 @@ if ('onhashchange' in window) { 2625 press ctrl-k 2626 ] 2627 run [ -2628 editor-event-loop screen, console, e +2628 editor-event-loop screen, console, e 2629 ] 2630 # cursor deletes just last character 2631 screen-should-contain [ @@ -2704,8 +2704,8 @@ if ('onhashchange' in window) { 2643 assume-screen 10/width, 5/height 2644 s:text <- new [123 2645 456] -2646 e:&:editor <- new-editor s, 0/left, 10/right -2647 editor-render screen, e +2646 e:&:editor <- new-editor s, 0/left, 10/right +2647 editor-render screen, e 2648 $clear-trace 2649 # start past end of line 2650 assume-console [ @@ -2713,7 +2713,7 @@ if ('onhashchange' in window) { 2652 press ctrl-k 2653 ] 2654 run [ -2655 editor-event-loop screen, console, e +2655 editor-event-loop screen, console, e 2656 ] 2657 # cursor deletes nothing 2658 screen-should-contain [ @@ -2731,8 +2731,8 @@ if ('onhashchange' in window) { 2670 assume-screen 10/width, 5/height 2671 s:text <- new [123 2672 456] -2673 e:&:editor <- new-editor s, 0/left, 10/right -2674 editor-render screen, e +2673 e:&:editor <- new-editor s, 0/left, 10/right +2674 editor-render screen, e 2675 $clear-trace 2676 # start at end of text 2677 assume-console [ @@ -2740,7 +2740,7 @@ if ('onhashchange' in window) { 2679 press ctrl-k 2680 ] 2681 run [ -2682 editor-event-loop screen, console, e +2682 editor-event-loop screen, console, e 2683 ] 2684 # cursor deletes just the final character 2685 screen-should-contain [ @@ -2758,8 +2758,8 @@ if ('onhashchange' in window) { 2697 assume-screen 10/width, 5/height 2698 s:text <- new [123 2699 456] -2700 e:&:editor <- new-editor s, 0/left, 10/right -2701 editor-render screen, e +2700 e:&:editor <- new-editor s, 0/left, 10/right +2701 editor-render screen, e 2702 $clear-trace 2703 # start past end of text 2704 assume-console [ @@ -2767,7 +2767,7 @@ if ('onhashchange' in window) { 2706 press ctrl-k 2707 ] 2708 run [ -2709 editor-event-loop screen, console, e +2709 editor-event-loop screen, console, e 2710 ] 2711 # cursor deletes nothing 2712 screen-should-contain [ @@ -2787,15 +2787,15 @@ if ('onhashchange' in window) { 2726 # create an editor with the first line wrapping to a second screen row 2727 s:text <- new [1234 2728 567] -2729 e:&:editor <- new-editor s, 0/left, 4/right -2730 editor-render screen, e +2729 e:&:editor <- new-editor s, 0/left, 4/right +2730 editor-render screen, e 2731 $clear-trace 2732 # delete all of the first wrapped line 2733 assume-console [ 2734 press ctrl-k 2735 ] 2736 run [ -2737 editor-event-loop screen, console, e +2737 editor-event-loop screen, console, e 2738 ] 2739 # screen shows an empty unwrapped first line 2740 screen-should-contain [ @@ -2820,8 +2820,8 @@ if ('onhashchange' in window) { 2759 b 2760 c 2761 d] -2762 e:&:editor <- new-editor s, 0/left, 10/right -2763 editor-render screen, e +2762 e:&:editor <- new-editor s, 0/left, 10/right +2763 editor-render screen, e 2764 screen-should-contain [ 2765 . . 2766 .a . @@ -2834,7 +2834,7 @@ if ('onhashchange' in window) { 2773 press down-arrow 2774 ] 2775 run [ -2776 editor-event-loop screen, console, e +2776 editor-event-loop screen, console, e 2777 ] 2778 # screen slides by one line 2779 screen-should-contain [ @@ -2847,12 +2847,12 @@ if ('onhashchange' in window) { 2786 2787 after <scroll-down> [ 2788 trace 10, [app], [scroll down] -2789 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2789 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2790 left:num <- get *editor, left:offset 2791 right:num <- get *editor, right:offset 2792 max:num <- subtract right, left -2793 old-top:&:duplex-list:char <- copy top-of-screen -2794 top-of-screen <- before-start-of-next-line top-of-screen, max +2793 old-top:&:duplex-list:char <- copy top-of-screen +2794 top-of-screen <- before-start-of-next-line top-of-screen, max 2795 *editor <- put *editor, top-of-screen:offset, top-of-screen 2796 no-movement?:bool <- equal old-top, top-of-screen 2797 return-if no-movement?, 0/don't-render @@ -2862,17 +2862,17 @@ if ('onhashchange' in window) { 2801 # positions until the next newline. 2802 # Returns original if no next newline. 2803 # Beware: never return null pointer. -2804 def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ +2804 def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ 2805 local-scope 2806 load-inputs 2807 count:num <- copy 0 -2808 curr:&:duplex-list:char <- copy original +2808 curr:&:duplex-list:char <- copy original 2809 # skip the initial newline if it exists 2810 { 2811 c:char <- get *curr, value:offset 2812 at-newline?:bool <- equal c, 10/newline 2813 break-unless at-newline? -2814 curr <- next curr +2814 curr <- next curr 2815 count <- add count, 1 2816 } 2817 { @@ -2882,7 +2882,7 @@ if ('onhashchange' in window) { 2821 c:char <- get *curr, value:offset 2822 at-newline?:bool <- equal c, 10/newline 2823 break-if at-newline? -2824 curr <- next curr +2824 curr <- next curr 2825 count <- add count, 1 2826 loop 2827 } @@ -2900,8 +2900,8 @@ if ('onhashchange' in window) { 2839 g 2840 h 2841 i] -2842 e:&:editor <- new-editor s, 0/left, 5/right -2843 editor-render screen, e +2842 e:&:editor <- new-editor s, 0/left, 5/right +2843 editor-render screen, e 2844 screen-should-contain [ 2845 . . 2846 .abcd↩ . @@ -2914,7 +2914,7 @@ if ('onhashchange' in window) { 2853 press down-arrow 2854 ] 2855 run [ -2856 editor-event-loop screen, console, e +2856 editor-event-loop screen, console, e 2857 ] 2858 # screen shows partial wrapped line 2859 screen-should-contain [ @@ -2934,14 +2934,14 @@ if ('onhashchange' in window) { 2873 k 2874 l 2875 m] -2876 e:&:editor <- new-editor s, 0/left, 5/right +2876 e:&:editor <- new-editor s, 0/left, 5/right 2877 # position cursor at last line, then try to move further down 2878 assume-console [ 2879 left-click 3, 0 2880 press down-arrow 2881 ] 2882 run [ -2883 editor-event-loop screen, console, e +2883 editor-event-loop screen, console, e 2884 ] 2885 # screen shows partial wrapped line containing a wrap icon 2886 screen-should-contain [ @@ -2955,7 +2955,7 @@ if ('onhashchange' in window) { 2894 press down-arrow 2895 ] 2896 run [ -2897 editor-event-loop screen, console, e +2897 editor-event-loop screen, console, e 2898 ] 2899 # screen shows partial wrapped line 2900 screen-should-contain [ @@ -2974,14 +2974,14 @@ if ('onhashchange' in window) { 2913 s:text <- new [a 2914 b 2915 cdef] -2916 e:&:editor <- new-editor s, 0/left, 5/right +2916 e:&:editor <- new-editor s, 0/left, 5/right 2917 # position cursor at end, type a character 2918 assume-console [ 2919 left-click 3, 4 2920 type [g] 2921 ] 2922 run [ -2923 editor-event-loop screen, console, e +2923 editor-event-loop screen, console, e 2924 3:num/raw <- get *e, cursor-row:offset 2925 4:num/raw <- get *e, cursor-column:offset 2926 ] @@ -3005,8 +3005,8 @@ if ('onhashchange' in window) { 2944 # initialize editor with 2 lines 2945 s:text <- new [a 2946 b] -2947 e:&:editor <- new-editor s, 0/left, 10/right -2948 editor-render screen, e +2947 e:&:editor <- new-editor s, 0/left, 10/right +2948 editor-render screen, e 2949 screen-should-contain [ 2950 . . 2951 .a . @@ -3019,7 +3019,7 @@ if ('onhashchange' in window) { 2958 press down-arrow 2959 ] 2960 run [ -2961 editor-event-loop screen, console, e +2961 editor-event-loop screen, console, e 2962 ] 2963 # no change since the bottom border was already visible 2964 screen-should-contain [ @@ -3037,14 +3037,14 @@ if ('onhashchange' in window) { 2976 s:text <- new [a 2977 b 2978 c] -2979 e:&:editor <- new-editor s, 0/left, 5/right +2979 e:&:editor <- new-editor s, 0/left, 5/right 2980 assume-console [ 2981 left-click 3, 4 2982 type [ 2983 ] 2984 ] 2985 run [ -2986 editor-event-loop screen, console, e +2986 editor-event-loop screen, console, e 2987 3:num/raw <- get *e, cursor-row:offset 2988 4:num/raw <- get *e, cursor-column:offset 2989 ] @@ -3069,14 +3069,14 @@ if ('onhashchange' in window) { 3008 s:text <- new [a 3009 b 3010 cdefgh] -3011 e:&:editor <- new-editor s, 0/left, 5/right +3011 e:&:editor <- new-editor s, 0/left, 5/right 3012 # position cursor at end of screen and try to move right 3013 assume-console [ 3014 left-click 3, 3 3015 press right-arrow 3016 ] 3017 run [ -3018 editor-event-loop screen, console, e +3018 editor-event-loop screen, console, e 3019 3:num/raw <- get *e, cursor-row:offset 3020 4:num/raw <- get *e, cursor-column:offset 3021 ] @@ -3102,14 +3102,14 @@ if ('onhashchange' in window) { 3041 b 3042 c 3043 d] -3044 e:&:editor <- new-editor s, 0/left, 5/right +3044 e:&:editor <- new-editor s, 0/left, 5/right 3045 # position cursor at end of screen and try to move right 3046 assume-console [ 3047 left-click 3, 3 3048 press right-arrow 3049 ] 3050 run [ -3051 editor-event-loop screen, console, e +3051 editor-event-loop screen, console, e 3052 3:num/raw <- get *e, cursor-row:offset 3053 4:num/raw <- get *e, cursor-column:offset 3054 ] @@ -3131,8 +3131,8 @@ if ('onhashchange' in window) { 3070 assume-screen 10/width, 5/height 3071 s:text <- new [abc 3072 de] -3073 e:&:editor <- new-editor s, 0/left, 10/right -3074 editor-render screen, e +3073 e:&:editor <- new-editor s, 0/left, 10/right +3074 editor-render screen, e 3075 $clear-trace 3076 # try to move down past end of text 3077 assume-console [ @@ -3140,7 +3140,7 @@ if ('onhashchange' in window) { 3079 press down-arrow 3080 ] 3081 run [ -3082 editor-event-loop screen, console, e +3082 editor-event-loop screen, console, e 3083 3:num/raw <- get *e, cursor-row:offset 3084 4:num/raw <- get *e, cursor-column:offset 3085 ] @@ -3163,16 +3163,16 @@ if ('onhashchange' in window) { 3102 e 3103 f 3104 g] -3105 e:&:editor <- new-editor s, 0/left, 5/right -3106 editor-render screen, e +3105 e:&:editor <- new-editor s, 0/left, 5/right +3106 editor-render screen, e 3107 # scroll down one page and one line 3108 assume-console [ -3109 press page-down +3109 press page-down 3110 left-click 3, 0 3111 press down-arrow 3112 ] 3113 run [ -3114 editor-event-loop screen, console, e +3114 editor-event-loop screen, console, e 3115 ] 3116 # screen scrolls down 3 lines 3117 screen-should-contain [ @@ -3194,8 +3194,8 @@ if ('onhashchange' in window) { 3133 b 3134 c 3135 d] -3136 e:&:editor <- new-editor s, 0/left, 10/right -3137 editor-render screen, e +3136 e:&:editor <- new-editor s, 0/left, 10/right +3137 editor-render screen, e 3138 screen-should-contain [ 3139 . . 3140 .a . @@ -3204,11 +3204,11 @@ if ('onhashchange' in window) { 3143 ] 3144 # position cursor at top of second page, then try to move up 3145 assume-console [ -3146 press page-down +3146 press page-down 3147 press up-arrow 3148 ] 3149 run [ -3150 editor-event-loop screen, console, e +3150 editor-event-loop screen, console, e 3151 ] 3152 # screen slides by one line 3153 screen-should-contain [ @@ -3221,9 +3221,9 @@ if ('onhashchange' in window) { 3160 3161 after <scroll-up> [ 3162 trace 10, [app], [scroll up] -3163 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset -3164 old-top:&:duplex-list:char <- copy top-of-screen -3165 top-of-screen <- before-previous-screen-line top-of-screen, editor +3163 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +3164 old-top:&:duplex-list:char <- copy top-of-screen +3165 top-of-screen <- before-previous-screen-line top-of-screen, editor 3166 *editor <- put *editor, top-of-screen:offset, top-of-screen 3167 no-movement?:bool <- equal old-top, top-of-screen 3168 return-if no-movement?, 0/don't-render @@ -3233,10 +3233,10 @@ if ('onhashchange' in window) { 3172 # previous *wrapped* line. 3173 # Returns original if no next newline. 3174 # Beware: never return null pointer. -3175 def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ +3175 def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ 3176 local-scope 3177 load-inputs -3178 curr:&:duplex-list:char <- copy in +3178 curr:&:duplex-list:char <- copy in 3179 c:char <- get *curr, value:offset 3180 # compute max, number of characters to skip 3181 # 1 + len%(width-1) @@ -3244,14 +3244,14 @@ if ('onhashchange' in window) { 3183 left:num <- get *editor, left:offset 3184 right:num <- get *editor, right:offset 3185 max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon -3186 sentinel:&:duplex-list:char <- get *editor, data:offset -3187 len:num <- previous-line-length curr, sentinel +3186 sentinel:&:duplex-list:char <- get *editor, data:offset +3187 len:num <- previous-line-length curr, sentinel 3188 { 3189 break-if len 3190 # empty line; just skip this newline -3191 prev:&:duplex-list:char <- prev curr -3192 return-unless prev, curr -3193 return prev +3191 prev:&:duplex-list:char <- prev curr +3192 return-unless prev, curr +3193 return prev 3194 } 3195 _, max:num <- divide-with-remainder len, max-line-length 3196 # remainder 0 => scan one width-worth @@ -3265,9 +3265,9 @@ if ('onhashchange' in window) { 3204 { 3205 done?:bool <- greater-or-equal count, max 3206 break-if done? -3207 prev:&:duplex-list:char <- prev curr -3208 break-unless prev -3209 curr <- copy prev +3207 prev:&:duplex-list:char <- prev curr +3208 break-unless prev +3209 curr <- copy prev 3210 count <- add count, 1 3211 loop 3212 } @@ -3284,8 +3284,8 @@ if ('onhashchange' in window) { 3223 g 3224 h 3225 i] -3226 e:&:editor <- new-editor s, 0/left, 5/right -3227 editor-render screen, e +3226 e:&:editor <- new-editor s, 0/left, 5/right +3227 editor-render screen, e 3228 screen-should-contain [ 3229 . . 3230 .abcd↩ . @@ -3294,10 +3294,10 @@ if ('onhashchange' in window) { 3233 ] 3234 # position cursor at top of second page, just below wrapped line 3235 assume-console [ -3236 press page-down +3236 press page-down 3237 ] 3238 run [ -3239 editor-event-loop screen, console, e +3239 editor-event-loop screen, console, e 3240 ] 3241 screen-should-contain [ 3242 . . @@ -3310,7 +3310,7 @@ if ('onhashchange' in window) { 3249 press up-arrow 3250 ] 3251 run [ -3252 editor-event-loop screen, console, e +3252 editor-event-loop screen, console, e 3253 ] 3254 # screen shows partial wrapped line 3255 screen-should-contain [ @@ -3330,14 +3330,14 @@ if ('onhashchange' in window) { 3269 k 3270 l 3271 m] -3272 e:&:editor <- new-editor s, 0/left, 5/right -3273 editor-render screen, e +3272 e:&:editor <- new-editor s, 0/left, 5/right +3273 editor-render screen, e 3274 # position cursor at top of second page 3275 assume-console [ -3276 press page-down +3276 press page-down 3277 ] 3278 run [ -3279 editor-event-loop screen, console, e +3279 editor-event-loop screen, console, e 3280 ] 3281 screen-should-contain [ 3282 . . @@ -3351,7 +3351,7 @@ if ('onhashchange' in window) { 3290 press up-arrow 3291 ] 3292 run [ -3293 editor-event-loop screen, console, e +3293 editor-event-loop screen, console, e 3294 ] 3295 # screen shows partial wrapped line 3296 screen-should-contain [ @@ -3366,7 +3366,7 @@ if ('onhashchange' in window) { 3305 press up-arrow 3306 ] 3307 run [ -3308 editor-event-loop screen, console, e +3308 editor-event-loop screen, console, e 3309 ] 3310 # screen shows partial wrapped line 3311 screen-should-contain [ @@ -3381,7 +3381,7 @@ if ('onhashchange' in window) { 3320 press up-arrow 3321 ] 3322 run [ -3323 editor-event-loop screen, console, e +3323 editor-event-loop screen, console, e 3324 ] 3325 # screen shows partial wrapped line 3326 screen-should-contain [ @@ -3405,8 +3405,8 @@ if ('onhashchange' in window) { 3344 g 3345 h 3346 i] -3347 e:&:editor <- new-editor s, 0/left, 6/right -3348 editor-render screen, e +3347 e:&:editor <- new-editor s, 0/left, 6/right +3348 editor-render screen, e 3349 screen-should-contain [ 3350 . . 3351 .abcde↩ . @@ -3415,10 +3415,10 @@ if ('onhashchange' in window) { 3354 ] 3355 # position cursor at top of second page, just below wrapped line 3356 assume-console [ -3357 press page-down +3357 press page-down 3358 ] 3359 run [ -3360 editor-event-loop screen, console, e +3360 editor-event-loop screen, console, e 3361 ] 3362 screen-should-contain [ 3363 . . @@ -3431,7 +3431,7 @@ if ('onhashchange' in window) { 3370 press up-arrow 3371 ] 3372 run [ -3373 editor-event-loop screen, console, e +3373 editor-event-loop screen, console, e 3374 ] 3375 # screen shows partial wrapped line 3376 screen-should-contain [ @@ -3453,13 +3453,13 @@ if ('onhashchange' in window) { 3392 c 3393 d 3394 e] -3395 e:&:editor <- new-editor s, 0/left, 6/right -3396 editor-render screen, e +3395 e:&:editor <- new-editor s, 0/left, 6/right +3396 editor-render screen, e 3397 assume-console [ -3398 press page-down +3398 press page-down 3399 ] 3400 run [ -3401 editor-event-loop screen, console, e +3401 editor-event-loop screen, console, e 3402 ] 3403 screen-should-contain [ 3404 . . @@ -3468,10 +3468,10 @@ if ('onhashchange' in window) { 3407 .d . 3408 ] 3409 assume-console [ -3410 press page-down +3410 press page-down 3411 ] 3412 run [ -3413 editor-event-loop screen, console, e +3413 editor-event-loop screen, console, e 3414 ] 3415 screen-should-contain [ 3416 . . @@ -3480,10 +3480,10 @@ if ('onhashchange' in window) { 3419 .╌╌╌╌╌╌ . 3420 ] 3421 assume-console [ -3422 press page-up +3422 press page-up 3423 ] 3424 run [ -3425 editor-event-loop screen, console, e +3425 editor-event-loop screen, console, e 3426 ] 3427 screen-should-contain [ 3428 . . @@ -3503,14 +3503,14 @@ if ('onhashchange' in window) { 3442 c 3443 d 3444 e] -3445 e:&:editor <- new-editor s, 0/left, 5/right -3446 editor-render screen, e +3445 e:&:editor <- new-editor s, 0/left, 5/right +3446 editor-render screen, e 3447 # position cursor at top of second page 3448 assume-console [ -3449 press page-down +3449 press page-down 3450 ] 3451 run [ -3452 editor-event-loop screen, console, e +3452 editor-event-loop screen, console, e 3453 ] 3454 screen-should-contain [ 3455 . . @@ -3523,7 +3523,7 @@ if ('onhashchange' in window) { 3462 press left-arrow 3463 ] 3464 run [ -3465 editor-event-loop screen, console, e +3465 editor-event-loop screen, console, e 3466 3:num/raw <- get *e, cursor-row:offset 3467 4:num/raw <- get *e, cursor-column:offset 3468 ] @@ -3549,8 +3549,8 @@ if ('onhashchange' in window) { 3488 b 3489 c 3490 d] -3491 e:&:editor <- new-editor s, 0/left, 10/right -3492 editor-render screen, e +3491 e:&:editor <- new-editor s, 0/left, 10/right +3492 editor-render screen, e 3493 screen-should-contain [ 3494 . . 3495 .a . @@ -3560,12 +3560,12 @@ if ('onhashchange' in window) { 3499 # position cursor at top of second page, then try to move up to start of 3500 # text 3501 assume-console [ -3502 press page-down +3502 press page-down 3503 press up-arrow 3504 press up-arrow 3505 ] 3506 run [ -3507 editor-event-loop screen, console, e +3507 editor-event-loop screen, console, e 3508 ] 3509 # screen slides by one line 3510 screen-should-contain [ @@ -3579,7 +3579,7 @@ if ('onhashchange' in window) { 3518 press up-arrow 3519 ] 3520 run [ -3521 editor-event-loop screen, console, e +3521 editor-event-loop screen, console, e 3522 ] 3523 # screen remains unchanged 3524 screen-should-contain [ @@ -3599,8 +3599,8 @@ if ('onhashchange' in window) { 3538 b 3539 c 3540 d] -3541 e:&:editor <- new-editor s, 0/left, 10/right -3542 editor-render screen, e +3541 e:&:editor <- new-editor s, 0/left, 10/right +3542 editor-render screen, e 3543 screen-should-contain [ 3544 . . 3545 .a . @@ -3609,10 +3609,10 @@ if ('onhashchange' in window) { 3548 ] 3549 # scroll down 3550 assume-console [ -3551 press page-down +3551 press page-down 3552 ] 3553 run [ -3554 editor-event-loop screen, console, e +3554 editor-event-loop screen, console, e 3555 ] 3556 # screen shows next page 3557 screen-should-contain [ @@ -3623,31 +3623,31 @@ if ('onhashchange' in window) { 3562 ] 3563 ] 3564 -3565 after <handle-special-character> [ +3565 after <handle-special-character> [ 3566 { 3567 page-down?:bool <- equal c, 6/ctrl-f 3568 break-unless page-down? -3569 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +3569 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 3570 <begin-move-cursor> -3571 page-down editor +3571 page-down editor 3572 undo-coalesce-tag:num <- copy 0/never 3573 <end-move-cursor> -3574 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +3574 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 3575 movement?:bool <- not-equal top-of-screen, old-top 3576 return movement?/go-render 3577 } 3578 ] 3579 -3580 after <handle-special-key> [ +3580 after <handle-special-key> [ 3581 { 3582 page-down?:bool <- equal k, 65518/page-down 3583 break-unless page-down? -3584 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +3584 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 3585 <begin-move-cursor> -3586 page-down editor +3586 page-down editor 3587 undo-coalesce-tag:num <- copy 0/never 3588 <end-move-cursor> -3589 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +3589 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 3590 movement?:bool <- not-equal top-of-screen, old-top 3591 return movement?/go-render 3592 } @@ -3655,32 +3655,32 @@ if ('onhashchange' in window) { 3594 3595 # page-down skips entire wrapped lines, so it can't scroll past lines 3596 # taking up the entire screen -3597 def page-down editor:&:editor -> editor:&:editor [ +3597 def page-down editor:&:editor -> editor:&:editor [ 3598 local-scope 3599 load-inputs 3600 # if editor contents don't overflow screen, do nothing -3601 bottom-of-screen:&:duplex-list:char <- get *editor, bottom-of-screen:offset +3601 bottom-of-screen:&:duplex-list:char <- get *editor, bottom-of-screen:offset 3602 return-unless bottom-of-screen 3603 # if not, position cursor at final character -3604 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -3605 before-cursor:&:duplex-list:char <- prev bottom-of-screen +3604 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +3605 before-cursor:&:duplex-list:char <- prev bottom-of-screen 3606 *editor <- put *editor, before-cursor:offset, before-cursor 3607 # keep one line in common with previous page 3608 { -3609 last:char <- get *before-cursor, value:offset -3610 newline?:bool <- equal last, 10/newline +3609 last:char <- get *before-cursor, value:offset +3610 newline?:bool <- equal last, 10/newline 3611 break-unless newline?:bool -3612 before-cursor <- prev before-cursor +3612 before-cursor <- prev before-cursor 3613 *editor <- put *editor, before-cursor:offset, before-cursor 3614 } 3615 # move cursor and top-of-screen to start of that line -3616 move-to-start-of-line editor +3616 move-to-start-of-line editor 3617 before-cursor <- get *editor, before-cursor:offset 3618 *editor <- put *editor, top-of-screen:offset, before-cursor 3619 ] 3620 3621 # jump to previous newline -3622 def move-to-start-of-line editor:&:editor -> editor:&:editor [ +3622 def move-to-start-of-line editor:&:editor -> editor:&:editor [ 3623 local-scope 3624 load-inputs 3625 # update cursor column @@ -3688,16 +3688,16 @@ if ('onhashchange' in window) { 3627 cursor-column:num <- copy left 3628 *editor <- put *editor, cursor-column:offset, cursor-column 3629 # update before-cursor -3630 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -3631 init:&:duplex-list:char <- get *editor, data:offset +3630 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +3631 init:&:duplex-list:char <- get *editor, data:offset 3632 # while not at start of line, move 3633 { 3634 at-start-of-text?:bool <- equal before-cursor, init 3635 break-if at-start-of-text? -3636 prev:char <- get *before-cursor, value:offset -3637 at-start-of-line?:bool <- equal prev, 10/newline +3636 prev:char <- get *before-cursor, value:offset +3637 at-start-of-line?:bool <- equal prev, 10/newline 3638 break-if at-start-of-line? -3639 before-cursor <- prev before-cursor +3639 before-cursor <- prev before-cursor 3640 *editor <- put *editor, before-cursor:offset, before-cursor 3641 assert before-cursor, [move-to-start-of-line tried to move before start of text] 3642 loop @@ -3709,8 +3709,8 @@ if ('onhashchange' in window) { 3648 assume-screen 10/width, 4/height 3649 s:text <- new [a 3650 b] -3651 e:&:editor <- new-editor s, 0/left, 10/right -3652 editor-render screen, e +3651 e:&:editor <- new-editor s, 0/left, 10/right +3652 editor-render screen, e 3653 screen-should-contain [ 3654 . . 3655 .a . @@ -3719,10 +3719,10 @@ if ('onhashchange' in window) { 3658 ] 3659 # scroll down 3660 assume-console [ -3661 press page-down +3661 press page-down 3662 ] 3663 run [ -3664 editor-event-loop screen, console, e +3664 editor-event-loop screen, console, e 3665 ] 3666 # screen remains unmodified 3667 screen-should-contain [ @@ -3742,8 +3742,8 @@ if ('onhashchange' in window) { 3681 b 3682 cdefgh] 3683 # editor screen triggers wrap of last line -3684 e:&:editor <- new-editor s, 0/left, 4/right -3685 editor-render screen, e +3684 e:&:editor <- new-editor s, 0/left, 4/right +3685 editor-render screen, e 3686 # some part of last line is not displayed 3687 screen-should-contain [ 3688 . . @@ -3753,10 +3753,10 @@ if ('onhashchange' in window) { 3692 ] 3693 # scroll down 3694 assume-console [ -3695 press page-down +3695 press page-down 3696 ] 3697 run [ -3698 editor-event-loop screen, console, e +3698 editor-event-loop screen, console, e 3699 ] 3700 # screen shows entire wrapped line 3701 screen-should-contain [ @@ -3775,8 +3775,8 @@ if ('onhashchange' in window) { 3714 # and still has something left over 3715 s:text <- new [a 3716 bcdefgh] -3717 e:&:editor <- new-editor s, 0/left, 4/right -3718 editor-render screen, e +3717 e:&:editor <- new-editor s, 0/left, 4/right +3718 editor-render screen, e 3719 # some part of last line is not displayed 3720 screen-should-contain [ 3721 . . @@ -3786,10 +3786,10 @@ if ('onhashchange' in window) { 3725 ] 3726 # scroll down 3727 assume-console [ -3728 press page-down +3728 press page-down 3729 ] 3730 run [ -3731 editor-event-loop screen, console, e +3731 editor-event-loop screen, console, e 3732 ] 3733 # screen shows entire wrapped line 3734 screen-should-contain [ @@ -3809,8 +3809,8 @@ if ('onhashchange' in window) { 3748 b 3749 c 3750 d] -3751 e:&:editor <- new-editor s, 0/left, 10/right -3752 editor-render screen, e +3751 e:&:editor <- new-editor s, 0/left, 10/right +3752 editor-render screen, e 3753 screen-should-contain [ 3754 . . 3755 .a . @@ -3819,10 +3819,10 @@ if ('onhashchange' in window) { 3758 ] 3759 # scroll down 3760 assume-console [ -3761 press page-down +3761 press page-down 3762 ] 3763 run [ -3764 editor-event-loop screen, console, e +3764 editor-event-loop screen, console, e 3765 ] 3766 # screen shows next page 3767 screen-should-contain [ @@ -3833,10 +3833,10 @@ if ('onhashchange' in window) { 3772 ] 3773 # scroll back up 3774 assume-console [ -3775 press page-up +3775 press page-up 3776 ] 3777 run [ -3778 editor-event-loop screen, console, e +3778 editor-event-loop screen, console, e 3779 ] 3780 # screen shows original page again 3781 screen-should-contain [ @@ -3847,49 +3847,49 @@ if ('onhashchange' in window) { 3786 ] 3787 ] 3788 -3789 after <handle-special-character> [ +3789 after <handle-special-character> [ 3790 { 3791 page-up?:bool <- equal c, 2/ctrl-b 3792 break-unless page-up? -3793 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +3793 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 3794 <begin-move-cursor> -3795 editor <- page-up editor, screen-height +3795 editor <- page-up editor, screen-height 3796 undo-coalesce-tag:num <- copy 0/never 3797 <end-move-cursor> -3798 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +3798 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 3799 movement?:bool <- not-equal top-of-screen, old-top 3800 return movement?/go-render 3801 } 3802 ] 3803 -3804 after <handle-special-key> [ +3804 after <handle-special-key> [ 3805 { 3806 page-up?:bool <- equal k, 65519/page-up 3807 break-unless page-up? -3808 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +3808 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 3809 <begin-move-cursor> -3810 editor <- page-up editor, screen-height +3810 editor <- page-up editor, screen-height 3811 undo-coalesce-tag:num <- copy 0/never 3812 <end-move-cursor> -3813 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +3813 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 3814 movement?:bool <- not-equal top-of-screen, old-top 3815 # don't bother re-rendering if nothing changed. todo: test this 3816 return movement?/go-render 3817 } 3818 ] 3819 -3820 def page-up editor:&:editor, screen-height:num -> editor:&:editor [ +3820 def page-up editor:&:editor, screen-height:num -> editor:&:editor [ 3821 local-scope 3822 load-inputs -3823 max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line +3823 max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line 3824 count:num <- copy 0 -3825 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +3825 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 3826 { 3827 done?:bool <- greater-or-equal count, max 3828 break-if done? -3829 prev:&:duplex-list:char <- before-previous-screen-line top-of-screen, editor -3830 break-unless prev -3831 top-of-screen <- copy prev +3829 prev:&:duplex-list:char <- before-previous-screen-line top-of-screen, editor +3830 break-unless prev +3831 top-of-screen <- copy prev 3832 *editor <- put *editor, top-of-screen:offset, top-of-screen 3833 count <- add count, 1 3834 loop @@ -3909,8 +3909,8 @@ if ('onhashchange' in window) { 3848 f 3849 g 3850 h] -3851 e:&:editor <- new-editor s, 0/left, 10/right -3852 editor-render screen, e +3851 e:&:editor <- new-editor s, 0/left, 10/right +3852 editor-render screen, e 3853 screen-should-contain [ 3854 . . 3855 .a . @@ -3919,11 +3919,11 @@ if ('onhashchange' in window) { 3858 ] 3859 # scroll down two pages 3860 assume-console [ -3861 press page-down -3862 press page-down +3861 press page-down +3862 press page-down 3863 ] 3864 run [ -3865 editor-event-loop screen, console, e +3865 editor-event-loop screen, console, e 3866 ] 3867 # screen shows third page 3868 screen-should-contain [ @@ -3934,10 +3934,10 @@ if ('onhashchange' in window) { 3873 ] 3874 # scroll up 3875 assume-console [ -3876 press page-up +3876 press page-up 3877 ] 3878 run [ -3879 editor-event-loop screen, console, e +3879 editor-event-loop screen, console, e 3880 ] 3881 # screen shows second page 3882 screen-should-contain [ @@ -3948,10 +3948,10 @@ if ('onhashchange' in window) { 3887 ] 3888 # scroll up again 3889 assume-console [ -3890 press page-up +3890 press page-up 3891 ] 3892 run [ -3893 editor-event-loop screen, console, e +3893 editor-event-loop screen, console, e 3894 ] 3895 # screen shows original page again 3896 screen-should-contain [ @@ -3978,8 +3978,8 @@ if ('onhashchange' in window) { 3917 n 3918 o] 3919 # editor screen triggers wrap of last line -3920 e:&:editor <- new-editor s, 0/left, 4/right -3921 editor-render screen, e +3920 e:&:editor <- new-editor s, 0/left, 4/right +3921 editor-render screen, e 3922 # some part of last line is not displayed 3923 screen-should-contain [ 3924 . . @@ -3991,12 +3991,12 @@ if ('onhashchange' in window) { 3930 ] 3931 # scroll down a page and a line 3932 assume-console [ -3933 press page-down +3933 press page-down 3934 left-click 5, 0 3935 press down-arrow 3936 ] 3937 run [ -3938 editor-event-loop screen, console, e +3938 editor-event-loop screen, console, e 3939 ] 3940 # screen shows entire wrapped line 3941 screen-should-contain [ @@ -4009,10 +4009,10 @@ if ('onhashchange' in window) { 3948 ] 3949 # now scroll up one page 3950 assume-console [ -3951 press page-up +3951 press page-up 3952 ] 3953 run [ -3954 editor-event-loop screen, console, e +3954 editor-event-loop screen, console, e 3955 ] 3956 # screen resets 3957 screen-should-contain [ @@ -4033,8 +4033,8 @@ if ('onhashchange' in window) { 3972 # and still has something left over 3973 s:text <- new [a 3974 bcdefgh] -3975 e:&:editor <- new-editor s, 0/left, 4/right -3976 editor-render screen, e +3975 e:&:editor <- new-editor s, 0/left, 4/right +3976 editor-render screen, e 3977 # some part of last line is not displayed 3978 screen-should-contain [ 3979 . . @@ -4044,10 +4044,10 @@ if ('onhashchange' in window) { 3983 ] 3984 # scroll down 3985 assume-console [ -3986 press page-down +3986 press page-down 3987 ] 3988 run [ -3989 editor-event-loop screen, console, e +3989 editor-event-loop screen, console, e 3990 ] 3991 # screen shows entire wrapped line 3992 screen-should-contain [ @@ -4058,10 +4058,10 @@ if ('onhashchange' in window) { 3997 ] 3998 # scroll back up 3999 assume-console [ -4000 press page-up +4000 press page-up 4001 ] 4002 run [ -4003 editor-event-loop screen, console, e +4003 editor-event-loop screen, console, e 4004 ] 4005 # screen resets 4006 screen-should-contain [ @@ -4085,8 +4085,8 @@ if ('onhashchange' in window) { 4024 gxx 4025 hxx 4026 ] -4027 e:&:editor <- new-editor s, 0/left, 4/right -4028 editor-render screen, e +4027 e:&:editor <- new-editor s, 0/left, 4/right +4028 editor-render screen, e 4029 screen-should-contain [ 4030 . . 4031 .axx . @@ -4094,10 +4094,10 @@ if ('onhashchange' in window) { 4033 .cxx . 4034 ] 4035 assume-console [ -4036 press page-down +4036 press page-down 4037 ] 4038 run [ -4039 editor-event-loop screen, console, e +4039 editor-event-loop screen, console, e 4040 ] 4041 screen-should-contain [ 4042 . . @@ -4106,10 +4106,10 @@ if ('onhashchange' in window) { 4045 .exx . 4046 ] 4047 assume-console [ -4048 press page-down +4048 press page-down 4049 ] 4050 run [ -4051 editor-event-loop screen, console, e +4051 editor-event-loop screen, console, e 4052 ] 4053 screen-should-contain [ 4054 . . @@ -4119,10 +4119,10 @@ if ('onhashchange' in window) { 4058 ] 4059 # scroll back up past empty line 4060 assume-console [ -4061 press page-up +4061 press page-up 4062 ] 4063 run [ -4064 editor-event-loop screen, console, e +4064 editor-event-loop screen, console, e 4065 ] 4066 screen-should-contain [ 4067 . . @@ -4145,8 +4145,8 @@ if ('onhashchange' in window) { 4084 fxy 4085 gxy 4086 ] -4087 e:&:editor <- new-editor s, 0/left, 4/right -4088 editor-render screen, e +4087 e:&:editor <- new-editor s, 0/left, 4/right +4088 editor-render screen, e 4089 screen-should-contain [ 4090 . . 4091 .axy . @@ -4154,10 +4154,10 @@ if ('onhashchange' in window) { 4093 .cxy . 4094 ] 4095 assume-console [ -4096 press page-down +4096 press page-down 4097 ] 4098 run [ -4099 editor-event-loop screen, console, e +4099 editor-event-loop screen, console, e 4100 ] 4101 screen-should-contain [ 4102 . . @@ -4166,10 +4166,10 @@ if ('onhashchange' in window) { 4105 .dxy . 4106 ] 4107 assume-console [ -4108 press page-down +4108 press page-down 4109 ] 4110 run [ -4111 editor-event-loop screen, console, e +4111 editor-event-loop screen, console, e 4112 ] 4113 screen-should-contain [ 4114 . . @@ -4179,10 +4179,10 @@ if ('onhashchange' in window) { 4118 ] 4119 # scroll back up past empty line 4120 assume-console [ -4121 press page-up +4121 press page-up 4122 ] 4123 run [ -4124 editor-event-loop screen, console, e +4124 editor-event-loop screen, console, e 4125 ] 4126 screen-should-contain [ 4127 . . @@ -4195,26 +4195,26 @@ if ('onhashchange' in window) { 4134 # ctrl-s - scroll up by one line 4135 # todo: scenarios 4136 -4137 after <handle-special-character> [ +4137 after <handle-special-character> [ 4138 { 4139 scroll-up?:bool <- equal c, 19/ctrl-s 4140 break-unless scroll-up? 4141 <begin-move-cursor> -4142 go-render?:bool, editor <- line-up editor, screen-height +4142 go-render?:bool, editor <- line-up editor, screen-height 4143 undo-coalesce-tag:num <- copy 5/line-up 4144 <end-move-cursor> 4145 return go-render? 4146 } 4147 ] 4148 -4149 def line-up editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ +4149 def line-up editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 4150 local-scope 4151 load-inputs 4152 left:num <- get *editor, left:offset 4153 right:num <- get *editor, right:offset 4154 max:num <- subtract right, left -4155 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset -4156 new-top:&:duplex-list:char <- before-start-of-next-line old-top, max +4155 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +4156 new-top:&:duplex-list:char <- before-start-of-next-line old-top, max 4157 movement?:bool <- not-equal old-top, new-top 4158 { 4159 break-unless movement? @@ -4226,23 +4226,23 @@ if ('onhashchange' in window) { 4165 # ctrl-x - scroll down by one line 4166 # todo: scenarios 4167 -4168 after <handle-special-character> [ +4168 after <handle-special-character> [ 4169 { 4170 scroll-down?:bool <- equal c, 24/ctrl-x 4171 break-unless scroll-down? 4172 <begin-move-cursor> -4173 go-render?:bool, editor <- line-down editor, screen-height +4173 go-render?:bool, editor <- line-down editor, screen-height 4174 undo-coalesce-tag:num <- copy 6/line-down 4175 <end-move-cursor> 4176 return go-render? 4177 } 4178 ] 4179 -4180 def line-down editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ +4180 def line-down editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 4181 local-scope 4182 load-inputs -4183 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset -4184 new-top:&:duplex-list:char <- before-previous-screen-line old-top, editor +4183 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +4184 new-top:&:duplex-list:char <- before-previous-screen-line old-top, editor 4185 movement?:bool <- not-equal old-top, new-top 4186 { 4187 break-unless movement? @@ -4254,15 +4254,15 @@ if ('onhashchange' in window) { 4193 # ctrl-t - move current line to top of screen 4194 # todo: scenarios 4195 -4196 after <handle-special-character> [ +4196 after <handle-special-character> [ 4197 { 4198 scroll-down?:bool <- equal c, 20/ctrl-t 4199 break-unless scroll-down? 4200 <begin-move-cursor> -4201 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset -4202 cursor:&:duplex-list:char <- get *editor, before-cursor:offset -4203 cursor <- next cursor -4204 new-top:&:duplex-list:char <- before-previous-screen-line cursor, editor +4201 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +4202 cursor:&:duplex-list:char <- get *editor, before-cursor:offset +4203 cursor <- next cursor +4204 new-top:&:duplex-list:char <- before-previous-screen-line cursor, editor 4205 *editor <- put *editor, top-of-screen:offset, new-top 4206 *editor <- put *editor, cursor-row:offset, 1 4207 go-render?:bool <- not-equal new-top, old-top @@ -4274,23 +4274,23 @@ if ('onhashchange' in window) { 4213 4214 # ctrl-/ - comment/uncomment current line 4215 -4216 after <handle-special-character> [ +4216 after <handle-special-character> [ 4217 { 4218 comment-toggle?:bool <- equal c, 31/ctrl-slash 4219 break-unless comment-toggle? 4220 cursor-column:num <- get *editor, cursor-column:offset -4221 data:&:duplex-list:char <- get *editor, data:offset +4221 data:&:duplex-list:char <- get *editor, data:offset 4222 <begin-insert-character> -4223 before-line-start:&:duplex-list:char <- before-start-of-screen-line editor -4224 line-start:&:duplex-list:char <- next before-line-start -4225 commented-out?:bool <- match line-start, [#? ] # comment prefix +4223 before-line-start:&:duplex-list:char <- before-start-of-screen-line editor +4224 line-start:&:duplex-list:char <- next before-line-start +4225 commented-out?:bool <- match line-start, [#? ] # comment prefix 4226 { 4227 break-unless commented-out? 4228 # uncomment 4229 data <- remove line-start, 3/length-comment-prefix, data 4230 cursor-column <- subtract cursor-column, 3/length-comment-prefix 4231 *editor <- put *editor, cursor-column:offset, cursor-column -4232 go-render? <- render-line-from-start screen, editor, 3/size-of-comment-leader +4232 go-render? <- render-line-from-start screen, editor, 3/size-of-comment-leader 4233 } 4234 { 4235 break-if commented-out? @@ -4298,7 +4298,7 @@ if ('onhashchange' in window) { 4237 insert before-line-start, [#? ] 4238 cursor-column <- add cursor-column, 3/length-comment-prefix 4239 *editor <- put *editor, cursor-column:offset, cursor-column -4240 go-render? <- render-line-from-start screen, editor, 0 +4240 go-render? <- render-line-from-start screen, editor, 0 4241 } 4242 <end-insert-character> 4243 return @@ -4308,19 +4308,19 @@ if ('onhashchange' in window) { 4247 # Render just from the start of the current line, and only if it wasn't 4248 # wrapping before (include margin) and isn't wrapping now. Otherwise just tell 4249 # the caller to go-render? the entire screen. -4250 def render-line-from-start screen:&:screen, editor:&:editor, right-margin:num -> go-render?:bool, screen:&:screen [ +4250 def render-line-from-start screen:&:screen, editor:&:editor, right-margin:num -> go-render?:bool, screen:&:screen [ 4251 local-scope 4252 load-inputs -4253 before-line-start:&:duplex-list:char <- before-start-of-screen-line editor -4254 line-start:&:duplex-list:char <- next before-line-start +4253 before-line-start:&:duplex-list:char <- before-start-of-screen-line editor +4254 line-start:&:duplex-list:char <- next before-line-start 4255 color:num <- copy 7/white 4256 left:num <- get *editor, left:offset 4257 cursor-row:num <- get *editor, cursor-row:offset -4258 screen <- move-cursor screen, cursor-row, left +4258 screen <- move-cursor screen, cursor-row, left 4259 right:num <- get *editor, right:offset 4260 end:num <- subtract right, right-margin 4261 i:num <- copy 0 -4262 curr:&:duplex-list:char <- copy line-start +4262 curr:&:duplex-list:char <- copy line-start 4263 { 4264 render-all?:bool <- greater-or-equal i, end 4265 return-if render-all?, 1/go-render @@ -4328,39 +4328,39 @@ if ('onhashchange' in window) { 4267 c:char <- get *curr, value:offset 4268 newline?:bool <- equal c, 10/newline 4269 break-if newline? -4270 color <- get-color color, c -4271 print screen, c, color -4272 curr <- next curr +4270 color <- get-color color, c +4271 print screen, c, color +4272 curr <- next curr 4273 i <- add i, 1 4274 loop 4275 } -4276 clear-line-until screen, right +4276 clear-line-until screen, right 4277 return 0/dont-render 4278 ] 4279 -4280 def before-start-of-screen-line editor:&:editor -> result:&:duplex-list:char [ +4280 def before-start-of-screen-line editor:&:editor -> result:&:duplex-list:char [ 4281 local-scope 4282 load-inputs -4283 cursor:&:duplex-list:char <- get *editor, before-cursor:offset +4283 cursor:&:duplex-list:char <- get *editor, before-cursor:offset 4284 { -4285 next:&:duplex-list:char <- next cursor -4286 break-unless next -4287 cursor <- copy next +4285 next:&:duplex-list:char <- next cursor +4286 break-unless next +4287 cursor <- copy next 4288 } -4289 result <- before-previous-screen-line cursor, editor +4289 result <- before-previous-screen-line cursor, editor 4290 ] 4291 4292 scenario editor-comments-empty-line [ 4293 local-scope 4294 assume-screen 10/width, 5/height -4295 e:&:editor <- new-editor [], 0/left, 5/right -4296 editor-render screen, e +4295 e:&:editor <- new-editor [], 0/left, 5/right +4296 editor-render screen, e 4297 $clear-trace 4298 assume-console [ 4299 press ctrl-slash 4300 ] 4301 run [ -4302 editor-event-loop screen, console, e +4302 editor-event-loop screen, console, e 4303 4:num/raw <- get *e, cursor-row:offset 4304 5:num/raw <- get *e, cursor-column:offset 4305 ] @@ -4380,14 +4380,14 @@ if ('onhashchange' in window) { 4319 scenario editor-comments-at-start-of-contents [ 4320 local-scope 4321 assume-screen 10/width, 5/height -4322 e:&:editor <- new-editor [ab], 0/left, 10/right -4323 editor-render screen, e +4322 e:&:editor <- new-editor [ab], 0/left, 10/right +4323 editor-render screen, e 4324 $clear-trace 4325 assume-console [ 4326 press ctrl-slash 4327 ] 4328 run [ -4329 editor-event-loop screen, console, e +4329 editor-event-loop screen, console, e 4330 4:num/raw <- get *e, cursor-row:offset 4331 5:num/raw <- get *e, cursor-column:offset 4332 ] @@ -4407,15 +4407,15 @@ if ('onhashchange' in window) { 4346 scenario editor-comments-at-end-of-contents [ 4347 local-scope 4348 assume-screen 10/width, 5/height -4349 e:&:editor <- new-editor [ab], 0/left, 10/right -4350 editor-render screen, e +4349 e:&:editor <- new-editor [ab], 0/left, 10/right +4350 editor-render screen, e 4351 $clear-trace 4352 assume-console [ 4353 left-click 1, 7 4354 press ctrl-slash 4355 ] 4356 run [ -4357 editor-event-loop screen, console, e +4357 editor-event-loop screen, console, e 4358 4:num/raw <- get *e, cursor-row:offset 4359 5:num/raw <- get *e, cursor-column:offset 4360 ] @@ -4436,7 +4436,7 @@ if ('onhashchange' in window) { 4375 press ctrl-slash 4376 ] 4377 run [ -4378 editor-event-loop screen, console, e +4378 editor-event-loop screen, console, e 4379 4:num/raw <- get *e, cursor-row:offset 4380 5:num/raw <- get *e, cursor-column:offset 4381 ] @@ -4453,8 +4453,8 @@ if ('onhashchange' in window) { 4392 local-scope 4393 assume-screen 10/width, 5/height 4394 # editor starts out with a non-wrapping line -4395 e:&:editor <- new-editor [abcd], 0/left, 5/right -4396 editor-render screen, e +4395 e:&:editor <- new-editor [abcd], 0/left, 5/right +4396 editor-render screen, e 4397 screen-should-contain [ 4398 . . 4399 .abcd . @@ -4468,7 +4468,7 @@ if ('onhashchange' in window) { 4407 press ctrl-slash 4408 ] 4409 run [ -4410 editor-event-loop screen, console, e +4410 editor-event-loop screen, console, e 4411 ] 4412 screen-should-contain [ 4413 . . @@ -4483,8 +4483,8 @@ if ('onhashchange' in window) { 4422 local-scope 4423 assume-screen 10/width, 5/height 4424 # editor starts out with a comment that wraps the line -4425 e:&:editor <- new-editor [#? ab], 0/left, 5/right -4426 editor-render screen, e +4425 e:&:editor <- new-editor [#? ab], 0/left, 5/right +4426 editor-render screen, e 4427 screen-should-contain [ 4428 . . 4429 .#? a↩ . @@ -4499,7 +4499,7 @@ if ('onhashchange' in window) { 4438 press ctrl-slash 4439 ] 4440 run [ -4441 editor-event-loop screen, console, e +4441 editor-event-loop screen, console, e 4442 ] 4443 screen-should-contain [ 4444 . . -- cgit 1.4.1-2-gfad0