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/012-editor-undo.mu.html | 584 +++++++++++++++++++------------------- 1 file changed, 292 insertions(+), 292 deletions(-) (limited to 'html/edit/012-editor-undo.mu.html') diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index 08babb4a..2d798df6 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -64,34 +64,34 @@ if ('onhashchange' in window) { 2 3 # for every undoable event, create a type of *operation* that contains all the 4 # information needed to reverse it - 5 exclusive-container operation [ - 6 typing:insert-operation - 7 move:move-operation - 8 delete:delete-operation + 5 exclusive-container operation [ + 6 typing:insert-operation + 7 move:move-operation + 8 delete:delete-operation 9 ] 10 - 11 container insert-operation [ + 11 container insert-operation [ 12 before-row:num 13 before-column:num - 14 before-top-of-screen:&:duplex-list:char + 14 before-top-of-screen:&:duplex-list:char 15 after-row:num 16 after-column:num - 17 after-top-of-screen:&:duplex-list:char + 17 after-top-of-screen:&:duplex-list:char 18 # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate - 19 insert-from:&:duplex-list:char - 20 insert-until:&:duplex-list:char + 19 insert-from:&:duplex-list:char + 20 insert-until:&:duplex-list:char 21 tag:num # event causing this operation; might be used to coalesce runs of similar events 22 # 0: no coalesce (enter+indent) 23 # 1: regular alphanumeric characters 24 ] 25 - 26 container move-operation [ + 26 container move-operation [ 27 before-row:num 28 before-column:num - 29 before-top-of-screen:&:duplex-list:char + 29 before-top-of-screen:&:duplex-list:char 30 after-row:num 31 after-column:num - 32 after-top-of-screen:&:duplex-list:char + 32 after-top-of-screen:&:duplex-list:char 33 tag:num # event causing this operation; might be used to coalesce runs of similar events 34 # 0: no coalesce (touch events, etc) 35 # 1: left arrow @@ -102,16 +102,16 @@ if ('onhashchange' in window) { 40 # 6: line down 41 ] 42 - 43 container delete-operation [ + 43 container delete-operation [ 44 before-row:num 45 before-column:num - 46 before-top-of-screen:&:duplex-list:char + 46 before-top-of-screen:&:duplex-list:char 47 after-row:num 48 after-column:num - 49 after-top-of-screen:&:duplex-list:char - 50 deleted-text:&:duplex-list:char - 51 delete-from:&:duplex-list:char - 52 delete-until:&:duplex-list:char + 49 after-top-of-screen:&:duplex-list:char + 50 deleted-text:&:duplex-list:char + 51 delete-from:&:duplex-list:char + 52 delete-until:&:duplex-list:char 53 tag:num # event causing this operation; might be used to coalesce runs of similar events 54 # 0: no coalesce (ctrl-k, ctrl-u) 55 # 1: backspace @@ -120,42 +120,42 @@ if ('onhashchange' in window) { 58 59 # every editor accumulates a list of operations to undo/redo 60 container editor [ - 61 undo:&:list:&:operation - 62 redo:&:list:&:operation + 61 undo:&:list:&:operation + 62 redo:&:list:&:operation 63 ] 64 65 # ctrl-z - undo operation - 66 after <handle-special-character> [ + 66 after <handle-special-character> [ 67 { 68 undo?:bool <- equal c, 26/ctrl-z 69 break-unless undo? - 70 undo:&:list:&:operation <- get *editor, undo:offset + 70 undo:&:list:&:operation <- get *editor, undo:offset 71 break-unless undo - 72 op:&:operation <- first undo - 73 undo <- rest undo + 72 op:&:operation <- first undo + 73 undo <- rest undo 74 *editor <- put *editor, undo:offset, undo - 75 redo:&:list:&:operation <- get *editor, redo:offset + 75 redo:&:list:&:operation <- get *editor, redo:offset 76 redo <- push op, redo 77 *editor <- put *editor, redo:offset, redo - 78 <handle-undo> + 78 <handle-undo> 79 return 1/go-render 80 } 81 ] 82 83 # ctrl-y - redo operation - 84 after <handle-special-character> [ + 84 after <handle-special-character> [ 85 { 86 redo?:bool <- equal c, 25/ctrl-y 87 break-unless redo? - 88 redo:&:list:&:operation <- get *editor, redo:offset + 88 redo:&:list:&:operation <- get *editor, redo:offset 89 break-unless redo - 90 op:&:operation <- first redo - 91 redo <- rest redo + 90 op:&:operation <- first redo + 91 redo <- rest redo 92 *editor <- put *editor, redo:offset, redo - 93 undo:&:list:&:operation <- get *editor, undo:offset + 93 undo:&:list:&:operation <- get *editor, undo:offset 94 undo <- push op, undo 95 *editor <- put *editor, undo:offset, undo - 96 <handle-redo> + 96 <handle-redo> 97 return 1/go-render 98 } 99 ] @@ -166,18 +166,18 @@ if ('onhashchange' in window) { 104 local-scope 105 # create an editor and type a character 106 assume-screen 10/width, 5/height - 107 e:&:editor <- new-editor [], 0/left, 10/right - 108 editor-render screen, e + 107 e:&:editor <- new-editor [], 0/left, 10/right + 108 editor-render screen, e 109 assume-console [ 110 type [0] 111 ] - 112 editor-event-loop screen, console, e + 112 editor-event-loop screen, console, e 113 # undo 114 assume-console [ 115 press ctrl-z 116 ] 117 run [ - 118 editor-event-loop screen, console, e + 118 editor-event-loop screen, console, e 119 ] 120 # character should be gone 121 screen-should-contain [ @@ -191,7 +191,7 @@ if ('onhashchange' in window) { 129 type [1] 130 ] 131 run [ - 132 editor-event-loop screen, console, e + 132 editor-event-loop screen, console, e 133 ] 134 screen-should-contain [ 135 . . @@ -203,24 +203,24 @@ if ('onhashchange' in window) { 141 142 # save operation to undo 143 after <begin-insert-character> [ - 144 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset - 145 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset + 144 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + 145 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset 146 ] 147 before <end-insert-character> [ - 148 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + 148 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 149 cursor-row:num <- get *editor, cursor-row:offset 150 cursor-column:num <- get *editor, cursor-column:offset - 151 undo:&:list:&:operation <- get *editor, undo:offset + 151 undo:&:list:&:operation <- get *editor, undo:offset 152 { 153 # if previous operation was an insert, coalesce this operation with it 154 break-unless undo - 155 op:&:operation <- first undo - 156 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant + 155 op:&:operation <- first undo + 156 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 157 break-unless is-insert? 158 previous-coalesce-tag:num <- get typing, tag:offset 159 break-unless previous-coalesce-tag - 160 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 161 insert-until:&:duplex-list:char <- next before-cursor + 160 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 161 insert-until:&:duplex-list:char <- next before-cursor 162 typing <- put typing, insert-until:offset, insert-until 163 typing <- put typing, after-row:offset, cursor-row 164 typing <- put typing, after-column:offset, cursor-column @@ -229,64 +229,64 @@ if ('onhashchange' in window) { 167 break +done-adding-insert-operation 168 } 169 # if not, create a new operation - 170 insert-from:&:duplex-list:char <- next cursor-before - 171 insert-to:&:duplex-list:char <- next insert-from - 172 op:&:operation <- new operation:type + 170 insert-from:&:duplex-list:char <- next cursor-before + 171 insert-to:&:duplex-list:char <- next insert-from + 172 op:&:operation <- new operation:type 173 *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 1/coalesce - 174 editor <- add-operation editor, op + 174 editor <- add-operation editor, op 175 +done-adding-insert-operation 176 ] 177 178 # enter operations never coalesce with typing before or after - 179 after <begin-insert-enter> [ + 179 after <begin-insert-enter> [ 180 cursor-row-before:num <- copy cursor-row 181 cursor-column-before:num <- copy cursor-column - 182 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset - 183 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset + 182 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + 183 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset 184 ] - 185 before <end-insert-enter> [ - 186 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + 185 before <end-insert-enter> [ + 186 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 187 cursor-row:num <- get *editor, cursor-row:offset 188 cursor-column:num <- get *editor, cursor-row:offset 189 # never coalesce - 190 insert-from:&:duplex-list:char <- next cursor-before - 191 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 192 insert-to:&:duplex-list:char <- next before-cursor - 193 op:&:operation <- new operation:type + 190 insert-from:&:duplex-list:char <- next cursor-before + 191 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 192 insert-to:&:duplex-list:char <- next before-cursor + 193 op:&:operation <- new operation:type 194 *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce - 195 editor <- add-operation editor, op + 195 editor <- add-operation editor, op 196 ] 197 198 # Everytime you add a new operation to the undo stack, be sure to clear the 199 # redo stack, because it's now obsolete. 200 # Beware: since we're counting cursor moves as operations, this means just 201 # moving the cursor can lose work on the undo stack. - 202 def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ + 202 def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ 203 local-scope 204 load-inputs - 205 undo:&:list:&:operation <- get *editor, undo:offset + 205 undo:&:list:&:operation <- get *editor, undo:offset 206 undo <- push op undo 207 *editor <- put *editor, undo:offset, undo - 208 redo:&:list:&:operation <- get *editor, redo:offset + 208 redo:&:list:&:operation <- get *editor, redo:offset 209 redo <- copy 0 210 *editor <- put *editor, redo:offset, redo 211 ] 212 - 213 after <handle-undo> [ + 213 after <handle-undo> [ 214 { - 215 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant + 215 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 216 break-unless is-insert? - 217 start:&:duplex-list:char <- get typing, insert-from:offset - 218 end:&:duplex-list:char <- get typing, insert-until:offset + 217 start:&:duplex-list:char <- get typing, insert-from:offset + 218 end:&:duplex-list:char <- get typing, insert-until:offset 219 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - 220 before-cursor:&:duplex-list:char <- prev start + 220 before-cursor:&:duplex-list:char <- prev start 221 *editor <- put *editor, before-cursor:offset, before-cursor - 222 remove-between before-cursor, end + 222 remove-between before-cursor, end 223 cursor-row <- get typing, before-row:offset 224 *editor <- put *editor, cursor-row:offset, cursor-row 225 cursor-column <- get typing, before-column:offset 226 *editor <- put *editor, cursor-column:offset, cursor-column - 227 top:&:duplex-list:char <- get typing, before-top-of-screen:offset + 227 top:&:duplex-list:char <- get typing, before-top-of-screen:offset 228 *editor <- put *editor, top-of-screen:offset, top 229 } 230 ] @@ -295,18 +295,18 @@ if ('onhashchange' in window) { 233 local-scope 234 # create an editor and type multiple characters 235 assume-screen 10/width, 5/height - 236 e:&:editor <- new-editor [], 0/left, 10/right - 237 editor-render screen, e + 236 e:&:editor <- new-editor [], 0/left, 10/right + 237 editor-render screen, e 238 assume-console [ 239 type [012] 240 ] - 241 editor-event-loop screen, console, e + 241 editor-event-loop screen, console, e 242 # undo 243 assume-console [ 244 press ctrl-z 245 ] 246 run [ - 247 editor-event-loop screen, console, e + 247 editor-event-loop screen, console, e 248 ] 249 # all characters must be gone 250 screen-should-contain [ @@ -321,13 +321,13 @@ if ('onhashchange' in window) { 259 local-scope 260 # create an editor with some text 261 assume-screen 10/width, 5/height - 262 e:&:editor <- new-editor [a], 0/left, 10/right - 263 editor-render screen, e + 262 e:&:editor <- new-editor [a], 0/left, 10/right + 263 editor-render screen, e 264 # type some characters 265 assume-console [ 266 type [012] 267 ] - 268 editor-event-loop screen, console, e + 268 editor-event-loop screen, console, e 269 screen-should-contain [ 270 . . 271 .012a . @@ -339,7 +339,7 @@ if ('onhashchange' in window) { 277 press ctrl-z 278 ] 279 run [ - 280 editor-event-loop screen, console, e + 280 editor-event-loop screen, console, e 281 ] 282 # back to original text 283 screen-should-contain [ @@ -353,7 +353,7 @@ if ('onhashchange' in window) { 291 type [3] 292 ] 293 run [ - 294 editor-event-loop screen, console, e + 294 editor-event-loop screen, console, e 295 ] 296 screen-should-contain [ 297 . . @@ -367,14 +367,14 @@ if ('onhashchange' in window) { 305 local-scope 306 # create an editor with some text 307 assume-screen 10/width, 5/height - 308 e:&:editor <- new-editor [ abc], 0/left, 10/right - 309 editor-render screen, e + 308 e:&:editor <- new-editor [ abc], 0/left, 10/right + 309 editor-render screen, e 310 # new line 311 assume-console [ 312 left-click 1, 8 313 press enter 314 ] - 315 editor-event-loop screen, console, e + 315 editor-event-loop screen, console, e 316 screen-should-contain [ 317 . . 318 . abc . @@ -394,7 +394,7 @@ if ('onhashchange' in window) { 332 press ctrl-z 333 ] 334 run [ - 335 editor-event-loop screen, console, e + 335 editor-event-loop screen, console, e 336 ] 337 3:num/raw <- get *e, cursor-row:offset 338 4:num/raw <- get *e, cursor-column:offset @@ -414,7 +414,7 @@ if ('onhashchange' in window) { 352 type [1] 353 ] 354 run [ - 355 editor-event-loop screen, console, e + 355 editor-event-loop screen, console, e 356 ] 357 screen-should-contain [ 358 . . @@ -430,13 +430,13 @@ if ('onhashchange' in window) { 368 local-scope 369 # create an editor, type something, undo 370 assume-screen 10/width, 5/height - 371 e:&:editor <- new-editor [a], 0/left, 10/right - 372 editor-render screen, e + 371 e:&:editor <- new-editor [a], 0/left, 10/right + 372 editor-render screen, e 373 assume-console [ 374 type [012] 375 press ctrl-z 376 ] - 377 editor-event-loop screen, console, e + 377 editor-event-loop screen, console, e 378 screen-should-contain [ 379 . . 380 .a . @@ -448,7 +448,7 @@ if ('onhashchange' in window) { 386 press ctrl-y 387 ] 388 run [ - 389 editor-event-loop screen, console, e + 389 editor-event-loop screen, console, e 390 ] 391 # all characters must be back 392 screen-should-contain [ @@ -462,7 +462,7 @@ if ('onhashchange' in window) { 400 type [3] 401 ] 402 run [ - 403 editor-event-loop screen, console, e + 403 editor-event-loop screen, console, e 404 ] 405 screen-should-contain [ 406 . . @@ -472,20 +472,20 @@ if ('onhashchange' in window) { 410 ] 411 ] 412 - 413 after <handle-redo> [ + 413 after <handle-redo> [ 414 { - 415 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant + 415 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 416 break-unless is-insert? 417 before-cursor <- get *editor, before-cursor:offset - 418 insert-from:&:duplex-list:char <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away + 418 insert-from:&:duplex-list:char <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away 419 # assert insert-to matches next(before-cursor) - 420 splice before-cursor, insert-from + 420 splice before-cursor, insert-from 421 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 422 cursor-row <- get typing, after-row:offset 423 *editor <- put *editor, cursor-row:offset, cursor-row 424 cursor-column <- get typing, after-column:offset 425 *editor <- put *editor, cursor-column:offset, cursor-column - 426 top:&:duplex-list:char <- get typing, after-top-of-screen:offset + 426 top:&:duplex-list:char <- get typing, after-top-of-screen:offset 427 *editor <- put *editor, top-of-screen:offset, top 428 } 429 ] @@ -494,13 +494,13 @@ if ('onhashchange' in window) { 432 local-scope 433 # create an editor, type something, undo 434 assume-screen 10/width, 5/height - 435 e:&:editor <- new-editor [], 0/left, 10/right - 436 editor-render screen, e + 435 e:&:editor <- new-editor [], 0/left, 10/right + 436 editor-render screen, e 437 assume-console [ 438 type [012] 439 press ctrl-z 440 ] - 441 editor-event-loop screen, console, e + 441 editor-event-loop screen, console, e 442 screen-should-contain [ 443 . . 444 . . @@ -512,7 +512,7 @@ if ('onhashchange' in window) { 450 press ctrl-y 451 ] 452 run [ - 453 editor-event-loop screen, console, e + 453 editor-event-loop screen, console, e 454 ] 455 # all characters must be back 456 screen-should-contain [ @@ -526,7 +526,7 @@ if ('onhashchange' in window) { 464 type [3] 465 ] 466 run [ - 467 editor-event-loop screen, console, e + 467 editor-event-loop screen, console, e 468 ] 469 screen-should-contain [ 470 . . @@ -543,18 +543,18 @@ if ('onhashchange' in window) { 481 contents:text <- new [abc 482 def 483 ghi] - 484 e:&:editor <- new-editor contents, 0/left, 10/right - 485 editor-render screen, e + 484 e:&:editor <- new-editor contents, 0/left, 10/right + 485 editor-render screen, e 486 assume-console [ 487 type [1] 488 press ctrl-z 489 ] - 490 editor-event-loop screen, console, e + 490 editor-event-loop screen, console, e 491 # do some more work 492 assume-console [ 493 type [0] 494 ] - 495 editor-event-loop screen, console, e + 495 editor-event-loop screen, console, e 496 screen-should-contain [ 497 . . 498 .0abc . @@ -567,7 +567,7 @@ if ('onhashchange' in window) { 505 press ctrl-y 506 ] 507 run [ - 508 editor-event-loop screen, console, e + 508 editor-event-loop screen, console, e 509 ] 510 # nothing should happen 511 screen-should-contain [ @@ -583,8 +583,8 @@ if ('onhashchange' in window) { 521 local-scope 522 # create an editor 523 assume-screen 10/width, 5/height - 524 e:&:editor <- new-editor [], 0/left, 10/right - 525 editor-render screen, e + 524 e:&:editor <- new-editor [], 0/left, 10/right + 525 editor-render screen, e 526 # insert some text and tabs, hit enter, some more text and tabs 527 assume-console [ 528 press tab @@ -595,7 +595,7 @@ if ('onhashchange' in window) { 533 press tab 534 type [efg] 535 ] - 536 editor-event-loop screen, console, e + 536 editor-event-loop screen, console, e 537 screen-should-contain [ 538 . . 539 . ab cd . @@ -614,7 +614,7 @@ if ('onhashchange' in window) { 552 press ctrl-z 553 ] 554 run [ - 555 editor-event-loop screen, console, e + 555 editor-event-loop screen, console, e 556 ] 557 # typing in second line deleted, but not indent 558 3:num/raw <- get *e, cursor-row:offset @@ -635,7 +635,7 @@ if ('onhashchange' in window) { 573 press ctrl-z 574 ] 575 run [ - 576 editor-event-loop screen, console, e + 576 editor-event-loop screen, console, e 577 ] 578 # indent and newline deleted 579 3:num/raw <- get *e, cursor-row:offset @@ -655,7 +655,7 @@ if ('onhashchange' in window) { 593 press ctrl-z 594 ] 595 run [ - 596 editor-event-loop screen, console, e + 596 editor-event-loop screen, console, e 597 ] 598 # empty screen 599 3:num/raw <- get *e, cursor-row:offset @@ -675,7 +675,7 @@ if ('onhashchange' in window) { 613 press ctrl-y 614 ] 615 run [ - 616 editor-event-loop screen, console, e + 616 editor-event-loop screen, console, e 617 ] 618 # first line inserted 619 3:num/raw <- get *e, cursor-row:offset @@ -695,7 +695,7 @@ if ('onhashchange' in window) { 633 press ctrl-y 634 ] 635 run [ - 636 editor-event-loop screen, console, e + 636 editor-event-loop screen, console, e 637 ] 638 # newline and indent inserted 639 3:num/raw <- get *e, cursor-row:offset @@ -716,7 +716,7 @@ if ('onhashchange' in window) { 654 press ctrl-y 655 ] 656 run [ - 657 editor-event-loop screen, console, e + 657 editor-event-loop screen, console, e 658 ] 659 # indent and newline deleted 660 3:num/raw <- get *e, cursor-row:offset @@ -743,19 +743,19 @@ if ('onhashchange' in window) { 681 contents:text <- new [abc 682 def 683 ghi] - 684 e:&:editor <- new-editor contents, 0/left, 10/right - 685 editor-render screen, e + 684 e:&:editor <- new-editor contents, 0/left, 10/right + 685 editor-render screen, e 686 # move the cursor 687 assume-console [ 688 left-click 3, 1 689 ] - 690 editor-event-loop screen, console, e + 690 editor-event-loop screen, console, e 691 # undo 692 assume-console [ 693 press ctrl-z 694 ] 695 run [ - 696 editor-event-loop screen, console, e + 696 editor-event-loop screen, console, e 697 ] 698 # click undone 699 3:num/raw <- get *e, cursor-row:offset @@ -769,7 +769,7 @@ if ('onhashchange' in window) { 707 type [1] 708 ] 709 run [ - 710 editor-event-loop screen, console, e + 710 editor-event-loop screen, console, e 711 ] 712 screen-should-contain [ 713 . . @@ -783,20 +783,20 @@ if ('onhashchange' in window) { 721 after <begin-move-cursor> [ 722 cursor-row-before:num <- get *editor, cursor-row:offset 723 cursor-column-before:num <- get *editor, cursor-column:offset - 724 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + 724 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 725 ] 726 before <end-move-cursor> [ - 727 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + 727 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 728 cursor-row:num <- get *editor, cursor-row:offset 729 cursor-column:num <- get *editor, cursor-column:offset 730 { 731 break-unless undo-coalesce-tag 732 # if previous operation was also a move, and also had the same coalesce 733 # tag, coalesce with it - 734 undo:&:list:&:operation <- get *editor, undo:offset + 734 undo:&:list:&:operation <- get *editor, undo:offset 735 break-unless undo - 736 op:&:operation <- first undo - 737 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant + 736 op:&:operation <- first undo + 737 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant 738 break-unless is-move? 739 previous-coalesce-tag:num <- get move, tag:offset 740 coalesce?:bool <- equal undo-coalesce-tag, previous-coalesce-tag @@ -807,22 +807,22 @@ if ('onhashchange' in window) { 745 *op <- merge 1/move-operation, move 746 break +done-adding-move-operation 747 } - 748 op:&:operation <- new operation:type + 748 op:&:operation <- new operation:type 749 *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag - 750 editor <- add-operation editor, op + 750 editor <- add-operation editor, op 751 +done-adding-move-operation 752 ] 753 - 754 after <handle-undo> [ + 754 after <handle-undo> [ 755 { - 756 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant + 756 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant 757 break-unless is-move? 758 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 759 cursor-row <- get move, before-row:offset 760 *editor <- put *editor, cursor-row:offset, cursor-row 761 cursor-column <- get move, before-column:offset 762 *editor <- put *editor, cursor-column:offset, cursor-column - 763 top:&:duplex-list:char <- get move, before-top-of-screen:offset + 763 top:&:duplex-list:char <- get move, before-top-of-screen:offset 764 *editor <- put *editor, top-of-screen:offset, top 765 } 766 ] @@ -835,13 +835,13 @@ if ('onhashchange' in window) { 773 contents:text <- new [a 774 b 775 cdefgh] - 776 e:&:editor <- new-editor contents, 0/left, 5/right + 776 e:&:editor <- new-editor contents, 0/left, 5/right 777 # position cursor at end of screen and try to move right 778 assume-console [ 779 left-click 3, 3 780 press right-arrow 781 ] - 782 editor-event-loop screen, console, e + 782 editor-event-loop screen, console, e 783 3:num/raw <- get *e, cursor-row:offset 784 4:num/raw <- get *e, cursor-column:offset 785 # screen scrolls @@ -860,7 +860,7 @@ if ('onhashchange' in window) { 798 press ctrl-z 799 ] 800 run [ - 801 editor-event-loop screen, console, e + 801 editor-event-loop screen, console, e 802 ] 803 # cursor moved back 804 3:num/raw <- get *e, cursor-row:offset @@ -881,7 +881,7 @@ if ('onhashchange' in window) { 819 type [1] 820 ] 821 run [ - 822 editor-event-loop screen, console, e + 822 editor-event-loop screen, console, e 823 ] 824 screen-should-contain [ 825 . . @@ -898,20 +898,20 @@ if ('onhashchange' in window) { 836 contents:text <- new [abc 837 def 838 ghi] - 839 e:&:editor <- new-editor contents, 0/left, 10/right - 840 editor-render screen, e + 839 e:&:editor <- new-editor contents, 0/left, 10/right + 840 editor-render screen, e 841 # move the cursor 842 assume-console [ 843 left-click 3, 1 844 press left-arrow 845 ] - 846 editor-event-loop screen, console, e + 846 editor-event-loop screen, console, e 847 # undo 848 assume-console [ 849 press ctrl-z 850 ] 851 run [ - 852 editor-event-loop screen, console, e + 852 editor-event-loop screen, console, e 853 ] 854 # cursor moves back 855 3:num/raw <- get *e, cursor-row:offset @@ -925,7 +925,7 @@ if ('onhashchange' in window) { 863 type [1] 864 ] 865 run [ - 866 editor-event-loop screen, console, e + 866 editor-event-loop screen, console, e 867 ] 868 screen-should-contain [ 869 . . @@ -943,14 +943,14 @@ if ('onhashchange' in window) { 881 contents:text <- new [abc 882 def 883 ghi] - 884 e:&:editor <- new-editor contents, 0/left, 10/right - 885 editor-render screen, e + 884 e:&:editor <- new-editor contents, 0/left, 10/right + 885 editor-render screen, e 886 # move the cursor 887 assume-console [ 888 left-click 3, 1 889 press up-arrow 890 ] - 891 editor-event-loop screen, console, e + 891 editor-event-loop screen, console, e 892 3:num/raw <- get *e, cursor-row:offset 893 4:num/raw <- get *e, cursor-column:offset 894 memory-should-contain [ @@ -962,7 +962,7 @@ if ('onhashchange' in window) { 900 press ctrl-z 901 ] 902 run [ - 903 editor-event-loop screen, console, e + 903 editor-event-loop screen, console, e 904 ] 905 # cursor moves back 906 3:num/raw <- get *e, cursor-row:offset @@ -976,7 +976,7 @@ if ('onhashchange' in window) { 914 type [1] 915 ] 916 run [ - 917 editor-event-loop screen, console, e + 917 editor-event-loop screen, console, e 918 ] 919 screen-should-contain [ 920 . . @@ -994,20 +994,20 @@ if ('onhashchange' in window) { 932 contents:text <- new [abc 933 def 934 ghi] - 935 e:&:editor <- new-editor contents, 0/left, 10/right - 936 editor-render screen, e + 935 e:&:editor <- new-editor contents, 0/left, 10/right + 936 editor-render screen, e 937 # move the cursor 938 assume-console [ 939 left-click 2, 1 940 press down-arrow 941 ] - 942 editor-event-loop screen, console, e + 942 editor-event-loop screen, console, e 943 # undo 944 assume-console [ 945 press ctrl-z 946 ] 947 run [ - 948 editor-event-loop screen, console, e + 948 editor-event-loop screen, console, e 949 ] 950 # cursor moves back 951 3:num/raw <- get *e, cursor-row:offset @@ -1021,7 +1021,7 @@ if ('onhashchange' in window) { 959 type [1] 960 ] 961 run [ - 962 editor-event-loop screen, console, e + 962 editor-event-loop screen, console, e 963 ] 964 screen-should-contain [ 965 . . @@ -1042,19 +1042,19 @@ if ('onhashchange' in window) { 980 d 981 e 982 f] - 983 e:&:editor <- new-editor contents, 0/left, 10/right - 984 editor-render screen, e + 983 e:&:editor <- new-editor contents, 0/left, 10/right + 984 editor-render screen, e 985 # scroll the page 986 assume-console [ 987 press ctrl-f 988 ] - 989 editor-event-loop screen, console, e + 989 editor-event-loop screen, console, e 990 # undo 991 assume-console [ 992 press ctrl-z 993 ] 994 run [ - 995 editor-event-loop screen, console, e + 995 editor-event-loop screen, console, e 996 ] 997 # screen should again show page 1 998 screen-should-contain [ @@ -1076,19 +1076,19 @@ if ('onhashchange' in window) { 1014 d 1015 e 1016 f] -1017 e:&:editor <- new-editor contents, 0/left, 10/right -1018 editor-render screen, e +1017 e:&:editor <- new-editor contents, 0/left, 10/right +1018 editor-render screen, e 1019 # scroll the page 1020 assume-console [ -1021 press page-down +1021 press page-down 1022 ] -1023 editor-event-loop screen, console, e +1023 editor-event-loop screen, console, e 1024 # undo 1025 assume-console [ 1026 press ctrl-z 1027 ] 1028 run [ -1029 editor-event-loop screen, console, e +1029 editor-event-loop screen, console, e 1030 ] 1031 # screen should again show page 1 1032 screen-should-contain [ @@ -1110,20 +1110,20 @@ if ('onhashchange' in window) { 1048 d 1049 e 1050 f] -1051 e:&:editor <- new-editor contents, 0/left, 10/right -1052 editor-render screen, e +1051 e:&:editor <- new-editor contents, 0/left, 10/right +1052 editor-render screen, e 1053 # scroll the page down and up 1054 assume-console [ -1055 press page-down +1055 press page-down 1056 press ctrl-b 1057 ] -1058 editor-event-loop screen, console, e +1058 editor-event-loop screen, console, e 1059 # undo 1060 assume-console [ 1061 press ctrl-z 1062 ] 1063 run [ -1064 editor-event-loop screen, console, e +1064 editor-event-loop screen, console, e 1065 ] 1066 # screen should again show page 2 1067 screen-should-contain [ @@ -1145,20 +1145,20 @@ if ('onhashchange' in window) { 1083 d 1084 e 1085 f] -1086 e:&:editor <- new-editor contents, 0/left, 10/right -1087 editor-render screen, e +1086 e:&:editor <- new-editor contents, 0/left, 10/right +1087 editor-render screen, e 1088 # scroll the page down and up 1089 assume-console [ -1090 press page-down -1091 press page-up +1090 press page-down +1091 press page-up 1092 ] -1093 editor-event-loop screen, console, e +1093 editor-event-loop screen, console, e 1094 # undo 1095 assume-console [ 1096 press ctrl-z 1097 ] 1098 run [ -1099 editor-event-loop screen, console, e +1099 editor-event-loop screen, console, e 1100 ] 1101 # screen should again show page 2 1102 screen-should-contain [ @@ -1177,20 +1177,20 @@ if ('onhashchange' in window) { 1115 contents:text <- new [abc 1116 def 1117 ghi] -1118 e:&:editor <- new-editor contents, 0/left, 10/right -1119 editor-render screen, e +1118 e:&:editor <- new-editor contents, 0/left, 10/right +1119 editor-render screen, e 1120 # move the cursor, then to start of line 1121 assume-console [ 1122 left-click 2, 1 1123 press ctrl-a 1124 ] -1125 editor-event-loop screen, console, e +1125 editor-event-loop screen, console, e 1126 # undo 1127 assume-console [ 1128 press ctrl-z 1129 ] 1130 run [ -1131 editor-event-loop screen, console, e +1131 editor-event-loop screen, console, e 1132 ] 1133 # cursor moves back 1134 3:num/raw <- get *e, cursor-row:offset @@ -1204,7 +1204,7 @@ if ('onhashchange' in window) { 1142 type [1] 1143 ] 1144 run [ -1145 editor-event-loop screen, console, e +1145 editor-event-loop screen, console, e 1146 ] 1147 screen-should-contain [ 1148 . . @@ -1222,20 +1222,20 @@ if ('onhashchange' in window) { 1160 contents:text <- new [abc 1161 def 1162 ghi] -1163 e:&:editor <- new-editor contents, 0/left, 10/right -1164 editor-render screen, e +1163 e:&:editor <- new-editor contents, 0/left, 10/right +1164 editor-render screen, e 1165 # move the cursor, then to start of line 1166 assume-console [ 1167 left-click 2, 1 1168 press home 1169 ] -1170 editor-event-loop screen, console, e +1170 editor-event-loop screen, console, e 1171 # undo 1172 assume-console [ 1173 press ctrl-z 1174 ] 1175 run [ -1176 editor-event-loop screen, console, e +1176 editor-event-loop screen, console, e 1177 ] 1178 # cursor moves back 1179 3:num/raw <- get *e, cursor-row:offset @@ -1249,7 +1249,7 @@ if ('onhashchange' in window) { 1187 type [1] 1188 ] 1189 run [ -1190 editor-event-loop screen, console, e +1190 editor-event-loop screen, console, e 1191 ] 1192 screen-should-contain [ 1193 . . @@ -1267,20 +1267,20 @@ if ('onhashchange' in window) { 1205 contents:text <- new [abc 1206 def 1207 ghi] -1208 e:&:editor <- new-editor contents, 0/left, 10/right -1209 editor-render screen, e +1208 e:&:editor <- new-editor contents, 0/left, 10/right +1209 editor-render screen, e 1210 # move the cursor, then to start of line 1211 assume-console [ 1212 left-click 2, 1 1213 press ctrl-e 1214 ] -1215 editor-event-loop screen, console, e +1215 editor-event-loop screen, console, e 1216 # undo 1217 assume-console [ 1218 press ctrl-z 1219 ] 1220 run [ -1221 editor-event-loop screen, console, e +1221 editor-event-loop screen, console, e 1222 ] 1223 # cursor moves back 1224 3:num/raw <- get *e, cursor-row:offset @@ -1294,7 +1294,7 @@ if ('onhashchange' in window) { 1232 type [1] 1233 ] 1234 run [ -1235 editor-event-loop screen, console, e +1235 editor-event-loop screen, console, e 1236 ] 1237 screen-should-contain [ 1238 . . @@ -1312,20 +1312,20 @@ if ('onhashchange' in window) { 1250 contents:text <- new [abc 1251 def 1252 ghi] -1253 e:&:editor <- new-editor contents, 0/left, 10/right -1254 editor-render screen, e +1253 e:&:editor <- new-editor contents, 0/left, 10/right +1254 editor-render screen, e 1255 # move the cursor, then to start of line 1256 assume-console [ 1257 left-click 2, 1 1258 press end 1259 ] -1260 editor-event-loop screen, console, e +1260 editor-event-loop screen, console, e 1261 # undo 1262 assume-console [ 1263 press ctrl-z 1264 ] 1265 run [ -1266 editor-event-loop screen, console, e +1266 editor-event-loop screen, console, e 1267 ] 1268 # cursor moves back 1269 3:num/raw <- get *e, cursor-row:offset @@ -1339,7 +1339,7 @@ if ('onhashchange' in window) { 1277 type [1] 1278 ] 1279 run [ -1280 editor-event-loop screen, console, e +1280 editor-event-loop screen, console, e 1281 ] 1282 screen-should-contain [ 1283 . . @@ -1357,8 +1357,8 @@ if ('onhashchange' in window) { 1295 contents:text <- new [abc 1296 def 1297 ghi] -1298 e:&:editor <- new-editor contents, 0/left, 10/right -1299 editor-render screen, e +1298 e:&:editor <- new-editor contents, 0/left, 10/right +1299 editor-render screen, e 1300 # move the cursor 1301 assume-console [ 1302 left-click 2, 1 @@ -1366,7 +1366,7 @@ if ('onhashchange' in window) { 1304 press right-arrow 1305 press up-arrow 1306 ] -1307 editor-event-loop screen, console, e +1307 editor-event-loop screen, console, e 1308 3:num/raw <- get *e, cursor-row:offset 1309 4:num/raw <- get *e, cursor-column:offset 1310 memory-should-contain [ @@ -1378,7 +1378,7 @@ if ('onhashchange' in window) { 1316 press ctrl-z 1317 ] 1318 run [ -1319 editor-event-loop screen, console, e +1319 editor-event-loop screen, console, e 1320 ] 1321 # up-arrow is undone 1322 3:num/raw <- get *e, cursor-row:offset @@ -1392,7 +1392,7 @@ if ('onhashchange' in window) { 1330 press ctrl-z 1331 ] 1332 run [ -1333 editor-event-loop screen, console, e +1333 editor-event-loop screen, console, e 1334 ] 1335 # both right-arrows are undone 1336 3:num/raw <- get *e, cursor-row:offset @@ -1412,19 +1412,19 @@ if ('onhashchange' in window) { 1350 contents:text <- new [abc 1351 def 1352 ghi] -1353 e:&:editor <- new-editor contents, 0/left, 10/right -1354 editor-render screen, e +1353 e:&:editor <- new-editor contents, 0/left, 10/right +1354 editor-render screen, e 1355 assume-console [ 1356 left-click 3, 1 1357 press ctrl-z 1358 ] -1359 editor-event-loop screen, console, e +1359 editor-event-loop screen, console, e 1360 # redo 1361 assume-console [ 1362 press ctrl-y 1363 ] 1364 run [ -1365 editor-event-loop screen, console, e +1365 editor-event-loop screen, console, e 1366 ] 1367 # cursor moves to left-click 1368 3:num/raw <- get *e, cursor-row:offset @@ -1438,7 +1438,7 @@ if ('onhashchange' in window) { 1376 type [1] 1377 ] 1378 run [ -1379 editor-event-loop screen, console, e +1379 editor-event-loop screen, console, e 1380 ] 1381 screen-should-contain [ 1382 . . @@ -1449,16 +1449,16 @@ if ('onhashchange' in window) { 1387 ] 1388 ] 1389 -1390 after <handle-redo> [ +1390 after <handle-redo> [ 1391 { -1392 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant +1392 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant 1393 break-unless is-move? 1394 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1395 cursor-row <- get move, after-row:offset 1396 *editor <- put *editor, cursor-row:offset, cursor-row 1397 cursor-column <- get move, after-column:offset 1398 *editor <- put *editor, cursor-column:offset, cursor-column -1399 top:&:duplex-list:char <- get move, after-top-of-screen:offset +1399 top:&:duplex-list:char <- get move, after-top-of-screen:offset 1400 *editor <- put *editor, top-of-screen:offset, top 1401 } 1402 ] @@ -1467,14 +1467,14 @@ if ('onhashchange' in window) { 1405 local-scope 1406 # create an editor, type some text, move the cursor, type some more text 1407 assume-screen 10/width, 5/height -1408 e:&:editor <- new-editor [], 0/left, 10/right -1409 editor-render screen, e +1408 e:&:editor <- new-editor [], 0/left, 10/right +1409 editor-render screen, e 1410 assume-console [ 1411 type [abc] 1412 left-click 1, 1 1413 type [d] 1414 ] -1415 editor-event-loop screen, console, e +1415 editor-event-loop screen, console, e 1416 3:num/raw <- get *e, cursor-row:offset 1417 4:num/raw <- get *e, cursor-column:offset 1418 screen-should-contain [ @@ -1492,7 +1492,7 @@ if ('onhashchange' in window) { 1430 press ctrl-z 1431 ] 1432 run [ -1433 editor-event-loop screen, console, e +1433 editor-event-loop screen, console, e 1434 3:num/raw <- get *e, cursor-row:offset 1435 4:num/raw <- get *e, cursor-column:offset 1436 ] @@ -1512,7 +1512,7 @@ if ('onhashchange' in window) { 1450 press ctrl-z 1451 ] 1452 run [ -1453 editor-event-loop screen, console, e +1453 editor-event-loop screen, console, e 1454 3:num/raw <- get *e, cursor-row:offset 1455 4:num/raw <- get *e, cursor-column:offset 1456 ] @@ -1532,7 +1532,7 @@ if ('onhashchange' in window) { 1470 press ctrl-z 1471 ] 1472 run [ -1473 editor-event-loop screen, console, e +1473 editor-event-loop screen, console, e 1474 3:num/raw <- get *e, cursor-row:offset 1475 4:num/raw <- get *e, cursor-column:offset 1476 ] @@ -1552,7 +1552,7 @@ if ('onhashchange' in window) { 1490 press ctrl-y 1491 ] 1492 run [ -1493 editor-event-loop screen, console, e +1493 editor-event-loop screen, console, e 1494 3:num/raw <- get *e, cursor-row:offset 1495 4:num/raw <- get *e, cursor-column:offset 1496 ] @@ -1572,7 +1572,7 @@ if ('onhashchange' in window) { 1510 press ctrl-y 1511 ] 1512 run [ -1513 editor-event-loop screen, console, e +1513 editor-event-loop screen, console, e 1514 3:num/raw <- get *e, cursor-row:offset 1515 4:num/raw <- get *e, cursor-column:offset 1516 ] @@ -1593,7 +1593,7 @@ if ('onhashchange' in window) { 1531 press ctrl-y 1532 ] 1533 run [ -1534 editor-event-loop screen, console, e +1534 editor-event-loop screen, console, e 1535 3:num/raw <- get *e, cursor-row:offset 1536 4:num/raw <- get *e, cursor-column:offset 1537 ] @@ -1616,15 +1616,15 @@ if ('onhashchange' in window) { 1554 local-scope 1555 # create an editor 1556 assume-screen 10/width, 5/height -1557 e:&:editor <- new-editor [], 0/left, 10/right -1558 editor-render screen, e +1557 e:&:editor <- new-editor [], 0/left, 10/right +1558 editor-render screen, e 1559 # insert some text and hit backspace 1560 assume-console [ 1561 type [abc] 1562 press backspace 1563 press backspace 1564 ] -1565 editor-event-loop screen, console, e +1565 editor-event-loop screen, console, e 1566 screen-should-contain [ 1567 . . 1568 .a . @@ -1642,7 +1642,7 @@ if ('onhashchange' in window) { 1580 press ctrl-z 1581 ] 1582 run [ -1583 editor-event-loop screen, console, e +1583 editor-event-loop screen, console, e 1584 ] 1585 3:num/raw <- get *e, cursor-row:offset 1586 4:num/raw <- get *e, cursor-column:offset @@ -1661,7 +1661,7 @@ if ('onhashchange' in window) { 1599 press ctrl-y 1600 ] 1601 run [ -1602 editor-event-loop screen, console, e +1602 editor-event-loop screen, console, e 1603 ] 1604 3:num/raw <- get *e, cursor-row:offset 1605 4:num/raw <- get *e, cursor-column:offset @@ -1678,29 +1678,29 @@ if ('onhashchange' in window) { 1616 ] 1617 1618 # save operation to undo -1619 after <begin-backspace-character> [ -1620 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +1619 after <begin-backspace-character> [ +1620 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 1621 ] -1622 before <end-backspace-character> [ +1622 before <end-backspace-character> [ 1623 { 1624 break-unless backspaced-cell # backspace failed; don't add an undo operation -1625 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +1625 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1626 cursor-row:num <- get *editor, cursor-row:offset 1627 cursor-column:num <- get *editor, cursor-row:offset -1628 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1629 undo:&:list:&:operation <- get *editor, undo:offset +1628 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1629 undo:&:list:&:operation <- get *editor, undo:offset 1630 { 1631 # if previous operation was an insert, coalesce this operation with it 1632 break-unless undo -1633 op:&:operation <- first undo -1634 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1633 op:&:operation <- first undo +1634 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1635 break-unless is-delete? 1636 previous-coalesce-tag:num <- get deletion, tag:offset 1637 coalesce?:bool <- equal previous-coalesce-tag, 1/coalesce-backspace 1638 break-unless coalesce? 1639 deletion <- put deletion, delete-from:offset, before-cursor -1640 backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset -1641 splice backspaced-cell, backspaced-so-far +1640 backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset +1641 splice backspaced-cell, backspaced-so-far 1642 deletion <- put deletion, deleted-text:offset, backspaced-cell 1643 deletion <- put deletion, after-row:offset, cursor-row 1644 deletion <- put deletion, after-column:offset, cursor-column @@ -1709,48 +1709,48 @@ if ('onhashchange' in window) { 1647 break +done-adding-backspace-operation 1648 } 1649 # if not, create a new operation -1650 op:&:operation <- new operation:type -1651 deleted-until:&:duplex-list:char <- next before-cursor +1650 op:&:operation <- new operation:type +1651 deleted-until:&:duplex-list:char <- next before-cursor 1652 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, 1/coalesce-backspace -1653 editor <- add-operation editor, op +1653 editor <- add-operation editor, op 1654 +done-adding-backspace-operation 1655 } 1656 ] 1657 -1658 after <handle-undo> [ +1658 after <handle-undo> [ 1659 { -1660 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1660 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1661 break-unless is-delete? -1662 anchor:&:duplex-list:char <- get deletion, delete-from:offset +1662 anchor:&:duplex-list:char <- get deletion, delete-from:offset 1663 break-unless anchor -1664 deleted:&:duplex-list:char <- get deletion, deleted-text:offset -1665 old-cursor:&:duplex-list:char <- last deleted -1666 splice anchor, deleted +1664 deleted:&:duplex-list:char <- get deletion, deleted-text:offset +1665 old-cursor:&:duplex-list:char <- last deleted +1666 splice anchor, deleted 1667 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1668 before-cursor <- copy old-cursor 1669 cursor-row <- get deletion, before-row:offset 1670 *editor <- put *editor, cursor-row:offset, cursor-row 1671 cursor-column <- get deletion, before-column:offset 1672 *editor <- put *editor, cursor-column:offset, cursor-column -1673 top:&:duplex-list:char <- get deletion, before-top-of-screen:offset +1673 top:&:duplex-list:char <- get deletion, before-top-of-screen:offset 1674 *editor <- put *editor, top-of-screen:offset, top 1675 } 1676 ] 1677 -1678 after <handle-redo> [ +1678 after <handle-redo> [ 1679 { -1680 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1680 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1681 break-unless is-delete? -1682 start:&:duplex-list:char <- get deletion, delete-from:offset -1683 end:&:duplex-list:char <- get deletion, delete-until:offset -1684 data:&:duplex-list:char <- get *editor, data:offset -1685 remove-between start, end +1682 start:&:duplex-list:char <- get deletion, delete-from:offset +1683 end:&:duplex-list:char <- get deletion, delete-until:offset +1684 data:&:duplex-list:char <- get *editor, data:offset +1685 remove-between start, end 1686 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1687 cursor-row <- get deletion, after-row:offset 1688 *editor <- put *editor, cursor-row:offset, cursor-row 1689 cursor-column <- get deletion, after-column:offset 1690 *editor <- put *editor, cursor-column:offset, cursor-column -1691 top:&:duplex-list:char <- get deletion, before-top-of-screen:offset +1691 top:&:duplex-list:char <- get deletion, before-top-of-screen:offset 1692 *editor <- put *editor, top-of-screen:offset, top 1693 } 1694 ] @@ -1761,8 +1761,8 @@ if ('onhashchange' in window) { 1699 local-scope 1700 # create an editor 1701 assume-screen 10/width, 5/height -1702 e:&:editor <- new-editor [], 0/left, 10/right -1703 editor-render screen, e +1702 e:&:editor <- new-editor [], 0/left, 10/right +1703 editor-render screen, e 1704 # insert some text and hit delete and backspace a few times 1705 assume-console [ 1706 type [abcdef] @@ -1772,7 +1772,7 @@ if ('onhashchange' in window) { 1710 press delete 1711 press delete 1712 ] -1713 editor-event-loop screen, console, e +1713 editor-event-loop screen, console, e 1714 screen-should-contain [ 1715 . . 1716 .af . @@ -1790,7 +1790,7 @@ if ('onhashchange' in window) { 1728 press ctrl-z 1729 ] 1730 run [ -1731 editor-event-loop screen, console, e +1731 editor-event-loop screen, console, e 1732 ] 1733 3:num/raw <- get *e, cursor-row:offset 1734 4:num/raw <- get *e, cursor-column:offset @@ -1809,7 +1809,7 @@ if ('onhashchange' in window) { 1747 press ctrl-z 1748 ] 1749 run [ -1750 editor-event-loop screen, console, e +1750 editor-event-loop screen, console, e 1751 ] 1752 3:num/raw <- get *e, cursor-row:offset 1753 4:num/raw <- get *e, cursor-column:offset @@ -1828,7 +1828,7 @@ if ('onhashchange' in window) { 1766 press ctrl-z 1767 ] 1768 run [ -1769 editor-event-loop screen, console, e +1769 editor-event-loop screen, console, e 1770 ] 1771 3:num/raw <- get *e, cursor-row:offset 1772 4:num/raw <- get *e, cursor-column:offset @@ -1847,7 +1847,7 @@ if ('onhashchange' in window) { 1785 press ctrl-y 1786 ] 1787 run [ -1788 editor-event-loop screen, console, e +1788 editor-event-loop screen, console, e 1789 ] 1790 # first line inserted 1791 3:num/raw <- get *e, cursor-row:offset @@ -1867,7 +1867,7 @@ if ('onhashchange' in window) { 1805 press ctrl-y 1806 ] 1807 run [ -1808 editor-event-loop screen, console, e +1808 editor-event-loop screen, console, e 1809 ] 1810 # first line inserted 1811 3:num/raw <- get *e, cursor-row:offset @@ -1887,7 +1887,7 @@ if ('onhashchange' in window) { 1825 press ctrl-y 1826 ] 1827 run [ -1828 editor-event-loop screen, console, e +1828 editor-event-loop screen, console, e 1829 ] 1830 # first line inserted 1831 3:num/raw <- get *e, cursor-row:offset @@ -1904,29 +1904,29 @@ if ('onhashchange' in window) { 1842 ] 1843 ] 1844 -1845 after <begin-delete-character> [ -1846 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +1845 after <begin-delete-character> [ +1846 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 1847 ] -1848 before <end-delete-character> [ +1848 before <end-delete-character> [ 1849 { 1850 break-unless deleted-cell # delete failed; don't add an undo operation -1851 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +1851 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1852 cursor-row:num <- get *editor, cursor-row:offset 1853 cursor-column:num <- get *editor, cursor-column:offset -1854 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1855 undo:&:list:&:operation <- get *editor, undo:offset +1854 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1855 undo:&:list:&:operation <- get *editor, undo:offset 1856 { 1857 # if previous operation was an insert, coalesce this operation with it 1858 break-unless undo -1859 op:&:operation <- first undo -1860 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1859 op:&:operation <- first undo +1860 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1861 break-unless is-delete? 1862 previous-coalesce-tag:num <- get deletion, tag:offset 1863 coalesce?:bool <- equal previous-coalesce-tag, 2/coalesce-delete 1864 break-unless coalesce? -1865 delete-until:&:duplex-list:char <- next before-cursor +1865 delete-until:&:duplex-list:char <- next before-cursor 1866 deletion <- put deletion, delete-until:offset, delete-until -1867 deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset +1867 deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset 1868 deleted-so-far <- append deleted-so-far, deleted-cell 1869 deletion <- put deletion, deleted-text:offset, deleted-so-far 1870 deletion <- put deletion, after-row:offset, cursor-row @@ -1936,10 +1936,10 @@ if ('onhashchange' in window) { 1874 break +done-adding-delete-operation 1875 } 1876 # if not, create a new operation -1877 op:&:operation <- new operation:type -1878 deleted-until:&:duplex-list:char <- next before-cursor +1877 op:&:operation <- new operation:type +1878 deleted-until:&:duplex-list:char <- next before-cursor 1879 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, 2/coalesce-delete -1880 editor <- add-operation editor, op +1880 editor <- add-operation editor, op 1881 +done-adding-delete-operation 1882 } 1883 ] @@ -1952,14 +1952,14 @@ if ('onhashchange' in window) { 1890 assume-screen 10/width, 5/height 1891 contents:text <- new [abc 1892 def] -1893 e:&:editor <- new-editor contents, 0/left, 10/right -1894 editor-render screen, e +1893 e:&:editor <- new-editor contents, 0/left, 10/right +1894 editor-render screen, e 1895 # insert some text and hit delete and backspace a few times 1896 assume-console [ 1897 left-click 1, 1 1898 press ctrl-k 1899 ] -1900 editor-event-loop screen, console, e +1900 editor-event-loop screen, console, e 1901 screen-should-contain [ 1902 . . 1903 .a . @@ -1978,7 +1978,7 @@ if ('onhashchange' in window) { 1916 press ctrl-z 1917 ] 1918 run [ -1919 editor-event-loop screen, console, e +1919 editor-event-loop screen, console, e 1920 ] 1921 screen-should-contain [ 1922 . . @@ -1998,7 +1998,7 @@ if ('onhashchange' in window) { 1936 press ctrl-y 1937 ] 1938 run [ -1939 editor-event-loop screen, console, e +1939 editor-event-loop screen, console, e 1940 ] 1941 # first line inserted 1942 screen-should-contain [ @@ -2019,7 +2019,7 @@ if ('onhashchange' in window) { 1957 type [1] 1958 ] 1959 run [ -1960 editor-event-loop screen, console, e +1960 editor-event-loop screen, console, e 1961 ] 1962 screen-should-contain [ 1963 . . @@ -2030,19 +2030,19 @@ if ('onhashchange' in window) { 1968 ] 1969 ] 1970 -1971 after <begin-delete-to-end-of-line> [ -1972 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +1971 after <begin-delete-to-end-of-line> [ +1972 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 1973 ] -1974 before <end-delete-to-end-of-line> [ +1974 before <end-delete-to-end-of-line> [ 1975 { 1976 break-unless deleted-cells # delete failed; don't add an undo operation -1977 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +1977 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1978 cursor-row:num <- get *editor, cursor-row:offset 1979 cursor-column:num <- get *editor, cursor-column:offset -1980 deleted-until:&:duplex-list:char <- next before-cursor -1981 op:&:operation <- new operation:type +1980 deleted-until:&:duplex-list:char <- next before-cursor +1981 op:&:operation <- new operation:type 1982 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce -1983 editor <- add-operation editor, op +1983 editor <- add-operation editor, op 1984 +done-adding-delete-operation 1985 } 1986 ] @@ -2055,14 +2055,14 @@ if ('onhashchange' in window) { 1993 assume-screen 10/width, 5/height 1994 contents:text <- new [abc 1995 def] -1996 e:&:editor <- new-editor contents, 0/left, 10/right -1997 editor-render screen, e +1996 e:&:editor <- new-editor contents, 0/left, 10/right +1997 editor-render screen, e 1998 # insert some text and hit delete and backspace a few times 1999 assume-console [ 2000 left-click 1, 2 2001 press ctrl-u 2002 ] -2003 editor-event-loop screen, console, e +2003 editor-event-loop screen, console, e 2004 screen-should-contain [ 2005 . . 2006 .c . @@ -2081,7 +2081,7 @@ if ('onhashchange' in window) { 2019 press ctrl-z 2020 ] 2021 run [ -2022 editor-event-loop screen, console, e +2022 editor-event-loop screen, console, e 2023 ] 2024 screen-should-contain [ 2025 . . @@ -2101,7 +2101,7 @@ if ('onhashchange' in window) { 2039 press ctrl-y 2040 ] 2041 run [ -2042 editor-event-loop screen, console, e +2042 editor-event-loop screen, console, e 2043 ] 2044 # first line inserted 2045 screen-should-contain [ @@ -2122,7 +2122,7 @@ if ('onhashchange' in window) { 2060 type [1] 2061 ] 2062 run [ -2063 editor-event-loop screen, console, e +2063 editor-event-loop screen, console, e 2064 ] 2065 screen-should-contain [ 2066 . . @@ -2133,20 +2133,20 @@ if ('onhashchange' in window) { 2071 ] 2072 ] 2073 -2074 after <begin-delete-to-start-of-line> [ -2075 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +2074 after <begin-delete-to-start-of-line> [ +2075 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 2076 ] -2077 before <end-delete-to-start-of-line> [ +2077 before <end-delete-to-start-of-line> [ 2078 { 2079 break-unless deleted-cells # delete failed; don't add an undo operation -2080 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset -2081 op:&:operation <- new operation:type -2082 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -2083 deleted-until:&:duplex-list:char <- next before-cursor +2080 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +2081 op:&:operation <- new operation:type +2082 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +2083 deleted-until:&:duplex-list:char <- next before-cursor 2084 cursor-row:num <- get *editor, cursor-row:offset 2085 cursor-column:num <- get *editor, cursor-column:offset 2086 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce -2087 editor <- add-operation editor, op +2087 editor <- add-operation editor, op 2088 +done-adding-delete-operation 2089 } 2090 ] @@ -2155,15 +2155,15 @@ if ('onhashchange' in window) { 2093 local-scope 2094 # create an editor 2095 assume-screen 10/width, 5/height -2096 e:&:editor <- new-editor [], 0/left, 10/right -2097 editor-render screen, e +2096 e:&:editor <- new-editor [], 0/left, 10/right +2097 editor-render screen, e 2098 # insert some text and hit delete and backspace a few times 2099 assume-console [ 2100 type [abc] 2101 press ctrl-u 2102 press ctrl-z 2103 ] -2104 editor-event-loop screen, console, e +2104 editor-event-loop screen, console, e 2105 screen-should-contain [ 2106 . . 2107 .abc . -- cgit 1.4.1-2-gfad0