diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-04-23 17:02:16 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-04-23 17:15:16 -0700 |
commit | 7bf9212fd47e505711cc0873d30456e3d793034d (patch) | |
tree | e6c84ac4666269b5e366ceff78dd040ac39343bc /sandbox | |
parent | 991d76f32817f5515fb8db25a7d5ca2912cfe4ac (diff) | |
download | mu-7bf9212fd47e505711cc0873d30456e3d793034d.tar.gz |
2861 - 'maybe-convert' no longer returns address
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/002-typing.mu | 26 | ||||
-rw-r--r-- | sandbox/003-shortcuts.mu | 34 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 22 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 6 | ||||
-rw-r--r-- | sandbox/006-sandbox-edit.mu | 4 | ||||
-rw-r--r-- | sandbox/007-sandbox-delete.mu | 2 | ||||
-rw-r--r-- | sandbox/008-sandbox-test.mu | 4 | ||||
-rw-r--r-- | sandbox/009-sandbox-trace.mu | 4 | ||||
-rw-r--r-- | sandbox/011-editor-undo.mu | 144 |
9 files changed, 125 insertions, 121 deletions
diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 1c27ce98..d7624ccf 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -25,15 +25,15 @@ def editor-event-loop screen:address:shared:screen, console:address:shared:conso break-if quit? # only in tests trace 10, [app], [next-event] # 'touch' event - t:address:touch-event <- maybe-convert e, touch:variant + t:touch-event, is-touch?:boolean <- maybe-convert e, touch:variant { - break-unless t - move-cursor-in-editor screen, editor, *t + break-unless is-touch? + move-cursor-in-editor screen, editor, t loop +next-event:label } # keyboard events { - break-if t + break-if is-touch? screen, editor, go-render?:boolean <- handle-keyboard-event screen, editor, e { break-unless go-render? @@ -177,24 +177,24 @@ def handle-keyboard-event screen:address:shared:screen, editor:address:shared:ed save-column:number <- copy cursor-column # character { - c:address:character <- maybe-convert e, text:variant - break-unless c + c:character, is-unicode?:boolean <- maybe-convert e, text:variant + break-unless is-unicode? trace 10, [app], [handle-keyboard-event: special character] # exceptions for special characters go here <handle-special-character> # ignore any other special characters - regular-character?:boolean <- greater-or-equal *c, 32/space + regular-character?:boolean <- greater-or-equal c, 32/space go-render? <- copy 0/false return-unless regular-character? # otherwise type it in <insert-character-begin> - editor, screen, go-render?:boolean <- insert-at-cursor editor, *c, screen + editor, screen, go-render?:boolean <- insert-at-cursor editor, c, screen <insert-character-end> return } # special key to modify the text or move the cursor - k:address:number <- maybe-convert e:event, keycode:variant - assert k, [event was of unknown type; neither keyboard nor mouse] + k:number, is-keycode?:boolean <- maybe-convert e:event, keycode:variant + assert is-keycode?, [event was of unknown type; neither keyboard nor mouse] # handlers for each special key will go here <handle-special-key> go-render? <- copy 1/true @@ -821,7 +821,7 @@ scenario editor-moves-cursor-down-after-inserting-newline [ after <handle-special-character> [ { - newline?:boolean <- equal *c, 10/newline + newline?:boolean <- equal c, 10/newline break-unless newline? <insert-enter-begin> editor <- insert-new-line-and-indent editor, screen @@ -1003,7 +1003,7 @@ ef] after <handle-special-key> [ { - paste-start?:boolean <- equal *k, 65507/paste-start + paste-start?:boolean <- equal k, 65507/paste-start break-unless paste-start? *editor <- put *editor, indent?:offset, 0/false go-render? <- copy 1/true @@ -1013,7 +1013,7 @@ after <handle-special-key> [ after <handle-special-key> [ { - paste-end?:boolean <- equal *k, 65506/paste-end + paste-end?:boolean <- equal k, 65506/paste-end break-unless paste-end? *editor <- put *editor, indent?:offset, 1/true go-render? <- copy 1/true diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index f29773af..8ed01de7 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -25,7 +25,7 @@ cd] after <handle-special-character> [ { - tab?:boolean <- equal *c, 9/tab + tab?:boolean <- equal c, 9/tab break-unless tab? <insert-character-begin> editor, screen, go-render?:boolean <- insert-at-cursor editor, 32/space, screen @@ -68,7 +68,7 @@ scenario editor-handles-backspace-key [ after <handle-special-character> [ { - delete-previous-character?:boolean <- equal *c, 8/backspace + delete-previous-character?:boolean <- equal c, 8/backspace break-unless delete-previous-character? <backspace-character-begin> editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen @@ -339,7 +339,7 @@ scenario editor-handles-delete-key [ after <handle-special-key> [ { - delete-next-character?:boolean <- equal *k, 65522/delete + delete-next-character?:boolean <- equal k, 65522/delete break-unless delete-next-character? <delete-character-begin> editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen @@ -415,7 +415,7 @@ scenario editor-moves-cursor-right-with-key [ after <handle-special-key> [ { - move-to-next-character?:boolean <- equal *k, 65514/right-arrow + move-to-next-character?:boolean <- equal k, 65514/right-arrow break-unless move-to-next-character? # if not at end of text next-cursor:address:shared:duplex-list:character <- next before-cursor @@ -699,7 +699,7 @@ scenario editor-moves-cursor-left-with-key [ after <handle-special-key> [ { - move-to-previous-character?:boolean <- equal *k, 65515/left-arrow + move-to-previous-character?:boolean <- equal k, 65515/left-arrow break-unless move-to-previous-character? trace 10, [app], [left arrow] # if not at start of text (before-cursor at § sentinel) @@ -963,7 +963,7 @@ def] after <handle-special-key> [ { - move-to-previous-line?:boolean <- equal *k, 65517/up-arrow + move-to-previous-line?:boolean <- equal k, 65517/up-arrow break-unless move-to-previous-line? <move-cursor-begin> editor, go-render? <- move-to-previous-line editor @@ -1193,7 +1193,7 @@ def] after <handle-special-key> [ { - move-to-next-line?:boolean <- equal *k, 65516/down-arrow + move-to-next-line?:boolean <- equal k, 65516/down-arrow break-unless move-to-next-line? <move-cursor-begin> editor, go-render? <- move-to-next-line editor, screen-height @@ -1324,7 +1324,7 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ after <handle-special-character> [ { - move-to-start-of-line?:boolean <- equal *c, 1/ctrl-a + move-to-start-of-line?:boolean <- equal c, 1/ctrl-a break-unless move-to-start-of-line? <move-cursor-begin> move-to-start-of-line editor @@ -1337,7 +1337,7 @@ after <handle-special-character> [ after <handle-special-key> [ { - move-to-start-of-line?:boolean <- equal *k, 65521/home + move-to-start-of-line?:boolean <- equal k, 65521/home break-unless move-to-start-of-line? <move-cursor-begin> move-to-start-of-line editor @@ -1496,7 +1496,7 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ after <handle-special-character> [ { - move-to-end-of-line?:boolean <- equal *c, 5/ctrl-e + move-to-end-of-line?:boolean <- equal c, 5/ctrl-e break-unless move-to-end-of-line? <move-cursor-begin> move-to-end-of-line editor @@ -1509,7 +1509,7 @@ after <handle-special-character> [ after <handle-special-key> [ { - move-to-end-of-line?:boolean <- equal *k, 65520/end + move-to-end-of-line?:boolean <- equal k, 65520/end break-unless move-to-end-of-line? <move-cursor-begin> move-to-end-of-line editor @@ -1642,7 +1642,7 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u [ after <handle-special-character> [ { - delete-to-start-of-line?:boolean <- equal *c, 21/ctrl-u + delete-to-start-of-line?:boolean <- equal c, 21/ctrl-u break-unless delete-to-start-of-line? <delete-to-start-of-line-begin> deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor @@ -1776,7 +1776,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k [ after <handle-special-character> [ { - delete-to-end-of-line?:boolean <- equal *c, 11/ctrl-k + delete-to-end-of-line?:boolean <- equal c, 11/ctrl-k break-unless delete-to-end-of-line? <delete-to-end-of-line-begin> deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor @@ -2718,7 +2718,7 @@ d] after <handle-special-character> [ { - page-down?:boolean <- equal *c, 6/ctrl-f + page-down?:boolean <- equal c, 6/ctrl-f break-unless page-down? old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> @@ -2734,7 +2734,7 @@ after <handle-special-character> [ after <handle-special-key> [ { - page-down?:boolean <- equal *k, 65518/page-down + page-down?:boolean <- equal k, 65518/page-down break-unless page-down? old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> @@ -2912,7 +2912,7 @@ d] after <handle-special-character> [ { - page-up?:boolean <- equal *c, 2/ctrl-b + page-up?:boolean <- equal c, 2/ctrl-b break-unless page-up? old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> @@ -2928,7 +2928,7 @@ after <handle-special-character> [ after <handle-special-key> [ { - page-up?:boolean <- equal *k, 65519/page-up + page-up?:boolean <- equal k, 65519/page-up break-unless page-up? old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index a329c8c1..22fe6745 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -56,35 +56,35 @@ def event-loop screen:address:shared:screen, console:address:shared:console, env <handle-event> # check for global events that will trigger regardless of which editor has focus { - k:address:number <- maybe-convert e:event, keycode:variant - break-unless k + k:number, is-keycode?:boolean <- maybe-convert e:event, keycode:variant + break-unless is-keycode? <global-keypress> } { - c:address:character <- maybe-convert e:event, text:variant - break-unless c + c:character, is-unicode?:boolean <- maybe-convert e:event, text:variant + break-unless is-unicode? <global-type> } # 'touch' event { - t:address:touch-event <- maybe-convert e:event, touch:variant - break-unless t + t:touch-event, is-touch?:boolean <- maybe-convert e:event, touch:variant + break-unless is-touch? # ignore all but 'left-click' events for now # todo: test this - touch-type:number <- get *t, type:offset + touch-type:number <- get t, type:offset is-left-click?:boolean <- equal touch-type, 65513/mouse-left loop-unless is-left-click?, +next-event:label # later exceptions for non-editor touches will go here <global-touch> - move-cursor-in-editor screen, current-sandbox, *t + move-cursor-in-editor screen, current-sandbox, t screen <- update-cursor screen, current-sandbox, env loop +next-event:label } # 'resize' event - redraw editor # todo: test this after supporting resize in assume-console { - r:address:resize-event <- maybe-convert e:event, resize:variant - break-unless r + r:resize-event, is-resize?:boolean <- maybe-convert e:event, resize:variant + break-unless is-resize? # if more events, we're still resizing; wait until we stop more-events?:boolean <- has-more-events? console { @@ -327,7 +327,7 @@ def render-code screen:address:shared:screen, s:address:shared:array:character, after <global-type> [ { - redraw-screen?:boolean <- equal *c, 12/ctrl-l + redraw-screen?:boolean <- equal c, 12/ctrl-l break-unless redraw-screen? screen <- render-all screen, env:address:shared:programming-environment-data sync-screen screen diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 0b6bd79c..7297c768 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -109,7 +109,7 @@ scenario run-and-show-results [ after <global-keypress> [ # F4? load all code and run all sandboxes. { - do-run?:boolean <- equal *k, 65532/F4 + do-run?:boolean <- equal k, 65532/F4 break-unless do-run? screen <- update-status screen, [running... ], 245/grey test-recipes:address:shared:array:character, _/optional <- next-ingredient @@ -606,7 +606,7 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ # down on sandbox side updates render-from when sandbox editor has cursor at bottom after <global-keypress> [ { - down?:boolean <- equal *k, 65516/down-arrow + down?:boolean <- equal k, 65516/down-arrow break-unless down? sandbox-bottom:number <- get *current-sandbox, bottom:offset sandbox-cursor:number <- get *current-sandbox, cursor-row:offset @@ -646,7 +646,7 @@ after <update-cursor-special-cases> [ # 'up' on sandbox side is like 'down': updates first-sandbox-to-render when necessary after <global-keypress> [ { - up?:boolean <- equal *k, 65517/up-arrow + up?:boolean <- equal k, 65517/up-arrow break-unless up? render-from:number <- get *env, render-from:offset at-beginning?:boolean <- equal render-from, -1 diff --git a/sandbox/006-sandbox-edit.mu b/sandbox/006-sandbox-edit.mu index c863efe1..91c632ed 100644 --- a/sandbox/006-sandbox-edit.mu +++ b/sandbox/006-sandbox-edit.mu @@ -67,13 +67,13 @@ after <global-touch> [ # below editor? pop appropriate sandbox contents back into sandbox editor provided it's empty { sandbox-left-margin:number <- get *current-sandbox, left:offset - click-column:number <- get *t, column:offset + click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset - click-row:number <- get *t, row:offset + click-row:number <- get t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? empty-sandbox-editor?:boolean <- empty-editor? current-sandbox diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index f99012b6..2fed31cd 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -66,7 +66,7 @@ scenario deleting-sandboxes [ after <global-touch> [ # on a sandbox delete icon? process delete { - was-delete?:boolean <- delete-sandbox *t, env + was-delete?:boolean <- delete-sandbox t, env break-unless was-delete? hide-screen screen screen <- render-sandbox-side screen, env diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu index acd4c04d..04a83ac6 100644 --- a/sandbox/008-sandbox-test.mu +++ b/sandbox/008-sandbox-test.mu @@ -106,13 +106,13 @@ after <global-touch> [ # check if it's inside the output of any sandbox { sandbox-left-margin:number <- get *current-sandbox, left:offset - click-column:number <- get *t, column:offset + click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset - click-row:number <- get *t, row:offset + click-row:number <- get t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on diff --git a/sandbox/009-sandbox-trace.mu b/sandbox/009-sandbox-trace.mu index a85a1920..c5f96726 100644 --- a/sandbox/009-sandbox-trace.mu +++ b/sandbox/009-sandbox-trace.mu @@ -134,13 +134,13 @@ after <global-touch> [ # check if it's inside the code of any sandbox { sandbox-left-margin:number <- get *current-sandbox, left:offset - click-column:number <- get *t, column:offset + click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset - click-row:number <- get *t, row:offset + click-row:number <- get t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose code is being clicked on diff --git a/sandbox/011-editor-undo.mu b/sandbox/011-editor-undo.mu index 07ecb14f..94135346 100644 --- a/sandbox/011-editor-undo.mu +++ b/sandbox/011-editor-undo.mu @@ -63,7 +63,7 @@ container editor-data [ # ctrl-z - undo operation after <handle-special-character> [ { - undo?:boolean <- equal *c, 26/ctrl-z + undo?:boolean <- equal c, 26/ctrl-z break-unless undo? undo:address:shared:list:address:shared:operation <- get *editor, undo:offset break-unless undo @@ -81,7 +81,7 @@ after <handle-special-character> [ # ctrl-y - redo operation after <handle-special-character> [ { - redo?:boolean <- equal *c, 25/ctrl-y + redo?:boolean <- equal c, 25/ctrl-y break-unless redo? redo:address:shared:list:address:shared:operation <- get *editor, redo:offset break-unless redo @@ -151,16 +151,17 @@ before <insert-character-end> [ # if previous operation was an insert, coalesce this operation with it break-unless undo op:address:shared:operation <- first undo - typing:address:insert-operation <- maybe-convert *op, typing:variant - break-unless typing - previous-coalesce-tag:number <- get *typing, tag:offset + typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant + break-unless is-insert? + previous-coalesce-tag:number <- get typing, tag:offset break-unless previous-coalesce-tag before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset insert-until:address:shared:duplex-list:character <- next before-cursor - *typing <- put *typing, insert-until:offset, insert-until - *typing <- put *typing, after-row:offset, cursor-row - *typing <- put *typing, after-column:offset, cursor-column - *typing <- put *typing, after-top-of-screen:offset, top-after + typing <- put typing, insert-until:offset, insert-until + typing <- put typing, after-row:offset, cursor-row + typing <- put typing, after-column:offset, cursor-column + typing <- put typing, after-top-of-screen:offset, top-after + *op <- merge 0/insert-operation, typing break +done-adding-insert-operation:label } # if not, create a new operation @@ -210,19 +211,19 @@ def add-operation editor:address:shared:editor-data, op:address:shared:operation after <handle-undo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant - break-unless typing - start:address:shared:duplex-list:character <- get *typing, insert-from:offset - end:address:shared:duplex-list:character <- get *typing, insert-until:offset + typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant + break-unless is-insert? + start:address:shared:duplex-list:character <- get typing, insert-from:offset + end:address:shared:duplex-list:character <- get typing, insert-until:offset # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen before-cursor:address:shared:duplex-list:character <- prev start *editor <- put *editor, before-cursor:offset, before-cursor remove-between before-cursor, end - cursor-row <- get *typing, before-row:offset + cursor-row <- get typing, before-row:offset *editor <- put *editor, cursor-row:offset, cursor-row - cursor-column <- get *typing, before-column:offset + cursor-column <- get typing, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get *typing, before-top-of-screen:offset + top:address:shared:duplex-list:character <- get typing, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -410,18 +411,18 @@ scenario editor-redo-typing [ after <handle-redo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant - break-unless typing + typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant + break-unless is-insert? before-cursor <- get *editor, before-cursor:offset - insert-from:address:shared:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away + insert-from:address:shared:duplex-list:character <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away # assert insert-to matches next(before-cursor) insert-range before-cursor, insert-from # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - cursor-row <- get *typing, after-row:offset + cursor-row <- get typing, after-row:offset *editor <- put *editor, cursor-row:offset, cursor-row - cursor-column <- get *typing, after-column:offset + cursor-column <- get typing, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get *typing, after-top-of-screen:offset + top:address:shared:duplex-list:character <- get typing, after-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -730,14 +731,15 @@ before <move-cursor-end> [ undo:address:shared:list:address:shared:operation <- get *editor, undo:offset break-unless undo op:address:shared:operation <- first undo - move:address:move-operation <- maybe-convert *op, move:variant - break-unless move - previous-coalesce-tag:number <- get *move, tag:offset + move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant + break-unless is-move? + previous-coalesce-tag:number <- get move, tag:offset coalesce?:boolean <- equal undo-coalesce-tag, previous-coalesce-tag break-unless coalesce? - *move <- put *move, after-row:offset, cursor-row - *move <- put *move, after-column:offset, cursor-column - *move <- put *move, after-top-of-screen:offset, top-after + move <- put move, after-row:offset, cursor-row + move <- put move, after-column:offset, cursor-column + move <- put move, after-top-of-screen:offset, top-after + *op <- merge 1/move-operation, move break +done-adding-move-operation:label } op:address:shared:operation <- new operation:type @@ -748,14 +750,14 @@ before <move-cursor-end> [ after <handle-undo> [ { - move:address:move-operation <- maybe-convert *op, move:variant - break-unless move + move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant + break-unless is-move? # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - cursor-row <- get *move, before-row:offset + cursor-row <- get move, before-row:offset *editor <- put *editor, cursor-row:offset, cursor-row - cursor-column <- get *move, before-column:offset + cursor-column <- get move, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get *move, before-top-of-screen:offset + top:address:shared:duplex-list:character <- get move, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1378,14 +1380,14 @@ ghi] after <handle-redo> [ { - move:address:move-operation <- maybe-convert *op, move:variant - break-unless move + move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant + break-unless is-move? # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - cursor-row <- get *move, after-row:offset + cursor-row <- get move, after-row:offset *editor <- put *editor, cursor-row:offset, cursor-row - cursor-column <- get *move, after-column:offset + cursor-column <- get move, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get *move, after-top-of-screen:offset + top:address:shared:duplex-list:character <- get move, after-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1620,18 +1622,19 @@ before <backspace-character-end> [ # if previous operation was an insert, coalesce this operation with it break-unless *undo op:address:shared:operation <- first undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant - break-unless deletion - previous-coalesce-tag:number <- get *deletion, tag:offset + deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + break-unless is-delete? + previous-coalesce-tag:number <- get deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace break-unless coalesce? - *deletion <- put *deletion, delete-from:offset, before-cursor - backspaced-so-far:address:shared:duplex-list:character <- get *deletion, deleted-text:offset + deletion <- put deletion, delete-from:offset, before-cursor + backspaced-so-far:address:shared:duplex-list:character <- get deletion, deleted-text:offset insert-range backspaced-cell, backspaced-so-far - *deletion <- put *deletion, deleted-text:offset, backspaced-cell - *deletion <- put *deletion, after-row:offset, cursor-row - *deletion <- put *deletion, after-column:offset, cursor-column - *deletion <- put *deletion, after-top-of-screen:offset, top-after + deletion <- put deletion, deleted-text:offset, backspaced-cell + deletion <- put deletion, after-row:offset, cursor-row + deletion <- put deletion, after-column:offset, cursor-column + deletion <- put deletion, after-top-of-screen:offset, top-after + *op <- merge 2/delete-operation, deletion break +done-adding-backspace-operation:label } # if not, create a new operation @@ -1645,38 +1648,38 @@ before <backspace-character-end> [ after <handle-undo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant - break-unless deletion - anchor:address:shared:duplex-list:character <- get *deletion, delete-from:offset + deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + break-unless is-delete? + anchor:address:shared:duplex-list:character <- get deletion, delete-from:offset break-unless anchor - deleted:address:shared:duplex-list:character <- get *deletion, deleted-text:offset + deleted:address:shared:duplex-list:character <- get deletion, deleted-text:offset old-cursor:address:shared:duplex-list:character <- last deleted insert-range anchor, deleted # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen before-cursor <- copy old-cursor - cursor-row <- get *deletion, before-row:offset + cursor-row <- get deletion, before-row:offset *editor <- put *editor, cursor-row:offset, cursor-row - cursor-column <- get *deletion, before-column:offset + cursor-column <- get deletion, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get *deletion, before-top-of-screen:offset + top:address:shared:duplex-list:character <- get deletion, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] after <handle-redo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant - break-unless deletion - start:address:shared:duplex-list:character <- get *deletion, delete-from:offset - end:address:shared:duplex-list:character <- get *deletion, delete-until:offset + deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + break-unless is-delete? + start:address:shared:duplex-list:character <- get deletion, delete-from:offset + end:address:shared:duplex-list:character <- get deletion, delete-until:offset data:address:shared:duplex-list:character <- get *editor, data:offset remove-between start, end # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - cursor-row <- get *deletion, after-row:offset + cursor-row <- get deletion, after-row:offset *editor <- put *editor, cursor-row:offset, cursor-row - cursor-column <- get *deletion, after-column:offset + cursor-column <- get deletion, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get *deletion, before-top-of-screen:offset + top:address:shared:duplex-list:character <- get deletion, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1845,19 +1848,20 @@ before <delete-character-end> [ # if previous operation was an insert, coalesce this operation with it break-unless undo op:address:shared:operation <- first undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant - break-unless deletion - previous-coalesce-tag:number <- get *deletion, tag:offset + deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + break-unless is-delete? + previous-coalesce-tag:number <- get deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete break-unless coalesce? delete-until:address:shared:duplex-list:character <- next before-cursor - *deletion <- put *deletion, delete-until:offset, delete-until - deleted-so-far:address:shared:duplex-list:character <- get *deletion, deleted-text:offset + deletion <- put deletion, delete-until:offset, delete-until + deleted-so-far:address:shared:duplex-list:character <- get deletion, deleted-text:offset deleted-so-far <- append deleted-so-far, deleted-cell - *deletion <- put *deletion, deleted-text:offset, deleted-so-far - *deletion <- put *deletion, after-row:offset, cursor-row - *deletion <- put *deletion, after-column:offset, cursor-column - *deletion <- put *deletion, after-top-of-screen:offset, top-after + deletion <- put deletion, deleted-text:offset, deleted-so-far + deletion <- put deletion, after-row:offset, cursor-row + deletion <- put deletion, after-column:offset, cursor-column + deletion <- put deletion, after-top-of-screen:offset, top-after + *op <- merge 2/delete-operation, deletion break +done-adding-delete-operation:label } # if not, create a new operation |