diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 17:54:55 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 17:54:55 -0700 |
commit | 2d91279bacda12ea42608b4aa74f66589772fce9 (patch) | |
tree | e5d8aafa6b34d32234239a77496c2f0c3d3899b1 /sandbox | |
parent | f344b250f6f062a1a1902bf69b23ebf9b565de0e (diff) | |
download | mu-2d91279bacda12ea42608b4aa74f66589772fce9.tar.gz |
3396
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/001-editor.mu | 22 | ||||
-rw-r--r-- | sandbox/002-typing.mu | 196 | ||||
-rw-r--r-- | sandbox/003-shortcuts.mu | 386 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 40 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 122 | ||||
-rw-r--r-- | sandbox/006-sandbox-copy.mu | 46 | ||||
-rw-r--r-- | sandbox/007-sandbox-delete.mu | 58 | ||||
-rw-r--r-- | sandbox/008-sandbox-edit.mu | 44 | ||||
-rw-r--r-- | sandbox/009-sandbox-test.mu | 22 | ||||
-rw-r--r-- | sandbox/010-sandbox-trace.mu | 32 | ||||
-rw-r--r-- | sandbox/011-errors.mu | 80 | ||||
-rw-r--r-- | sandbox/012-editor-undo.mu | 446 |
12 files changed, 747 insertions, 747 deletions
diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 5f6f7361..0b5aaa4a 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -27,7 +27,7 @@ scenario editor-initially-prints-text-to-screen [ ] ] -container editor-data [ +container editor [ # editable text: doubly linked list of characters (head contains a special sentinel) data:&:duplex-list:char top-of-screen:&:duplex-list:char @@ -48,12 +48,12 @@ container editor-data [ # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -def new-editor s:text, screen:&:screen, left:num, right:num -> result:&:editor-data, screen:&:screen [ +def new-editor s:text, screen:&:screen, left:num, right:num -> result:&:editor, screen:&:screen [ local-scope load-ingredients # no clipping of bounds right <- subtract right, 1 - result <- new editor-data:type + result <- new editor:type # initialize screen-related fields *result <- put *result, left:offset, left *result <- put *result, right:offset, right @@ -71,7 +71,7 @@ def new-editor s:text, screen:&:screen, left:num, right:num -> result:&:editor-d <editor-initialization> ] -def insert-text editor:&:editor-data, text:text -> editor:&:editor-data [ +def insert-text editor:&:editor, text:text -> editor:&:editor [ local-scope load-ingredients # early exit if text is empty @@ -97,8 +97,8 @@ def insert-text editor:&:editor-data, text:text -> editor:&:editor-data [ scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ - 1:&:editor-data <- new-editor 0/data, screen:&:screen, 2/left, 5/right - 2:editor-data <- copy *1:&:editor-data + 1:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right + 2:editor <- copy *1:&:editor ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -121,7 +121,7 @@ scenario editor-initializes-without-data [ # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -def render screen:&:screen, editor:&:editor-data -> last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ +def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ local-scope load-ingredients return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 @@ -146,7 +146,7 @@ def render screen:&:screen, editor:&:editor-data -> last-row:num, last-column:nu break-unless curr off-screen?:bool <- greater-or-equal row, screen-height break-if off-screen? - # update editor-data.before-cursor + # update editor.before-cursor # Doing so at the start of each iteration ensures it stays one step behind # the current character. { @@ -343,9 +343,9 @@ scenario editor-initializes-empty-text [ assume-screen 5/width, 5/height run [ 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 7d91a2c9..f51d5fe1 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -6,12 +6,12 @@ def! main text:text [ local-scope load-ingredients open-console - editor:&:editor-data <- new-editor text, 0/screen, 5/left, 45/right + editor:&:editor <- new-editor text, 0/screen, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] -def editor-event-loop screen:&:screen, console:&:console, editor:&:editor-data -> screen:&:screen, console:&:console, editor:&:editor-data [ +def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> screen:&:screen, console:&:console, editor:&:editor [ local-scope load-ingredients { @@ -45,7 +45,7 @@ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor-data - ] # process click, return if it was on current editor -def move-cursor-in-editor screen:&:screen, editor:&:editor-data, t:touch-event -> in-focus?:bool, editor:&:editor-data [ +def move-cursor-in-editor screen:&:screen, editor:&:editor, t:touch-event -> in-focus?:bool, editor:&:editor [ local-scope load-ingredients return-unless editor, 0/false @@ -70,7 +70,7 @@ def move-cursor-in-editor screen:&:screen, editor:&:editor-data, t:touch-event - # Variant of 'render' that only moves the cursor (coordinates and # before-cursor). If it's past the end of a line, it 'slides' it left. If it's # past the last line it positions at end of last line. -def snap-cursor screen:&:screen, editor:&:editor-data, target-row:num, target-column:num -> editor:&:editor-data [ +def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column:num -> editor:&:editor [ local-scope load-ingredients return-unless editor @@ -93,7 +93,7 @@ def snap-cursor screen:&:screen, editor:&:editor-data, target-row:num, target-co break-unless curr off-screen?:bool <- greater-or-equal row, screen-height break-if off-screen? - # update editor-data.before-cursor + # update editor.before-cursor # Doing so at the start of each iteration ensures it stays one step behind # the current character. { @@ -161,7 +161,7 @@ def snap-cursor screen:&:screen, editor:&:editor-data, target-row:num, target-co # Process an event 'e' and try to minimally update the screen. # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. -def handle-keyboard-event screen:&:screen, editor:&:editor-data, e:event -> screen:&:screen, editor:&:editor-data, go-render?:bool [ +def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> screen:&:screen, editor:&:editor, go-render?:bool [ local-scope load-ingredients go-render? <- copy 0/false @@ -201,7 +201,7 @@ def handle-keyboard-event screen:&:screen, editor:&:editor-data, e:event -> scre return ] -def insert-at-cursor editor:&:editor-data, c:char, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool [ +def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ local-scope load-ingredients before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset @@ -267,7 +267,7 @@ def insert-at-cursor editor:&:editor-data, c:char, screen:&:screen -> editor:&:e ] # helper for tests -def editor-render screen:&:screen, editor:&:editor-data -> screen:&:screen, editor:&:editor-data [ +def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:editor [ local-scope load-ingredients left:num <- get *editor, left:offset @@ -283,11 +283,11 @@ def editor-render screen:&:screen, editor:&:editor-data -> screen:&:screen, edit scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -300,16 +300,16 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -327,15 +327,15 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 # cursor row @@ -348,15 +348,15 @@ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 # cursor row @@ -369,15 +369,15 @@ scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 2 # cursor row @@ -390,17 +390,17 @@ scenario editor-handles-mouse-clicks-outside-column [ assume-screen 10/width, 5/height 1:text <- new [abc] # editor occupies only left half of screen - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -418,17 +418,17 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # no change to cursor memory-should-contain [ @@ -440,14 +440,14 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -461,8 +461,8 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # type two letters at different places assume-console [ @@ -471,7 +471,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -485,15 +485,15 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -508,15 +508,15 @@ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -531,15 +531,15 @@ d] scenario editor-inserts-characters-at-cursor-3 [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -554,15 +554,15 @@ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -578,15 +578,15 @@ scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -601,13 +601,13 @@ d] scenario editor-moves-cursor-after-inserting-characters [ assume-screen 10/width, 5/height 1:text <- new [ab] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor assume-console [ type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -622,14 +622,14 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ assume-screen 5/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # no wrap yet screen-should-contain [ @@ -644,7 +644,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # now wrap screen-should-contain [ @@ -661,17 +661,17 @@ scenario editor-wraps-line-on-insert-2 [ assume-screen 10/width, 5/height 1:text <- new [abcdefg defg] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor is not wrapped memory-should-contain [ @@ -741,15 +741,15 @@ after <insert-character-special-case> [ scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ assume-screen 10/width, 5/height 1:text <- new [abcde] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + 2:&:editor <- new-editor 1:text, 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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -770,7 +770,7 @@ scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ # create an editor containing two lines contents:text <- new [abc xyz] - 1:&:editor-data/raw <- new-editor contents, screen, 0/left, 5/right + 1:&:editor/raw <- new-editor contents, screen, 0/left, 5/right screen-should-contain [ . . .abc . @@ -782,7 +782,7 @@ xyz] type [de] # trigger wrap ] run [ - editor-event-loop screen:&:screen, console:&:console, 1:&:editor-data/raw + editor-event-loop screen:&:screen, console:&:console, 1:&:editor/raw ] screen-should-contain [ . . @@ -796,15 +796,15 @@ xyz] scenario editor-wraps-cursor-to-left-margin [ assume-screen 10/width, 5/height 1:text <- new [abcde] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 2/left, 7/right + 2:&:editor <- new-editor 1:text, 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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -821,7 +821,7 @@ scenario editor-wraps-cursor-to-left-margin [ # if newline, move cursor to start of next line, and maybe align indent with previous line -container editor-data [ +container editor [ indent?:bool ] @@ -832,13 +832,13 @@ after <editor-initialization> [ scenario editor-moves-cursor-down-after-inserting-newline [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -861,7 +861,7 @@ after <handle-special-character> [ } ] -def insert-new-line-and-indent editor:&:editor-data, screen:&:screen -> editor:&:editor-data, 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 @@ -937,13 +937,13 @@ def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num scenario editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 1/left, 10/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -957,7 +957,7 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ scenario editor-clears-previous-line-completely-after-inserting-newline [ assume-screen 10/width, 5/height 1:text <- new [abcde] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right assume-console [ press enter ] @@ -969,7 +969,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # line should be fully cleared screen-should-contain [ @@ -986,7 +986,7 @@ scenario editor-inserts-indent-after-newline [ 1:text <- new [ab cd ef] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -994,9 +994,9 @@ ef] ] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor should be below start of previous line memory-should-contain [ @@ -1010,7 +1010,7 @@ scenario editor-skips-indent-around-paste [ 1:text <- new [ab cd ef] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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 +1019,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor should be below start of previous line memory-should-contain [ @@ -1073,7 +1073,7 @@ def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:scree } screen <- move-cursor screen, row, x { - continue?:bool <- lesser-or-equal x, right # right is inclusive, to match editor-data semantics + continue?:bool <- lesser-or-equal x, right # right is inclusive, to match editor semantics break-unless continue? print screen, style, color, bg-color x <- add x, 1 diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index 9ee6855b..d4f124ae 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -9,12 +9,12 @@ scenario editor-inserts-two-spaces-on-tab [ # just one character in final line 1:text <- new [ab cd] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -41,17 +41,17 @@ after <handle-special-character> [ scenario editor-handles-backspace-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -80,7 +80,7 @@ after <handle-special-character> [ # return values: # go-render? - whether caller needs to update the screen # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. -def delete-before-cursor editor:&:editor-data, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool, backspaced-cell:&:duplex-list:char [ +def delete-before-cursor editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool, backspaced-cell:&:duplex-list:char [ local-scope load-ingredients before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset @@ -128,7 +128,7 @@ def delete-before-cursor editor:&:editor-data, screen:&:screen -> editor:&:edito go-render? <- copy 0/false ] -def move-cursor-coordinates-left editor:&:editor-data -> editor:&:editor-data [ +def move-cursor-coordinates-left editor:&:editor -> editor:&:editor [ local-scope load-ingredients before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset @@ -214,15 +214,15 @@ scenario editor-clears-last-line-on-backspace [ # just one character in final line 1:text <- new [ab cd] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -241,8 +241,8 @@ scenario editor-joins-and-wraps-lines-on-backspace [ # initialize editor with two long-ish but non-wrapping lines 1:text <- new [abc def ghi jkl] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -250,7 +250,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # resulting single line should wrap correctly screen-should-contain [ @@ -266,8 +266,8 @@ scenario editor-wraps-long-lines-on-backspace [ 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-data <- new-editor 1:text, screen:&:screen, 0/left, 8/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 8/right + editor-render screen, 2:&:editor # confirm that it wraps screen-should-contain [ . . @@ -282,7 +282,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -299,14 +299,14 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -320,7 +320,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -342,7 +342,7 @@ after <handle-special-key> [ } ] -def delete-at-cursor editor:&:editor-data, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool, deleted-cell:&:duplex-list:char [ +def delete-at-cursor editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool, deleted-cell:&:duplex-list:char [ local-scope load-ingredients before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset @@ -388,15 +388,15 @@ def delete-at-cursor editor:&:editor-data, screen:&:screen -> editor:&:editor-da scenario editor-moves-cursor-right-with-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -426,7 +426,7 @@ after <handle-special-key> [ } ] -def move-cursor-coordinates-right editor:&:editor-data, screen-height:num -> editor:&:editor-data, go-render?:bool [ +def move-cursor-coordinates-right editor:&:editor, screen-height:num -> editor:&:editor, go-render?:bool [ local-scope load-ingredients before-cursor:&:duplex-list:char <- get *editor before-cursor:offset @@ -484,8 +484,8 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -495,7 +495,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -503,7 +503,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -519,8 +519,8 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 1/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right + editor-render screen, 2:&:editor assume-console [ press right-arrow press right-arrow @@ -529,7 +529,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -543,17 +543,17 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen 10/width, 5/height 1:text <- new [abcdef] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -573,8 +573,8 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen 10/width, 5/height # line just barely wrapping 1:text <- new [abcde] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -582,9 +582,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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 2 @@ -595,9 +595,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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 2 @@ -609,17 +609,17 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ assume-screen 10/width, 5/height 1:text <- new [abcdef] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 1/left, 6/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 6/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] screen-should-contain [ . . @@ -639,8 +639,8 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -649,7 +649,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # new character should be in next line screen-should-contain [ @@ -669,8 +669,8 @@ d] scenario editor-moves-cursor-left-with-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 2 @@ -678,7 +678,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -713,8 +713,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ # initialize editor with two lines 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -722,9 +722,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 @@ -739,8 +739,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 1:text <- new [abc def g] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -750,7 +750,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -767,8 +767,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 1:text <- new [abc def g] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -777,7 +777,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # left-arrow should have had no effect screen-should-contain [ @@ -796,8 +796,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 1:text <- new [abc d] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # position cursor right after empty line assume-console [ @@ -806,7 +806,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -822,8 +822,8 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with a wrapping line 1:text <- new [abcdef] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace screen-should-contain [ . . @@ -838,9 +838,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-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 # previous row @@ -854,8 +854,8 @@ scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ # initialize editor with a wrapping line followed by a second line 1:text <- new [abcdef g] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace screen-should-contain [ . . @@ -870,9 +870,9 @@ g] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 2 # previous row @@ -886,8 +886,8 @@ scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ # initialize editor with a line on the verge of wrapping, followed by a second line 1:text <- new [abcd e] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor $clear-trace screen-should-contain [ . . @@ -902,9 +902,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 # previous row @@ -921,17 +921,17 @@ scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 @@ -942,7 +942,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -965,7 +965,7 @@ after <handle-special-key> [ } ] -def move-to-previous-line editor:&:editor-data -> editor:&:editor-data, go-render?:bool [ +def move-to-previous-line editor:&:editor -> editor:&:editor, go-render?:bool [ local-scope load-ingredients cursor-row:num <- get *editor, cursor-row:offset @@ -1036,17 +1036,17 @@ scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height 1:text <- new [ab def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 @@ -1057,7 +1057,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1072,17 +1072,17 @@ scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height 1:text <- new [ def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 1 @@ -1093,7 +1093,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1110,8 +1110,8 @@ scenario editor-moves-to-previous-line-from-left-margin [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1119,9 +1119,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 2 @@ -1132,7 +1132,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1149,17 +1149,17 @@ scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # ..and ends at (2, 0) memory-should-contain [ @@ -1171,7 +1171,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1194,7 +1194,7 @@ after <handle-special-key> [ } ] -def move-to-next-line editor:&:editor-data, screen-height:num -> editor:&:editor-data [ +def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [ local-scope load-ingredients cursor-row:num <- get *editor, cursor-row:offset @@ -1240,17 +1240,17 @@ scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height 1:text <- new [abc de] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 3 <- 2 @@ -1261,7 +1261,7 @@ de] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1278,8 +1278,8 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1287,9 +1287,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1325,7 +1325,7 @@ after <handle-special-key> [ } ] -def move-to-start-of-line editor:&:editor-data -> editor:&:editor-data [ +def move-to-start-of-line editor:&:editor -> editor:&:editor [ local-scope load-ingredients # update cursor column @@ -1353,8 +1353,8 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1362,9 +1362,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-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1378,7 +1378,7 @@ scenario editor-moves-to-start-of-line-with-home [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1386,9 +1386,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1402,8 +1402,8 @@ scenario editor-moves-to-start-of-line-with-home-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1411,9 +1411,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1429,8 +1429,8 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1438,9 +1438,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1453,9 +1453,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] memory-should-contain [ 4 <- 1 @@ -1497,7 +1497,7 @@ after <handle-special-key> [ } ] -def move-to-end-of-line editor:&:editor-data -> editor:&:editor-data [ +def move-to-end-of-line editor:&:editor -> editor:&:editor [ local-scope load-ingredients before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset @@ -1521,8 +1521,8 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1530,9 +1530,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-data - 4:num <- get *2:&:editor-data, cursor-row:offset - 5:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1546,8 +1546,8 @@ scenario editor-moves-to-end-of-line-with-end [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on first line, press 'end' assume-console [ @@ -1555,9 +1555,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1571,8 +1571,8 @@ scenario editor-moves-to-end-of-line-with-end-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1580,9 +1580,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1598,14 +1598,14 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes to start of line screen-should-contain [ @@ -1629,7 +1629,7 @@ after <handle-special-character> [ } ] -def delete-to-start-of-line editor:&:editor-data -> result:&:duplex-list:char, editor:&:editor-data [ +def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ local-scope load-ingredients # compute range to delete @@ -1661,14 +1661,14 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes to start of line screen-should-contain [ @@ -1684,14 +1684,14 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes to start of line screen-should-contain [ @@ -1707,14 +1707,14 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes to start of line screen-should-contain [ @@ -1732,14 +1732,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes to end of line screen-should-contain [ @@ -1763,7 +1763,7 @@ after <handle-special-character> [ } ] -def delete-to-end-of-line editor:&:editor-data -> result:&:duplex-list:char, editor:&:editor-data [ +def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ local-scope load-ingredients # compute range to delete @@ -1787,14 +1787,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes to end of line screen-should-contain [ @@ -1810,14 +1810,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes just last character screen-should-contain [ @@ -1833,14 +1833,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes nothing screen-should-contain [ @@ -1856,14 +1856,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes just the final character screen-should-contain [ @@ -1879,14 +1879,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # cursor deletes nothing screen-should-contain [ @@ -1932,7 +1932,7 @@ def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:dup # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line # beware: never return null pointer -def before-previous-line in:&:duplex-list:char, editor:&:editor-data -> out:&:duplex-list:char [ +def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ local-scope load-ingredients curr:&:duplex-list:char <- copy in diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 51319340..f39f0b35 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -5,27 +5,27 @@ def! main [ open-console initial-sandbox:text <- new [] hide-screen 0/screen - env:&:programming-environment-data <- new-programming-environment 0/screen, initial-sandbox + env:&:environment <- new-programming-environment 0/screen, initial-sandbox env <- restore-sandboxes env render-sandbox-side 0/screen, env, render - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset update-cursor 0/screen, current-sandbox, env show-screen 0/screen event-loop 0/screen, 0/console, env # never gets here ] -container programming-environment-data [ - current-sandbox:&:editor-data +container environment [ + current-sandbox:&:editor ] -def new-programming-environment screen:&:screen, initial-sandbox-contents:text -> result:&:programming-environment-data, screen:&:screen [ +def new-programming-environment screen:&:screen, initial-sandbox-contents:text -> result:&:environment, screen:&:screen [ local-scope load-ingredients width:num <- screen-width screen height:num <- screen-height screen # top menu - result <- new programming-environment-data:type + result <- new environment:type draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey button-start:num <- subtract width, 20 button-on-screen?:bool <- greater-or-equal button-start, 0 @@ -33,15 +33,15 @@ def new-programming-environment screen:&:screen, initial-sandbox-contents:text - screen <- move-cursor screen, 0/row, button-start print screen, [ run (F4) ], 255/white, 161/reddish # sandbox editor - current-sandbox:&:editor-data <- new-editor initial-sandbox-contents, screen, 0, width/right + current-sandbox:&:editor <- new-editor initial-sandbox-contents, screen, 0, width/right *result <- put *result, current-sandbox:offset, current-sandbox <programming-environment-initialization> ] -def event-loop screen:&:screen, console:&:console, env:&:programming-environment-data -> screen:&:screen, console:&:console, env:&:programming-environment-data [ +def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&:screen, console:&:console, env:&:environment [ local-scope load-ingredients - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset # if we fall behind we'll stop updating the screen, but then we have to # render the entire screen when we catch up. # todo: test this @@ -137,13 +137,13 @@ def event-loop screen:&:screen, console:&:console, env:&:programming-environment } ] -def resize screen:&:screen, env:&:programming-environment-data -> env:&:programming-environment-data, screen:&:screen [ +def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions width:num <- screen-width screen # update sandbox editor - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset right:num <- subtract width, 1 *current-sandbox <- put *current-sandbox right:offset, right # reset cursor @@ -154,7 +154,7 @@ def resize screen:&:screen, env:&:programming-environment-data -> env:&:programm # Variant of 'render' that updates cursor-row and cursor-column based on # before-cursor (rather than the other way around). If before-cursor moves # off-screen, it resets cursor-row and cursor-column. -def render-without-moving-cursor screen:&:screen, editor:&:editor-data -> last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ +def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ local-scope load-ingredients return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 @@ -183,7 +183,7 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor-data -> last-r off-screen?:bool <- greater-or-equal row, screen-height break-if off-screen? # if we find old-before-cursor still on the new resized screen, update - # editor-data.cursor-row and editor-data.cursor-column based on + # editor.cursor-row and editor.cursor-column based on # old-before-cursor { at-cursor?:bool <- equal old-before-cursor, prev @@ -234,7 +234,7 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor-data -> last-r return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -def render-all screen:&:screen, env:&:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:&:screen, env:&:programming-environment-data [ +def render-all screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ local-scope load-ingredients trace 10, [app], [render all] @@ -252,17 +252,17 @@ def render-all screen:&:screen, env:&:programming-environment-data, {render-edit screen <- render-sandbox-side screen, env, render-editor <render-components-end> # - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset screen <- update-cursor screen, current-sandbox, env # show-screen screen ] # replaced in a later layer -def render-sandbox-side screen:&:screen, env:&:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:&:screen, env:&:programming-environment-data [ +def render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ local-scope load-ingredients - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset left:num <- get *current-sandbox, left:offset right:num <- get *current-sandbox, right:offset row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox @@ -274,7 +274,7 @@ def render-sandbox-side screen:&:screen, env:&:programming-environment-data, {re clear-screen-from screen, row, left, left, right ] -def update-cursor screen:&:screen, current-sandbox:&:editor-data, env:&:programming-environment-data -> screen:&:screen [ +def update-cursor screen:&:screen, current-sandbox:&:editor, env:&:environment -> screen:&:screen [ local-scope load-ingredients <update-cursor-special-cases> @@ -352,13 +352,13 @@ after <global-type> [ { redraw-screen?:bool <- equal c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:&:programming-environment-data, render + screen <- render-all screen, env:&:environment, render sync-screen screen loop +next-event:label } ] # dummy -def restore-sandboxes env:&:programming-environment-data -> env:&:programming-environment-data [ +def restore-sandboxes env:&:environment -> env:&:environment [ # do nothing; redefined later ] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index a069df5e..4d6e2bdc 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -7,8 +7,8 @@ # This layer draws the menubar buttons non-editable sandboxes but they don't # do anything yet. Later layers implement each button. -container programming-environment-data [ - sandbox:&:sandbox-data # list of sandboxes, from top to bottom +container environment [ + sandbox:&:sandbox # list of sandboxes, from top to bottom render-from:num number-of-sandboxes:num ] @@ -17,7 +17,7 @@ after <programming-environment-initialization> [ *result <- put *result, render-from:offset, -1 ] -container sandbox-data [ +container sandbox [ data:text response:text # coordinates to track clicks @@ -25,7 +25,7 @@ container sandbox-data [ starting-row-on-screen:num code-ending-row-on-screen:num # past end of code screen:&:screen # prints in the sandbox go here - next-sandbox:&:sandbox-data + next-sandbox:&:sandbox ] scenario run-and-show-results [ @@ -33,13 +33,13 @@ scenario run-and-show-results [ assume-screen 50/width, 15/height # sandbox editor contains an instruction without storing outputs 1:text <- new [divide-with-remainder 11, 3] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # check that screen prints both sandboxes screen-should-contain [ @@ -122,22 +122,22 @@ after <global-keypress> [ } ] -def run-sandboxes env:&:programming-environment-data, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ +def run-sandboxes env:&:environment, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:environment, screen:&:screen [ local-scope load-ingredients errors-found?:bool, env, screen <- update-recipes env, screen, test-recipes # check contents of editor <run-sandboxes-begin> - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset { sandbox-contents:text <- editor-contents current-sandbox break-unless sandbox-contents # if contents exist, first save them - # run them and turn them into a new sandbox-data - new-sandbox:&:sandbox-data <- new sandbox-data:type + # run them and turn them into a new sandbox + new-sandbox:&:sandbox <- new sandbox:type *new-sandbox <- put *new-sandbox, data:offset, sandbox-contents # push to head of sandbox list - dest:&:sandbox-data <- get *env, sandbox:offset + dest:&:sandbox <- get *env, sandbox:offset *new-sandbox <- put *new-sandbox, next-sandbox:offset, dest *env <- put *env, sandbox:offset, new-sandbox # update sandbox count @@ -152,7 +152,7 @@ def run-sandboxes env:&:programming-environment-data, screen:&:screen, test-reci # save all sandboxes before running, just in case we die when running save-sandboxes env # run all sandboxes - curr:&:sandbox-data <- get *env, sandbox:offset + curr:&:sandbox <- get *env, sandbox:offset idx:num <- copy 0 { break-unless curr @@ -166,7 +166,7 @@ def run-sandboxes env:&:programming-environment-data, screen:&:screen, test-reci # load code from recipes.mu, or from test-recipes in tests # replaced in a later layer (whereupon errors-found? will actually be set) -def update-recipes env:&:programming-environment-data, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ +def update-recipes env:&:environment, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:environment, screen:&:screen [ local-scope load-ingredients { @@ -182,7 +182,7 @@ def update-recipes env:&:programming-environment-data, screen:&:screen, test-rec ] # replaced in a later layer -def! update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num -> sandbox:&:sandbox-data, env:&:programming-environment-data [ +def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ local-scope load-ingredients data:text <- get *sandbox, data:offset @@ -198,13 +198,13 @@ def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [ screen <- print screen, msg, color, 238/grey/background ] -def save-sandboxes env:&:programming-environment-data [ +def save-sandboxes env:&:environment [ local-scope load-ingredients - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset # first clear previous versions, in case we deleted some sandbox $system [rm lesson/[0-9]* >/dev/null 2>/dev/null] # some shells can't handle '>&' - curr:&:sandbox-data <- get *env, sandbox:offset + curr:&:sandbox <- get *env, sandbox:offset idx:num <- copy 0 { break-unless curr @@ -218,11 +218,11 @@ def save-sandboxes env:&:programming-environment-data [ } ] -def! render-sandbox-side screen:&:screen, env:&:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:&:screen, env:&:programming-environment-data [ +def! render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ local-scope load-ingredients trace 11, [app], [render sandbox side] - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset row:num, column:num <- copy 1, 0 left:num <- get *current-sandbox, left:offset right:num <- get *current-sandbox, right:offset @@ -237,15 +237,15 @@ def! render-sandbox-side screen:&:screen, env:&:programming-environment-data, {r } # render sandboxes draw-horizontal screen, row, left, right, 9473/horizontal-double - sandbox:&:sandbox-data <- get *env, sandbox:offset + sandbox:&:sandbox <- get *env, sandbox:offset row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from, 0, env clear-rest-of-screen screen, row, left, right ] -def render-sandboxes screen:&:screen, sandbox:&:sandbox-data, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox-data [ +def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ local-scope load-ingredients - env:&:programming-environment-data, _/optional <- next-ingredient + env:&:environment, _/optional <- next-ingredient return-unless sandbox screen-height:num <- screen-height screen at-bottom?:bool <- greater-or-equal row, screen-height @@ -293,7 +293,7 @@ def render-sandboxes screen:&:screen, sandbox:&:sandbox-data, left:num, right:nu <end-render-sandbox-reset-hidden> } # draw next sandbox - next-sandbox:&:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset next-idx:num <- add idx, 1 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx, env ] @@ -401,20 +401,20 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num ] # assumes programming environment has no sandboxes; restores them from previous session -def! restore-sandboxes env:&:programming-environment-data -> env:&:programming-environment-data [ +def! restore-sandboxes env:&:environment -> env:&:environment [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios idx:num <- copy 0 - curr:&:sandbox-data <- copy 0 - prev:&:sandbox-data <- copy 0 + curr:&:sandbox <- copy 0 + prev:&:sandbox <- copy 0 { filename:text <- to-text idx contents:text <- restore filename break-unless contents # stop at first error; assuming file didn't exist # todo: handle empty sandbox # create new sandbox for file - curr <- new sandbox-data:type + curr <- new sandbox:type *curr <- put *curr, data:offset, contents <end-restore-sandbox> { @@ -512,12 +512,12 @@ return z ]] # sandbox editor contains an instruction without storing outputs 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text # run the code in the editors assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes screen-should-contain [ . run (F4) . . . @@ -539,7 +539,7 @@ return z press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes ] # check that screen updates the result on the right screen-should-contain [ @@ -559,13 +559,13 @@ scenario run-instruction-manages-screen-per-sandbox [ assume-screen 50/width, 20/height # editor contains an instruction 1:text <- new [print-integer screen, 4] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # check that it prints a little toy screen screen-should-contain [ @@ -585,7 +585,7 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -def editor-contents editor:&:editor-data -> result:text [ +def editor-contents editor:&:editor -> result:text [ local-scope load-ingredients buf:&:buffer <- new-buffer 80 @@ -607,14 +607,14 @@ def editor-contents editor:&:editor-data -> result:text [ scenario editor-provides-edited-contents [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:text <- editor-contents 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor + 3:text <- editor-contents 2:&:editor 4:@:char <- copy *3:text ] memory-should-contain [ @@ -629,13 +629,13 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ assume-screen 50/width, 20/height # initialize 1:text <- new [add 2, 2] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, render assume-console [ # create a sandbox press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment screen-should-contain [ . run (F4) . . . @@ -651,7 +651,7 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 3:char/cursor <- copy 9251/␣ print screen:&:screen, 3:char/cursor ] @@ -671,7 +671,7 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 3:char/cursor <- copy 9251/␣ print screen:&:screen, 3:char/cursor ] @@ -693,7 +693,7 @@ after <global-keypress> [ { page-down?:bool <- equal k, 65518/page-down break-unless page-down? - sandbox:&:sandbox-data <- get *env, sandbox:offset + sandbox:&:sandbox <- get *env, sandbox:offset break-unless sandbox # slide down if possible { @@ -743,12 +743,12 @@ after <global-keypress> [ # sandbox belonging to 'env' whose next-sandbox is 'in' # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox -def previous-sandbox env:&:programming-environment-data, in:&:sandbox-data -> out:&:sandbox-data [ +def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ local-scope load-ingredients - curr:&:sandbox-data <- get *env, sandbox:offset + curr:&:sandbox <- get *env, sandbox:offset return-unless curr, 0/nil - next:&:sandbox-data <- get *curr, next-sandbox:offset + next:&:sandbox <- get *curr, next-sandbox:offset { return-unless next, 0/nil found?:bool <- equal next, in @@ -765,8 +765,8 @@ scenario scrolling-through-multiple-sandboxes [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, render # create 2 sandboxes assume-console [ press ctrl-n @@ -775,7 +775,7 @@ scenario scrolling-through-multiple-sandboxes [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 3:char/cursor <- copy 9251/␣ print screen:&:screen, 3:char/cursor screen-should-contain [ @@ -797,7 +797,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 3:char/cursor <- copy 9251/␣ print screen:&:screen, 3:char/cursor ] @@ -821,7 +821,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # back to displaying both sandboxes without editor screen-should-contain [ @@ -876,7 +876,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 3:char/cursor <- copy 9251/␣ print screen:&:screen, 3:char/cursor ] @@ -900,7 +900,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 3:char/cursor <- copy 9251/␣ print screen:&:screen, 3:char/cursor ] @@ -926,15 +926,15 @@ scenario scrolling-manages-sandbox-index-correctly [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, render # create a sandbox assume-console [ press ctrl-n type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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 4a072b03..c6472841 100644 --- a/sandbox/006-sandbox-copy.mu +++ b/sandbox/006-sandbox-copy.mu @@ -8,8 +8,8 @@ scenario copy-a-sandbox-to-editor [ assume-console [ press F4 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . @@ -70,8 +70,8 @@ scenario copy-a-sandbox-to-editor-2 [ assume-console [ press F4 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . @@ -141,14 +141,14 @@ after <global-touch> [ ] # some preconditions for attempting to copy a sandbox -def should-attempt-copy? click-row:num, click-column:num, env:&:programming-environment-data -> result:bool [ +def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope load-ingredients # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env reply-unless click-sandbox-area?, 0/false # narrower, is the click in the columns spanning the 'copy' button? - first-sandbox:&:editor-data <- get *env, current-sandbox:offset + first-sandbox:&:editor <- get *env, current-sandbox:offset assert first-sandbox, [!!] sandbox-left-margin:num <- get *first-sandbox, left:offset sandbox-right-margin:num <- get *first-sandbox, right:offset @@ -156,28 +156,28 @@ def should-attempt-copy? click-row:num, click-column:num, env:&:programming-envi copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right reply-unless copy-button-vertical-area?, 0/false # finally, is sandbox editor empty? - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset result <- empty-editor? current-sandbox ] -def try-copy-sandbox click-row:num, env:&:programming-environment-data -> clicked-on-copy-button?:bool, env:&:programming-environment-data [ +def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button?:bool, env:&:environment [ local-scope load-ingredients # identify the sandbox to copy, if the click was actually on the 'copy' button - sandbox:&:sandbox-data <- find-sandbox env, click-row + sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false clicked-on-copy-button? <- copy 1/true text:text <- get *sandbox, data:offset - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset current-sandbox <- insert-text current-sandbox, text # reset scroll *env <- put *env, render-from:offset, -1 ] -def find-sandbox env:&:programming-environment-data, click-row:num -> result:&:sandbox-data [ +def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [ local-scope load-ingredients - curr-sandbox:&:sandbox-data <- get *env, sandbox:offset + curr-sandbox:&:sandbox <- get *env, sandbox:offset { break-unless curr-sandbox start:num <- get *curr-sandbox, starting-row-on-screen:offset @@ -189,16 +189,16 @@ def find-sandbox env:&:programming-environment-data, click-row:num -> result:&:s return 0/not-found ] -def click-on-sandbox-area? click-row:num, env:&:programming-environment-data -> result:bool [ +def click-on-sandbox-area? click-row:num, env:&:environment -> result:bool [ local-scope load-ingredients - first-sandbox:&:sandbox-data <- get *env, sandbox:offset + first-sandbox:&:sandbox <- get *env, sandbox:offset return-unless first-sandbox, 0/false first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset result <- greater-or-equal click-row, first-sandbox-begins ] -def empty-editor? editor:&:editor-data -> result:bool [ +def empty-editor? editor:&:editor -> result:bool [ local-scope load-ingredients head:&:duplex-list:char <- get *editor, data:offset @@ -221,8 +221,8 @@ scenario copy-fails-if-sandbox-editor-not-empty [ assume-console [ press F4 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index a3732d1c..03dcb4ec 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -4,7 +4,7 @@ scenario deleting-sandboxes [ trace-until 100/app # trace too long assume-screen 50/width, 15/height 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment screen-should-contain [ . run (F4) . . . @@ -33,7 +33,7 @@ scenario deleting-sandboxes [ left-click 7, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . @@ -50,7 +50,7 @@ scenario deleting-sandboxes [ left-click 3, 49 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . @@ -76,14 +76,14 @@ after <global-touch> [ ] # some preconditions for attempting to delete a sandbox -def should-attempt-delete? click-row:num, click-column:num, env:&:programming-environment-data -> result:bool [ +def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope load-ingredients # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env reply-unless click-sandbox-area?, 0/false # narrower, is the click in the columns spanning the 'copy' button? - first-sandbox:&:editor-data <- get *env, current-sandbox:offset + first-sandbox:&:editor <- get *env, current-sandbox:offset assert first-sandbox, [!!] sandbox-left-margin:num <- get *first-sandbox, left:offset sandbox-right-margin:num <- get *first-sandbox, right:offset @@ -91,31 +91,31 @@ def should-attempt-delete? click-row:num, click-column:num, env:&:programming-en result <- within-range? click-column, delete-button-left, sandbox-right-margin ] -def try-delete-sandbox click-row:num, env:&:programming-environment-data -> clicked-on-delete-button?:bool, env:&:programming-environment-data [ +def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [ local-scope load-ingredients # identify the sandbox to delete, if the click was actually on the 'delete' button - sandbox:&:sandbox-data <- find-sandbox env, click-row + sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false clicked-on-delete-button? <- copy 1/true env <- delete-sandbox env, sandbox ] -def delete-sandbox env:&:programming-environment-data, sandbox:&:sandbox-data -> env:&:programming-environment-data [ +def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ local-scope load-ingredients - curr-sandbox:&:sandbox-data <- get *env, sandbox:offset + curr-sandbox:&:sandbox <- get *env, sandbox:offset first-sandbox?:bool <- equal curr-sandbox, sandbox { # first sandbox? pop break-unless first-sandbox? - next-sandbox:&:sandbox-data <- get *curr-sandbox, next-sandbox:offset + next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset *env <- put *env, sandbox:offset, next-sandbox } { # not first sandbox? break-if first-sandbox? - prev-sandbox:&:sandbox-data <- copy curr-sandbox + prev-sandbox:&:sandbox <- copy curr-sandbox curr-sandbox <- get *curr-sandbox, next-sandbox:offset { assert curr-sandbox, [sandbox not found! something is wrong.] @@ -126,7 +126,7 @@ def delete-sandbox env:&:programming-environment-data, sandbox:&:sandbox-data -> loop } # snip sandbox out of its list - next-sandbox:&:sandbox-data <- get *curr-sandbox, next-sandbox:offset + next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset *prev-sandbox <- put *prev-sandbox, next-sandbox:offset, next-sandbox } # update sandbox count @@ -148,8 +148,8 @@ scenario deleting-sandbox-after-scroll [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -196,8 +196,8 @@ scenario deleting-top-sandbox-after-scroll [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -244,8 +244,8 @@ scenario deleting-final-sandbox-after-scroll [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # implicitly scroll up to first sandbox screen-should-contain [ @@ -291,8 +291,8 @@ scenario deleting-updates-sandbox-count [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # shouldn't go past last sandbox screen-should-contain [ diff --git a/sandbox/008-sandbox-edit.mu b/sandbox/008-sandbox-edit.mu index 51a01b58..515daa1b 100644 --- a/sandbox/008-sandbox-edit.mu +++ b/sandbox/008-sandbox-edit.mu @@ -8,8 +8,8 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ assume-console [ press F4 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . @@ -65,14 +65,14 @@ after <global-touch> [ ] # some preconditions for attempting to edit a sandbox -def should-attempt-edit? click-row:num, click-column:num, env:&:programming-environment-data -> result:bool [ +def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope load-ingredients # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env reply-unless click-sandbox-area?, 0/false # narrower, is the click in the columns spanning the 'edit' button? - first-sandbox:&:editor-data <- get *env, current-sandbox:offset + first-sandbox:&:editor <- get *env, current-sandbox:offset assert first-sandbox, [!!] sandbox-left-margin:num <- get *first-sandbox, left:offset sandbox-right-margin:num <- get *first-sandbox, right:offset @@ -80,20 +80,20 @@ def should-attempt-edit? click-row:num, click-column:num, env:&:programming-envi edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right reply-unless edit-button-vertical-area?, 0/false # finally, is sandbox editor empty? - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset result <- empty-editor? current-sandbox ] -def try-edit-sandbox click-row:num, env:&:programming-environment-data -> clicked-on-edit-button?:bool, env:&:programming-environment-data [ +def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [ local-scope load-ingredients # identify the sandbox to edit, if the click was actually on the 'edit' button - sandbox:&:sandbox-data <- find-sandbox env, click-row + sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false clicked-on-edit-button? <- copy 1/true # 'edit' button = 'copy' button + 'delete' button text:text <- get *sandbox, data:offset - current-sandbox:&:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor <- get *env, current-sandbox:offset current-sandbox <- insert-text current-sandbox, text env <- delete-sandbox env, sandbox # reset scroll @@ -105,12 +105,12 @@ scenario sandbox-with-print-can-be-edited [ assume-screen 50/width, 20/height # run a print instruction 1:text <- new [print-integer screen, 4] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text # run the sandbox assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . run (F4) . @@ -147,8 +147,8 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -194,8 +194,8 @@ scenario editing-sandbox-updates-sandbox-count [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:programming-environment-data, render + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:environment, 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # 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:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # screen should show just final sandbox screen-should-contain [ diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index 7a2c5772..3b2e91db 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -13,8 +13,8 @@ def foo [ assume-console [ press F4 ] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + 3:&:environment <- new-programming-environment screen:&:screen, 2:text + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes screen-should-contain [ . run (F4) . . . @@ -30,7 +30,7 @@ def foo [ left-click 5, 21 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -67,7 +67,7 @@ def foo [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/new-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/new-test-recipes ] # result turns red screen-should-contain-in-color 1/red, [ @@ -82,7 +82,7 @@ def foo [ ] # this requires tracking a couple more things -container sandbox-data [ +container sandbox [ response-starting-row-on-screen:num expected-response:text ] @@ -114,14 +114,14 @@ after <global-touch> [ click-column:num <- get t, column:offset on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:&:sandbox-data <- get *env, sandbox:offset + first-sandbox:&:sandbox <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset click-row:num <- get t, row:offset below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on - sandbox:&:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:&:sandbox <- find-click-in-sandbox-output env, click-row break-unless sandbox # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox @@ -135,17 +135,17 @@ after <global-touch> [ } ] -def find-click-in-sandbox-output env:&:programming-environment-data, click-row:num -> sandbox:&:sandbox-data [ +def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:&:sandbox-data <- get *env, sandbox:offset + sandbox:&:sandbox <- get *env, sandbox:offset start:num <- get *sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:bool <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:&:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:num <- get *next-sandbox, starting-row-on-screen:offset found?:bool <- lesser-than click-row, next-start @@ -161,7 +161,7 @@ def find-click-in-sandbox-output env:&:programming-environment-data, click-row:n return sandbox ] -def toggle-expected-response sandbox:&:sandbox-data -> sandbox:&:sandbox-data [ +def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ local-scope load-ingredients expected-response:text <- get *sandbox, expected-response:offset diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index 96e346c8..dd1aed15 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -8,8 +8,8 @@ scenario sandbox-click-on-code-toggles-app-trace [ assume-console [ press F4 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment screen-should-contain [ . run (F4) . . . @@ -24,7 +24,7 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 21 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment 4:char/cursor-icon <- copy 9251/␣ print screen:&:screen, 4:char/cursor-icon ] @@ -50,7 +50,7 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 25 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment print screen:&:screen, 4:char/cursor-icon ] # trace hidden again @@ -74,8 +74,8 @@ add 2, 2] assume-console [ press F4 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment screen-should-contain [ . run (F4) . . . @@ -92,7 +92,7 @@ add 2, 2] left-click 4, 21 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # trace now printed above result screen-should-contain [ @@ -118,8 +118,8 @@ scenario clicking-on-app-trace-does-nothing [ press F4 left-click 4, 1 ] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 2:&:environment <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:environment screen-should-contain [ . run (F4) . . . @@ -133,7 +133,7 @@ scenario clicking-on-app-trace-does-nothing [ left-click 5, 7 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # no change; doesn't die screen-should-contain [ @@ -146,13 +146,13 @@ scenario clicking-on-app-trace-does-nothing [ ] ] -container sandbox-data [ +container sandbox [ trace:text display-trace?:bool ] # replaced in a later layer -def! update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num -> sandbox:&:sandbox-data, env:&:programming-environment-data [ +def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ local-scope load-ingredients data:text <- get *sandbox, data:offset @@ -170,14 +170,14 @@ after <global-touch> [ click-column:num <- get t, column:offset on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:&:sandbox-data <- get *env, sandbox:offset + first-sandbox:&:sandbox <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset click-row:num <- get t, row:offset below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose code is being clicked on - sandbox:&:sandbox-data <- find-click-in-sandbox-code env, click-row + sandbox:&:sandbox <- find-click-in-sandbox-code env, click-row break-unless sandbox # toggle its display-trace? property x:bool <- get *sandbox, display-trace?:offset @@ -192,7 +192,7 @@ after <global-touch> [ } ] -def find-click-in-sandbox-code env:&:programming-environment-data, click-row:num -> sandbox:&:sandbox-data [ +def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -202,7 +202,7 @@ def find-click-in-sandbox-code env:&:programming-environment-data, click-row:num assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:&:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:num <- get *next-sandbox, starting-row-on-screen:offset found?:bool <- lesser-than click-row, next-start diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index ccdf0863..561b5309 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -1,12 +1,12 @@ ## handling malformed programs -container programming-environment-data [ +container environment [ recipe-errors:text ] # copy code from recipe editor, persist, load into mu, save any errors # test-recipes is a hook for testing -def! update-recipes env:&:programming-environment-data, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ +def! update-recipes env:&:environment, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:environment, screen:&:screen [ local-scope load-ingredients { @@ -39,7 +39,7 @@ before <render-components-end> [ } ] -container programming-environment-data [ +container environment [ error-index:num # index of first sandbox with an error (or -1 if none) ] @@ -72,11 +72,11 @@ before <render-components-end> [ } ] -container sandbox-data [ +container sandbox [ errors:text ] -def! update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num -> sandbox:&:sandbox-data, env:&:programming-environment-data [ +def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ local-scope load-ingredients { @@ -132,12 +132,12 @@ def foo [ get 123:num, foo:offset ]] 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -160,7 +160,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ assume-screen 50/width, 20/height 1:text <- new [] 2:text <- new [] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ # create invalid sandbox 1 type [get foo, x:offset] @@ -170,7 +170,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes ] # status line shows that error is in first sandbox screen-should-contain [ @@ -183,7 +183,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ assume-screen 50/width, 20/height 1:text <- new [] 2:text <- new [] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ # create invalid sandbox 2 type [get foo, x:offset] @@ -196,7 +196,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes ] # status line shows that error is in second sandbox screen-should-contain [ @@ -209,11 +209,11 @@ scenario run-hides-errors-from-past-sandboxes [ assume-screen 50/width, 20/height 1:text <- new [] 2:text <- new [get foo, x:offset] # invalid - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 # generate error ] - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes assume-console [ left-click 3, 10 press ctrl-k @@ -221,7 +221,7 @@ scenario run-hides-errors-from-past-sandboxes [ press F4 # update sandbox ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 3:&:environment ] # error should disappear screen-should-contain [ @@ -247,11 +247,11 @@ y:&:num <- copy 0 z <- add x, y ]] 2:text <- new [foo 2] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes screen-should-contain [ . errors found (0) run (F4) . . . @@ -268,7 +268,7 @@ z <- add x, y press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] # error should remain unchanged screen-should-contain [ @@ -293,12 +293,12 @@ scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ # call code that uses other variants of it, but not it itself 2:text <- new [x:&:list:num <- copy 0 to-text x] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text # run it once assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-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 +316,7 @@ to-text x] press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] # still no errors screen-should-contain-in-color 1/red, [ @@ -340,12 +340,12 @@ def foo [ x <- copy 0 ]] 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -366,12 +366,12 @@ recipe foo \\[ x <- copy 0 ] 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -396,12 +396,12 @@ def foo [ get x:&:point, 1:offset ]] 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -425,12 +425,12 @@ def foo [ get *y:&:point, x:num ]] 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -453,11 +453,11 @@ def foo [ x:num <- copy y:num ]] 2:text <- new [foo] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes screen-should-contain [ . errors found run (F4) . . . @@ -471,7 +471,7 @@ def foo [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -487,12 +487,12 @@ scenario run-instruction-and-print-errors [ trace-until 100/app # trace too long assume-screen 50/width, 15/height 1:text <- new [get 1:&:point, 1:offset] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . errors found (0) run (F4) . @@ -523,14 +523,14 @@ scenario run-instruction-and-print-errors-only-once [ assume-screen 50/width, 10/height # editor contains an illegal instruction 1:text <- new [get 1234:num, foo:offset] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] # check that screen prints error message just once screen-should-contain [ @@ -554,13 +554,13 @@ scenario sandbox-can-handle-infinite-loop [ 1:text <- new [{ loop }] - 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + 2:&:environment <- new-programming-environment screen:&:screen, 1:text # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:environment ] screen-should-contain [ . errors found (0) run (F4) . @@ -589,12 +589,12 @@ _, c:num <- divide-with-remainder a, b return b ]] 2:text <- new [foo 4, 0] - 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + 3:&:environment <- new-programming-environment screen:&:screen, 2:text # run assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes # screen prints error message screen-should-contain [ . errors found (0) run (F4) . @@ -612,7 +612,7 @@ return b left-click 4, 15 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes ] # screen should expand trace screen-should-contain [ diff --git a/sandbox/012-editor-undo.mu b/sandbox/012-editor-undo.mu index 99ebecd9..371a9ef1 100644 --- a/sandbox/012-editor-undo.mu +++ b/sandbox/012-editor-undo.mu @@ -55,7 +55,7 @@ container delete-operation [ ] # every editor accumulates a list of operations to undo/redo -container editor-data [ +container editor [ undo:&:list:&:operation redo:&:list:&:operation ] @@ -102,18 +102,18 @@ scenario editor-can-undo-typing [ # create an editor and type a character assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -197,7 +197,7 @@ before <insert-enter-end> [ # redo stack, because it's now obsolete. # Beware: since we're counting cursor moves as operations, this means just # moving the cursor can lose work on the undo stack. -def add-operation editor:&:editor-data, op:&:operation -> editor:&:editor-data [ +def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ local-scope load-ingredients undo:&:list:&:operation <- get *editor, undo:offset @@ -232,18 +232,18 @@ scenario editor-can-undo-typing-multiple [ # create an editor and type multiple characters assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # all characters must be gone screen-should-contain [ @@ -258,13 +258,13 @@ scenario editor-can-undo-typing-multiple-2 [ # create an editor with some text assume-screen 10/width, 5/height 1:text <- new [a] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # type some characters assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -304,14 +304,14 @@ scenario editor-can-undo-typing-enter [ # create an editor with some text assume-screen 10/width, 5/height 1:text <- new [ abc] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . . abc . @@ -320,8 +320,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -367,13 +367,13 @@ scenario editor-redo-typing [ # create an editor, type something, undo assume-screen 10/width, 5/height 1:text <- new [a] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -431,13 +431,13 @@ scenario editor-redo-typing-empty [ # create an editor, type something, undo assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -479,18 +479,18 @@ scenario editor-work-clears-redo-stack [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # do some more work assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . .0abc . @@ -503,7 +503,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # nothing should happen screen-should-contain [ @@ -519,8 +519,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -531,7 +531,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . . ab cd . @@ -539,8 +539,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -550,11 +550,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # typing in second line deleted, but not indent - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -571,11 +571,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # indent and newline deleted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -591,11 +591,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # empty screen - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -611,11 +611,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # first line inserted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -631,11 +631,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # newline and indent inserted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -652,11 +652,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # indent and newline deleted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -678,21 +678,21 @@ scenario editor-can-undo-touch [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # click undone memory-should-contain [ @@ -704,7 +704,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -768,22 +768,22 @@ scenario editor-can-undo-left-arrow [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -795,7 +795,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -812,16 +812,16 @@ scenario editor-can-undo-up-arrow [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 memory-should-contain [ 3 <- 2 4 <- 1 @@ -831,9 +831,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -845,7 +845,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -862,22 +862,22 @@ scenario editor-can-undo-down-arrow [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -889,7 +889,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -906,22 +906,22 @@ scenario editor-can-undo-ctrl-a [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -933,7 +933,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -950,22 +950,22 @@ scenario editor-can-undo-home [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -977,7 +977,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -994,22 +994,22 @@ scenario editor-can-undo-ctrl-e [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -1021,7 +1021,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1038,22 +1038,22 @@ scenario editor-can-undo-end [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves back memory-should-contain [ @@ -1065,7 +1065,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1082,8 +1082,8 @@ scenario editor-can-undo-multiple-arrows-in-the-same-direction [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # move the cursor assume-console [ left-click 2, 1 @@ -1091,9 +1091,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 memory-should-contain [ 3 <- 1 4 <- 3 @@ -1103,9 +1103,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # up-arrow is undone memory-should-contain [ @@ -1117,9 +1117,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # both right-arrows are undone memory-should-contain [ @@ -1136,21 +1136,21 @@ scenario editor-redo-touch [ 1:text <- new [abc def ghi] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves to left-click memory-should-contain [ @@ -1162,7 +1162,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1191,16 +1191,16 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ # create an editor, type some text, move the cursor, type some more text assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 screen-should-contain [ . . .adbc . @@ -1216,9 +1216,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # last letter typed is deleted screen-should-contain [ @@ -1236,9 +1236,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # no change to screen; cursor moves screen-should-contain [ @@ -1256,9 +1256,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # screen empty screen-should-contain [ @@ -1276,9 +1276,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # first insert screen-should-contain [ @@ -1296,9 +1296,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # cursor moves screen-should-contain [ @@ -1317,9 +1317,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 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 ] # second insert screen-should-contain [ @@ -1340,23 +1340,23 @@ scenario editor-can-undo-and-redo-backspace [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1366,10 +1366,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1385,10 +1385,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1485,8 +1485,8 @@ scenario editor-can-undo-and-redo-delete [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1496,15 +1496,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1514,10 +1514,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1533,10 +1533,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1552,10 +1552,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1571,11 +1571,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # first line inserted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1591,11 +1591,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # first line inserted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1611,11 +1611,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # first line inserted - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1675,14 +1675,14 @@ scenario editor-can-undo-and-redo-ctrl-k [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . .a . @@ -1690,8 +1690,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1701,7 +1701,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1710,8 +1710,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1721,7 +1721,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # first line inserted screen-should-contain [ @@ -1731,8 +1731,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1742,7 +1742,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1777,14 +1777,14 @@ scenario editor-can-undo-and-redo-ctrl-u [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . .c . @@ -1792,8 +1792,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1803,7 +1803,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1812,8 +1812,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1823,7 +1823,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] # first line inserted screen-should-contain [ @@ -1833,8 +1833,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor-data, cursor-row:offset - 4:num <- get *2:&:editor-data, cursor-column:offset + 3:num <- get *2:&:editor, cursor-row:offset + 4:num <- get *2:&:editor, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1844,7 +1844,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor ] screen-should-contain [ . . @@ -1877,15 +1877,15 @@ scenario editor-can-undo-and-redo-ctrl-u-2 [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor-data + 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor # 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-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor screen-should-contain [ . . .abc . |