diff options
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/001-editor.mu | 38 | ||||
-rw-r--r-- | sandbox/002-typing.mu | 238 | ||||
-rw-r--r-- | sandbox/003-shortcuts.mu | 490 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 112 | ||||
-rw-r--r-- | sandbox/006-sandbox-copy.mu | 30 | ||||
-rw-r--r-- | sandbox/007-sandbox-delete.mu | 50 | ||||
-rw-r--r-- | sandbox/008-sandbox-edit.mu | 40 | ||||
-rw-r--r-- | sandbox/009-sandbox-test.mu | 26 | ||||
-rw-r--r-- | sandbox/010-sandbox-trace.mu | 33 | ||||
-rw-r--r-- | sandbox/011-errors.mu | 137 | ||||
-rw-r--r-- | sandbox/012-editor-undo.mu | 503 |
11 files changed, 883 insertions, 814 deletions
diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 0b5aaa4a..bbe16390 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -14,10 +14,10 @@ def! main text:text [ ] scenario editor-initially-prints-text-to-screen [ + local-scope assume-screen 10/width, 5/height run [ - 1:text <- new [abc] - new-editor 1:text, screen:&:screen, 0/left, 10/right + new-editor [abc], screen:&:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -95,10 +95,11 @@ def insert-text editor:&:editor, text:text -> editor:&:editor [ ] scenario editor-initializes-without-data [ + local-scope assume-screen 5/width, 3/height run [ - 1:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right - 2:editor <- copy *1:&:editor + e:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right + 2:editor/raw <- copy *e ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -255,11 +256,12 @@ def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen ] scenario editor-initially-prints-multiple-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -270,10 +272,11 @@ def] ] scenario editor-initially-handles-offsets [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc] - new-editor s:text, screen:&:screen, 1/left, 5/right + new-editor s, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -283,11 +286,12 @@ scenario editor-initially-handles-offsets [ ] scenario editor-initially-prints-multiple-lines-at-offset [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 1/left, 5/right + new-editor s, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -298,10 +302,11 @@ def] ] scenario editor-initially-wraps-long-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -318,10 +323,11 @@ scenario editor-initially-wraps-long-lines [ ] scenario editor-initially-wraps-barely-long-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abcde] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -340,12 +346,12 @@ scenario editor-initially-wraps-barely-long-lines [ ] scenario editor-initializes-empty-text [ + local-scope assume-screen 5/width, 5/height run [ - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + e:&:editor <- new-editor [], screen:&:screen, 0/left, 5/right + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -361,12 +367,13 @@ scenario editor-initializes-empty-text [ # just a little color for mu code scenario render-colors-comments [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc # de f] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -442,12 +449,13 @@ def get-color color:num, c:char -> color:num [ ] scenario render-colors-assignment [ + local-scope assume-screen 8/width, 5/height run [ s:text <- new [abc d <- e f] - new-editor s:text, screen:&:screen, 0/left, 8/right + new-editor s, screen:&:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 92ebb654..07466d38 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -281,13 +281,13 @@ def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&: ] scenario editor-handles-empty-event-queue [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -298,18 +298,18 @@ scenario editor-handles-empty-event-queue [ ] scenario editor-handles-mouse-clicks [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -325,17 +325,17 @@ scenario editor-handles-mouse-clicks [ ] scenario editor-handles-mouse-clicks-outside-text [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # last line, to the right of text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -345,18 +345,19 @@ scenario editor-handles-mouse-clicks-outside-text [ ] scenario editor-handles-mouse-clicks-outside-text-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # interior line, to the right of text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -366,18 +367,19 @@ def] ] scenario editor-handles-mouse-clicks-outside-text-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -387,20 +389,20 @@ def] ] scenario editor-handles-mouse-clicks-outside-column [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] # editor occupies only left half of screen - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -416,19 +418,19 @@ scenario editor-handles-mouse-clicks-outside-column [ ] scenario editor-handles-mouse-clicks-in-menu-area [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -438,16 +440,16 @@ scenario editor-handles-mouse-clicks-in-menu-area [ ] scenario editor-inserts-characters-into-empty-editor [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -459,10 +461,10 @@ scenario editor-inserts-characters-into-empty-editor [ ] scenario editor-inserts-characters-at-cursor [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # type two letters at different places assume-console [ @@ -471,7 +473,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -483,17 +485,17 @@ scenario editor-inserts-characters-at-cursor [ ] scenario editor-inserts-characters-at-cursor-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -505,18 +507,19 @@ scenario editor-inserts-characters-at-cursor-2 [ ] scenario editor-inserts-characters-at-cursor-5 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -529,17 +532,17 @@ d] ] scenario editor-inserts-characters-at-cursor-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -551,18 +554,19 @@ scenario editor-inserts-characters-at-cursor-3 [ ] scenario editor-inserts-characters-at-cursor-4 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -575,18 +579,19 @@ d] ] scenario editor-inserts-characters-at-cursor-6 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -599,15 +604,15 @@ d] ] scenario editor-moves-cursor-after-inserting-characters [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ab] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [ab], screen:&:screen, 0/left, 5/right + editor-render screen, e assume-console [ type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -620,16 +625,16 @@ scenario editor-moves-cursor-after-inserting-characters [ # if the cursor reaches the right margin, wrap the line scenario editor-wraps-line-on-insert [ + local-scope assume-screen 5/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # no wrap yet screen-should-contain [ @@ -644,7 +649,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # now wrap screen-should-contain [ @@ -657,21 +662,22 @@ scenario editor-wraps-line-on-insert [ ] scenario editor-wraps-line-on-insert-2 [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abcdefg + s:text <- new [abcdefg defg] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -732,6 +738,7 @@ after <insert-character-special-case> [ { below-screen?:bool <- greater-or-equal cursor-row, screen-height break-unless below-screen? + <scroll-down> } go-render? <- copy 1/true return @@ -739,17 +746,17 @@ after <insert-character-special-case> [ ] scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -768,9 +775,9 @@ scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ local-scope assume-screen 10/width, 5/height # create an editor containing two lines - contents:text <- new [abc + s:text <- new [abc xyz] - 1:&:editor/raw <- new-editor contents, screen, 0/left, 5/right + e:&:editor <- new-editor s, screen, 0/left, 5/right screen-should-contain [ . . .abc . @@ -782,7 +789,7 @@ xyz] type [de] # trigger wrap ] run [ - editor-event-loop screen:&:screen, console:&:console, 1:&:editor/raw + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -794,17 +801,17 @@ xyz] ] scenario editor-wraps-cursor-to-left-margin [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 2/left, 7/right + e:&:editor <- new-editor [abcde], screen:&:screen, 2/left, 7/right assume-console [ left-click 1, 5 # line is full; no wrap icon yet type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -830,15 +837,15 @@ after <editor-initialization> [ ] scenario editor-moves-cursor-down-after-inserting-newline [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -854,14 +861,14 @@ after <handle-special-character> [ newline?:bool <- equal c, 10/newline break-unless newline? <insert-enter-begin> - editor <- insert-newline-and-indent editor, screen + editor <- insert-new-line-and-indent editor, screen <insert-enter-end> go-render? <- copy 1/true return } ] -def insert-newline-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ +def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ local-scope load-ingredients cursor-row:num <- get *editor, cursor-row:offset @@ -882,6 +889,7 @@ def insert-newline-and-indent editor:&:editor, screen:&:screen -> editor:&:edito { below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal, never greater break-unless below-screen? + <scroll-down> go-render? <- copy 1/true cursor-row <- subtract cursor-row, 1 # bring back into screen range *editor <- put *editor, cursor-row:offset, cursor-row @@ -935,15 +943,15 @@ def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num ] scenario editor-moves-cursor-down-after-inserting-newline-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -955,9 +963,9 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ ] scenario editor-clears-previous-line-completely-after-inserting-newline [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right assume-console [ press enter ] @@ -969,7 +977,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # line should be fully cleared screen-should-contain [ @@ -982,11 +990,12 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ ] scenario editor-inserts-indent-after-newline [ + local-scope assume-screen 10/width, 10/height - 1:text <- new [ab + s:text <- new [ab cd ef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -994,9 +1003,9 @@ ef] ] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1006,11 +1015,12 @@ ef] ] scenario editor-skips-indent-around-paste [ + local-scope assume-screen 10/width, 10/height - 1:text <- new [ab + s:text <- new [ab cd ef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -1019,9 +1029,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index d4f124ae..3c0f36d5 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -5,16 +5,17 @@ # tab - insert two spaces scenario editor-inserts-two-spaces-on-tab [ + local-scope assume-screen 10/width, 5/height # just one character in final line - 1:text <- new [ab + s:text <- new [ab cd] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -39,19 +40,19 @@ after <handle-special-character> [ # backspace - delete character before cursor scenario editor-handles-backspace-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -210,19 +211,20 @@ def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> re ] scenario editor-clears-last-line-on-backspace [ + local-scope assume-screen 10/width, 5/height # just one character in final line - 1:text <- new [ab + s:text <- new [ab cd] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right assume-console [ left-click 2, 0 # cursor at only character in final line press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -237,12 +239,13 @@ cd] ] scenario editor-joins-and-wraps-lines-on-backspace [ + local-scope assume-screen 10/width, 5/height # initialize editor with two long-ish but non-wrapping lines - 1:text <- new [abc def + s:text <- new [abc def ghi jkl] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -250,7 +253,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # resulting single line should wrap correctly screen-should-contain [ @@ -263,11 +266,11 @@ ghi jkl] ] scenario editor-wraps-long-lines-on-backspace [ + local-scope assume-screen 10/width, 5/height # initialize editor in part of the screen with a long line - 1:text <- new [abc def ghij] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 8/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc def ghij], screen:&:screen, 0/left, 8/right + editor-render screen, e # confirm that it wraps screen-should-contain [ . . @@ -282,7 +285,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -297,16 +300,16 @@ scenario editor-wraps-long-lines-on-backspace [ # delete - delete character at cursor scenario editor-handles-delete-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -320,7 +323,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -386,17 +389,17 @@ def delete-at-cursor editor:&:editor, screen:&:screen -> editor:&:editor, screen # right arrow scenario editor-moves-cursor-right-with-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -481,11 +484,12 @@ def move-cursor-coordinates-right editor:&:editor, screen-height:num -> editor:& ] scenario editor-moves-cursor-to-next-line-with-right-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -495,7 +499,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -503,7 +507,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -516,11 +520,12 @@ d] ] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 1/left, 10/right + editor-render screen, e assume-console [ press right-arrow press right-arrow @@ -529,7 +534,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -541,19 +546,19 @@ d] ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -570,11 +575,11 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ + local-scope assume-screen 10/width, 5/height # line just barely wrapping - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -582,9 +587,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -595,9 +600,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -607,19 +612,19 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 6/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 1/left, 6/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -636,11 +641,12 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ ] scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -649,7 +655,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # new character should be in next line screen-should-contain [ @@ -667,10 +673,10 @@ d] # left arrow scenario editor-moves-cursor-left-with-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 2 @@ -678,7 +684,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -709,12 +715,13 @@ after <handle-special-key> [ ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ + local-scope assume-screen 10/width, 5/height # initialize editor with two lines - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -722,9 +729,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -734,13 +741,14 @@ d] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ + local-scope assume-screen 10/width, 5/height # initialize editor with three lines - 1:text <- new [abc + s:text <- new [abc def g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s:text, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -750,7 +758,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -763,12 +771,13 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -777,7 +786,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # left-arrow should have had no effect screen-should-contain [ @@ -791,13 +800,14 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ + local-scope assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e:&:editor $clear-trace # position cursor right after empty line assume-console [ @@ -806,7 +816,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -819,11 +829,11 @@ d] ] scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a wrapping line - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -838,9 +848,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -850,12 +860,13 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ ] scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a wrapping line followed by a second line - 1:text <- new [abcdef + s:text <- new [abcdef g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -870,9 +881,9 @@ g] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 # previous row @@ -882,12 +893,13 @@ g] ] scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a line on the verge of wrapping, followed by a second line - 1:text <- new [abcd + s:text <- new [abcd e] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -902,9 +914,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -918,20 +930,21 @@ e] # up arrow scenario editor-moves-to-previous-line-with-up-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -942,7 +955,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1033,20 +1046,21 @@ def move-to-previous-line editor:&:editor -> editor:&:editor, go-render?:bool [ ] scenario editor-adjusts-column-at-previous-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ab + s:text <- new [ab def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1057,7 +1071,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1069,20 +1083,21 @@ def] ] scenario editor-adjusts-column-at-empty-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ + s:text <- new [ def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1093,7 +1108,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1105,13 +1120,14 @@ def] ] scenario editor-moves-to-previous-line-from-left-margin [ + local-scope assume-screen 10/width, 5/height # start out with three lines - 1:text <- new [abc + s:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1119,9 +1135,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1132,7 +1148,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1146,20 +1162,21 @@ ghi] # down arrow scenario editor-moves-to-next-line-with-down-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1171,7 +1188,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1237,20 +1254,21 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [ ] scenario editor-adjusts-column-at-next-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc de] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1261,7 +1279,7 @@ de] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1275,11 +1293,12 @@ de] # ctrl-a/home - move cursor to start of line scenario editor-moves-to-start-of-line-with-ctrl-a [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1287,9 +1306,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1350,11 +1369,12 @@ def move-to-start-of-line editor:&:editor -> editor:&:editor [ ] scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1362,9 +1382,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1375,10 +1395,11 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ ] scenario editor-moves-to-start-of-line-with-home [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1386,9 +1407,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1399,11 +1420,12 @@ scenario editor-moves-to-start-of-line-with-home [ ] scenario editor-moves-to-start-of-line-with-home-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1411,9 +1433,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1426,11 +1448,12 @@ scenario editor-moves-to-start-of-line-with-home-2 [ # ctrl-e/end - move cursor to end of line scenario editor-moves-to-end-of-line-with-ctrl-e [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1438,9 +1461,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1453,9 +1476,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1518,11 +1541,12 @@ def move-to-end-of-line editor:&:editor -> editor:&:editor [ ] scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1530,9 +1554,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1543,11 +1567,12 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ ] scenario editor-moves-to-end-of-line-with-end [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line, press 'end' assume-console [ @@ -1555,9 +1580,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1568,11 +1593,12 @@ scenario editor-moves-to-end-of-line-with-end [ ] scenario editor-moves-to-end-of-line-with-end-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1580,9 +1606,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1595,17 +1621,18 @@ scenario editor-moves-to-end-of-line-with-end-2 [ # ctrl-u - delete text from start of line until (but not at) cursor scenario editor-deletes-to-start-of-line-with-ctrl-u [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on second line, press ctrl-u assume-console [ left-click 2, 2 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1658,17 +1685,18 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor ] scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on first line (no newline before), press ctrl-u assume-console [ left-click 1, 2 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1681,17 +1709,18 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ ] scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of line, press ctrl-u assume-console [ left-click 1, 3 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1704,17 +1733,18 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ ] scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of final line, press ctrl-u assume-console [ left-click 2, 3 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1729,17 +1759,18 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ # ctrl-k - delete text from cursor to end of line (but not the newline) scenario editor-deletes-to-end-of-line-with-ctrl-k [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on first line, press ctrl-k assume-console [ left-click 1, 1 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to end of line screen-should-contain [ @@ -1784,17 +1815,18 @@ def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:& ] scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on second line (no newline after), press ctrl-k assume-console [ left-click 2, 1 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to end of line screen-should-contain [ @@ -1807,17 +1839,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes just last character screen-should-contain [ @@ -1830,17 +1863,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes nothing screen-should-contain [ @@ -1853,17 +1887,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes just the final character screen-should-contain [ @@ -1876,17 +1911,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes nothing screen-should-contain [ diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 4d6e2bdc..c83e9f9c 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -29,17 +29,17 @@ container sandbox [ ] scenario run-and-show-results [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 15/height # sandbox editor contains an instruction without storing outputs - 1:text <- new [divide-with-remainder 11, 3] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [divide-with-remainder 11, 3] # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints the results screen-should-contain [ @@ -82,7 +82,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints both sandboxes screen-should-contain [ @@ -501,23 +501,23 @@ def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, ] scenario run-updates-results [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope z:num <- add 2, 2 -return z +reply z ]] # sandbox editor contains an instruction without storing outputs - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] # run the code in the editors assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . run (F4) . . . @@ -529,7 +529,7 @@ return z . . ] # make a change (incrementing one of the args to 'add'), then rerun - 1:text <- new [ + recipes:text <- new [ def foo [ local-scope z:num <- add 2, 3 @@ -539,7 +539,7 @@ return z press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # check that screen updates the result on the right screen-should-contain [ @@ -555,17 +555,17 @@ return z ] scenario run-instruction-manages-screen-per-sandbox [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # editor contains an instruction - 1:text <- new [print-integer screen, 4] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [print-integer screen, 4] # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that it prints a little toy screen screen-should-contain [ @@ -605,37 +605,37 @@ def editor-contents editor:&:editor -> result:text [ ] scenario editor-provides-edited-contents [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:text <- editor-contents 2:&:editor - 4:@:char <- copy *3:text + editor-event-loop screen:&:screen, console:&:console, e + s:text <- editor-contents e + 1:@:char/raw <- copy *s ] memory-should-contain [ - 4:array:character <- [abdefc] + 1:array:character <- [abdefc] ] ] # scrolling through sandboxes scenario scrolling-down-past-bottom-of-sandbox-editor [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize - 1:text <- new [add 2, 2] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [add 2, 2] + render-all screen, env, render assume-console [ # create a sandbox press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -651,9 +651,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -671,9 +671,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor displays again screen-should-contain [ @@ -761,12 +761,12 @@ def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ ] scenario scrolling-through-multiple-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -775,9 +775,9 @@ scenario scrolling-through-multiple-sandboxes [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor screen-should-contain [ . run (F4) . .␣ . @@ -797,9 +797,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -821,7 +821,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # just second sandbox displayed screen-should-contain [ @@ -838,7 +838,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change screen-should-contain [ @@ -855,7 +855,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # back to displaying both sandboxes without editor screen-should-contain [ @@ -876,9 +876,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -900,9 +900,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # no change screen-should-contain [ @@ -922,19 +922,19 @@ scenario scrolling-through-multiple-sandboxes [ ] scenario scrolling-manages-sandbox-index-correctly [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create a sandbox assume-console [ press ctrl-n type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -950,7 +950,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -968,7 +968,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -986,7 +986,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox diff --git a/sandbox/006-sandbox-copy.mu b/sandbox/006-sandbox-copy.mu index c6472841..ea7d86ab 100644 --- a/sandbox/006-sandbox-copy.mu +++ b/sandbox/006-sandbox-copy.mu @@ -2,14 +2,14 @@ ## see code operate in multiple situations scenario copy-a-sandbox-to-editor [ + local-scope trace-until 50/app # trace too long assume-screen 50/width, 10/height - 1:text <- new [add 1, 1] + env:&:environment <- new-programming-environment screen:&:screen, [add 1, 1] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -27,7 +27,7 @@ scenario copy-a-sandbox-to-editor [ left-click 3, 19 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # it copies into editor screen-should-contain [ @@ -47,7 +47,7 @@ scenario copy-a-sandbox-to-editor [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -64,14 +64,14 @@ scenario copy-a-sandbox-to-editor [ ] scenario copy-a-sandbox-to-editor-2 [ + local-scope trace-until 50/app # trace too long assume-screen 50/width, 10/height - 1:text <- new [add 1, 1] + env:&:environment <- new-programming-environment screen:&:screen, [add 1, 1] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -89,7 +89,7 @@ scenario copy-a-sandbox-to-editor-2 [ left-click 3, 33 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # it copies into editor screen-should-contain [ @@ -109,7 +109,7 @@ scenario copy-a-sandbox-to-editor-2 [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -215,14 +215,14 @@ def within-range? x:num, low:num, high:num -> result:bool [ ] scenario copy-fails-if-sandbox-editor-not-empty [ + local-scope trace-until 50/app # trace too long assume-screen 50/width, 10/height - 1:text <- new [add 1, 1] + env:&:environment <- new-programming-environment screen:&:screen, [add 1, 1] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -240,7 +240,7 @@ scenario copy-fails-if-sandbox-editor-not-empty [ left-click 3, 20 # click 'copy' button ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # copy doesn't happen screen-should-contain [ @@ -258,7 +258,7 @@ scenario copy-fails-if-sandbox-editor-not-empty [ type [1] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index 03dcb4ec..59fa2c6b 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -1,10 +1,10 @@ ## deleting sandboxes scenario deleting-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [] # run a few commands assume-console [ type [divide-with-remainder 11, 3] @@ -12,7 +12,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -33,7 +33,7 @@ scenario deleting-sandboxes [ left-click 7, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -50,7 +50,7 @@ scenario deleting-sandboxes [ left-click 3, 49 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -144,12 +144,12 @@ def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ ] scenario deleting-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -159,7 +159,7 @@ scenario deleting-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -177,7 +177,7 @@ scenario deleting-sandbox-after-scroll [ left-click 6, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -192,12 +192,12 @@ scenario deleting-sandbox-after-scroll [ ] scenario deleting-top-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -207,7 +207,7 @@ scenario deleting-top-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -225,7 +225,7 @@ scenario deleting-top-sandbox-after-scroll [ left-click 2, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -240,12 +240,12 @@ scenario deleting-top-sandbox-after-scroll [ ] scenario deleting-final-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -256,7 +256,7 @@ scenario deleting-final-sandbox-after-scroll [ press page-down press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -271,7 +271,7 @@ scenario deleting-final-sandbox-after-scroll [ left-click 2, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # implicitly scroll up to first sandbox screen-should-contain [ @@ -287,12 +287,12 @@ scenario deleting-final-sandbox-after-scroll [ ] scenario deleting-updates-sandbox-count [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -301,7 +301,7 @@ scenario deleting-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -321,7 +321,7 @@ scenario deleting-updates-sandbox-count [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # shouldn't go past last sandbox screen-should-contain [ diff --git a/sandbox/008-sandbox-edit.mu b/sandbox/008-sandbox-edit.mu index 515daa1b..7cf1ad53 100644 --- a/sandbox/008-sandbox-edit.mu +++ b/sandbox/008-sandbox-edit.mu @@ -1,15 +1,15 @@ ## editing sandboxes after they've been created scenario clicking-on-a-sandbox-moves-it-to-editor [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # run something - 1:text <- new [add 2, 2] + env:&:environment <- new-programming-environment screen:&:screen, [add 2, 2] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -25,7 +25,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ left-click 3, 4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # it pops back into editor screen-should-contain [ @@ -39,7 +39,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -101,16 +101,16 @@ def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button? ] scenario sandbox-with-print-can-be-edited [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # run a print instruction - 1:text <- new [print-integer screen, 4] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [print-integer screen, 4] # run the sandbox assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -131,7 +131,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 18 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -143,12 +143,12 @@ scenario sandbox-with-print-can-be-edited [ ] scenario editing-sandbox-after-scrolling-resets-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -159,7 +159,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ press page-down press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -174,7 +174,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ left-click 2, 10 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -190,12 +190,12 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ ] scenario editing-sandbox-updates-sandbox-count [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -204,7 +204,7 @@ scenario editing-sandbox-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -221,7 +221,7 @@ scenario editing-sandbox-updates-sandbox-count [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change in contents screen-should-contain [ @@ -241,7 +241,7 @@ scenario editing-sandbox-updates-sandbox-count [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # screen should show just final sandbox screen-should-contain [ diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index 3b2e91db..aebb34c2 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -1,20 +1,20 @@ ## clicking on sandbox results to 'fix' them and turn sandboxes into tests scenario sandbox-click-on-result-toggles-color-to-green [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # basic recipe - 1:text <- new [ -def foo [ - return 4 + recipes:text <- new [ +recipe foo [ + reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . run (F4) . . . @@ -30,7 +30,7 @@ def foo [ left-click 5, 21 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -44,8 +44,8 @@ def foo [ ] # cursor should remain unmoved run [ - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] screen-should-contain [ . run (F4) . @@ -58,16 +58,16 @@ def foo [ . . ] # now change the result - 1:text <- new [ -def foo [ - return 3 + new-recipes:text <- new [ +recipe foo [ + reply 3 ]] # then rerun assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/new-test-recipes + event-loop screen:&:screen, console:&:console, env, new-recipes ] # result turns red screen-should-contain-in-color 1/red, [ diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index dd1aed15..b921c15d 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -1,15 +1,15 @@ ## clicking on the code typed into a sandbox toggles its trace scenario sandbox-click-on-code-toggles-app-trace [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height + env:&:environment <- new-programming-environment screen:&:screen, [stash [abc]] # run a stash instruction - 1:text <- new [stash [abc]] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -24,9 +24,9 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 21 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 4:char/cursor-icon <- copy 9251/␣ - print screen:&:screen, 4:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -50,8 +50,8 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 25 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - print screen:&:screen, 4:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + print screen:&:screen, cursor ] # trace hidden again screen-should-contain [ @@ -66,16 +66,17 @@ scenario sandbox-click-on-code-toggles-app-trace [ ] scenario sandbox-shows-app-trace-and-result [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # run a stash instruction and some code - 1:text <- new [stash [abc] + sandbox:text <- new [stash [abc] add 2, 2] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + env:&:environment <- new-programming-environment screen:&:screen, sandbox + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -92,7 +93,7 @@ add 2, 2] left-click 4, 21 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # trace now printed above result screen-should-contain [ @@ -110,16 +111,16 @@ add 2, 2] ] scenario clicking-on-app-trace-does-nothing [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height + env:&:environment <- new-programming-environment screen:&:screen, [stash 123456789] # create and expand the trace - 1:text <- new [stash 123456789] assume-console [ press F4 left-click 4, 1 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -133,7 +134,7 @@ scenario clicking-on-app-trace-does-nothing [ left-click 5, 7 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change; doesn't die screen-should-contain [ diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index 561b5309..9ca8ab6d 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -125,19 +125,19 @@ after <render-sandbox-trace-done> [ ] scenario run-shows-errors-in-get [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ get 123:num, foo:offset ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -156,11 +156,10 @@ def foo [ ] scenario run-updates-status-with-first-erroneous-sandbox [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [] assume-console [ # create invalid sandbox 1 type [get foo, x:offset] @@ -170,7 +169,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, env, [] ] # status line shows that error is in first sandbox screen-should-contain [ @@ -179,11 +178,10 @@ scenario run-updates-status-with-first-erroneous-sandbox [ ] scenario run-updates-status-with-first-erroneous-sandbox-2 [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [] assume-console [ # create invalid sandbox 2 type [get foo, x:offset] @@ -196,7 +194,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, env, [] ] # status line shows that error is in second sandbox screen-should-contain [ @@ -205,15 +203,14 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ ] scenario run-hides-errors-from-past-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [] - 2:text <- new [get foo, x:offset] # invalid - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [get foo, x:offset] # invalid assume-console [ press F4 # generate error ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, env, [] assume-console [ left-click 3, 10 press ctrl-k @@ -221,7 +218,7 @@ scenario run-hides-errors-from-past-sandboxes [ press F4 # update sandbox ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # error should disappear screen-should-contain [ @@ -237,21 +234,21 @@ scenario run-hides-errors-from-past-sandboxes [ ] scenario run-updates-errors-for-shape-shifting-recipes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # define a shape-shifting recipe with an error - 1:text <- new [recipe foo x:_elem -> z:_elem [ + recipes:text <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients y:&:num <- copy 0 z <- add x, y ]] - 2:text <- new [foo 2] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo 2] assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . errors found (0) run (F4) . . . @@ -268,7 +265,7 @@ z <- add x, y press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # error should remain unchanged screen-should-contain [ @@ -285,20 +282,21 @@ z <- add x, y ] scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # overload a well-known shape-shifting recipe - 1:text <- new [recipe length l:&:list:_elem -> n:num [ + recipes:text <- new [recipe length l:&:list:_elem -> n:num [ ]] # call code that uses other variants of it, but not it itself - 2:text <- new [x:&:list:num <- copy 0 + sandbox:text <- new [x:&:list:num <- copy 0 to-text x] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, sandbox # run it once assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes # no errors anywhere on screen (can't check anything else, since to-text will return an address) screen-should-contain-in-color 1/red, [ . . @@ -316,7 +314,7 @@ to-text x] press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # still no errors screen-should-contain-in-color 1/red, [ @@ -333,19 +331,19 @@ to-text x] ] scenario run-shows-missing-type-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ x <- copy 0 ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -358,20 +356,20 @@ def foo [ ] scenario run-shows-unbalanced-bracket-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # recipe is incomplete (unbalanced '[') - 1:text <- new [ + recipes:text <- new [ recipe foo \\[ x <- copy 0 ] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -387,21 +385,21 @@ recipe foo \\[ ] scenario run-shows-get-on-non-container-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope x:&:point <- new point:type get x:&:point, 1:offset ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -415,22 +413,22 @@ def foo [ ] scenario run-shows-non-literal-get-argument-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope x:num <- copy 0 y:&:point <- new point:type get *y:&:point, x:num ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -444,20 +442,20 @@ def foo [ ] scenario run-shows-errors-everytime [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # try to run a file with an error - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope x:num <- copy y:num ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . errors found run (F4) . . . @@ -471,7 +469,7 @@ def foo [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -484,16 +482,17 @@ def foo [ ] scenario run-instruction-and-print-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:text <- new [get 1:&:point, 1:offset] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [get 1:&:point, 1:offset] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] + # check that screen prints error message in red screen-should-contain [ . errors found (0) run (F4) . . . @@ -519,18 +518,19 @@ scenario run-instruction-and-print-errors [ ] scenario run-instruction-and-print-errors-only-once [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # editor contains an illegal instruction - 1:text <- new [get 1234:num, foo:offset] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + sandbox:text <- new [get 1234:num, foo:offset] + env:&:environment <- new-programming-environment screen:&:screen, sandbox # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints error message just once screen-should-contain [ @@ -548,19 +548,20 @@ scenario run-instruction-and-print-errors-only-once [ ] scenario sandbox-can-handle-infinite-loop [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # editor contains an infinite loop - 1:text <- new [{ + sandbox:text <- new [{ loop }] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, sandbox # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found (0) run (F4) . @@ -577,24 +578,24 @@ loop ] scenario sandbox-with-errors-shows-trace [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # generate a stash and a error - 1:text <- new [recipe foo [ + recipes:text <- new [recipe foo [ local-scope a:num <- next-ingredient b:num <- next-ingredient stash [dividing by], b _, c:num <- divide-with-remainder a, b -return b +reply b ]] - 2:text <- new [foo 4, 0] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo 4, 0] # run assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes # screen prints error message screen-should-contain [ . errors found (0) run (F4) . @@ -612,7 +613,7 @@ return b left-click 4, 15 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # screen should expand trace screen-should-contain [ diff --git a/sandbox/012-editor-undo.mu b/sandbox/012-editor-undo.mu index 371a9ef1..0b13de25 100644 --- a/sandbox/012-editor-undo.mu +++ b/sandbox/012-editor-undo.mu @@ -99,21 +99,21 @@ after <handle-special-character> [ # undo typing scenario editor-can-undo-typing [ + local-scope # create an editor and type a character assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # character should be gone screen-should-contain [ @@ -127,7 +127,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -229,21 +229,21 @@ after <handle-undo> [ ] scenario editor-can-undo-typing-multiple [ + local-scope # create an editor and type multiple characters assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be gone screen-should-contain [ @@ -255,16 +255,16 @@ scenario editor-can-undo-typing-multiple [ ] scenario editor-can-undo-typing-multiple-2 [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [a] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right + editor-render screen, e # type some characters assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .012a . @@ -276,7 +276,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # back to original text screen-should-contain [ @@ -290,7 +290,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -301,17 +301,17 @@ scenario editor-can-undo-typing-multiple-2 [ ] scenario editor-can-undo-typing-enter [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [ abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [ abc], screen:&:screen, 0/left, 10/right + editor-render screen, e # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . abc . @@ -320,8 +320,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -331,10 +331,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -351,7 +351,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -364,16 +364,16 @@ scenario editor-can-undo-typing-enter [ # redo typing scenario editor-redo-typing [ + local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - 1:text <- new [a] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . @@ -385,7 +385,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be back screen-should-contain [ @@ -399,7 +399,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -428,16 +428,16 @@ after <handle-redo> [ ] scenario editor-redo-typing-empty [ + local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . . @@ -449,7 +449,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be back screen-should-contain [ @@ -463,7 +463,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -474,23 +474,24 @@ scenario editor-redo-typing-empty [ ] scenario editor-work-clears-redo-stack [ + local-scope # create an editor with some text, do some work, undo assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # do some more work assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .0abc . @@ -503,7 +504,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # nothing should happen screen-should-contain [ @@ -516,11 +517,11 @@ ghi] ] scenario editor-can-redo-typing-and-enter-and-tab [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -531,7 +532,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . ab cd . @@ -539,8 +540,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -550,11 +551,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # typing in second line deleted, but not indent - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -571,11 +572,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # indent and newline deleted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -591,11 +592,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # empty screen - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -611,11 +612,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -631,11 +632,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # newline and indent inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -652,11 +653,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # indent and newline deleted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -673,28 +674,29 @@ scenario editor-can-redo-typing-and-enter-and-tab [ # undo cursor movement scenario editor-can-undo-touch [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # click undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -704,7 +706,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -763,29 +765,30 @@ after <handle-undo> [ ] scenario editor-can-undo-left-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -795,7 +798,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -807,21 +810,22 @@ ghi] ] scenario editor-can-undo-up-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -831,11 +835,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -845,7 +849,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -857,29 +861,30 @@ ghi] ] scenario editor-can-undo-down-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -889,7 +894,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -901,29 +906,30 @@ ghi] ] scenario editor-can-undo-ctrl-a [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -933,7 +939,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -945,29 +951,30 @@ ghi] ] scenario editor-can-undo-home [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -977,7 +984,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -989,29 +996,30 @@ ghi] ] scenario editor-can-undo-ctrl-e [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1021,7 +1029,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1033,29 +1041,30 @@ ghi] ] scenario editor-can-undo-end [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1065,7 +1074,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1077,13 +1086,14 @@ ghi] ] scenario editor-can-undo-multiple-arrows-in-the-same-direction [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 2, 1 @@ -1091,9 +1101,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1103,11 +1113,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # up-arrow is undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 3 @@ -1117,11 +1127,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # both right-arrows are undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1131,28 +1141,29 @@ ghi] # redo cursor movement scenario editor-redo-touch [ + local-scope # create an editor with some text, click on a character, undo assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves to left-click + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -1162,7 +1173,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1188,19 +1199,19 @@ after <handle-redo> [ ] scenario editor-separates-undo-insert-from-undo-cursor-move [ + local-scope # create an editor, type some text, move the cursor, type some more text assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1216,9 +1227,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1236,9 +1247,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1256,9 +1267,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1276,9 +1287,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # first insert screen-should-contain [ @@ -1296,9 +1307,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1317,9 +1328,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # second insert screen-should-contain [ @@ -1337,26 +1348,26 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ # undo backspace scenario editor-can-undo-and-redo-backspace [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1366,10 +1377,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1385,10 +1396,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1482,11 +1493,11 @@ after <handle-redo> [ # undo delete scenario editor-can-undo-and-redo-delete [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1496,15 +1507,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1514,10 +1525,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1533,10 +1544,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1552,10 +1563,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1571,11 +1582,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1591,11 +1602,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1611,11 +1622,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1671,18 +1682,19 @@ before <delete-character-end> [ # undo ctrl-k scenario editor-can-undo-and-redo-ctrl-k [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 1 press ctrl-k ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . @@ -1690,8 +1702,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1701,7 +1713,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1710,8 +1722,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1721,7 +1733,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted screen-should-contain [ @@ -1731,8 +1743,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1742,7 +1754,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1773,18 +1785,19 @@ before <delete-to-end-of-line-end> [ # undo ctrl-u scenario editor-can-undo-and-redo-ctrl-u [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 2 press ctrl-u ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .c . @@ -1792,8 +1805,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1803,7 +1816,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1812,8 +1825,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1823,7 +1836,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted screen-should-contain [ @@ -1833,8 +1846,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1844,7 +1857,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1874,18 +1887,18 @@ before <delete-to-start-of-line-end> [ ] scenario editor-can-undo-and-redo-ctrl-u-2 [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ type [abc] press ctrl-u press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .abc . |