diff options
Diffstat (limited to 'edit')
-rw-r--r-- | edit/001-editor.mu | 76 | ||||
-rw-r--r-- | edit/002-typing.mu | 272 | ||||
-rw-r--r-- | edit/003-shortcuts.mu | 836 | ||||
-rw-r--r-- | edit/004-programming-environment.mu | 124 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 214 | ||||
-rw-r--r-- | edit/006-sandbox-edit.mu | 70 | ||||
-rw-r--r-- | edit/007-sandbox-delete.mu | 76 | ||||
-rw-r--r-- | edit/008-sandbox-test.mu | 36 | ||||
-rw-r--r-- | edit/009-sandbox-trace.mu | 44 | ||||
-rw-r--r-- | edit/010-errors.mu | 182 | ||||
-rw-r--r-- | edit/011-editor-undo.mu | 736 |
11 files changed, 1333 insertions, 1333 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu index 614608c2..06c5a8dc 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -2,7 +2,7 @@ # temporary main for this layer: just render the given text at the given # screen dimensions, then stop -def! main text:address:shared:array:character [ +def! main text:address:array:character [ local-scope load-ingredients open-console @@ -16,8 +16,8 @@ def! main text:address:shared:array:character [ scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ - 1:address:shared:array:character <- new [abc] - new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 1:address:array:character <- new [abc] + new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -29,11 +29,11 @@ scenario editor-initially-prints-text-to-screen [ container editor-data [ # editable text: doubly linked list of characters (head contains a special sentinel) - data:address:shared:duplex-list:character - top-of-screen:address:shared:duplex-list:character - bottom-of-screen:address:shared:duplex-list:character + data:address:duplex-list:character + top-of-screen:address:duplex-list:character + bottom-of-screen:address:duplex-list:character # location before cursor inside data - before-cursor:address:shared:duplex-list:character + before-cursor:address:duplex-list:character # raw bounds of display area on screen # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen @@ -48,7 +48,7 @@ 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:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ +def new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data, screen:address:screen [ local-scope load-ingredients # no clipping of bounds @@ -61,7 +61,7 @@ def new-editor s:address:shared:array:character, screen:address:shared:screen, l *result <- put *result, cursor-row:offset, 1/top *result <- put *result, cursor-column:offset, left # initialize empty contents - init:address:shared:duplex-list:character <- push 167/§, 0/tail + init:address:duplex-list:character <- push 167/§, 0/tail *result <- put *result, data:offset, init *result <- put *result, top-of-screen:offset, init *result <- put *result, before-cursor:offset, init @@ -71,7 +71,7 @@ def new-editor s:address:shared:array:character, screen:address:shared:screen, l <editor-initialization> ] -def insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ +def insert-text editor:address:editor-data, text:address:array:character -> editor:address:editor-data [ local-scope load-ingredients # early exit if text is empty @@ -80,7 +80,7 @@ def insert-text editor:address:shared:editor-data, text:address:shared:array:cha return-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character - curr:address:shared:duplex-list:character <- get *editor, data:offset + curr:address:duplex-list:character <- get *editor, data:offset { done?:boolean <- greater-or-equal idx, len break-if done? @@ -97,8 +97,8 @@ def insert-text editor:address:shared:editor-data, text:address:shared:array:cha scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ - 1:address:shared:editor-data <- new-editor 0/data, screen:address:shared:screen, 2/left, 5/right - 2:editor-data <- copy *1:address:shared:editor-data + 1:address:editor-data <- new-editor 0/data, screen:address:screen, 2/left, 5/right + 2:editor-data <- copy *1:address:editor-data ] 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:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ +def render screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ local-scope load-ingredients return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 @@ -129,8 +129,8 @@ def render screen:address:shared:screen, editor:address:shared:editor-data -> la screen-height:number <- screen-height screen right:number <- get *editor, right:offset # traversing editor - curr:address:shared:duplex-list:character <- get *editor, top-of-screen:offset - prev:address:shared:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr:address:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr # traversing screen +render-loop-initialization @@ -139,7 +139,7 @@ def render screen:address:shared:screen, editor:address:shared:editor-data -> la column:number <- copy left cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset screen <- move-cursor screen, row, column { +next-character @@ -222,7 +222,7 @@ def render screen:address:shared:screen, editor:address:shared:editor-data -> la return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -def clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ +def clear-line-delimited screen:address:screen, column:number, right:number -> screen:address:screen [ local-scope load-ingredients space:character <- copy 32/space @@ -241,7 +241,7 @@ def clear-line-delimited screen:address:shared:screen, column:number, right:numb } ] -def clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ +def clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number -> screen:address:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive @@ -257,7 +257,7 @@ def clear-screen-from screen:address:shared:screen, row:number, column:number, l return screen/same-as-ingredient:0 ] -def clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ +def clear-rest-of-screen screen:address:screen, row:number, left:number, right:number -> screen:address:screen [ local-scope load-ingredients row <- add row, 1 @@ -276,9 +276,9 @@ def clear-rest-of-screen screen:address:shared:screen, row:number, left:number, scenario editor-initially-prints-multiple-lines [ assume-screen 5/width, 5/height run [ - s:address:shared:array:character <- new [abc + s:address:array:character <- new [abc def] - new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -291,8 +291,8 @@ def] scenario editor-initially-handles-offsets [ assume-screen 5/width, 5/height run [ - s:address:shared:array:character <- new [abc] - new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right + s:address:array:character <- new [abc] + new-editor s:address:array:character, screen:address:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -304,9 +304,9 @@ scenario editor-initially-handles-offsets [ scenario editor-initially-prints-multiple-lines-at-offset [ assume-screen 5/width, 5/height run [ - s:address:shared:array:character <- new [abc + s:address:array:character <- new [abc def] - new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right + new-editor s:address:array:character, screen:address:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -319,8 +319,8 @@ def] scenario editor-initially-wraps-long-lines [ assume-screen 5/width, 5/height run [ - s:address:shared:array:character <- new [abc def] - new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + s:address:array:character <- new [abc def] + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -339,8 +339,8 @@ scenario editor-initially-wraps-long-lines [ scenario editor-initially-wraps-barely-long-lines [ assume-screen 5/width, 5/height run [ - s:address:shared:array:character <- new [abcde] - new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + s:address:array:character <- new [abcde] + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -361,10 +361,10 @@ scenario editor-initially-wraps-barely-long-lines [ scenario editor-initializes-empty-text [ assume-screen 5/width, 5/height run [ - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -382,10 +382,10 @@ scenario editor-initializes-empty-text [ scenario render-colors-comments [ assume-screen 5/width, 5/height run [ - s:address:shared:array:character <- new [abc + s:address:array:character <- new [abc # de f] - new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -463,10 +463,10 @@ def get-color color:number, c:character -> color:number [ scenario render-colors-assignment [ assume-screen 8/width, 5/height run [ - s:address:shared:array:character <- new [abc + s:address:array:character <- new [abc d <- e f] - new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right + new-editor s:address:array:character, screen:address:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/edit/002-typing.mu b/edit/002-typing.mu index d7624ccf..88079641 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -2,16 +2,16 @@ # temporary main: interactive editor # hit ctrl-c to exit -def! main text:address:shared:array:character [ +def! main text:address:array:character [ local-scope load-ingredients open-console - editor:address:shared:editor-data <- new-editor text, 0/screen, 5/left, 45/right + editor:address:editor-data <- new-editor text, 0/screen, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] -def editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ +def editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data -> screen:address:screen, console:address:console, editor:address:editor-data [ local-scope load-ingredients { @@ -20,7 +20,7 @@ def editor-event-loop screen:address:shared:screen, console:address:shared:conso cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column - e:event, console:address:shared:console, found?:boolean, quit?:boolean <- read-event console + e:event, console:address:console, found?:boolean, quit?:boolean <- read-event console loop-unless found? break-if quit? # only in tests trace 10, [app], [next-event] @@ -45,7 +45,7 @@ def editor-event-loop screen:address:shared:screen, console:address:shared:conso ] # process click, return if it was on current editor -def move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ +def move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event -> in-focus?:boolean, editor:address:editor-data [ local-scope load-ingredients return-unless editor, 0/false @@ -70,7 +70,7 @@ def move-cursor-in-editor screen:address:shared:screen, editor:address:shared:ed # 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:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ +def snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number -> editor:address:editor-data [ local-scope load-ingredients return-unless editor @@ -78,8 +78,8 @@ def snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, right:number <- get *editor, right:offset screen-height:number <- screen-height screen # count newlines until screen row - curr:address:shared:duplex-list:character <- get *editor, top-of-screen:offset - prev:address:shared:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr:address:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr row:number <- copy 1/top column:number <- copy left @@ -87,7 +87,7 @@ def snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, cursor-row:number <- copy target-row *editor <- put *editor, cursor-column:offset, target-column cursor-column:number <- copy target-column - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset { +next-character break-unless curr @@ -161,7 +161,7 @@ def snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, # 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:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ +def handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event -> screen:address:screen, editor:address:editor-data, go-render?:boolean [ local-scope load-ingredients go-render? <- copy 0/false @@ -170,7 +170,7 @@ def handle-keyboard-event screen:address:shared:screen, editor:address:shared:ed screen-height:number <- screen-height screen left:number <- get *editor, left:offset right:number <- get *editor, right:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset save-row:number <- copy cursor-row @@ -201,10 +201,10 @@ def handle-keyboard-event screen:address:shared:screen, editor:address:shared:ed return ] -def insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ +def insert-at-cursor editor:address:editor-data, c:character, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset insert c, before-cursor before-cursor <- next before-cursor *editor <- put *editor, before-cursor:offset, before-cursor @@ -221,7 +221,7 @@ def insert-at-cursor editor:address:shared:editor-data, c:character, screen:addr # but mostly we'll just move the cursor right cursor-column <- add cursor-column, 1 *editor <- put *editor, cursor-column:offset, cursor-column - next:address:shared:duplex-list:character <- next before-cursor + next:address:duplex-list:character <- next before-cursor { # at end of all text? no need to scroll? just print the character and leave at-end?:boolean <- equal next, 0/null @@ -241,7 +241,7 @@ def insert-at-cursor editor:address:shared:editor-data, c:character, screen:addr break-unless next at-right?:boolean <- greater-or-equal cursor-column, screen-width break-if at-right? - curr:address:shared:duplex-list:character <- copy before-cursor + curr:address:duplex-list:character <- copy before-cursor move-cursor screen, save-row, save-column curr-column:number <- copy save-column { @@ -267,7 +267,7 @@ def insert-at-cursor editor:address:shared:editor-data, c:character, screen:addr ] # helper for tests -def editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ +def editor-render screen:address:screen, editor:address:editor-data -> screen:address:screen, editor:address:editor-data [ local-scope load-ingredients left:number <- get *editor, left:offset @@ -282,12 +282,12 @@ def editor-render screen:address:shared:screen, editor:address:shared:editor-dat scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -299,17 +299,17 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -326,16 +326,16 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -346,17 +346,17 @@ scenario editor-handles-mouse-clicks-outside-text [ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -367,17 +367,17 @@ def] scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -388,19 +388,19 @@ def] scenario editor-handles-mouse-clicks-outside-column [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] + 1:address:array:character <- new [abc] # editor occupies only left half of screen - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -417,18 +417,18 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -439,15 +439,15 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -460,9 +460,9 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -484,16 +484,16 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -506,17 +506,17 @@ scenario editor-inserts-characters-at-cursor-2 [ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -530,16 +530,16 @@ d] scenario editor-inserts-characters-at-cursor-3 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -552,17 +552,17 @@ scenario editor-inserts-characters-at-cursor-3 [ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -576,17 +576,17 @@ d] scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -600,14 +600,14 @@ d] scenario editor-moves-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [ab] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [ab] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data assume-console [ type [01] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -621,15 +621,15 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ assume-screen 5/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # no wrap yet screen-should-contain [ @@ -644,7 +644,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # now wrap screen-should-contain [ @@ -659,19 +659,19 @@ scenario editor-wraps-line-on-insert [ scenario editor-wraps-line-on-insert-2 [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abcdefg + 1:address:array:character <- new [abcdefg defg] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -713,16 +713,16 @@ after <insert-character-special-case> [ scenario editor-wraps-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abcde] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 1:address:array:character <- new [abcde] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right assume-console [ left-click 1, 4 # line is full; no wrap icon yet type [f] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -739,16 +739,16 @@ scenario editor-wraps-cursor-after-inserting-characters [ scenario editor-wraps-cursor-after-inserting-characters-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abcde] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 1:address:array:character <- new [abcde] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -765,16 +765,16 @@ scenario editor-wraps-cursor-after-inserting-characters-2 [ scenario editor-wraps-cursor-to-left-margin [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abcde] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 2/left, 7/right + 1:address:array:character <- new [abcde] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -801,14 +801,14 @@ after <editor-initialization> [ scenario editor-moves-cursor-down-after-inserting-newline [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -831,12 +831,12 @@ after <handle-special-character> [ } ] -def insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ +def insert-new-line-and-indent editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ local-scope load-ingredients cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset screen-height:number <- screen-height screen @@ -860,8 +860,8 @@ def insert-new-line-and-indent editor:address:shared:editor-data, screen:address # indent if necessary indent?:boolean <- get *editor, indent?:offset return-unless indent? - d:address:shared:duplex-list:character <- get *editor, data:offset - end-of-previous-line:address:shared:duplex-list:character <- prev before-cursor + d:address:duplex-list:character <- get *editor, data:offset + end-of-previous-line:address:duplex-list:character <- prev before-cursor indent:number <- line-indent end-of-previous-line, d i:number <- copy 0 { @@ -875,7 +875,7 @@ def insert-new-line-and-indent editor:address:shared:editor-data, screen:address # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the number of spaces at the start of the line containing 'curr'. -def line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ +def line-indent curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -907,14 +907,14 @@ def line-indent curr:address:shared:duplex-list:character, start:address:shared: scenario editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 10/right + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -927,8 +927,8 @@ 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:address:shared:array:character <- new [abcde] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 1:address:array:character <- new [abcde] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right assume-console [ press enter ] @@ -940,7 +940,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # line should be fully cleared screen-should-contain [ @@ -954,10 +954,10 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ scenario editor-inserts-indent-after-newline [ assume-screen 10/width, 10/height - 1:address:shared:array:character <- new [ab + 1:address:array:character <- new [ab cd ef] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -965,9 +965,9 @@ ef] ] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -978,10 +978,10 @@ ef] scenario editor-skips-indent-around-paste [ assume-screen 10/width, 10/height - 1:address:shared:array:character <- new [ab + 1:address:array:character <- new [ab cd ef] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -990,9 +990,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1023,7 +1023,7 @@ after <handle-special-key> [ ## helpers -def draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ +def draw-horizontal screen:address:screen, row:number, x:number, right:number -> screen:address:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index 8ed01de7..40956cb3 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -7,14 +7,14 @@ scenario editor-inserts-two-spaces-on-tab [ assume-screen 10/width, 5/height # just one character in final line - 1:address:shared:array:character <- new [ab + 1:address:array:character <- new [ab cd] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -40,18 +40,18 @@ after <handle-special-character> [ scenario editor-handles-backspace-key [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -71,7 +71,7 @@ after <handle-special-character> [ delete-previous-character?:boolean <- equal c, 8/backspace break-unless delete-previous-character? <backspace-character-begin> - editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen + editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character <- delete-before-cursor editor, screen <backspace-character-end> return } @@ -80,19 +80,19 @@ 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:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ +def delete-before-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, backspaced-cell:address:duplex-list:character [ local-scope load-ingredients - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - data:address:shared:duplex-list:character <- get *editor, data:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + data:address:duplex-list:character <- get *editor, data:offset # if at start of text (before-cursor at § sentinel), return - prev:address:shared:duplex-list:character <- prev before-cursor + prev:address:duplex-list:character <- prev before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted return-unless prev trace 10, [app], [delete-before-cursor] original-row:number <- get *editor, cursor-row:offset editor, scroll?:boolean <- move-cursor-coordinates-left editor - backspaced-cell:address:shared:duplex-list:character <- copy before-cursor + backspaced-cell:address:duplex-list:character <- copy before-cursor data <- remove before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/before-cursor before-cursor <- copy prev *editor <- put *editor, before-cursor:offset, before-cursor @@ -107,7 +107,7 @@ def delete-before-cursor editor:address:shared:editor-data, screen:address:share return-unless same-row? left:number <- get *editor, left:offset right:number <- get *editor, right:offset - curr:address:shared:duplex-list:character <- next before-cursor + curr:address:duplex-list:character <- next before-cursor screen <- move-cursor screen, cursor-row, cursor-column curr-column:number <- copy cursor-column { @@ -131,10 +131,10 @@ def delete-before-cursor editor:address:shared:editor-data, screen:address:share go-render? <- copy 0/false ] -def move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ +def move-cursor-coordinates-left editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -168,7 +168,7 @@ def move-cursor-coordinates-left editor:address:shared:editor-data -> editor:add break-unless previous-character-is-newline? # compute length of previous line trace 10, [app], [switching to previous line] - d:address:shared:duplex-list:character <- get *editor, data:offset + d:address:duplex-list:character <- get *editor, data:offset end-of-line:number <- previous-line-length before-cursor, d right:number <- get *editor, right:offset width:number <- subtract right, left @@ -195,7 +195,7 @@ def move-cursor-coordinates-left editor:address:shared:editor-data -> editor:add # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -def previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ +def previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -218,17 +218,17 @@ def previous-line-length curr:address:shared:duplex-list:character, start:addres scenario editor-clears-last-line-on-backspace [ assume-screen 10/width, 5/height # just one character in final line - 1:address:shared:array:character <- new [ab + 1:address:array:character <- new [ab cd] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -245,10 +245,10 @@ cd] scenario editor-joins-and-wraps-lines-on-backspace [ assume-screen 10/width, 5/height # initialize editor with two long-ish but non-wrapping lines - 1:address:shared:array:character <- new [abc def + 1:address:array:character <- new [abc def ghi jkl] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -256,7 +256,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # resulting single line should wrap correctly screen-should-contain [ @@ -271,9 +271,9 @@ ghi jkl] 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:address:shared:array:character <- new [abc def ghij] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc def ghij] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 8/right + editor-render screen, 2:address:editor-data # confirm that it wraps screen-should-contain [ . . @@ -288,7 +288,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -304,15 +304,15 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -326,7 +326,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -342,18 +342,18 @@ after <handle-special-key> [ delete-next-character?:boolean <- equal k, 65522/delete break-unless delete-next-character? <delete-character-begin> - editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen + editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character <- delete-at-cursor editor, screen <delete-character-end> return } ] -def delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ +def delete-at-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, deleted-cell:address:duplex-list:character [ local-scope load-ingredients - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - data:address:shared:duplex-list:character <- get *editor, data:offset - deleted-cell:address:shared:duplex-list:character <- next before-cursor + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + data:address:duplex-list:character <- get *editor, data:offset + deleted-cell:address:duplex-list:character <- next before-cursor go-render? <- copy 0/false return-unless deleted-cell currc:character <- get *deleted-cell, value:offset @@ -362,7 +362,7 @@ def delete-at-cursor editor:address:shared:editor-data, screen:address:shared:sc go-render? <- copy 1/true return-if deleted-newline? # wasn't a newline? render rest of line - curr:address:shared:duplex-list:character <- next before-cursor # refresh after remove above + curr:address:duplex-list:character <- next before-cursor # refresh after remove above cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column @@ -393,16 +393,16 @@ def delete-at-cursor editor:address:shared:editor-data, screen:address:shared:sc scenario editor-moves-cursor-right-with-key [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -418,7 +418,7 @@ after <handle-special-key> [ move-to-next-character?:boolean <- equal k, 65514/right-arrow break-unless move-to-next-character? # if not at end of text - next-cursor:address:shared:duplex-list:character <- next before-cursor + next-cursor:address:duplex-list:character <- next before-cursor break-unless next-cursor # scan to next character <move-cursor-begin> @@ -432,10 +432,10 @@ after <handle-special-key> [ } ] -def move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ +def move-cursor-coordinates-right editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:shared:duplex-list:character <- get *editor before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor before-cursor:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -465,7 +465,7 @@ def move-cursor-coordinates-right editor:address:shared:editor-data, screen-heig at-wrap?:boolean <- equal cursor-column, wrap-column break-unless at-wrap? # and if next character isn't newline - next:address:shared:duplex-list:character <- next before-cursor + next:address:duplex-list:character <- next before-cursor break-unless next next-character:character <- get *next, value:offset newline?:boolean <- equal next-character, 10/newline @@ -490,10 +490,10 @@ def move-cursor-coordinates-right editor:address:shared:editor-data, screen-heig scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -503,7 +503,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -511,7 +511,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -525,10 +525,10 @@ d] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ press right-arrow press right-arrow @@ -537,7 +537,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -550,18 +550,18 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abcdef] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abcdef] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -580,9 +580,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen 10/width, 5/height # line just barely wrapping - 1:address:shared:array:character <- new [abcde] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abcde] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -590,9 +590,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -603,9 +603,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -616,18 +616,18 @@ 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:address:shared:array:character <- new [abcdef] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 6/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abcdef] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 6/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -645,10 +645,10 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -657,7 +657,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # new character should be in next line screen-should-contain [ @@ -676,9 +676,9 @@ d] scenario editor-moves-cursor-left-with-key [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 2 @@ -686,7 +686,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -703,7 +703,7 @@ after <handle-special-key> [ break-unless move-to-previous-character? trace 10, [app], [left arrow] # if not at start of text (before-cursor at § sentinel) - prev:address:shared:duplex-list:character <- prev before-cursor + prev:address:duplex-list:character <- prev before-cursor go-render? <- copy 0/false return-unless prev <move-cursor-begin> @@ -719,10 +719,10 @@ after <handle-special-key> [ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ assume-screen 10/width, 5/height # initialize editor with two lines - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -730,9 +730,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -744,11 +744,11 @@ d] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ assume-screen 10/width, 5/height # initialize editor with three lines - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def g] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -758,7 +758,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -772,11 +772,11 @@ g] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def g] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -785,7 +785,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # left-arrow should have had no effect screen-should-contain [ @@ -801,11 +801,11 @@ g] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # position cursor right after empty line assume-console [ @@ -814,7 +814,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -829,9 +829,9 @@ d] scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with a wrapping line - 1:address:shared:array:character <- new [abcdef] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [abcdef] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace screen-should-contain [ . . @@ -846,9 +846,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -860,10 +860,10 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with a wrapping line followed by a second line - 1:address:shared:array:character <- new [abcdef + 1:address:array:character <- new [abcdef g] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace screen-should-contain [ . . @@ -878,9 +878,9 @@ g] press left-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 # previous row @@ -892,10 +892,10 @@ g] scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with a line on the verge of wrapping, followed by a second line - 1:address:shared:array:character <- new [abcd + 1:address:array:character <- new [abcd e] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + editor-render screen, 2:address:editor-data $clear-trace screen-should-contain [ . . @@ -910,9 +910,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -927,19 +927,19 @@ e] scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -950,7 +950,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -973,12 +973,12 @@ after <handle-special-key> [ } ] -def move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ +def move-to-previous-line editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset already-at-top?:boolean <- lesser-or-equal cursor-row, 1/top @@ -988,13 +988,13 @@ def move-to-previous-line editor:address:shared:editor-data -> editor:address:sh # if not at newline, move to start of line (previous newline) # then scan back another line # if either step fails, give up without modifying cursor or coordinates - curr:address:shared:duplex-list:character <- copy before-cursor + curr:address:duplex-list:character <- copy before-cursor { - old:address:shared:duplex-list:character <- copy curr + old:address:duplex-list:character <- copy curr c2:character <- get *curr, value:offset at-newline?:boolean <- equal c2, 10/newline break-if at-newline? - curr:address:shared:duplex-list:character <- before-previous-line curr, editor + curr:address:duplex-list:character <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false return-if no-motion? @@ -1017,7 +1017,7 @@ def move-to-previous-line editor:address:shared:editor-data -> editor:address:sh { done?:boolean <- greater-or-equal cursor-column, target-column break-if done? - curr:address:shared:duplex-list:character <- next before-cursor + curr:address:duplex-list:character <- next before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -1043,19 +1043,19 @@ def move-to-previous-line editor:address:shared:editor-data -> editor:address:sh scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [ab + 1:address:array:character <- new [ab def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1066,7 +1066,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1079,19 +1079,19 @@ def] scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1102,7 +1102,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1116,11 +1116,11 @@ def] scenario editor-moves-to-previous-line-from-left-margin [ assume-screen 10/width, 5/height # start out with three lines - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1128,9 +1128,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1141,7 +1141,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1156,19 +1156,19 @@ ghi] scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1180,7 +1180,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1203,12 +1203,12 @@ after <handle-special-key> [ } ] -def move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ +def move-to-next-line editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset last-line:number <- subtract screen-height, 1 @@ -1218,7 +1218,7 @@ def move-to-next-line editor:address:shared:editor-data, screen-height:number -> break-if already-at-bottom? # scan to start of next line, then to right column or until end of line max:number <- subtract right, left - next-line:address:shared:duplex-list:character <- before-start-of-next-line before-cursor, max + next-line:address:duplex-list:character <- before-start-of-next-line before-cursor, max { # already at end of buffer? try to scroll up (so we can see more # warnings or sandboxes below) @@ -1239,7 +1239,7 @@ def move-to-next-line editor:address:shared:editor-data, screen-height:number -> { done?:boolean <- greater-or-equal cursor-column, target-column break-if done? - curr:address:shared:duplex-list:character <- next before-cursor + curr:address:duplex-list:character <- next before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -1261,19 +1261,19 @@ def move-to-next-line editor:address:shared:editor-data, screen-height:number -> scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc de] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1284,7 +1284,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1299,10 +1299,10 @@ de] scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1310,9 +1310,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1348,7 +1348,7 @@ after <handle-special-key> [ } ] -def move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def move-to-start-of-line editor:address:editor-data -> editor:address:editor-data [ local-scope load-ingredients # update cursor column @@ -1356,8 +1356,8 @@ def move-to-start-of-line editor:address:shared:editor-data -> editor:address:sh cursor-column:number <- copy left *editor <- put *editor, cursor-column:offset, cursor-column # update before-cursor - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - init:address:shared:duplex-list:character <- get *editor, data:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + init:address:duplex-list:character <- get *editor, data:offset # while not at start of line, move { at-start-of-text?:boolean <- equal before-cursor, init @@ -1374,10 +1374,10 @@ def move-to-start-of-line editor:address:shared:editor-data -> editor:address:sh scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1385,9 +1385,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1399,9 +1399,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ scenario editor-moves-to-start-of-line-with-home [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1409,9 +1409,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1423,10 +1423,10 @@ scenario editor-moves-to-start-of-line-with-home [ scenario editor-moves-to-start-of-line-with-home-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1434,9 +1434,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1450,10 +1450,10 @@ scenario editor-moves-to-start-of-line-with-home-2 [ scenario editor-moves-to-end-of-line-with-ctrl-e [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1461,9 +1461,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1476,9 +1476,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1520,14 +1520,14 @@ after <handle-special-key> [ } ] -def move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def move-to-end-of-line editor:address:editor-data -> editor:address:editor-data [ local-scope load-ingredients - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset cursor-column:number <- get *editor, cursor-column:offset # while not at start of line, move { - next:address:shared:duplex-list:character <- next before-cursor + next:address:duplex-list:character <- next before-cursor break-unless next # end of text nextc:character <- get *next, value:offset at-end-of-line?:boolean <- equal nextc, 10/newline @@ -1542,10 +1542,10 @@ def move-to-end-of-line editor:address:shared:editor-data -> editor:address:shar scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1553,9 +1553,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 4:number <- get *2:address:shared:editor-data, cursor-row:offset - 5:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 4:number <- get *2:address:editor-data, cursor-row:offset + 5:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1567,10 +1567,10 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ scenario editor-moves-to-end-of-line-with-end [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on first line, press 'end' assume-console [ @@ -1578,9 +1578,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1592,10 +1592,10 @@ scenario editor-moves-to-end-of-line-with-end [ scenario editor-moves-to-end-of-line-with-end-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1603,9 +1603,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1619,16 +1619,16 @@ scenario editor-moves-to-end-of-line-with-end-2 [ scenario editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1645,21 +1645,21 @@ after <handle-special-character> [ delete-to-start-of-line?:boolean <- equal c, 21/ctrl-u break-unless delete-to-start-of-line? <delete-to-start-of-line-begin> - deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor + deleted-cells:address:duplex-list:character <- delete-to-start-of-line editor <delete-to-start-of-line-end> go-render? <- copy 1/true return } ] -def delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ +def delete-to-start-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ local-scope load-ingredients # compute range to delete - init:address:shared:duplex-list:character <- get *editor, data:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - start:address:shared:duplex-list:character <- copy before-cursor - end:address:shared:duplex-list:character <- next before-cursor + init:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + start:address:duplex-list:character <- copy before-cursor + end:address:duplex-list:character <- next before-cursor { at-start-of-text?:boolean <- equal start, init break-if at-start-of-text? @@ -1671,7 +1671,7 @@ def delete-to-start-of-line editor:address:shared:editor-data -> result:address: loop } # snip it out - result:address:shared:duplex-list:character <- next start + result:address:duplex-list:character <- next start remove-between start, end # adjust cursor before-cursor <- copy start @@ -1682,16 +1682,16 @@ def delete-to-start-of-line editor:address:shared:editor-data -> result:address: scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1705,16 +1705,16 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1728,16 +1728,16 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1753,16 +1753,16 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ scenario editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1779,19 +1779,19 @@ after <handle-special-character> [ delete-to-end-of-line?:boolean <- equal c, 11/ctrl-k break-unless delete-to-end-of-line? <delete-to-end-of-line-begin> - deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor + deleted-cells:address:duplex-list:character <- delete-to-end-of-line editor <delete-to-end-of-line-end> go-render? <- copy 1/true return } ] -def delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ +def delete-to-end-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ local-scope load-ingredients # compute range to delete - start:address:shared:duplex-list:character <- get *editor, before-cursor:offset - end:address:shared:duplex-list:character <- next start + start:address:duplex-list:character <- get *editor, before-cursor:offset + end:address:duplex-list:character <- next start { at-end-of-text?:boolean <- equal end, 0/null break-if at-end-of-text? @@ -1808,16 +1808,16 @@ def delete-to-end-of-line editor:address:shared:editor-data -> result:address:sh scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address: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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1831,16 +1831,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes just last character screen-should-contain [ @@ -1854,16 +1854,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1877,16 +1877,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes just the final character screen-should-contain [ @@ -1900,16 +1900,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [123 + 1:address:array:character <- new [123 456] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1927,11 +1927,11 @@ scenario editor-can-scroll-down-using-arrow-keys [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -1944,7 +1944,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen slides by one line screen-should-contain [ @@ -1957,11 +1957,11 @@ d] after <scroll-down> [ trace 10, [app], [scroll down] - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset max:number <- subtract right, left - old-top:address:shared:duplex-list:character <- copy top-of-screen + old-top:address:duplex-list:character <- copy top-of-screen top-of-screen <- before-start-of-next-line top-of-screen, max *editor <- put *editor, top-of-screen:offset, top-of-screen no-movement?:boolean <- equal old-top, top-of-screen @@ -1972,11 +1972,11 @@ after <scroll-down> [ # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline # beware: never return null pointer. -def before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ +def before-start-of-next-line original:address:duplex-list:character, max:number -> curr:address:duplex-list:character [ local-scope load-ingredients count:number <- copy 0 - curr:address:shared:duplex-list:character <- copy original + curr:address:duplex-list:character <- copy original # skip the initial newline if it exists { c:character <- get *curr, value:offset @@ -2005,11 +2005,11 @@ scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:shared:array:character <- new [abcdef + 1:address:array:character <- new [abcdef g h i] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2022,7 +2022,7 @@ i] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2037,18 +2037,18 @@ scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # editor starts with a long line wrapping twice - 1:address:shared:array:character <- new [abcdefghij + 1:address:array:character <- new [abcdefghij k l m] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at last line, then try to move further down assume-console [ left-click 3, 0 press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line containing a wrap icon screen-should-contain [ @@ -2062,7 +2062,7 @@ m] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2077,19 +2077,19 @@ scenario editor-scrolls-down-when-line-wraps [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a long line in the third line - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b cdef] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at end, type a character assume-console [ left-click 3, 4 type [g] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2107,19 +2107,19 @@ cdef] scenario editor-scrolls-down-on-newline [ assume-screen 5/width, 4/height # position cursor after last line and type newline - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right assume-console [ left-click 3, 4 type [ ] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2138,19 +2138,19 @@ scenario editor-scrolls-down-on-right-arrow [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b cdefgh] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at end of screen and try to move right assume-console [ left-click 3, 3 press right-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2169,20 +2169,20 @@ scenario editor-scrolls-down-on-right-arrow-2 [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains more lines than can fit on screen - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at end of screen and try to move right assume-console [ left-click 3, 3 press right-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2199,10 +2199,10 @@ d] scenario editor-scrolls-at-end-on-down-arrow [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc de] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data $clear-trace # try to move down past end of text assume-console [ @@ -2210,9 +2210,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen should scroll, moving cursor to end of text memory-should-contain [ @@ -2223,7 +2223,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2238,9 +2238,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen stops scrolling because cursor is already at top memory-should-contain [ @@ -2252,7 +2252,7 @@ de] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2266,14 +2266,14 @@ scenario editor-combines-page-and-line-scroll [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a few pages of lines - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e f g] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # scroll down one page and one line assume-console [ press page-down @@ -2281,7 +2281,7 @@ g] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen scrolls down 3 lines screen-should-contain [ @@ -2298,11 +2298,11 @@ scenario editor-can-scroll-up-using-arrow-keys [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2315,7 +2315,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen slides by one line screen-should-contain [ @@ -2328,8 +2328,8 @@ d] after <scroll-up> [ trace 10, [app], [scroll up] - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset - old-top:address:shared:duplex-list:character <- copy top-of-screen + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + old-top:address:duplex-list:character <- copy top-of-screen top-of-screen <- before-previous-line top-of-screen, editor *editor <- put *editor, top-of-screen:offset, top-of-screen no-movement?:boolean <- equal old-top, top-of-screen @@ -2340,10 +2340,10 @@ after <scroll-up> [ # 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:address:shared:duplex-list:character, editor:address:shared:editor-data -> out:address:shared:duplex-list:character [ +def before-previous-line in:address:duplex-list:character, editor:address:editor-data -> out:address:duplex-list:character [ local-scope load-ingredients - curr:address:shared:duplex-list:character <- copy in + curr:address:duplex-list:character <- copy in c:character <- get *curr, value:offset # compute max, number of characters to skip # 1 + len%(width-1) @@ -2351,12 +2351,12 @@ def before-previous-line in:address:shared:duplex-list:character, editor:address left:number <- get *editor, left:offset right:number <- get *editor, right:offset max-line-length:number <- subtract right, left, -1/exclusive-right, 1/wrap-icon - sentinel:address:shared:duplex-list:character <- get *editor, data:offset + sentinel:address:duplex-list:character <- get *editor, data:offset len:number <- previous-line-length curr, sentinel { break-if len # empty line; just skip this newline - prev:address:shared:duplex-list:character <- prev curr + prev:address:duplex-list:character <- prev curr return-unless prev, curr return prev } @@ -2372,7 +2372,7 @@ def before-previous-line in:address:shared:duplex-list:character, editor:address { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:shared:duplex-list:character <- prev curr + prev:address:duplex-list:character <- prev curr break-unless prev curr <- copy prev count <- add count, 1 @@ -2386,11 +2386,11 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:shared:array:character <- new [abcdef + 1:address:array:character <- new [abcdef g h i] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2402,7 +2402,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2415,7 +2415,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2430,17 +2430,17 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [ # screen has 1 line for menu + 4 lines assume-screen 10/width, 5/height # editor starts with a long line wrapping twice, occupying 3 of the 4 lines - 1:address:shared:array:character <- new [abcdefghij + 1:address:array:character <- new [abcdefghij k l m] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2454,7 +2454,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2469,7 +2469,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2484,7 +2484,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2503,11 +2503,11 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-3 [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:shared:array:character <- new [abcdef + 1:address:array:character <- new [abcdef g h i] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right screen-should-contain [ . . .abcde↩ . @@ -2519,7 +2519,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2532,7 +2532,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2547,18 +2547,18 @@ i] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ assume-screen 10/width, 4/height # initialize editor with some lines around an empty line - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right assume-console [ press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2570,7 +2570,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2582,7 +2582,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2596,18 +2596,18 @@ scenario editor-scrolls-up-on-left-arrow [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains >3 lines - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2620,9 +2620,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2641,11 +2641,11 @@ scenario editor-can-scroll-up-to-start-of-file [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2660,7 +2660,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen slides by one line screen-should-contain [ @@ -2674,7 +2674,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen remains unchanged screen-should-contain [ @@ -2689,11 +2689,11 @@ d] scenario editor-can-scroll [ assume-screen 10/width, 4/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2705,7 +2705,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows next page screen-should-contain [ @@ -2720,12 +2720,12 @@ after <handle-special-character> [ { page-down?:boolean <- equal c, 6/ctrl-f break-unless page-down? - old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + old-top:address:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never <move-cursor-end> - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset no-movement?:boolean <- equal top-of-screen, old-top go-render? <- not no-movement? return @@ -2736,12 +2736,12 @@ after <handle-special-key> [ { page-down?:boolean <- equal k, 65518/page-down break-unless page-down? - old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + old-top:address:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never <move-cursor-end> - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset no-movement?:boolean <- equal top-of-screen, old-top go-render? <- not no-movement? return @@ -2750,15 +2750,15 @@ after <handle-special-key> [ # page-down skips entire wrapped lines, so it can't scroll past lines # taking up the entire screen -def page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def page-down editor:address:editor-data -> editor:address:editor-data [ local-scope load-ingredients # if editor contents don't overflow screen, do nothing - bottom-of-screen:address:shared:duplex-list:character <- get *editor, bottom-of-screen:offset + bottom-of-screen:address:duplex-list:character <- get *editor, bottom-of-screen:offset return-unless bottom-of-screen # if not, position cursor at final character - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - before-cursor:address:shared:duplex-list:character <- prev bottom-of-screen + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:duplex-list:character <- prev bottom-of-screen *editor <- put *editor, before-cursor:offset, before-cursor # keep one line in common with previous page { @@ -2776,10 +2776,10 @@ def page-down editor:address:shared:editor-data -> editor:address:shared:editor- scenario editor-does-not-scroll-past-end [ assume-screen 10/width, 4/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data screen-should-contain [ . . .a . @@ -2791,7 +2791,7 @@ b] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen remains unmodified screen-should-contain [ @@ -2806,11 +2806,11 @@ scenario editor-starts-next-page-at-start-of-wrapped-line [ # screen has 1 line for menu + 3 lines for text assume-screen 10/width, 4/height # editor contains a long last line - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b cdefgh] # editor screen triggers wrap of last line - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2823,7 +2823,7 @@ cdefgh] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2839,9 +2839,9 @@ scenario editor-starts-next-page-at-start-of-wrapped-line-2 [ assume-screen 10/width, 4/height # editor contains a very long line that occupies last two lines of screen # and still has something left over - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a bcdefgh] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2854,7 +2854,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2869,11 +2869,11 @@ bcdefgh] scenario editor-can-scroll-up [ assume-screen 10/width, 4/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2885,7 +2885,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows next page screen-should-contain [ @@ -2899,7 +2899,7 @@ d] press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows original page again screen-should-contain [ @@ -2914,12 +2914,12 @@ after <handle-special-character> [ { page-up?:boolean <- equal c, 2/ctrl-b break-unless page-up? - old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + old-top:address:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never <move-cursor-end> - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset no-movement?:boolean <- equal top-of-screen, old-top go-render? <- not no-movement? return @@ -2930,12 +2930,12 @@ after <handle-special-key> [ { page-up?:boolean <- equal k, 65519/page-up break-unless page-up? - old-top:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + old-top:address:duplex-list:character <- get *editor, top-of-screen:offset <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never <move-cursor-end> - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset no-movement?:boolean <- equal top-of-screen, old-top # don't bother re-rendering if nothing changed. todo: test this go-render? <- not no-movement? @@ -2943,16 +2943,16 @@ after <handle-special-key> [ } ] -def page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ +def page-up editor:address:editor-data, screen-height:number -> editor:address:editor-data [ local-scope load-ingredients max:number <- subtract screen-height, 1/menu-bar, 1/overlapping-line count:number <- copy 0 - top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:shared:duplex-list:character <- before-previous-line top-of-screen, editor + prev:address:duplex-list:character <- before-previous-line top-of-screen, editor break-unless prev top-of-screen <- copy prev *editor <- put *editor, top-of-screen:offset, top-of-screen @@ -2965,7 +2965,7 @@ scenario editor-can-scroll-up-multiple-pages [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with 8 lines - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d @@ -2973,7 +2973,7 @@ e f g h] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2986,7 +2986,7 @@ h] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows third page screen-should-contain [ @@ -3000,7 +3000,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows second page screen-should-contain [ @@ -3014,7 +3014,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows original page again screen-should-contain [ @@ -3029,7 +3029,7 @@ scenario editor-can-scroll-up-wrapped-lines [ # screen has 1 line for menu + 5 lines for text assume-screen 10/width, 6/height # editor contains a long line in the first page - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b cdefgh i @@ -3040,7 +3040,7 @@ m n o] # editor screen triggers wrap of last line - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -3057,7 +3057,7 @@ o] press down-arrow ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -3073,7 +3073,7 @@ o] press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen resets screen-should-contain [ @@ -3091,9 +3091,9 @@ scenario editor-can-scroll-up-wrapped-lines-2 [ assume-screen 10/width, 4/height # editor contains a very long line that occupies last two lines of screen # and still has something left over - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a bcdefgh] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -3106,7 +3106,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -3120,7 +3120,7 @@ bcdefgh] press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # screen resets screen-should-contain [ @@ -3134,7 +3134,7 @@ bcdefgh] scenario editor-can-scroll-up-past-nonempty-lines [ assume-screen 10/width, 4/height # text with empty line in second screen - 1:address:shared:array:character <- new [axx + 1:address:array:character <- new [axx bxx cxx dxx @@ -3143,7 +3143,7 @@ fxx gxx hxx ] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right screen-should-contain [ . . .axx . @@ -3154,7 +3154,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -3166,7 +3166,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -3179,7 +3179,7 @@ hxx press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -3192,7 +3192,7 @@ hxx scenario editor-can-scroll-up-past-empty-lines [ assume-screen 10/width, 4/height # text with empty line in second screen - 1:address:shared:array:character <- new [axy + 1:address:array:character <- new [axy bxy cxy @@ -3201,7 +3201,7 @@ exy fxy gxy ] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right screen-should-contain [ . . .axy . @@ -3212,7 +3212,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -3224,7 +3224,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -3237,7 +3237,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 3503f008..e7509bf7 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -6,22 +6,22 @@ def! main [ local-scope open-console - initial-recipe:address:shared:array:character <- restore [recipes.mu] - initial-sandbox:address:shared:array:character <- new [] + initial-recipe:address:array:character <- restore [recipes.mu] + initial-sandbox:address:array:character <- new [] hide-screen 0/screen - env:address:shared:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox + env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox render-all 0/screen, env event-loop 0/screen, 0/console, env # never gets here ] container programming-environment-data [ - recipes:address:shared:editor-data - current-sandbox:address:shared:editor-data + recipes:address:editor-data + current-sandbox:address:editor-data sandbox-in-focus?:boolean # false => cursor in recipes; true => cursor in current-sandbox ] -def new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ +def new-programming-environment screen:address:screen, initial-recipe-contents:address:array:character, initial-sandbox-contents:address:array:character -> result:address:programming-environment-data, screen:address:screen [ local-scope load-ingredients width:number <- screen-width screen @@ -38,21 +38,21 @@ def new-programming-environment screen:address:shared:screen, initial-recipe-con divider:number, _ <- divide-with-remainder width, 2 draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted # recipe editor on the left - recipes:address:shared:editor-data <- new-editor initial-recipe-contents, screen, 0/left, divider/right + recipes:address:editor-data <- new-editor initial-recipe-contents, screen, 0/left, divider/right # sandbox editor on the right sandbox-left:number <- add divider, 1 - current-sandbox:address:shared:editor-data <- new-editor initial-sandbox-contents, screen, sandbox-left, width/right + current-sandbox:address:editor-data <- new-editor initial-sandbox-contents, screen, sandbox-left, width/right *result <- put *result, recipes:offset, recipes *result <- put *result, current-sandbox:offset, current-sandbox *result <- put *result, sandbox-in-focus?:offset, 0/false <programming-environment-initialization> ] -def event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ +def event-loop screen:address:screen, console:address:console, env:address:programming-environment-data -> screen:address:screen, console:address:console, env:address:programming-environment-data [ local-scope load-ingredients - recipes:address:shared:editor-data <- get *env, recipes:offset - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + recipes:address:editor-data <- get *env, recipes:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset sandbox-in-focus?:boolean <- get *env, sandbox-in-focus?:offset # if we fall behind we'll stop updating the screen, but then we have to # render the entire screen when we catch up. @@ -182,21 +182,21 @@ def event-loop screen:address:shared:screen, console:address:shared:console, env } ] -def resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ +def resize screen:address:screen, env:address:programming-environment-data -> env:address:programming-environment-data, screen:address:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions width:number <- screen-width screen divider:number, _ <- divide-with-remainder width, 2 # update recipe editor - recipes:address:shared:editor-data <- get *env, recipes:offset + recipes:address:editor-data <- get *env, recipes:offset right:number <- subtract divider, 1 *recipes <- put *recipes, right:offset, right # reset cursor (later we'll try to preserve its position) *recipes <- put *recipes, cursor-row:offset, 1 *recipes <- put *recipes, cursor-column:offset, 0 # update sandbox editor - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset left:number <- add divider, 1 *current-sandbox <- put *current-sandbox, left:offset, left right:number <- subtract width, 1 @@ -210,9 +210,9 @@ scenario point-at-multiple-editors [ trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize both halves of screen - 1:address:shared:array:character <- new [abc] - 2:address:shared:array:character <- new [def] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 1:address:array:character <- new [abc] + 2:address:array:character <- new [def] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # focus on both sides assume-console [ left-click 1, 1 @@ -220,11 +220,11 @@ scenario point-at-multiple-editors [ ] # check cursor column in each run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data - 4:address:shared:editor-data <- get *3:address:shared:programming-environment-data, recipes:offset - 5:number <- get *4:address:shared:editor-data, cursor-column:offset - 6:address:shared:editor-data <- get *3:address:shared:programming-environment-data, current-sandbox:offset - 7:number <- get *6:address:shared:editor-data, cursor-column:offset + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + 4:address:editor-data <- get *3:address:programming-environment-data, recipes:offset + 5:number <- get *4:address:editor-data, cursor-column:offset + 6:address:editor-data <- get *3:address:programming-environment-data, current-sandbox:offset + 7:number <- get *6:address:editor-data, cursor-column:offset ] memory-should-contain [ 5 <- 1 @@ -236,10 +236,10 @@ scenario edit-multiple-editors [ trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize both halves of screen - 1:address:shared:array:character <- new [abc] - 2:address:shared:array:character <- new [def] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [abc] + 2:address:array:character <- new [def] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # type one letter in each of them assume-console [ left-click 1, 1 @@ -248,11 +248,11 @@ scenario edit-multiple-editors [ type [1] ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data - 4:address:shared:editor-data <- get *3:address:shared:programming-environment-data, recipes:offset - 5:number <- get *4:address:shared:editor-data, cursor-column:offset - 6:address:shared:editor-data <- get *3:address:shared:programming-environment-data, current-sandbox:offset - 7:number <- get *6:address:shared:editor-data, cursor-column:offset + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + 4:address:editor-data <- get *3:address:programming-environment-data, recipes:offset + 5:number <- get *4:address:editor-data, cursor-column:offset + 6:address:editor-data <- get *3:address:programming-environment-data, current-sandbox:offset + 7:number <- get *6:address:editor-data, cursor-column:offset ] screen-should-contain [ . run (F4) . # this line has a different background, but we don't test that yet @@ -267,7 +267,7 @@ scenario edit-multiple-editors [ # show the cursor at the right window run [ 8:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 8:character/cursor + print screen:address:screen, 8:character/cursor ] screen-should-contain [ . run (F4) . @@ -281,10 +281,10 @@ scenario multiple-editors-cover-only-their-own-areas [ trace-until 100/app # trace too long assume-screen 60/width, 10/height run [ - 1:address:shared:array:character <- new [abc] - 2:address:shared:array:character <- new [def] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [abc] + 2:address:array:character <- new [def] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data ] # divider isn't messed up screen-should-contain [ @@ -299,16 +299,16 @@ scenario multiple-editors-cover-only-their-own-areas [ scenario editor-in-focus-keeps-cursor [ trace-until 100/app # trace too long assume-screen 30/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:array:character <- new [def] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [abc] + 2:address:array:character <- new [def] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # initialize programming environment and highlight cursor assume-console [] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # is cursor at the right place? screen-should-contain [ @@ -322,9 +322,9 @@ scenario editor-in-focus-keeps-cursor [ type [z] ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # cursor should still be right screen-should-contain [ @@ -339,11 +339,11 @@ scenario backspace-in-sandbox-editor-joins-lines [ trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize sandbox side with two lines - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [abc + 1:address:array:character <- new [] + 2:address:array:character <- new [abc def] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊abc . @@ -357,9 +357,9 @@ def] press backspace ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # cursor moves to end of old line screen-should-contain [ @@ -370,7 +370,7 @@ def] ] ] -def render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def render-all screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients trace 10, [app], [render all] @@ -394,19 +394,19 @@ def render-all screen:address:shared:screen, env:address:shared:programming-envi screen <- render-sandbox-side screen, env <render-components-end> # - recipes:address:shared:editor-data <- get *env, recipes:offset - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + recipes:address:editor-data <- get *env, recipes:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset sandbox-in-focus?:boolean <- get *env, sandbox-in-focus?:offset screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env # show-screen screen ] -def render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def render-recipes screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render recipes] - recipes:address:shared:editor-data <- get *env, recipes:offset + recipes:address:editor-data <- get *env, recipes:offset # render recipes left:number <- get *recipes, left:offset right:number <- get *recipes, right:offset @@ -421,10 +421,10 @@ def render-recipes screen:address:shared:screen, env:address:shared:programming- ] # replaced in a later layer -def render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset row:number, column:number, screen, current-sandbox <- render screen, current-sandbox @@ -436,7 +436,7 @@ def render-sandbox-side screen:address:shared:screen, env:address:shared:program clear-screen-from screen, row, left, left, right ] -def update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean, env:address:shared:programming-environment-data -> screen:address:shared:screen [ +def update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean, env:address:programming-environment-data -> screen:address:screen [ local-scope load-ingredients <update-cursor-special-cases> @@ -455,7 +455,7 @@ def update-cursor screen:address:shared:screen, recipes:address:shared:editor-da # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -def render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ +def render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients return-unless s @@ -516,7 +516,7 @@ def render screen:address:shared:screen, s:address:shared:array:character, left: ] # like 'render' for texts, but with colorization for comments like in the editor -def render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ +def render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients return-unless s @@ -584,7 +584,7 @@ after <global-type> [ { redraw-screen?:boolean <- equal c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:address:shared:programming-environment-data + screen <- render-all screen, env:address:programming-environment-data sync-screen screen loop +next-event:label } @@ -607,7 +607,7 @@ after <global-type> [ ## helpers -def draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number -> screen:address:shared:screen [ +def draw-vertical screen:address:screen, col:number, y:number, bottom:number -> screen:address:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 89f52fb6..4d4b93ef 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -7,10 +7,10 @@ def! main [ local-scope open-console - initial-recipe:address:shared:array:character <- restore [recipes.mu] - initial-sandbox:address:shared:array:character <- new [] + initial-recipe:address:array:character <- restore [recipes.mu] + initial-sandbox:address:array:character <- new [] hide-screen 0/screen - env:address:shared:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox + env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox env <- restore-sandboxes env render-all 0/screen, env event-loop 0/screen, 0/console, env @@ -18,7 +18,7 @@ def! main [ ] container programming-environment-data [ - sandbox:address:shared:sandbox-data # list of sandboxes, from top to bottom + sandbox:address:sandbox-data # list of sandboxes, from top to bottom render-from:number number-of-sandboxes:number ] @@ -28,30 +28,30 @@ after <programming-environment-initialization> [ ] container sandbox-data [ - data:address:shared:array:character - response:address:shared:array:character + data:address:array:character + response:address:array:character # coordinates to track clicks # constraint: will be 0 for sandboxes at positions before env.render-from starting-row-on-screen:number code-ending-row-on-screen:number # past end of code - screen:address:shared:screen # prints in the sandbox go here - next-sandbox:address:shared:sandbox-data + screen:address:screen # prints in the sandbox go here + next-sandbox:address:sandbox-data ] scenario run-and-show-results [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe editor is empty - 1:address:shared:array:character <- new [] + 1:address:array:character <- new [] # sandbox editor contains an instruction without storing outputs - 2:address:shared:array:character <- new [divide-with-remainder 11, 3] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [divide-with-remainder 11, 3] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -101,7 +101,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -139,23 +139,23 @@ after <global-keypress> [ } ] -def run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def run-sandboxes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ local-scope load-ingredients errors-found?:boolean, env, screen <- update-recipes env, screen return-if errors-found? # check contents of right editor (sandbox) <run-sandboxes-begin> - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset { - sandbox-contents:address:shared:array:character <- editor-contents current-sandbox + sandbox-contents:address:array:character <- 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:address:shared:sandbox-data <- new sandbox-data:type + new-sandbox:address:sandbox-data <- new sandbox-data:type *new-sandbox <- put *new-sandbox, data:offset, sandbox-contents # push to head of sandbox list - dest:address:shared:sandbox-data <- get *env, sandbox:offset + dest:address:sandbox-data <- get *env, sandbox:offset *new-sandbox <- put *new-sandbox, next-sandbox:offset, dest *env <- put *env, sandbox:offset, new-sandbox # update sandbox count @@ -163,14 +163,14 @@ def run-sandboxes env:address:shared:programming-environment-data, screen:addres sandbox-count <- add sandbox-count, 1 *env <- put *env, number-of-sandboxes:offset, sandbox-count # clear sandbox editor - init:address:shared:duplex-list:character <- push 167/§, 0/tail + init:address:duplex-list:character <- push 167/§, 0/tail *current-sandbox <- put *current-sandbox, data:offset, init *current-sandbox <- put *current-sandbox, top-of-screen:offset, init } # save all sandboxes before running, just in case we die when running save-sandboxes env # run all sandboxes - curr:address:shared:sandbox-data <- get *env, sandbox:offset + curr:address:sandbox-data <- get *env, sandbox:offset idx:number <- copy 0 { break-unless curr @@ -184,45 +184,45 @@ def run-sandboxes env:address:shared:programming-environment-data, screen:addres # copy code from recipe editor, persist, load into mu # replaced in a later layer (whereupon errors-found? will actually be set) -def update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ local-scope load-ingredients - recipes:address:shared:editor-data <- get *env, recipes:offset - in:address:shared:array:character <- editor-contents recipes + recipes:address:editor-data <- get *env, recipes:offset + in:address:array:character <- editor-contents recipes save [recipes.mu], in # newlayer: persistence reload in errors-found? <- copy 0/false ] # replaced in a later layer -def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [ local-scope load-ingredients - data:address:shared:array:character <- get *sandbox, data:offset - response:address:shared:array:character, _, fake-screen:address:shared:screen <- run-interactive data + data:address:array:character <- get *sandbox, data:offset + response:address:array:character, _, fake-screen:address:screen <- run-interactive data *sandbox <- put *sandbox, response:offset, response *sandbox <- put *sandbox, screen:offset, fake-screen ] -def update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ +def update-status screen:address:screen, msg:address:array:character, color:number -> screen:address:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -def save-sandboxes env:address:shared:programming-environment-data [ +def save-sandboxes env:address:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:editor-data <- 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:address:shared:sandbox-data <- get *env, sandbox:offset + curr:address:sandbox-data <- get *env, sandbox:offset idx:number <- copy 0 { break-unless curr - data:address:shared:array:character <- get *curr, data:offset - filename:address:shared:array:character <- to-text idx + data:address:array:character <- get *curr, data:offset + filename:address:array:character <- to-text idx save filename, data <end-save-sandbox> idx <- add idx, 1 @@ -231,11 +231,11 @@ def save-sandboxes env:address:shared:programming-environment-data [ } ] -def! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def! render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render sandbox side] - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset row:number, column:number <- copy 1, 0 left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset @@ -250,12 +250,12 @@ def! render-sandbox-side screen:address:shared:screen, env:address:shared:progra } # render sandboxes draw-horizontal screen, row, left, right, 9473/horizontal-double - sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + sandbox:address:sandbox-data <- get *env, sandbox:offset row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from clear-rest-of-screen screen, row, left, right ] -def render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ +def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:screen, sandbox:address:sandbox-data [ local-scope load-ingredients return-unless sandbox @@ -277,14 +277,14 @@ def render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbo # render sandbox contents row <- add row, 1 screen <- move-cursor screen, row, left - sandbox-data:address:shared:array:character <- get *sandbox, data:offset + sandbox-data:address:array:character <- get *sandbox, data:offset row, screen <- render-code screen, sandbox-data, left, right, row *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row # render sandbox warnings, screen or response, in that order - sandbox-response:address:shared:array:character <- get *sandbox, response:offset + sandbox-response:address:array:character <- get *sandbox, response:offset <render-sandbox-results> { - sandbox-screen:address:shared:screen <- get *sandbox, screen:offset + sandbox-screen:address:screen <- get *sandbox, screen:offset empty-screen?:boolean <- fake-screen-is-empty? sandbox-screen break-if empty-screen? row, screen <- render-screen screen, sandbox-screen, left, right, row @@ -308,22 +308,22 @@ def render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbo <end-render-sandbox-reset-hidden> } # draw next sandbox - next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset next-idx:number <- add idx, 1 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] # assumes programming environment has no sandboxes; restores them from previous session -def restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ +def restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios idx:number <- copy 0 - curr:address:shared:sandbox-data <- copy 0 - prev:address:shared:sandbox-data <- copy 0 + curr:address:sandbox-data <- copy 0 + prev:address:sandbox-data <- copy 0 { - filename:address:shared:array:character <- to-text idx - contents:address:shared:array:character <- restore filename + filename:address:array:character <- to-text idx + contents:address:array:character <- restore filename break-unless contents # stop at first error; assuming file didn't exist # create new sandbox for file curr <- new sandbox-data:type @@ -351,7 +351,7 @@ def restore-sandboxes env:address:shared:programming-environment-data -> env:add # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -def render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ +def render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients return-unless sandbox-screen @@ -362,7 +362,7 @@ def render-screen screen:address:shared:screen, sandbox-screen:address:shared:sc column:number <- copy left s-width:number <- screen-width sandbox-screen s-height:number <- screen-height sandbox-screen - buf:address:shared:array:screen-cell <- get *sandbox-screen, data:offset + buf:address:array:screen-cell <- get *sandbox-screen, data:offset stop-printing:number <- add left, s-width, 3 max-column:number <- min stop-printing, right i:number <- copy 0 @@ -420,20 +420,20 @@ scenario run-updates-results [ trace-until 100/app # trace too long assume-screen 100/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ local-scope z:number <- add 2, 2 reply z ]] # sandbox editor contains an instruction without storing outputs - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the code in the editors assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -453,7 +453,7 @@ reply z press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # check that screen updates the result on the right screen-should-contain [ @@ -473,16 +473,16 @@ scenario run-instruction-manages-screen-per-sandbox [ trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:address:shared:array:character <- new [] + 1:address:array:character <- new [] # right editor contains an instruction - 2:address:shared:array:character <- new [print-integer screen, 4] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [print-integer screen, 4] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # check that it prints a little toy screen screen-should-contain [ @@ -502,11 +502,11 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -def editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ +def editor-contents editor:address:editor-data -> result:address:array:character [ local-scope load-ingredients - buf:address:shared:buffer <- new-buffer 80 - curr:address:shared:duplex-list:character <- get *editor, data:offset + buf:address:buffer <- new-buffer 80 + curr:address:duplex-list:character <- get *editor, data:offset # skip § sentinel assert curr, [editor without data is illegal; must have at least a sentinel] curr <- next curr @@ -523,16 +523,16 @@ def editor-contents editor:address:shared:editor-data -> result:address:shared:a scenario editor-provides-edited-contents [ assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:address:shared:array:character <- editor-contents 2:address:shared:editor-data - 4:array:character <- copy *3:address:shared:array:character + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:address:array:character <- editor-contents 2:address:editor-data + 4:array:character <- copy *3:address:array:character ] memory-should-contain [ 4:array:character <- [abdefc] @@ -545,10 +545,10 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize sandbox side - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [add 2, 2] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [add 2, 2] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data assume-console [ # create a sandbox press F4 @@ -558,9 +558,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ ] ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] screen-should-contain [ . . # minor: F4 clears menu tooltip in very narrow screens @@ -575,9 +575,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -595,9 +595,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press up-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # sandbox editor displays again screen-should-contain [ @@ -620,7 +620,7 @@ after <global-keypress> [ sandbox-cursor:number <- get *current-sandbox, cursor-row:offset sandbox-cursor-on-last-line?:boolean <- equal sandbox-bottom, sandbox-cursor break-unless sandbox-cursor-on-last-line? - sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + sandbox:address:sandbox-data <- get *env, sandbox:offset break-unless sandbox # slide down if possible { @@ -672,12 +672,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:address:shared:programming-environment-data, in:address:shared:sandbox-data -> out:address:shared:sandbox-data [ +def previous-sandbox env:address:programming-environment-data, in:address:sandbox-data -> out:address:sandbox-data [ local-scope load-ingredients - curr:address:shared:sandbox-data <- get *env, sandbox:offset + curr:address:sandbox-data <- get *env, sandbox:offset return-unless curr, 0/nil - next:address:shared:sandbox-data <- get *curr, next-sandbox:offset + next:address:sandbox-data <- get *curr, next-sandbox:offset { return-unless next, 0/nil found?:boolean <- equal next, in @@ -693,24 +693,24 @@ scenario scrolling-down-on-recipe-side [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize sandbox side and create a sandbox - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ ] # create a sandbox - 2:address:shared:array:character <- new [add 2, 2] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 2:address:array:character <- new [add 2, 2] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data # hit 'down' in recipe editor assume-console [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # cursor moves down on recipe side screen-should-contain [ @@ -729,10 +729,10 @@ scenario scrolling-through-multiple-sandboxes [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes assume-console [ press ctrl-n @@ -741,9 +741,9 @@ scenario scrolling-through-multiple-sandboxes [ type [add 1, 1] press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor screen-should-contain [ . . . ┊␣ . @@ -761,9 +761,9 @@ scenario scrolling-through-multiple-sandboxes [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -784,7 +784,7 @@ scenario scrolling-through-multiple-sandboxes [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # just second sandbox displayed screen-should-contain [ @@ -802,7 +802,7 @@ scenario scrolling-through-multiple-sandboxes [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # no change screen-should-contain [ @@ -820,7 +820,7 @@ scenario scrolling-through-multiple-sandboxes [ press up-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # back to displaying both sandboxes without editor screen-should-contain [ @@ -840,9 +840,9 @@ scenario scrolling-through-multiple-sandboxes [ press up-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -862,7 +862,7 @@ scenario scrolling-through-multiple-sandboxes [ press up-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # no change screen-should-contain [ @@ -883,17 +883,17 @@ scenario scrolling-manages-sandbox-index-correctly [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create a sandbox assume-console [ press ctrl-n type [add 1, 1] press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊ . @@ -909,7 +909,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -927,7 +927,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press up-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -945,7 +945,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu index ebfac6ac..257aed22 100644 --- a/edit/006-sandbox-edit.mu +++ b/edit/006-sandbox-edit.mu @@ -4,17 +4,17 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:shared:array:character <- new [foo] + 2:address:array:character <- new [foo] assume-console [ press F4 ] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 3, 30 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # it pops back into editor screen-should-contain [ @@ -48,7 +48,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -69,7 +69,7 @@ after <global-touch> [ click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get t, row:offset @@ -78,9 +78,9 @@ after <global-touch> [ empty-sandbox-editor?:boolean <- empty-editor? current-sandbox break-unless empty-sandbox-editor? # don't clobber existing contents # identify the sandbox to edit and remove it from the sandbox list - sandbox:address:shared:sandbox-data <- extract-sandbox env, click-row + sandbox:address:sandbox-data <- extract-sandbox env, click-row break-unless sandbox - text:address:shared:array:character <- get *sandbox, data:offset + text:address:array:character <- get *sandbox, data:offset current-sandbox <- insert-text current-sandbox, text *env <- put *env, render-from:offset, -1 hide-screen screen @@ -91,18 +91,18 @@ after <global-touch> [ } ] -def empty-editor? editor:address:shared:editor-data -> result:boolean [ +def empty-editor? editor:address:editor-data -> result:boolean [ local-scope load-ingredients - head:address:shared:duplex-list:character <- get *editor, data:offset - first:address:shared:duplex-list:character <- next head + head:address:duplex-list:character <- get *editor, data:offset + first:address:duplex-list:character <- next head result <- not first ] -def extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def extract-sandbox env:address:programming-environment-data, click-row:number -> result:address:sandbox-data, env:address:programming-environment-data [ local-scope load-ingredients - curr-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + curr-sandbox:address:sandbox-data <- get *env, sandbox:offset start:number <- get *curr-sandbox, starting-row-on-screen:offset in-editor?:boolean <- lesser-than click-row, start return-if in-editor?, 0 @@ -110,16 +110,16 @@ def extract-sandbox env:address:shared:programming-environment-data, click-row:n { # first sandbox? pop break-unless first-sandbox? - next-sandbox:address:shared:sandbox-data <- get *curr-sandbox, next-sandbox:offset + next-sandbox:address:sandbox-data <- get *curr-sandbox, next-sandbox:offset *env <- put *env, sandbox:offset, next-sandbox } { # not first sandbox? break-if first-sandbox? - prev-sandbox:address:shared:sandbox-data <- copy curr-sandbox + prev-sandbox:address:sandbox-data <- copy curr-sandbox curr-sandbox <- get *curr-sandbox, next-sandbox:offset { - next-sandbox:address:shared:sandbox-data <- get *curr-sandbox, next-sandbox:offset + next-sandbox:address:sandbox-data <- get *curr-sandbox, next-sandbox:offset break-unless next-sandbox # if click-row < sandbox.next-sandbox.starting-row-on-screen, break next-start:number <- get *next-sandbox, starting-row-on-screen:offset @@ -145,15 +145,15 @@ scenario sandbox-with-print-can-be-edited [ trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:address:shared:array:character <- new [] + 1:address:array:character <- new [] # right editor contains an instruction - 2:address:shared:array:character <- new [print-integer screen, 4] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [print-integer screen, 4] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the sandbox assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -174,7 +174,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 70 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -189,10 +189,10 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -203,7 +203,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ press down-arrow press down-arrow ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊━━━━━━━━━━━━━━. @@ -218,7 +218,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ left-click 2, 20 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -237,10 +237,10 @@ scenario editing-sandbox-updates-sandbox-count [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes assume-console [ press ctrl-n @@ -249,7 +249,7 @@ scenario editing-sandbox-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊ . @@ -266,7 +266,7 @@ scenario editing-sandbox-updates-sandbox-count [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # no change in contents screen-should-contain [ @@ -286,7 +286,7 @@ scenario editing-sandbox-updates-sandbox-count [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # screen should show just final sandbox screen-should-contain [ diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu index aed22244..3df11a4a 100644 --- a/edit/007-sandbox-delete.mu +++ b/edit/007-sandbox-delete.mu @@ -3,9 +3,9 @@ scenario deleting-sandboxes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run a few commands assume-console [ left-click 1, 80 @@ -14,7 +14,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -35,7 +35,7 @@ scenario deleting-sandboxes [ left-click 7, 99 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -53,7 +53,7 @@ scenario deleting-sandboxes [ left-click 3, 99 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -77,29 +77,29 @@ after <global-touch> [ } ] -def delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ +def delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean, env:address:programming-environment-data [ local-scope load-ingredients click-column:number <- get t, column:offset - current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:editor-data <- get *env, current-sandbox:offset right:number <- get *current-sandbox, right:offset at-right?:boolean <- equal click-column, right return-unless at-right?, 0/false click-row:number <- get t, row:offset { - first:address:shared:sandbox-data <- get *env, sandbox:offset + first:address:sandbox-data <- get *env, sandbox:offset reply-unless first, 0/false target-row:number <- get *first, starting-row-on-screen:offset delete-first?:boolean <- equal target-row, click-row break-unless delete-first? - new-first:address:shared:sandbox-data <- get *first, next-sandbox:offset + new-first:address:sandbox-data <- get *first, next-sandbox:offset *env <- put *env, sandbox:offset, new-first env <- fixup-delete env, new-first return 1/true # force rerender } - prev:address:shared:sandbox-data <- get *env, sandbox:offset + prev:address:sandbox-data <- get *env, sandbox:offset assert prev, [failed to find any sandboxes!] - curr:address:shared:sandbox-data <- get *prev, next-sandbox:offset + curr:address:sandbox-data <- get *prev, next-sandbox:offset { break-unless curr # more sandboxes to check @@ -108,7 +108,7 @@ def delete-sandbox t:touch-event, env:address:shared:programming-environment-dat delete-curr?:boolean <- equal target-row, click-row break-unless delete-curr? # delete this sandbox - next:address:shared:sandbox-data <- get *curr, next-sandbox:offset + next:address:sandbox-data <- get *curr, next-sandbox:offset *prev <- put *prev, next-sandbox:offset, next env <- fixup-delete env, next return 1/true # force rerender @@ -120,7 +120,7 @@ def delete-sandbox t:touch-event, env:address:shared:programming-environment-dat return 0/false ] -def fixup-delete env:address:shared:programming-environment-data, next:address:shared:sandbox-data -> env:address:shared:programming-environment-data [ +def fixup-delete env:address:programming-environment-data, next:address:sandbox-data -> env:address:programming-environment-data [ local-scope load-ingredients # update sandbox count @@ -142,10 +142,10 @@ scenario deleting-sandbox-after-scroll [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -155,7 +155,7 @@ scenario deleting-sandbox-after-scroll [ press F4 press down-arrow ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊━━━━━━━━━━━━━━. @@ -170,7 +170,7 @@ scenario deleting-sandbox-after-scroll [ left-click 6, 29 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -188,10 +188,10 @@ scenario deleting-top-sandbox-after-scroll [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -201,7 +201,7 @@ scenario deleting-top-sandbox-after-scroll [ press F4 press down-arrow ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊━━━━━━━━━━━━━━. @@ -216,7 +216,7 @@ scenario deleting-top-sandbox-after-scroll [ left-click 2, 29 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -234,10 +234,10 @@ scenario deleting-final-sandbox-after-scroll [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -248,7 +248,7 @@ scenario deleting-final-sandbox-after-scroll [ press down-arrow press down-arrow ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊━━━━━━━━━━━━━━. @@ -263,7 +263,7 @@ scenario deleting-final-sandbox-after-scroll [ left-click 2, 29 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # implicitly scroll up to first sandbox screen-should-contain [ @@ -282,10 +282,10 @@ scenario deleting-updates-sandbox-count [ trace-until 100/app # trace too long assume-screen 30/width, 10/height # initialize environment - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - render-all screen, 3:address:shared:programming-environment-data + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + render-all screen, 3:address:programming-environment-data # create 2 sandboxes assume-console [ press ctrl-n @@ -294,7 +294,7 @@ scenario deleting-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . . . ┊ . @@ -314,7 +314,7 @@ scenario deleting-updates-sandbox-count [ press down-arrow ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # shouldn't go past last sandbox screen-should-contain [ diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu index c35cf802..98d1bf57 100644 --- a/edit/008-sandbox-test.mu +++ b/edit/008-sandbox-test.mu @@ -4,17 +4,17 @@ scenario sandbox-click-on-result-toggles-color-to-green [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:shared:array:character <- new [foo] + 2:address:array:character <- new [foo] assume-console [ press F4 ] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 5, 21 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -46,7 +46,7 @@ recipe foo [ # cursor should remain unmoved run [ 4:character/cursor <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor + print screen:address:screen, 4:character/cursor ] screen-should-contain [ . run (F4) . @@ -67,7 +67,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # result turns red screen-should-contain-in-color 1/red, [ @@ -85,13 +85,13 @@ recipe foo [ # this requires tracking a couple more things container sandbox-data [ response-starting-row-on-screen:number - expected-response:address:shared:array:character + expected-response:address:array:character ] # include expected response when saving or restoring a sandbox before <end-save-sandbox> [ { - expected-response:address:shared:array:character <- get *curr, expected-response:offset + expected-response:address:array:character <- get *curr, expected-response:offset break-unless expected-response filename <- append filename, [.out] save filename, expected-response @@ -110,14 +110,14 @@ after <global-touch> [ click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on - sandbox:address:shared:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row break-unless sandbox # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox @@ -131,17 +131,17 @@ after <global-touch> [ } ] -def find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + sandbox:address:sandbox-data <- get *env, sandbox:offset start:number <- get *sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:boolean <- 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:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -157,10 +157,10 @@ def find-click-in-sandbox-output env:address:shared:programming-environment-data return sandbox ] -def toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ +def toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ local-scope load-ingredients - expected-response:address:shared:array:character <- get *sandbox, expected-response:offset + expected-response:address:array:character <- get *sandbox, expected-response:offset { # if expected-response is set, reset break-unless expected-response @@ -169,7 +169,7 @@ def toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:addr { # if not, set expected response to the current response break-if expected-response - response:address:shared:array:character <- get *sandbox, response:offset + response:address:array:character <- get *sandbox, response:offset *sandbox <- put *sandbox, expected-response:offset, response } ] @@ -179,7 +179,7 @@ after <render-sandbox-response> [ { break-unless sandbox-response *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row - expected-response:address:shared:array:character <- get *sandbox, expected-response:offset + expected-response:address:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- equal expected-response, sandbox-response { diff --git a/edit/009-sandbox-trace.mu b/edit/009-sandbox-trace.mu index 71eb7cfb..bf6d9fb6 100644 --- a/edit/009-sandbox-trace.mu +++ b/edit/009-sandbox-trace.mu @@ -4,17 +4,17 @@ scenario sandbox-click-on-code-toggles-app-trace [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ stash [abc] ]] # run it - 2:address:shared:array:character <- new [foo] + 2:address:array:character <- new [foo] assume-console [ press F4 ] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -29,9 +29,9 @@ recipe foo [ left-click 4, 21 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data 4:character/cursor-icon <- copy 9251/␣ - print screen:address:shared:screen, 4:character/cursor-icon + print screen:address:screen, 4:character/cursor-icon ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -59,8 +59,8 @@ recipe foo [ left-click 4, 25 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data - print screen:address:shared:screen, 4:character/cursor-icon + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + print screen:address:screen, 4:character/cursor-icon ] # trace hidden again screen-should-contain [ @@ -78,18 +78,18 @@ scenario sandbox-shows-app-trace-and-result [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ stash [abc] reply 4 ]] # run it - 2:address:shared:array:character <- new [foo] + 2:address:array:character <- new [foo] assume-console [ press F4 ] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -105,7 +105,7 @@ recipe foo [ left-click 4, 21 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # trace now printed above result screen-should-contain [ @@ -122,16 +122,16 @@ recipe foo [ ] container sandbox-data [ - trace:address:shared:array:character + trace:address:array:character display-trace?:boolean ] # replaced in a later layer -def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [ local-scope load-ingredients - data:address:shared:array:character <- get *sandbox, data:offset - response:address:shared:array:character, _, fake-screen:address:shared:screen, trace:address:shared:array:character <- run-interactive data + data:address:array:character <- get *sandbox, data:offset + response:address:array:character, _, fake-screen:address:screen, trace:address:array:character <- run-interactive data *sandbox <- put *sandbox, response:offset, response *sandbox <- put *sandbox, screen:offset, fake-screen *sandbox <- put *sandbox, trace:offset, trace @@ -145,14 +145,14 @@ after <global-touch> [ click-column:number <- get t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose code is being clicked on - sandbox:address:shared:sandbox-data <- find-click-in-sandbox-code env, click-row + sandbox:address:sandbox-data <- find-click-in-sandbox-code env, click-row break-unless sandbox # toggle its display-trace? property x:boolean <- get *sandbox, display-trace?:offset @@ -167,7 +167,7 @@ after <global-touch> [ } ] -def find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-code env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -177,7 +177,7 @@ def find-click-in-sandbox-code env:address:shared:programming-environment-data, assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -203,7 +203,7 @@ after <render-sandbox-results> [ { display-trace?:boolean <- get *sandbox, display-trace?:offset break-unless display-trace? - sandbox-trace:address:shared:array:character <- get *sandbox, trace:offset + sandbox-trace:address:array:character <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on row, screen <- render screen, sandbox-trace, left, right, 245/grey, row } diff --git a/edit/010-errors.mu b/edit/010-errors.mu index 494871e5..fcedc191 100644 --- a/edit/010-errors.mu +++ b/edit/010-errors.mu @@ -1,17 +1,17 @@ ## handling malformed programs container programming-environment-data [ - recipe-errors:address:shared:array:character + recipe-errors:address:array:character ] # copy code from recipe editor, persist, load into mu, save any errors -def! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def! update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ local-scope load-ingredients - recipes:address:shared:editor-data <- get *env, recipes:offset - in:address:shared:array:character <- editor-contents recipes + recipes:address:editor-data <- get *env, recipes:offset + in:address:array:character <- editor-contents recipes save [recipes.mu], in - recipe-errors:address:shared:array:character <- reload in + recipe-errors:address:array:character <- reload in *env <- put *env, recipe-errors:offset, recipe-errors # if recipe editor has errors, stop { @@ -25,7 +25,7 @@ def! update-recipes env:address:shared:programming-environment-data, screen:addr before <render-components-end> [ trace 11, [app], [render status] - recipe-errors:address:shared:array:character <- get *env, recipe-errors:offset + recipe-errors:address:array:character <- get *env, recipe-errors:offset { break-unless recipe-errors update-status screen, [errors found ], 1/red @@ -34,7 +34,7 @@ before <render-components-end> [ before <render-recipe-components-end> [ { - recipe-errors:address:shared:array:character <- get *env, recipe-errors:offset + recipe-errors:address:array:character <- get *env, recipe-errors:offset break-unless recipe-errors row, screen <- render screen, recipe-errors, left, right, 1/red, row } @@ -67,21 +67,21 @@ before <render-components-end> [ error-index:number <- get *env, error-index:offset sandboxes-completed-successfully?:boolean <- equal error-index, -1 break-if sandboxes-completed-successfully? - error-index-text:address:shared:array:character <- to-text error-index - status:address:shared:array:character <- interpolate [errors found (_) ], error-index-text + error-index-text:address:array:character <- to-text error-index + status:address:array:character <- interpolate [errors found (_) ], error-index-text update-status screen, status, 1/red } ] container sandbox-data [ - errors:address:shared:array:character + errors:address:array:character ] -def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [ local-scope load-ingredients - data:address:shared:array:character <- get *sandbox, data:offset - response:address:shared:array:character, errors:address:shared:array:character, fake-screen:address:shared:screen, trace:address:shared:array:character, completed?:boolean <- run-interactive data + data:address:array:character <- get *sandbox, data:offset + response:address:array:character, errors:address:array:character, fake-screen:address:screen, trace:address:array:character, completed?:boolean <- run-interactive data *sandbox <- put *sandbox, response:offset, response *sandbox <- put *sandbox, errors:offset, errors *sandbox <- put *sandbox, screen:offset, fake-screen @@ -105,7 +105,7 @@ def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:prog # make sure we render any trace after <render-sandbox-trace-done> [ { - sandbox-errors:address:shared:array:character <- get *sandbox, errors:offset + sandbox-errors:address:array:character <- get *sandbox, errors:offset break-unless sandbox-errors *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 # no response row, screen <- render screen, sandbox-errors, left, right, 1/red, row @@ -117,17 +117,17 @@ after <render-sandbox-trace-done> [ scenario run-shows-errors-in-get [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ get 123:number, foo:offset ]] - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -157,9 +157,9 @@ recipe foo [ scenario run-updates-status-with-first-erroneous-sandbox [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ left-click 3, 80 # create invalid sandbox 1 @@ -170,7 +170,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # status line shows that error is in first sandbox screen-should-contain [ @@ -181,9 +181,9 @@ scenario run-updates-status-with-first-erroneous-sandbox [ scenario run-updates-status-with-first-erroneous-sandbox-2 [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ left-click 3, 80 # create invalid sandbox 2 @@ -197,7 +197,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # status line shows that error is in second sandbox screen-should-contain [ @@ -208,14 +208,14 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ scenario run-hides-errors-from-past-sandboxes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [] - 2:address:shared:array:character <- new [get foo, x:offset] # invalid - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 1:address:array:character <- new [] + 2:address:array:character <- new [get foo, x:offset] # invalid + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 # generate error ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] assume-console [ left-click 3, 80 @@ -224,7 +224,7 @@ scenario run-hides-errors-from-past-sandboxes [ press F4 # update sandbox ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # error should disappear screen-should-contain [ @@ -243,18 +243,18 @@ scenario run-updates-errors-for-shape-shifting-recipes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # define a shape-shifting recipe with an error - 1:address:shared:array:character <- new [recipe foo x:_elem -> z:_elem [ + 1:address:array:character <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients y:address:number <- copy 0 z <- add x, y ]] - 2:address:shared:array:character <- new [foo 2] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo 2] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . errors found (0) run (F4) . .recipe foo x:_elem -> z:_elem [ ┊ . @@ -271,7 +271,7 @@ z <- add x, y press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # error should remain unchanged screen-should-contain [ @@ -291,24 +291,24 @@ scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # overload a well-known shape-shifting recipe - 1:address:shared:array:character <- new [recipe length l:address:shared:list:_elem -> n:number [ + 1:address:array:character <- new [recipe length l:address:list:_elem -> n:number [ ]] # call code that uses other variants of it, but not it itself - 2:address:shared:array:character <- new [x:address:shared:list:number <- copy 0 + 2:address:array:character <- new [x:address:list:number <- copy 0 to-text x] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run it once assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data # no errors anywhere on screen (can't check anything else, since to-text will return an address) screen-should-contain-in-color 1/red, [ . . . . . . . . - . <- . + . <- . . . . . . . @@ -325,7 +325,7 @@ to-text x] press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # still no errors screen-should-contain-in-color 1/red, [ @@ -333,7 +333,7 @@ to-text x] . . . . . . - . <- . + . <- . . . . . . . @@ -350,17 +350,17 @@ to-text x] scenario run-shows-missing-type-errors [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ x <- copy 0 ]] - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -376,18 +376,18 @@ scenario run-shows-unbalanced-bracket-errors [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe is incomplete (unbalanced '[') - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo « x <- copy 0 ] - replace 1:address:shared:array:character, 171/«, 91 # '[' - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + replace 1:address:array:character, 171/«, 91 # '[' + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -404,30 +404,30 @@ recipe foo « scenario run-shows-get-on-non-container-errors [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ local-scope - x:address:shared:point <- new point:type - get x:address:shared:point, 1:offset + x:address:point <- new point:type + get x:address:point, 1:offset ]] - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found run (F4) . . ┊foo . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . local-scope ┊ . - . x:address:shared:point <- new point:type ┊ . - . get x:address:shared:point, 1:offset ┊ . + . x:address:point <- new point:type ┊ . + . get x:address:point, 1:offset ┊ . .] ┊ . .foo: first ingredient of 'get' should be a contai↩┊ . - .ner, but got x:address:shared:point ┊ . + .ner, but got x:address:point ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . . ┊ . ] @@ -436,20 +436,20 @@ recipe foo [ scenario run-shows-non-literal-get-argument-errors [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ local-scope x:number <- copy 0 - y:address:shared:point <- new point:type - get *y:address:shared:point, x:number + y:address:point <- new point:type + get *y:address:point, x:number ]] - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -457,8 +457,8 @@ recipe foo [ .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . local-scope ┊ . . x:number <- copy 0 ┊ . - . y:address:shared:point <- new point:type ┊ . - . get *y:address:shared:point, x:number ┊ . + . y:address:point <- new point:type ┊ . + . get *y:address:point, x:number ┊ . .] ┊ . .foo: second ingredient of 'get' should have type ↩┊ . .'offset', but got x:number ┊ . @@ -471,17 +471,17 @@ scenario run-shows-errors-everytime [ trace-until 100/app # trace too long # try to run a file with an error assume-screen 100/width, 15/height - 1:address:shared:array:character <- new [ + 1:address:array:character <- new [ recipe foo [ local-scope x:number <- copy y:number ]] - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data screen-should-contain [ . errors found run (F4) . . ┊foo . @@ -498,7 +498,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -517,16 +517,16 @@ scenario run-instruction-and-print-errors [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # left editor is empty - 1:address:shared:array:character <- new [] + 1:address:array:character <- new [] # right editor contains an illegal instruction - 2:address:shared:array:character <- new [get 1234:number, foo:offset] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [get 1234:number, foo:offset] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # check that screen prints error message in red screen-should-contain [ @@ -580,17 +580,17 @@ scenario run-instruction-and-print-errors-only-once [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # left editor is empty - 1:address:shared:array:character <- new [] + 1:address:array:character <- new [] # right editor contains an illegal instruction - 2:address:shared:array:character <- new [get 1234:number, foo:offset] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [get 1234:number, foo:offset] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # check that screen prints error message just once screen-should-contain [ @@ -611,20 +611,20 @@ scenario sandbox-can-handle-infinite-loop [ trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:address:shared:array:character <- new [recipe foo [ + 1:address:array:character <- new [recipe foo [ { loop } ]] # right editor contains an instruction - 2:address:shared:array:character <- new [foo] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] screen-should-contain [ . errors found (0) run (F4) . @@ -642,7 +642,7 @@ scenario sandbox-with-errors-shows-trace [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # generate a stash and a error - 1:address:shared:array:character <- new [recipe foo [ + 1:address:array:character <- new [recipe foo [ local-scope a:number <- next-ingredient b:number <- next-ingredient @@ -650,13 +650,13 @@ stash [dividing by], b _, c:number <- divide-with-remainder a, b reply b ]] - 2:address:shared:array:character <- new [foo 4, 0] - 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + 2:address:array:character <- new [foo 4, 0] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character # run assume-console [ press F4 ] - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data # screen prints error message screen-should-contain [ . errors found (0) run (F4) . @@ -674,7 +674,7 @@ reply b left-click 4, 55 ] run [ - event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data ] # screen should expand trace screen-should-contain [ diff --git a/edit/011-editor-undo.mu b/edit/011-editor-undo.mu index 94135346..5c9876d0 100644 --- a/edit/011-editor-undo.mu +++ b/edit/011-editor-undo.mu @@ -11,13 +11,13 @@ exclusive-container operation [ container insert-operation [ before-row:number before-column:number - before-top-of-screen:address:shared:duplex-list:character + before-top-of-screen:address:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:shared:duplex-list:character + after-top-of-screen:address:duplex-list:character # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate - insert-from:address:shared:duplex-list:character - insert-until:address:shared:duplex-list:character + insert-from:address:duplex-list:character + insert-until:address:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (enter+indent) # 1: regular alphanumeric characters @@ -26,10 +26,10 @@ container insert-operation [ container move-operation [ before-row:number before-column:number - before-top-of-screen:address:shared:duplex-list:character + before-top-of-screen:address:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:shared:duplex-list:character + after-top-of-screen:address:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (touch events, etc) # 1: left arrow @@ -41,13 +41,13 @@ container move-operation [ container delete-operation [ before-row:number before-column:number - before-top-of-screen:address:shared:duplex-list:character + before-top-of-screen:address:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:shared:duplex-list:character - deleted-text:address:shared:duplex-list:character - delete-from:address:shared:duplex-list:character - delete-until:address:shared:duplex-list:character + after-top-of-screen:address:duplex-list:character + deleted-text:address:duplex-list:character + delete-from:address:duplex-list:character + delete-until:address:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (ctrl-k, ctrl-u) # 1: backspace @@ -56,8 +56,8 @@ container delete-operation [ # every editor accumulates a list of operations to undo/redo container editor-data [ - undo:address:shared:list:address:shared:operation - redo:address:shared:list:address:shared:operation + undo:address:list:address:operation + redo:address:list:address:operation ] # ctrl-z - undo operation @@ -65,12 +65,12 @@ after <handle-special-character> [ { undo?:boolean <- equal c, 26/ctrl-z break-unless undo? - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + undo:address:list:address:operation <- get *editor, undo:offset break-unless undo - op:address:shared:operation <- first undo + op:address:operation <- first undo undo <- rest undo *editor <- put *editor, undo:offset, undo - redo:address:shared:list:address:shared:operation <- get *editor, redo:offset + redo:address:list:address:operation <- get *editor, redo:offset redo <- push op, redo *editor <- put *editor, redo:offset, redo <handle-undo> @@ -83,12 +83,12 @@ after <handle-special-character> [ { redo?:boolean <- equal c, 25/ctrl-y break-unless redo? - redo:address:shared:list:address:shared:operation <- get *editor, redo:offset + redo:address:list:address:operation <- get *editor, redo:offset break-unless redo - op:address:shared:operation <- first redo + op:address:operation <- first redo redo <- rest redo *editor <- put *editor, redo:offset, redo - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + undo:address:list:address:operation <- get *editor, undo:offset undo <- push op, undo *editor <- put *editor, undo:offset, undo <handle-redo> @@ -101,19 +101,19 @@ after <handle-special-character> [ scenario editor-can-undo-typing [ # create an editor and type a character assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ type [0] ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # character should be gone screen-should-contain [ @@ -127,7 +127,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -139,24 +139,24 @@ scenario editor-can-undo-typing [ # save operation to undo after <insert-character-begin> [ - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:shared:duplex-list:character <- get *editor, before-cursor:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:duplex-list:character <- get *editor, before-cursor:offset ] before <insert-character-end> [ - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + undo:address:list:address:operation <- get *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless undo - op:address:shared:operation <- first undo + op:address:operation <- first undo typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant break-unless is-insert? previous-coalesce-tag:number <- get typing, tag:offset break-unless previous-coalesce-tag - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - insert-until:address:shared:duplex-list:character <- next before-cursor + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + insert-until:address:duplex-list:character <- next before-cursor typing <- put typing, insert-until:offset, insert-until typing <- put typing, after-row:offset, cursor-row typing <- put typing, after-column:offset, cursor-column @@ -165,9 +165,9 @@ before <insert-character-end> [ break +done-adding-insert-operation:label } # if not, create a new operation - insert-from:address:shared:duplex-list:character <- next cursor-before - insert-to:address:shared:duplex-list:character <- next insert-from - op:address:shared:operation <- new operation:type + insert-from:address:duplex-list:character <- next cursor-before + insert-to:address:duplex-list:character <- next insert-from + op:address:operation <- new operation:type *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 1/coalesce editor <- add-operation editor, op +done-adding-insert-operation @@ -177,18 +177,18 @@ before <insert-character-end> [ after <insert-enter-begin> [ cursor-row-before:number <- copy cursor-row cursor-column-before:number <- copy cursor-column - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:shared:duplex-list:character <- get *editor, before-cursor:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:duplex-list:character <- get *editor, before-cursor:offset ] before <insert-enter-end> [ - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-row:offset # never coalesce - insert-from:address:shared:duplex-list:character <- next cursor-before - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - insert-to:address:shared:duplex-list:character <- next before-cursor - op:address:shared:operation <- new operation:type + insert-from:address:duplex-list:character <- next cursor-before + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + insert-to:address:duplex-list:character <- next before-cursor + op:address:operation <- new operation:type *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce editor <- add-operation editor, op ] @@ -197,13 +197,13 @@ 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:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ +def add-operation editor:address:editor-data, op:address:operation -> editor:address:editor-data [ local-scope load-ingredients - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + undo:address:list:address:operation <- get *editor, undo:offset undo <- push op undo *editor <- put *editor, undo:offset, undo - redo:address:shared:list:address:shared:operation <- get *editor, redo:offset + redo:address:list:address:operation <- get *editor, redo:offset redo <- copy 0 *editor <- put *editor, redo:offset, redo return editor/same-as-ingredient:0 @@ -213,17 +213,17 @@ after <handle-undo> [ { typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant break-unless is-insert? - start:address:shared:duplex-list:character <- get typing, insert-from:offset - end:address:shared:duplex-list:character <- get typing, insert-until:offset + start:address:duplex-list:character <- get typing, insert-from:offset + end:address:duplex-list:character <- get typing, insert-until:offset # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - before-cursor:address:shared:duplex-list:character <- prev start + before-cursor:address:duplex-list:character <- prev start *editor <- put *editor, before-cursor:offset, before-cursor remove-between before-cursor, end cursor-row <- get typing, before-row:offset *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get typing, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get typing, before-top-of-screen:offset + top:address:duplex-list:character <- get typing, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -231,19 +231,19 @@ after <handle-undo> [ scenario editor-can-undo-typing-multiple [ # create an editor and type multiple characters assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ type [012] ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # all characters must be gone screen-should-contain [ @@ -257,14 +257,14 @@ scenario editor-can-undo-typing-multiple [ scenario editor-can-undo-typing-multiple-2 [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [a] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [a] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # type some characters assume-console [ type [012] ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .012a . @@ -276,7 +276,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -303,15 +303,15 @@ scenario editor-can-undo-typing-multiple-2 [ scenario editor-can-undo-typing-enter [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [ abc] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [ abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . . abc . @@ -320,8 +320,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -366,14 +366,14 @@ scenario editor-can-undo-typing-enter [ scenario editor-redo-typing [ # create an editor, type something, undo assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [a] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [a] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .a . @@ -385,7 +385,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # all characters must be back screen-should-contain [ @@ -399,7 +399,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -414,7 +414,7 @@ after <handle-redo> [ typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant break-unless is-insert? before-cursor <- get *editor, before-cursor:offset - insert-from:address:shared:duplex-list:character <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away + insert-from:address:duplex-list:character <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away # assert insert-to matches next(before-cursor) insert-range before-cursor, insert-from # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen @@ -422,7 +422,7 @@ after <handle-redo> [ *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get typing, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get typing, after-top-of-screen:offset + top:address:duplex-list:character <- get typing, after-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -430,14 +430,14 @@ after <handle-redo> [ scenario editor-redo-typing-empty [ # create an editor, type something, undo assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . . . @@ -449,7 +449,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # all characters must be back screen-should-contain [ @@ -463,7 +463,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -476,21 +476,21 @@ scenario editor-redo-typing-empty [ scenario editor-work-clears-redo-stack [ # create an editor with some text, do some work, undo assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # do some more work assume-console [ type [0] ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .0abc . @@ -503,7 +503,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # nothing should happen screen-should-contain [ @@ -518,9 +518,9 @@ ghi] scenario editor-can-redo-typing-and-enter-and-tab [ # create an editor assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . . ab cd . @@ -539,8 +539,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # typing in second line deleted, but not indent - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # indent and newline deleted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # empty screen - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # first line inserted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # newline and indent inserted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # indent and newline deleted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -675,24 +675,24 @@ scenario editor-can-redo-typing-and-enter-and-tab [ scenario editor-can-undo-touch [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # click undone memory-should-contain [ @@ -704,7 +704,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -718,19 +718,19 @@ ghi] after <move-cursor-begin> [ cursor-row-before:number <- get *editor, cursor-row:offset cursor-column-before:number <- get *editor, cursor-column:offset - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset ] before <move-cursor-end> [ - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset { break-unless undo-coalesce-tag # if previous operation was also a move, and also had the same coalesce # tag, coalesce with it - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + undo:address:list:address:operation <- get *editor, undo:offset break-unless undo - op:address:shared:operation <- first undo + op:address:operation <- first undo move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant break-unless is-move? previous-coalesce-tag:number <- get move, tag:offset @@ -742,7 +742,7 @@ before <move-cursor-end> [ *op <- merge 1/move-operation, move break +done-adding-move-operation:label } - op:address:shared:operation <- new operation:type + op:address:operation <- new operation:type *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag editor <- add-operation editor, op +done-adding-move-operation @@ -757,7 +757,7 @@ after <handle-undo> [ *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get move, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get move, before-top-of-screen:offset + top:address:duplex-list:character <- get move, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -766,18 +766,18 @@ scenario editor-can-undo-scroll [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b cdefgh] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right # position cursor at end of screen and try to move right assume-console [ left-click 3, 3 press right-arrow ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset # screen scrolls screen-should-contain [ . . @@ -794,9 +794,9 @@ cdefgh] press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moved back memory-should-contain [ @@ -815,7 +815,7 @@ cdefgh] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -828,25 +828,25 @@ cdefgh] scenario editor-can-undo-left-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -858,7 +858,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -872,19 +872,19 @@ ghi] scenario editor-can-undo-up-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -894,9 +894,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -908,7 +908,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -922,25 +922,25 @@ ghi] scenario editor-can-undo-down-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -952,7 +952,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -966,27 +966,27 @@ ghi] scenario editor-can-undo-ctrl-f [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e f] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # scroll the page assume-console [ press ctrl-f ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen should again show page 1 screen-should-contain [ @@ -1001,27 +1001,27 @@ f] scenario editor-can-undo-page-down [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e f] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # scroll the page assume-console [ press page-down ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen should again show page 1 screen-should-contain [ @@ -1036,28 +1036,28 @@ f] scenario editor-can-undo-ctrl-b [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e f] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # scroll the page down and up assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen should again show page 2 screen-should-contain [ @@ -1072,28 +1072,28 @@ f] scenario editor-can-undo-page-up [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [a + 1:address:array:character <- new [a b c d e f] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # scroll the page down and up assume-console [ press page-down press page-up ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen should again show page 2 screen-should-contain [ @@ -1108,25 +1108,25 @@ f] scenario editor-can-undo-ctrl-a [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1138,7 +1138,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1152,25 +1152,25 @@ ghi] scenario editor-can-undo-home [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1182,7 +1182,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1196,25 +1196,25 @@ ghi] scenario editor-can-undo-ctrl-e [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1226,7 +1226,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1240,25 +1240,25 @@ ghi] scenario editor-can-undo-end [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1270,7 +1270,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1284,11 +1284,11 @@ ghi] scenario editor-can-undo-multiple-arrows-in-the-same-direction [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # move the cursor assume-console [ left-click 2, 1 @@ -1296,9 +1296,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1308,9 +1308,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # up-arrow is undone memory-should-contain [ @@ -1322,9 +1322,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # both right-arrows are undone memory-should-contain [ @@ -1338,24 +1338,24 @@ ghi] scenario editor-redo-touch [ # create an editor with some text, click on a character, undo assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def ghi] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves to left-click memory-should-contain [ @@ -1367,7 +1367,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1387,7 +1387,7 @@ after <handle-redo> [ *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get move, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get move, after-top-of-screen:offset + top:address:duplex-list:character <- get move, after-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1395,17 +1395,17 @@ after <handle-redo> [ 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:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1421,9 +1421,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1441,9 +1441,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1461,9 +1461,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1481,9 +1481,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # first insert screen-should-contain [ @@ -1501,9 +1501,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1522,9 +1522,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset ] # second insert screen-should-contain [ @@ -1544,24 +1544,24 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ scenario editor-can-undo-and-redo-backspace [ # create an editor assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1571,10 +1571,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1590,10 +1590,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1608,27 +1608,27 @@ scenario editor-can-undo-and-redo-backspace [ # save operation to undo after <backspace-character-begin> [ - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset ] before <backspace-character-end> [ { break-unless backspaced-cell # backspace failed; don't add an undo operation - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-row:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + undo:address:list:address:operation <- get *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:shared:operation <- first undo + op:address:operation <- first undo deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant break-unless is-delete? previous-coalesce-tag:number <- get deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace break-unless coalesce? deletion <- put deletion, delete-from:offset, before-cursor - backspaced-so-far:address:shared:duplex-list:character <- get deletion, deleted-text:offset + backspaced-so-far:address:duplex-list:character <- get deletion, deleted-text:offset insert-range backspaced-cell, backspaced-so-far deletion <- put deletion, deleted-text:offset, backspaced-cell deletion <- put deletion, after-row:offset, cursor-row @@ -1638,8 +1638,8 @@ before <backspace-character-end> [ break +done-adding-backspace-operation:label } # if not, create a new operation - op:address:shared:operation <- new operation:type - deleted-until:address:shared:duplex-list:character <- next before-cursor + op:address:operation <- new operation:type + deleted-until:address:duplex-list:character <- next before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, 1/coalesce-backspace editor <- add-operation editor, op +done-adding-backspace-operation @@ -1650,10 +1650,10 @@ after <handle-undo> [ { deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant break-unless is-delete? - anchor:address:shared:duplex-list:character <- get deletion, delete-from:offset + anchor:address:duplex-list:character <- get deletion, delete-from:offset break-unless anchor - deleted:address:shared:duplex-list:character <- get deletion, deleted-text:offset - old-cursor:address:shared:duplex-list:character <- last deleted + deleted:address:duplex-list:character <- get deletion, deleted-text:offset + old-cursor:address:duplex-list:character <- last deleted insert-range anchor, deleted # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen before-cursor <- copy old-cursor @@ -1661,7 +1661,7 @@ after <handle-undo> [ *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get deletion, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get deletion, before-top-of-screen:offset + top:address:duplex-list:character <- get deletion, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1670,16 +1670,16 @@ after <handle-redo> [ { deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant break-unless is-delete? - start:address:shared:duplex-list:character <- get deletion, delete-from:offset - end:address:shared:duplex-list:character <- get deletion, delete-until:offset - data:address:shared:duplex-list:character <- get *editor, data:offset + start:address:duplex-list:character <- get deletion, delete-from:offset + end:address:duplex-list:character <- get deletion, delete-until:offset + data:address:duplex-list:character <- get *editor, data:offset remove-between start, end # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen cursor-row <- get deletion, after-row:offset *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get deletion, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:shared:duplex-list:character <- get deletion, before-top-of-screen:offset + top:address:duplex-list:character <- get deletion, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1689,9 +1689,9 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-delete [ # create an editor assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1701,15 +1701,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1719,10 +1719,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1738,10 +1738,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1757,10 +1757,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1776,11 +1776,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # first line inserted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1796,11 +1796,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # first line inserted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1816,11 +1816,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # first line inserted - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1834,28 +1834,28 @@ scenario editor-can-undo-and-redo-delete [ ] after <delete-character-begin> [ - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-character-end> [ { break-unless deleted-cell # delete failed; don't add an undo operation - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - undo:address:shared:list:address:shared:operation <- get *editor, undo:offset + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + undo:address:list:address:operation <- get *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless undo - op:address:shared:operation <- first undo + op:address:operation <- first undo deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant break-unless is-delete? previous-coalesce-tag:number <- get deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete break-unless coalesce? - delete-until:address:shared:duplex-list:character <- next before-cursor + delete-until:address:duplex-list:character <- next before-cursor deletion <- put deletion, delete-until:offset, delete-until - deleted-so-far:address:shared:duplex-list:character <- get deletion, deleted-text:offset + deleted-so-far:address:duplex-list:character <- get deletion, deleted-text:offset deleted-so-far <- append deleted-so-far, deleted-cell deletion <- put deletion, deleted-text:offset, deleted-so-far deletion <- put deletion, after-row:offset, cursor-row @@ -1865,8 +1865,8 @@ before <delete-character-end> [ break +done-adding-delete-operation:label } # if not, create a new operation - op:address:shared:operation <- new operation:type - deleted-until:address:shared:duplex-list:character <- next before-cursor + op:address:operation <- new operation:type + deleted-until:address:duplex-list:character <- next before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, 2/coalesce-delete editor <- add-operation editor, op +done-adding-delete-operation @@ -1878,16 +1878,16 @@ before <delete-character-end> [ scenario editor-can-undo-and-redo-ctrl-k [ # create an editor assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 1 press ctrl-k ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .a . @@ -1895,8 +1895,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1906,7 +1906,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1915,8 +1915,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1926,7 +1926,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # first line inserted screen-should-contain [ @@ -1936,8 +1936,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1947,7 +1947,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -1959,16 +1959,16 @@ def] ] after <delete-to-end-of-line-begin> [ - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-to-end-of-line-end> [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset - deleted-until:address:shared:duplex-list:character <- next before-cursor - op:address:shared:operation <- new operation:type + deleted-until:address:duplex-list:character <- next before-cursor + op:address:operation <- new operation:type *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -1980,16 +1980,16 @@ before <delete-to-end-of-line-end> [ scenario editor-can-undo-and-redo-ctrl-u [ # create an editor assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [abc + 1:address:array:character <- new [abc def] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 2 press ctrl-u ] - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .c . @@ -1997,8 +1997,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2008,7 +2008,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2017,8 +2017,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -2028,7 +2028,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] # first line inserted screen-should-contain [ @@ -2038,8 +2038,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:shared:editor-data, cursor-row:offset - 4:number <- get *2:address:shared:editor-data, cursor-column:offset + 3:number <- get *2:address:editor-data, cursor-row:offset + 4:number <- get *2:address:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2049,7 +2049,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data ] screen-should-contain [ . . @@ -2061,15 +2061,15 @@ def] ] after <delete-to-start-of-line-begin> [ - top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-to-start-of-line-end> [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset - op:address:shared:operation <- new operation:type - before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset - deleted-until:address:shared:duplex-list:character <- next before-cursor + top-after:address:duplex-list:character <- get *editor, top-of-screen:offset + op:address:operation <- new operation:type + before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + deleted-until:address:duplex-list:character <- next before-cursor cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce @@ -2081,16 +2081,16 @@ before <delete-to-start-of-line-end> [ scenario editor-can-undo-and-redo-ctrl-u-2 [ # create an editor assume-screen 10/width, 5/height - 1:address:shared:array:character <- new [] - 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right - editor-render screen, 2:address:shared:editor-data + 1:address:array:character <- new [] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + editor-render screen, 2:address:editor-data # 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:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data screen-should-contain [ . . .abc . |