From 6c52e24e2996a77aa6297b26159003d503aef8a0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 18 Apr 2017 11:33:33 -0700 Subject: 3830 - crosslink shape-shifting containers in html --- html/edit/001-editor.mu.html | 18 ++-- html/edit/002-typing.mu.html | 24 ++--- html/edit/003-shortcuts.mu.html | 134 ++++++++++++------------ html/edit/004-programming-environment.mu.html | 8 +- html/edit/005-sandbox.mu.html | 6 +- html/edit/006-sandbox-copy.mu.html | 4 +- html/edit/011-errors.mu.html | 4 +- html/edit/012-editor-undo.mu.html | 144 +++++++++++++------------- 8 files changed, 171 insertions(+), 171 deletions(-) (limited to 'html/edit') diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index f9282fcc..14307ec2 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -92,11 +92,11 @@ if ('onhashchange' in window) { 29 30 container editor [ 31 # editable text: doubly linked list of characters (head contains a special sentinel) - 32 data:&:duplex-list:char - 33 top-of-screen:&:duplex-list:char - 34 bottom-of-screen:&:duplex-list:char + 32 data:&:duplex-list:char + 33 top-of-screen:&:duplex-list:char + 34 bottom-of-screen:&:duplex-list:char 35 # location before cursor inside data - 36 before-cursor:&:duplex-list:char + 36 before-cursor:&:duplex-list:char 37 38 # raw bounds of display area on screen 39 # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen @@ -123,7 +123,7 @@ if ('onhashchange' in window) { 60 *result <- put *result, cursor-row:offset, 1/top 61 *result <- put *result, cursor-column:offset, left 62 # initialize empty contents - 63 init:&:duplex-list:char <- push 167/§, 0/tail + 63 init:&:duplex-list:char <- push 167/§, 0/tail 64 *result <- put *result, data:offset, init 65 *result <- put *result, top-of-screen:offset, init 66 *result <- put *result, before-cursor:offset, init @@ -140,7 +140,7 @@ if ('onhashchange' in window) { 77 return-unless len 78 idx:num <- copy 0 79 # now we can start appending the rest, character by character - 80 curr:&:duplex-list:char <- get *editor, data:offset + 80 curr:&:duplex-list:char <- get *editor, data:offset 81 { 82 ¦ done?:bool <- greater-or-equal idx, len 83 ¦ break-if done? @@ -189,8 +189,8 @@ if ('onhashchange' in window) { 126 screen-height:num <- screen-height screen 127 right:num <- get *editor, right:offset 128 # traversing editor -129 curr:&:duplex-list:char <- get *editor, top-of-screen:offset -130 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev +129 curr:&:duplex-list:char <- get *editor, top-of-screen:offset +130 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev 131 curr <- next curr 132 # traversing screen 133 color:num <- copy 7/white @@ -198,7 +198,7 @@ if ('onhashchange' in window) { 135 column:num <- copy left 136 cursor-row:num <- get *editor, cursor-row:offset 137 cursor-column:num <- get *editor, cursor-column:offset -138 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +138 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 139 screen <- move-cursor screen, row, column 140 { 141 ¦ +next-character diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 3b48c3cc..ad249e5c 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -141,8 +141,8 @@ if ('onhashchange' in window) { 78 right:num <- get *editor, right:offset 79 screen-height:num <- screen-height screen 80 # count newlines until screen row - 81 curr:&:duplex-list:char <- get *editor, top-of-screen:offset - 82 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev + 81 curr:&:duplex-list:char <- get *editor, top-of-screen:offset + 82 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev 83 curr <- next curr 84 row:num <- copy 1/top 85 column:num <- copy left @@ -150,7 +150,7 @@ if ('onhashchange' in window) { 87 cursor-row:num <- copy target-row 88 *editor <- put *editor, cursor-column:offset, target-column 89 cursor-column:num <- copy target-column - 90 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 90 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 91 { 92 ¦ +next-character 93 ¦ break-unless curr @@ -232,7 +232,7 @@ if ('onhashchange' in window) { 169 screen-height:num <- screen-height screen 170 left:num <- get *editor, left:offset 171 right:num <- get *editor, right:offset - 172 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 172 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 173 cursor-row:num <- get *editor, cursor-row:offset 174 cursor-column:num <- get *editor, cursor-column:offset 175 save-row:num <- copy cursor-row @@ -264,7 +264,7 @@ if ('onhashchange' in window) { 201 def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool, editor:&:editor, screen:&:screen [ 202 local-scope 203 load-ingredients - 204 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 204 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 205 insert c, before-cursor 206 before-cursor <- next before-cursor 207 *editor <- put *editor, before-cursor:offset, before-cursor @@ -281,7 +281,7 @@ if ('onhashchange' in window) { 218 # but mostly we'll just move the cursor right 219 cursor-column <- add cursor-column, 1 220 *editor <- put *editor, cursor-column:offset, cursor-column - 221 next:&:duplex-list:char <- next before-cursor + 221 next:&:duplex-list:char <- next before-cursor 222 { 223 ¦ # at end of all text? no need to scroll? just print the character and leave 224 ¦ at-end?:bool <- equal next, 0/null @@ -300,7 +300,7 @@ if ('onhashchange' in window) { 237 ¦ break-unless next 238 ¦ at-right?:bool <- greater-or-equal cursor-column, screen-width 239 ¦ break-if at-right? - 240 ¦ curr:&:duplex-list:char <- copy before-cursor + 240 ¦ curr:&:duplex-list:char <- copy before-cursor 241 ¦ move-cursor screen, save-row, save-column 242 ¦ curr-column:num <- copy save-column 243 ¦ { @@ -760,7 +760,7 @@ if ('onhashchange' in window) { 697 ¦ before-wrap-column:num <- subtract wrap-column, 1 698 ¦ at-wrap?:bool <- greater-or-equal cursor-column, wrap-column 699 ¦ just-before-wrap?:bool <- greater-or-equal cursor-column, before-wrap-column - 700 ¦ next:&:duplex-list:char <- next before-cursor + 700 ¦ next:&:duplex-list:char <- next before-cursor 701 ¦ # at end of line? next == 0 || next.value == 10/newline 702 ¦ at-end-of-line?:bool <- equal next, 0 703 ¦ { @@ -929,7 +929,7 @@ if ('onhashchange' in window) { 866 load-ingredients 867 cursor-row:num <- get *editor, cursor-row:offset 868 cursor-column:num <- get *editor, cursor-column:offset - 869 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 869 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 870 left:num <- get *editor, left:offset 871 right:num <- get *editor, right:offset 872 screen-height:num <- screen-height screen @@ -952,8 +952,8 @@ if ('onhashchange' in window) { 889 # indent if necessary 890 indent?:bool <- get *editor, indent?:offset 891 return-unless indent? - 892 d:&:duplex-list:char <- get *editor, data:offset - 893 end-of-previous-line:&:duplex-list:char <- prev before-cursor + 892 d:&:duplex-list:char <- get *editor, data:offset + 893 end-of-previous-line:&:duplex-list:char <- prev before-cursor 894 indent:num <- line-indent end-of-previous-line, d 895 i:num <- copy 0 896 { @@ -967,7 +967,7 @@ if ('onhashchange' in window) { 904 905 # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts 906 # the number of spaces at the start of the line containing 'curr'. - 907 def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ + 907 def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ 908 local-scope 909 load-ingredients 910 result:num <- copy 0 diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index c1fd5eca..83871010 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -133,7 +133,7 @@ if ('onhashchange' in window) { 71 ¦ delete-previous-character?:bool <- equal c, 8/backspace 72 ¦ break-unless delete-previous-character? 73 ¦ <backspace-character-begin> - 74 ¦ go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen + 74 ¦ go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen 75 ¦ <backspace-character-end> 76 ¦ return 77 } @@ -142,18 +142,18 @@ if ('onhashchange' in window) { 80 # return values: 81 # go-render? - whether caller needs to update the screen 82 # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. - 83 def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ + 83 def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ 84 local-scope 85 load-ingredients - 86 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 87 data:&:duplex-list:char <- get *editor, data:offset + 86 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 87 data:&:duplex-list:char <- get *editor, data:offset 88 # if at start of text (before-cursor at § sentinel), return - 89 prev:&:duplex-list:char <- prev before-cursor + 89 prev:&:duplex-list:char <- prev before-cursor 90 return-unless prev, 0/no-more-render, 0/nothing-deleted 91 trace 10, [app], [delete-before-cursor] 92 original-row:num <- get *editor, cursor-row:offset 93 scroll?:bool <- move-cursor-coordinates-left editor - 94 backspaced-cell:&:duplex-list:char <- copy before-cursor + 94 backspaced-cell:&:duplex-list:char <- copy before-cursor 95 data <- remove before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/before-cursor 96 before-cursor <- copy prev 97 *editor <- put *editor, before-cursor:offset, before-cursor @@ -166,7 +166,7 @@ if ('onhashchange' in window) { 104 return-unless same-row?, 1/go-render 105 left:num <- get *editor, left:offset 106 right:num <- get *editor, right:offset - 107 curr:&:duplex-list:char <- next before-cursor + 107 curr:&:duplex-list:char <- next before-cursor 108 screen <- move-cursor screen, cursor-row, cursor-column 109 curr-column:num <- copy cursor-column 110 { @@ -193,7 +193,7 @@ if ('onhashchange' in window) { 131 local-scope 132 load-ingredients 133 go-render?:bool <- copy 0/false - 134 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 134 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 135 cursor-row:num <- get *editor, cursor-row:offset 136 cursor-column:num <- get *editor, cursor-column:offset 137 left:num <- get *editor, left:offset @@ -225,7 +225,7 @@ if ('onhashchange' in window) { 163 ¦ break-unless previous-character-is-newline? 164 ¦ # compute length of previous line 165 ¦ trace 10, [app], [switching to previous line] - 166 ¦ d:&:duplex-list:char <- get *editor, data:offset + 166 ¦ d:&:duplex-list:char <- get *editor, data:offset 167 ¦ end-of-line:num <- previous-line-length before-cursor, d 168 ¦ right:num <- get *editor, right:offset 169 ¦ width:num <- subtract right, left @@ -252,7 +252,7 @@ if ('onhashchange' in window) { 190 191 # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts 192 # the length of the previous line before the 'curr' pointer. - 193 def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ + 193 def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ 194 local-scope 195 load-ingredients 196 result:num <- copy 0 @@ -401,25 +401,25 @@ if ('onhashchange' in window) { 339 ¦ delete-next-character?:bool <- equal k, 65522/delete 340 ¦ break-unless delete-next-character? 341 ¦ <delete-character-begin> - 342 ¦ go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen + 342 ¦ go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen 343 ¦ <delete-character-end> 344 ¦ return 345 } 346 ] 347 - 348 def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ + 348 def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ 349 local-scope 350 load-ingredients - 351 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 352 data:&:duplex-list:char <- get *editor, data:offset - 353 deleted-cell:&:duplex-list:char <- next before-cursor + 351 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 352 data:&:duplex-list:char <- get *editor, data:offset + 353 deleted-cell:&:duplex-list:char <- next before-cursor 354 return-unless deleted-cell, 0/don't-render 355 currc:char <- get *deleted-cell, value:offset 356 data <- remove deleted-cell, data 357 deleted-newline?:bool <- equal currc, 10/newline 358 return-if deleted-newline?, 1/go-render 359 # wasn't a newline? render rest of line - 360 curr:&:duplex-list:char <- next before-cursor # refresh after remove above + 360 curr:&:duplex-list:char <- next before-cursor # refresh after remove above 361 cursor-row:num <- get *editor, cursor-row:offset 362 cursor-column:num <- get *editor, cursor-column:offset 363 screen <- move-cursor screen, cursor-row, cursor-column @@ -474,7 +474,7 @@ if ('onhashchange' in window) { 412 ¦ move-to-next-character?:bool <- equal k, 65514/right-arrow 413 ¦ break-unless move-to-next-character? 414 ¦ # if not at end of text - 415 ¦ next-cursor:&:duplex-list:char <- next before-cursor + 415 ¦ next-cursor:&:duplex-list:char <- next before-cursor 416 ¦ break-unless next-cursor 417 ¦ # scan to next character 418 ¦ <move-cursor-begin> @@ -491,7 +491,7 @@ if ('onhashchange' in window) { 429 def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 430 local-scope 431 load-ingredients - 432 before-cursor:&:duplex-list:char <- get *editor before-cursor:offset + 432 before-cursor:&:duplex-list:char <- get *editor before-cursor:offset 433 cursor-row:num <- get *editor, cursor-row:offset 434 cursor-column:num <- get *editor, cursor-column:offset 435 left:num <- get *editor, left:offset @@ -519,7 +519,7 @@ if ('onhashchange' in window) { 457 ¦ at-wrap?:bool <- equal cursor-column, wrap-column 458 ¦ break-unless at-wrap? 459 ¦ # and if next character isn't newline - 460 ¦ next:&:duplex-list:char <- next before-cursor + 460 ¦ next:&:duplex-list:char <- next before-cursor 461 ¦ break-unless next 462 ¦ next-character:char <- get *next, value:offset 463 ¦ newline?:bool <- equal next-character, 10/newline @@ -759,7 +759,7 @@ if ('onhashchange' in window) { 697 ¦ break-unless move-to-previous-character? 698 ¦ trace 10, [app], [left arrow] 699 ¦ # if not at start of text (before-cursor at § sentinel) - 700 ¦ prev:&:duplex-list:char <- prev before-cursor + 700 ¦ prev:&:duplex-list:char <- prev before-cursor 701 ¦ return-unless prev, 0/don't-render 702 ¦ <move-cursor-begin> 703 ¦ go-render? <- move-cursor-coordinates-left editor @@ -1041,7 +1041,7 @@ if ('onhashchange' in window) { 979 go-render?:bool <- copy 0/false 980 cursor-row:num <- get *editor, cursor-row:offset 981 cursor-column:num <- get *editor, cursor-column:offset - 982 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 982 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 983 left:num <- get *editor, left:offset 984 right:num <- get *editor, right:offset 985 already-at-top?:bool <- lesser-or-equal cursor-row, 1/top @@ -1051,13 +1051,13 @@ if ('onhashchange' in window) { 989 ¦ # if not at newline, move to start of line (previous newline) 990 ¦ # then scan back another line 991 ¦ # if either step fails, give up without modifying cursor or coordinates - 992 ¦ curr:&:duplex-list:char <- copy before-cursor + 992 ¦ curr:&:duplex-list:char <- copy before-cursor 993 ¦ { - 994 ¦ ¦ old:&:duplex-list:char <- copy curr + 994 ¦ ¦ old:&:duplex-list:char <- copy curr 995 ¦ ¦ c2:char <- get *curr, value:offset 996 ¦ ¦ at-newline?:bool <- equal c2, 10/newline 997 ¦ ¦ break-if at-newline? - 998 ¦ ¦ curr:&:duplex-list:char <- before-previous-line curr, editor + 998 ¦ ¦ curr:&:duplex-list:char <- before-previous-line curr, editor 999 ¦ ¦ no-motion?:bool <- equal curr, old 1000 ¦ ¦ return-if no-motion? 1001 ¦ } @@ -1078,7 +1078,7 @@ if ('onhashchange' in window) { 1016 ¦ { 1017 ¦ ¦ done?:bool <- greater-or-equal cursor-column, target-column 1018 ¦ ¦ break-if done? -1019 ¦ ¦ curr:&:duplex-list:char <- next before-cursor +1019 ¦ ¦ curr:&:duplex-list:char <- next before-cursor 1020 ¦ ¦ break-unless curr 1021 ¦ ¦ currc:char <- get *curr, value:offset 1022 ¦ ¦ at-newline?:bool <- equal currc, 10/newline @@ -1271,7 +1271,7 @@ if ('onhashchange' in window) { 1209 load-ingredients 1210 cursor-row:num <- get *editor, cursor-row:offset 1211 cursor-column:num <- get *editor, cursor-column:offset -1212 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1212 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1213 left:num <- get *editor, left:offset 1214 right:num <- get *editor, right:offset 1215 last-line:num <- subtract screen-height, 1 @@ -1281,7 +1281,7 @@ if ('onhashchange' in window) { 1219 ¦ break-if already-at-bottom? 1220 ¦ # scan to start of next line, then to right column or until end of line 1221 ¦ max:num <- subtract right, left -1222 ¦ next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max +1222 ¦ next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max 1223 ¦ { 1224 ¦ ¦ # already at end of buffer? try to scroll up (so we can see more 1225 ¦ ¦ # warnings or sandboxes below) @@ -1301,7 +1301,7 @@ if ('onhashchange' in window) { 1239 ¦ { 1240 ¦ ¦ done?:bool <- greater-or-equal cursor-column, target-column 1241 ¦ ¦ break-if done? -1242 ¦ ¦ curr:&:duplex-list:char <- next before-cursor +1242 ¦ ¦ curr:&:duplex-list:char <- next before-cursor 1243 ¦ ¦ break-unless curr 1244 ¦ ¦ currc:char <- get *curr, value:offset 1245 ¦ ¦ at-newline?:bool <- equal currc, 10/newline @@ -1417,8 +1417,8 @@ if ('onhashchange' in window) { 1355 cursor-column:num <- copy left 1356 *editor <- put *editor, cursor-column:offset, cursor-column 1357 # update before-cursor -1358 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1359 init:&:duplex-list:char <- get *editor, data:offset +1358 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1359 init:&:duplex-list:char <- get *editor, data:offset 1360 # while not at start of line, move 1361 { 1362 ¦ at-start-of-text?:bool <- equal before-cursor, init @@ -1586,11 +1586,11 @@ if ('onhashchange' in window) { 1524 def move-to-end-of-line editor:&:editor -> editor:&:editor [ 1525 local-scope 1526 load-ingredients -1527 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1527 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1528 cursor-column:num <- get *editor, cursor-column:offset 1529 # while not at start of line, move 1530 { -1531 ¦ next:&:duplex-list:char <- next before-cursor +1531 ¦ next:&:duplex-list:char <- next before-cursor 1532 ¦ break-unless next # end of text 1533 ¦ nextc:char <- get *next, value:offset 1534 ¦ at-end-of-line?:bool <- equal nextc, 10/newline @@ -1712,20 +1712,20 @@ if ('onhashchange' in window) { 1650 ¦ delete-to-start-of-line?:bool <- equal c, 21/ctrl-u 1651 ¦ break-unless delete-to-start-of-line? 1652 ¦ <delete-to-start-of-line-begin> -1653 ¦ deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor +1653 ¦ deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor 1654 ¦ <delete-to-start-of-line-end> 1655 ¦ return 1/go-render 1656 } 1657 ] 1658 -1659 def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ +1659 def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ 1660 local-scope 1661 load-ingredients 1662 # compute range to delete -1663 init:&:duplex-list:char <- get *editor, data:offset -1664 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1665 start:&:duplex-list:char <- copy before-cursor -1666 end:&:duplex-list:char <- next before-cursor +1663 init:&:duplex-list:char <- get *editor, data:offset +1664 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1665 start:&:duplex-list:char <- copy before-cursor +1666 end:&:duplex-list:char <- next before-cursor 1667 { 1668 ¦ at-start-of-text?:bool <- equal start, init 1669 ¦ break-if at-start-of-text? @@ -1737,7 +1737,7 @@ if ('onhashchange' in window) { 1675 ¦ loop 1676 } 1677 # snip it out -1678 result:&:duplex-list:char <- next start +1678 result:&:duplex-list:char <- next start 1679 remove-between start, end 1680 # adjust cursor 1681 before-cursor <- copy start @@ -1849,18 +1849,18 @@ if ('onhashchange' in window) { 1787 ¦ delete-to-end-of-line?:bool <- equal c, 11/ctrl-k 1788 ¦ break-unless delete-to-end-of-line? 1789 ¦ <delete-to-end-of-line-begin> -1790 ¦ deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor +1790 ¦ deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor 1791 ¦ <delete-to-end-of-line-end> 1792 ¦ return 1/go-render 1793 } 1794 ] 1795 -1796 def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ +1796 def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ 1797 local-scope 1798 load-ingredients 1799 # compute range to delete -1800 start:&:duplex-list:char <- get *editor, before-cursor:offset -1801 end:&:duplex-list:char <- next start +1800 start:&:duplex-list:char <- get *editor, before-cursor:offset +1801 end:&:duplex-list:char <- next start 1802 { 1803 ¦ at-end-of-text?:bool <- equal end, 0/null 1804 ¦ break-if at-end-of-text? @@ -2033,11 +2033,11 @@ if ('onhashchange' in window) { 1971 1972 after <scroll-down> [ 1973 trace 10, [app], [scroll down] -1974 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +1974 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 1975 left:num <- get *editor, left:offset 1976 right:num <- get *editor, right:offset 1977 max:num <- subtract right, left -1978 old-top:&:duplex-list:char <- copy top-of-screen +1978 old-top:&:duplex-list:char <- copy top-of-screen 1979 top-of-screen <- before-start-of-next-line top-of-screen, max 1980 *editor <- put *editor, top-of-screen:offset, top-of-screen 1981 no-movement?:bool <- equal old-top, top-of-screen @@ -2047,11 +2047,11 @@ if ('onhashchange' in window) { 1985 # takes a pointer into the doubly-linked list, scans ahead at most 'max' 1986 # positions until the next newline 1987 # beware: never return null pointer. -1988 def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ +1988 def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ 1989 local-scope 1990 load-ingredients 1991 count:num <- copy 0 -1992 curr:&:duplex-list:char <- copy original +1992 curr:&:duplex-list:char <- copy original 1993 # skip the initial newline if it exists 1994 { 1995 ¦ c:char <- get *curr, value:offset @@ -2415,8 +2415,8 @@ if ('onhashchange' in window) { 2353 2354 after <scroll-up> [ 2355 trace 10, [app], [scroll up] -2356 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset -2357 old-top:&:duplex-list:char <- copy top-of-screen +2356 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2357 old-top:&:duplex-list:char <- copy top-of-screen 2358 top-of-screen <- before-previous-line top-of-screen, editor 2359 *editor <- put *editor, top-of-screen:offset, top-of-screen 2360 no-movement?:bool <- equal old-top, top-of-screen @@ -2426,10 +2426,10 @@ if ('onhashchange' in window) { 2364 # takes a pointer into the doubly-linked list, scans back to before start of 2365 # previous *wrapped* line 2366 # beware: never return null pointer -2367 def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ +2367 def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ 2368 local-scope 2369 load-ingredients -2370 curr:&:duplex-list:char <- copy in +2370 curr:&:duplex-list:char <- copy in 2371 c:char <- get *curr, value:offset 2372 # compute max, number of characters to skip 2373 # 1 + len%(width-1) @@ -2437,12 +2437,12 @@ if ('onhashchange' in window) { 2375 left:num <- get *editor, left:offset 2376 right:num <- get *editor, right:offset 2377 max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon -2378 sentinel:&:duplex-list:char <- get *editor, data:offset +2378 sentinel:&:duplex-list:char <- get *editor, data:offset 2379 len:num <- previous-line-length curr, sentinel 2380 { 2381 ¦ break-if len 2382 ¦ # empty line; just skip this newline -2383 ¦ prev:&:duplex-list:char <- prev curr +2383 ¦ prev:&:duplex-list:char <- prev curr 2384 ¦ return-unless prev, curr 2385 ¦ return prev 2386 } @@ -2458,7 +2458,7 @@ if ('onhashchange' in window) { 2396 { 2397 ¦ done?:bool <- greater-or-equal count, max 2398 ¦ break-if done? -2399 ¦ prev:&:duplex-list:char <- prev curr +2399 ¦ prev:&:duplex-list:char <- prev curr 2400 ¦ break-unless prev 2401 ¦ curr <- copy prev 2402 ¦ count <- add count, 1 @@ -2820,12 +2820,12 @@ if ('onhashchange' in window) { 2758 { 2759 ¦ page-down?:bool <- equal c, 6/ctrl-f 2760 ¦ break-unless page-down? -2761 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +2761 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2762 ¦ <move-cursor-begin> 2763 ¦ page-down editor 2764 ¦ undo-coalesce-tag:num <- copy 0/never 2765 ¦ <move-cursor-end> -2766 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2766 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2767 ¦ movement?:bool <- not-equal top-of-screen, old-top 2768 ¦ return movement?/go-render 2769 } @@ -2835,12 +2835,12 @@ if ('onhashchange' in window) { 2773 { 2774 ¦ page-down?:bool <- equal k, 65518/page-down 2775 ¦ break-unless page-down? -2776 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +2776 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2777 ¦ <move-cursor-begin> 2778 ¦ page-down editor 2779 ¦ undo-coalesce-tag:num <- copy 0/never 2780 ¦ <move-cursor-end> -2781 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2781 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2782 ¦ movement?:bool <- not-equal top-of-screen, old-top 2783 ¦ return movement?/go-render 2784 } @@ -2852,11 +2852,11 @@ if ('onhashchange' in window) { 2790 local-scope 2791 load-ingredients 2792 # if editor contents don't overflow screen, do nothing -2793 bottom-of-screen:&:duplex-list:char <- get *editor, bottom-of-screen:offset +2793 bottom-of-screen:&:duplex-list:char <- get *editor, bottom-of-screen:offset 2794 return-unless bottom-of-screen 2795 # if not, position cursor at final character -2796 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -2797 before-cursor:&:duplex-list:char <- prev bottom-of-screen +2796 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +2797 before-cursor:&:duplex-list:char <- prev bottom-of-screen 2798 *editor <- put *editor, before-cursor:offset, before-cursor 2799 # keep one line in common with previous page 2800 { @@ -3019,12 +3019,12 @@ if ('onhashchange' in window) { 2957 { 2958 ¦ page-up?:bool <- equal c, 2/ctrl-b 2959 ¦ break-unless page-up? -2960 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +2960 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2961 ¦ <move-cursor-begin> 2962 ¦ editor <- page-up editor, screen-height 2963 ¦ undo-coalesce-tag:num <- copy 0/never 2964 ¦ <move-cursor-end> -2965 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2965 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2966 ¦ movement?:bool <- not-equal top-of-screen, old-top 2967 ¦ return movement?/go-render 2968 } @@ -3034,12 +3034,12 @@ if ('onhashchange' in window) { 2972 { 2973 ¦ page-up?:bool <- equal k, 65519/page-up 2974 ¦ break-unless page-up? -2975 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset +2975 ¦ old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2976 ¦ <move-cursor-begin> 2977 ¦ editor <- page-up editor, screen-height 2978 ¦ undo-coalesce-tag:num <- copy 0/never 2979 ¦ <move-cursor-end> -2980 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2980 ¦ top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2981 ¦ movement?:bool <- not-equal top-of-screen, old-top 2982 ¦ # don't bother re-rendering if nothing changed. todo: test this 2983 ¦ return movement?/go-render @@ -3051,11 +3051,11 @@ if ('onhashchange' in window) { 2989 load-ingredients 2990 max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line 2991 count:num <- copy 0 -2992 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +2992 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2993 { 2994 ¦ done?:bool <- greater-or-equal count, max 2995 ¦ break-if done? -2996 ¦ prev:&:duplex-list:char <- before-previous-line top-of-screen, editor +2996 ¦ prev:&:duplex-list:char <- before-previous-line top-of-screen, editor 2997 ¦ break-unless prev 2998 ¦ top-of-screen <- copy prev 2999 ¦ *editor <- put *editor, top-of-screen:offset, top-of-screen diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 639825f9..2aeba796 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -257,19 +257,19 @@ if ('onhashchange' in window) { 194 left:num <- get *editor, left:offset 195 screen-height:num <- screen-height screen 196 right:num <- get *editor, right:offset -197 curr:&:duplex-list:char <- get *editor, top-of-screen:offset -198 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev +197 curr:&:duplex-list:char <- get *editor, top-of-screen:offset +198 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev 199 curr <- next curr 200 color:num <- copy 7/white 201 row:num <- copy 1/top 202 column:num <- copy left 203 # save before-cursor -204 old-before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +204 old-before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 205 # initialze cursor-row/cursor-column/before-cursor to the top of the screen 206 # by default 207 *editor <- put *editor, cursor-row:offset, row 208 *editor <- put *editor, cursor-column:offset, column -209 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset +209 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 210 *editor <- put *editor, before-cursor:offset, top-of-screen 211 screen <- move-cursor screen, row, column 212 { diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 8346152a..9eb7d9f8 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -227,7 +227,7 @@ if ('onhashchange' in window) { 164 ¦ sandbox-count <- add sandbox-count, 1 165 ¦ *env <- put *env, number-of-sandboxes:offset, sandbox-count 166 ¦ # clear sandbox editor - 167 ¦ init:&:duplex-list:char <- push 167/§, 0/tail + 167 ¦ init:&:duplex-list:char <- push 167/§, 0/tail 168 ¦ *current-sandbox <- put *current-sandbox, data:offset, init 169 ¦ *current-sandbox <- put *current-sandbox, top-of-screen:offset, init 170 } @@ -759,8 +759,8 @@ if ('onhashchange' in window) { 696 def editor-contents editor:&:editor -> result:text [ 697 local-scope 698 load-ingredients - 699 buf:&:buffer <- new-buffer 80 - 700 curr:&:duplex-list:char <- get *editor, data:offset + 699 buf:&:buffer <- new-buffer 80 + 700 curr:&:duplex-list:char <- get *editor, data:offset 701 # skip § sentinel 702 assert curr, [editor without data is illegal; must have at least a sentinel] 703 curr <- next curr diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index 16b8d819..61a06072 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -263,8 +263,8 @@ if ('onhashchange' in window) { 201 def empty-editor? editor:&:editor -> result:bool [ 202 local-scope 203 load-ingredients -204 head:&:duplex-list:char <- get *editor, data:offset -205 first:&:duplex-list:char <- next head +204 head:&:duplex-list:char <- get *editor, data:offset +205 first:&:duplex-list:char <- next head 206 result <- not first 207 ] 208 diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index a22244b0..8c2a1f1c 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -377,12 +377,12 @@ if ('onhashchange' in window) { 314 # overload a well-known shape-shifting recipe 315 assume-resources [ 316 ¦ [lesson/recipes.mu] <- [ -317 ¦ ¦ |recipe length l:&:list:_elem -> n:num [| +317 ¦ ¦ |recipe length l:&:list:_elem -> n:num [| 318 ¦ ¦ |]| 319 ¦ ] 320 ] 321 # call code that uses other variants of it, but not it itself -322 test-sandbox:text <- new [x:&:list:num <- copy 0 +322 test-sandbox:text <- new [x:&:list:num <- copy 0 323 to-text x] 324 env:&:environment <- new-programming-environment resources, screen, test-sandbox 325 # run it once diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index bf1b7c99..2c227c0f 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -74,13 +74,13 @@ if ('onhashchange' in window) { 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 @@ -89,10 +89,10 @@ if ('onhashchange' in window) { 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 @@ -104,13 +104,13 @@ if ('onhashchange' in window) { 41 container delete-operation [ 42 before-row:num 43 before-column:num - 44 before-top-of-screen:&:duplex-list:char + 44 before-top-of-screen:&:duplex-list:char 45 after-row:num 46 after-column:num - 47 after-top-of-screen:&:duplex-list:char - 48 deleted-text:&:duplex-list:char - 49 delete-from:&:duplex-list:char - 50 delete-until:&:duplex-list:char + 47 after-top-of-screen:&:duplex-list:char + 48 deleted-text:&:duplex-list:char + 49 delete-from:&:duplex-list:char + 50 delete-until:&:duplex-list:char 51 tag:num # event causing this operation; might be used to coalesce runs of similar events 52 ¦ # 0: no coalesce (ctrl-k, ctrl-u) 53 ¦ # 1: backspace @@ -119,8 +119,8 @@ if ('onhashchange' in window) { 56 57 # every editor accumulates a list of operations to undo/redo 58 container editor [ - 59 undo:&:list:&:operation - 60 redo:&:list:&:operation + 59 undo:&:list:&:operation + 60 redo:&:list:&:operation 61 ] 62 63 # ctrl-z - undo operation @@ -128,12 +128,12 @@ if ('onhashchange' in window) { 65 { 66 ¦ undo?:bool <- equal c, 26/ctrl-z 67 ¦ break-unless undo? - 68 ¦ undo:&:list:&:operation <- get *editor, undo:offset + 68 ¦ undo:&:list:&:operation <- get *editor, undo:offset 69 ¦ break-unless undo 70 ¦ op:&:operation <- first undo 71 ¦ undo <- rest undo 72 ¦ *editor <- put *editor, undo:offset, undo - 73 ¦ redo:&:list:&:operation <- get *editor, redo:offset + 73 ¦ redo:&:list:&:operation <- get *editor, redo:offset 74 ¦ redo <- push op, redo 75 ¦ *editor <- put *editor, redo:offset, redo 76 ¦ <handle-undo> @@ -146,12 +146,12 @@ if ('onhashchange' in window) { 83 { 84 ¦ redo?:bool <- equal c, 25/ctrl-y 85 ¦ break-unless redo? - 86 ¦ redo:&:list:&:operation <- get *editor, redo:offset + 86 ¦ redo:&:list:&:operation <- get *editor, redo:offset 87 ¦ break-unless redo 88 ¦ op:&:operation <- first redo 89 ¦ redo <- rest redo 90 ¦ *editor <- put *editor, redo:offset, redo - 91 ¦ undo:&:list:&:operation <- get *editor, undo:offset + 91 ¦ undo:&:list:&:operation <- get *editor, undo:offset 92 ¦ undo <- push op, undo 93 ¦ *editor <- put *editor, undo:offset, undo 94 ¦ <handle-redo> @@ -202,14 +202,14 @@ if ('onhashchange' in window) { 139 140 # save operation to undo 141 after <insert-character-begin> [ - 142 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset - 143 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset + 142 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + 143 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset 144 ] 145 before <insert-character-end> [ - 146 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + 146 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 147 cursor-row:num <- get *editor, cursor-row:offset 148 cursor-column:num <- get *editor, cursor-column:offset - 149 undo:&:list:&:operation <- get *editor, undo:offset + 149 undo:&:list:&:operation <- get *editor, undo:offset 150 { 151 ¦ # if previous operation was an insert, coalesce this operation with it 152 ¦ break-unless undo @@ -218,8 +218,8 @@ if ('onhashchange' in window) { 155 ¦ break-unless is-insert? 156 ¦ previous-coalesce-tag:num <- get typing, tag:offset 157 ¦ break-unless previous-coalesce-tag - 158 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 159 ¦ insert-until:&:duplex-list:char <- next before-cursor + 158 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 159 ¦ insert-until:&:duplex-list:char <- next before-cursor 160 ¦ typing <- put typing, insert-until:offset, insert-until 161 ¦ typing <- put typing, after-row:offset, cursor-row 162 ¦ typing <- put typing, after-column:offset, cursor-column @@ -228,8 +228,8 @@ if ('onhashchange' in window) { 165 ¦ break +done-adding-insert-operation 166 } 167 # if not, create a new operation - 168 insert-from:&:duplex-list:char <- next cursor-before - 169 insert-to:&:duplex-list:char <- next insert-from + 168 insert-from:&:duplex-list:char <- next cursor-before + 169 insert-to:&:duplex-list:char <- next insert-from 170 op:&:operation <- new operation:type 171 *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 172 editor <- add-operation editor, op @@ -240,17 +240,17 @@ if ('onhashchange' in window) { 177 after <insert-enter-begin> [ 178 cursor-row-before:num <- copy cursor-row 179 cursor-column-before:num <- copy cursor-column - 180 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset - 181 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset + 180 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + 181 cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset 182 ] 183 before <insert-enter-end> [ - 184 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + 184 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 185 cursor-row:num <- get *editor, cursor-row:offset 186 cursor-column:num <- get *editor, cursor-row:offset 187 # never coalesce - 188 insert-from:&:duplex-list:char <- next cursor-before - 189 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 190 insert-to:&:duplex-list:char <- next before-cursor + 188 insert-from:&:duplex-list:char <- next cursor-before + 189 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + 190 insert-to:&:duplex-list:char <- next before-cursor 191 op:&:operation <- new operation:type 192 *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 193 editor <- add-operation editor, op @@ -263,10 +263,10 @@ if ('onhashchange' in window) { 200 def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ 201 local-scope 202 load-ingredients - 203 undo:&:list:&:operation <- get *editor, undo:offset + 203 undo:&:list:&:operation <- get *editor, undo:offset 204 undo <- push op undo 205 *editor <- put *editor, undo:offset, undo - 206 redo:&:list:&:operation <- get *editor, redo:offset + 206 redo:&:list:&:operation <- get *editor, redo:offset 207 redo <- copy 0 208 *editor <- put *editor, redo:offset, redo 209 ] @@ -275,17 +275,17 @@ if ('onhashchange' in window) { 212 { 213 ¦ typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 214 ¦ break-unless is-insert? - 215 ¦ start:&:duplex-list:char <- get typing, insert-from:offset - 216 ¦ end:&:duplex-list:char <- get typing, insert-until:offset + 215 ¦ start:&:duplex-list:char <- get typing, insert-from:offset + 216 ¦ end:&:duplex-list:char <- get typing, insert-until:offset 217 ¦ # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - 218 ¦ before-cursor:&:duplex-list:char <- prev start + 218 ¦ before-cursor:&:duplex-list:char <- prev start 219 ¦ *editor <- put *editor, before-cursor:offset, before-cursor 220 ¦ remove-between before-cursor, end 221 ¦ cursor-row <- get typing, before-row:offset 222 ¦ *editor <- put *editor, cursor-row:offset, cursor-row 223 ¦ cursor-column <- get typing, before-column:offset 224 ¦ *editor <- put *editor, cursor-column:offset, cursor-column - 225 ¦ top:&:duplex-list:char <- get typing, before-top-of-screen:offset + 225 ¦ top:&:duplex-list:char <- get typing, before-top-of-screen:offset 226 ¦ *editor <- put *editor, top-of-screen:offset, top 227 } 228 ] @@ -476,7 +476,7 @@ if ('onhashchange' in window) { 413 ¦ typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 414 ¦ break-unless is-insert? 415 ¦ before-cursor <- get *editor, before-cursor:offset - 416 ¦ insert-from:&:duplex-list:char <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away + 416 ¦ insert-from:&:duplex-list:char <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away 417 ¦ # assert insert-to matches next(before-cursor) 418 ¦ insert-range before-cursor, insert-from 419 ¦ # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen @@ -484,7 +484,7 @@ if ('onhashchange' in window) { 421 ¦ *editor <- put *editor, cursor-row:offset, cursor-row 422 ¦ cursor-column <- get typing, after-column:offset 423 ¦ *editor <- put *editor, cursor-column:offset, cursor-column - 424 ¦ top:&:duplex-list:char <- get typing, after-top-of-screen:offset + 424 ¦ top:&:duplex-list:char <- get typing, after-top-of-screen:offset 425 ¦ *editor <- put *editor, top-of-screen:offset, top 426 } 427 ] @@ -782,17 +782,17 @@ if ('onhashchange' in window) { 719 after <move-cursor-begin> [ 720 cursor-row-before:num <- get *editor, cursor-row:offset 721 cursor-column-before:num <- get *editor, cursor-column:offset - 722 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + 722 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 723 ] 724 before <move-cursor-end> [ - 725 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + 725 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 726 cursor-row:num <- get *editor, cursor-row:offset 727 cursor-column:num <- get *editor, cursor-column:offset 728 { 729 ¦ break-unless undo-coalesce-tag 730 ¦ # if previous operation was also a move, and also had the same coalesce 731 ¦ # tag, coalesce with it - 732 ¦ undo:&:list:&:operation <- get *editor, undo:offset + 732 ¦ undo:&:list:&:operation <- get *editor, undo:offset 733 ¦ break-unless undo 734 ¦ op:&:operation <- first undo 735 ¦ move:move-operation, is-move?:bool <- maybe-convert *op, move:variant @@ -821,7 +821,7 @@ if ('onhashchange' in window) { 758 ¦ *editor <- put *editor, cursor-row:offset, cursor-row 759 ¦ cursor-column <- get move, before-column:offset 760 ¦ *editor <- put *editor, cursor-column:offset, cursor-column - 761 ¦ top:&:duplex-list:char <- get move, before-top-of-screen:offset + 761 ¦ top:&:duplex-list:char <- get move, before-top-of-screen:offset 762 ¦ *editor <- put *editor, top-of-screen:offset, top 763 } 764 ] @@ -1457,7 +1457,7 @@ if ('onhashchange' in window) { 1394 ¦ *editor <- put *editor, cursor-row:offset, cursor-row 1395 ¦ cursor-column <- get move, after-column:offset 1396 ¦ *editor <- put *editor, cursor-column:offset, cursor-column -1397 ¦ top:&:duplex-list:char <- get move, after-top-of-screen:offset +1397 ¦ top:&:duplex-list:char <- get move, after-top-of-screen:offset 1398 ¦ *editor <- put *editor, top-of-screen:offset, top 1399 } 1400 ] @@ -1678,16 +1678,16 @@ if ('onhashchange' in window) { 1615 1616 # save operation to undo 1617 after <backspace-character-begin> [ -1618 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +1618 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 1619 ] 1620 before <backspace-character-end> [ 1621 { 1622 ¦ break-unless backspaced-cell # backspace failed; don't add an undo operation -1623 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +1623 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1624 ¦ cursor-row:num <- get *editor, cursor-row:offset 1625 ¦ cursor-column:num <- get *editor, cursor-row:offset -1626 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1627 ¦ undo:&:list:&:operation <- get *editor, undo:offset +1626 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1627 ¦ undo:&:list:&:operation <- get *editor, undo:offset 1628 ¦ { 1629 ¦ ¦ # if previous operation was an insert, coalesce this operation with it 1630 ¦ ¦ break-unless undo @@ -1698,7 +1698,7 @@ if ('onhashchange' in window) { 1635 ¦ ¦ coalesce?:bool <- equal previous-coalesce-tag, 1/coalesce-backspace 1636 ¦ ¦ break-unless coalesce? 1637 ¦ ¦ deletion <- put deletion, delete-from:offset, before-cursor -1638 ¦ ¦ backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset +1638 ¦ ¦ backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset 1639 ¦ ¦ insert-range backspaced-cell, backspaced-so-far 1640 ¦ ¦ deletion <- put deletion, deleted-text:offset, backspaced-cell 1641 ¦ ¦ deletion <- put deletion, after-row:offset, cursor-row @@ -1709,7 +1709,7 @@ if ('onhashchange' in window) { 1646 ¦ } 1647 ¦ # if not, create a new operation 1648 ¦ op:&:operation <- new operation:type -1649 ¦ deleted-until:&:duplex-list:char <- next before-cursor +1649 ¦ deleted-until:&:duplex-list:char <- next before-cursor 1650 ¦ *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 1651 ¦ editor <- add-operation editor, op 1652 ¦ +done-adding-backspace-operation @@ -1720,10 +1720,10 @@ if ('onhashchange' in window) { 1657 { 1658 ¦ deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1659 ¦ break-unless is-delete? -1660 ¦ anchor:&:duplex-list:char <- get deletion, delete-from:offset +1660 ¦ anchor:&:duplex-list:char <- get deletion, delete-from:offset 1661 ¦ break-unless anchor -1662 ¦ deleted:&:duplex-list:char <- get deletion, deleted-text:offset -1663 ¦ old-cursor:&:duplex-list:char <- last deleted +1662 ¦ deleted:&:duplex-list:char <- get deletion, deleted-text:offset +1663 ¦ old-cursor:&:duplex-list:char <- last deleted 1664 ¦ insert-range anchor, deleted 1665 ¦ # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1666 ¦ before-cursor <- copy old-cursor @@ -1731,7 +1731,7 @@ if ('onhashchange' in window) { 1668 ¦ *editor <- put *editor, cursor-row:offset, cursor-row 1669 ¦ cursor-column <- get deletion, before-column:offset 1670 ¦ *editor <- put *editor, cursor-column:offset, cursor-column -1671 ¦ top:&:duplex-list:char <- get deletion, before-top-of-screen:offset +1671 ¦ top:&:duplex-list:char <- get deletion, before-top-of-screen:offset 1672 ¦ *editor <- put *editor, top-of-screen:offset, top 1673 } 1674 ] @@ -1740,16 +1740,16 @@ if ('onhashchange' in window) { 1677 { 1678 ¦ deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1679 ¦ break-unless is-delete? -1680 ¦ start:&:duplex-list:char <- get deletion, delete-from:offset -1681 ¦ end:&:duplex-list:char <- get deletion, delete-until:offset -1682 ¦ data:&:duplex-list:char <- get *editor, data:offset +1680 ¦ start:&:duplex-list:char <- get deletion, delete-from:offset +1681 ¦ end:&:duplex-list:char <- get deletion, delete-until:offset +1682 ¦ data:&:duplex-list:char <- get *editor, data:offset 1683 ¦ remove-between start, end 1684 ¦ # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1685 ¦ cursor-row <- get deletion, after-row:offset 1686 ¦ *editor <- put *editor, cursor-row:offset, cursor-row 1687 ¦ cursor-column <- get deletion, after-column:offset 1688 ¦ *editor <- put *editor, cursor-column:offset, cursor-column -1689 ¦ top:&:duplex-list:char <- get deletion, before-top-of-screen:offset +1689 ¦ top:&:duplex-list:char <- get deletion, before-top-of-screen:offset 1690 ¦ *editor <- put *editor, top-of-screen:offset, top 1691 } 1692 ] @@ -1904,16 +1904,16 @@ if ('onhashchange' in window) { 1841 ] 1842 1843 after <delete-character-begin> [ -1844 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +1844 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 1845 ] 1846 before <delete-character-end> [ 1847 { 1848 ¦ break-unless deleted-cell # delete failed; don't add an undo operation -1849 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +1849 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1850 ¦ cursor-row:num <- get *editor, cursor-row:offset 1851 ¦ cursor-column:num <- get *editor, cursor-column:offset -1852 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1853 ¦ undo:&:list:&:operation <- get *editor, undo:offset +1852 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +1853 ¦ undo:&:list:&:operation <- get *editor, undo:offset 1854 ¦ { 1855 ¦ ¦ # if previous operation was an insert, coalesce this operation with it 1856 ¦ ¦ break-unless undo @@ -1923,9 +1923,9 @@ if ('onhashchange' in window) { 1860 ¦ ¦ previous-coalesce-tag:num <- get deletion, tag:offset 1861 ¦ ¦ coalesce?:bool <- equal previous-coalesce-tag, 2/coalesce-delete 1862 ¦ ¦ break-unless coalesce? -1863 ¦ ¦ delete-until:&:duplex-list:char <- next before-cursor +1863 ¦ ¦ delete-until:&:duplex-list:char <- next before-cursor 1864 ¦ ¦ deletion <- put deletion, delete-until:offset, delete-until -1865 ¦ ¦ deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset +1865 ¦ ¦ deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset 1866 ¦ ¦ deleted-so-far <- append deleted-so-far, deleted-cell 1867 ¦ ¦ deletion <- put deletion, deleted-text:offset, deleted-so-far 1868 ¦ ¦ deletion <- put deletion, after-row:offset, cursor-row @@ -1936,7 +1936,7 @@ if ('onhashchange' in window) { 1873 ¦ } 1874 ¦ # if not, create a new operation 1875 ¦ op:&:operation <- new operation:type -1876 ¦ deleted-until:&:duplex-list:char <- next before-cursor +1876 ¦ deleted-until:&:duplex-list:char <- next before-cursor 1877 ¦ *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 1878 ¦ editor <- add-operation editor, op 1879 ¦ +done-adding-delete-operation @@ -2030,15 +2030,15 @@ if ('onhashchange' in window) { 1967 ] 1968 1969 after <delete-to-end-of-line-begin> [ -1970 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +1970 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 1971 ] 1972 before <delete-to-end-of-line-end> [ 1973 { 1974 ¦ break-unless deleted-cells # delete failed; don't add an undo operation -1975 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +1975 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1976 ¦ cursor-row:num <- get *editor, cursor-row:offset 1977 ¦ cursor-column:num <- get *editor, cursor-column:offset -1978 ¦ deleted-until:&:duplex-list:char <- next before-cursor +1978 ¦ deleted-until:&:duplex-list:char <- next before-cursor 1979 ¦ op:&:operation <- new operation:type 1980 ¦ *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 1981 ¦ editor <- add-operation editor, op @@ -2133,15 +2133,15 @@ if ('onhashchange' in window) { 2070 ] 2071 2072 after <delete-to-start-of-line-begin> [ -2073 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset +2073 top-before:&:duplex-list:char <- get *editor, top-of-screen:offset 2074 ] 2075 before <delete-to-start-of-line-end> [ 2076 { 2077 ¦ break-unless deleted-cells # delete failed; don't add an undo operation -2078 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset +2078 ¦ top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 2079 ¦ op:&:operation <- new operation:type -2080 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -2081 ¦ deleted-until:&:duplex-list:char <- next before-cursor +2080 ¦ before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +2081 ¦ deleted-until:&:duplex-list:char <- next before-cursor 2082 ¦ cursor-row:num <- get *editor, cursor-row:offset 2083 ¦ cursor-column:num <- get *editor, cursor-column:offset 2084 ¦ *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 -- cgit 1.4.1-2-gfad0