diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-01-19 23:18:03 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-01-19 23:18:03 -0800 |
commit | 455fbac64f101b05f7eaca89b84470569e4df3fd (patch) | |
tree | 32cfd5b092ad86086e4d15992bb10fd06a12bf13 /edit | |
parent | 7163e18a774781c62f0c0542e4cb9037f6a71d22 (diff) | |
download | mu-455fbac64f101b05f7eaca89b84470569e4df3fd.tar.gz |
2576 - distinguish allocated addresses from others
This is the one major refinement on the C programming model I'm planning to introduce in mu. Instead of Rust's menagerie of pointer types and static checking, I want to introduce just one new type, and use it to perform ref-counting at runtime. So far all we're doing is updating new's interface. The actual ref-counting implementation is next. One implication: I might sometimes need duplicate implementations for a recipe with allocated vs vanilla addresses of the same type. So far it seems I can get away with just always passing in allocated addresses; the situations when you want to pass an unallocated address to a recipe should be few and far between.
Diffstat (limited to 'edit')
-rw-r--r-- | edit/001-editor.mu | 82 | ||||
-rw-r--r-- | edit/002-typing.mu | 272 | ||||
-rw-r--r-- | edit/003-shortcuts.mu | 810 | ||||
-rw-r--r-- | edit/004-programming-environment.mu | 128 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 152 | ||||
-rw-r--r-- | edit/006-sandbox-edit.mu | 40 | ||||
-rw-r--r-- | edit/007-sandbox-delete.mu | 20 | ||||
-rw-r--r-- | edit/008-sandbox-test.mu | 32 | ||||
-rw-r--r-- | edit/009-sandbox-trace.mu | 48 | ||||
-rw-r--r-- | edit/010-warnings.mu | 172 | ||||
-rw-r--r-- | edit/011-editor-undo.mu | 758 |
11 files changed, 1257 insertions, 1257 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu index fd44d493..773b7d77 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 -recipe! main text:address:array:character [ +recipe! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -16,8 +16,8 @@ recipe! main text:address:array:character [ scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ - 1:address:array:character <- new [abc] - new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + new-editor 1:address:shared:array:character, screen:address:shared: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:duplex-list:character - top-of-screen:address:duplex-list:character - bottom-of-screen:address:duplex-list:character + data:address:shared:duplex-list:character + top-of-screen:address:shared:duplex-list:character + bottom-of-screen:address:shared:duplex-list:character # location before cursor inside data - before-cursor:address:duplex-list:character + before-cursor:address:shared: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 @@ -47,7 +47,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 -recipe new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data, screen:address:screen [ +recipe new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ local-scope load-ingredients # no clipping of bounds @@ -63,11 +63,11 @@ recipe new-editor s:address:array:character, screen:address:screen, left:number, *x <- copy 1/top x <- get-address *result, cursor-column:offset *x <- copy left - init:address:address:duplex-list:character <- get-address *result, data:offset + init:address:address:shared:duplex-list:character <- get-address *result, data:offset *init <- push 167/§, 0/tail - top-of-screen:address:address:duplex-list:character <- get-address *result, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *result, top-of-screen:offset *top-of-screen <- copy *init - y:address:address:duplex-list:character <- get-address *result, before-cursor:offset + y:address:address:shared:duplex-list:character <- get-address *result, before-cursor:offset *y <- copy *init result <- insert-text result, s # initialize cursor to top of screen @@ -78,7 +78,7 @@ recipe new-editor s:address:array:character, screen:address:screen, left:number, <editor-initialization> ] -recipe insert-text editor:address:editor-data, text:address:array:character -> editor:address:editor-data [ +recipe insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ local-scope load-ingredients # early exit if text is empty @@ -87,7 +87,7 @@ recipe insert-text editor:address:editor-data, text:address:array:character -> e reply-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character - curr:address:duplex-list:character <- get *editor, data:offset + curr:address:shared:duplex-list:character <- get *editor, data:offset { done?:boolean <- greater-or-equal idx, len break-if done? @@ -104,8 +104,8 @@ recipe insert-text editor:address:editor-data, text:address:array:character -> e scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ - 1:address:editor-data <- new-editor 0/data, screen:address:screen, 2/left, 5/right - 2:editor-data <- copy *1:address:editor-data + 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 ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -127,7 +127,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. -recipe render screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +recipe 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 [ local-scope load-ingredients reply-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 @@ -135,8 +135,8 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb screen-height:number <- screen-height screen right:number <- get *editor, right:offset # traversing editor - 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: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 <- next curr # traversing screen +render-loop-initialization @@ -145,7 +145,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb column:number <- copy left cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset screen <- move-cursor screen, row, column { +next-character @@ -208,7 +208,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb loop } # save first character off-screen - bottom-of-screen:address:address:duplex-list:character <- get-address *editor, bottom-of-screen:offset + bottom-of-screen:address:address:shared:duplex-list:character <- get-address *editor, bottom-of-screen:offset *bottom-of-screen <- copy curr # is cursor to the right of the last line? move to end { @@ -225,7 +225,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited screen:address:screen, column:number, right:number -> screen:address:screen [ +recipe clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients space:character <- copy 32/space @@ -238,7 +238,7 @@ recipe clear-line-delimited screen:address:screen, column:number, right:number - } ] -recipe clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number -> screen:address:screen [ +recipe clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive @@ -254,7 +254,7 @@ recipe clear-screen-from screen:address:screen, row:number, column:number, left: reply screen/same-as-ingredient:0 ] -recipe clear-rest-of-screen screen:address:screen, row:number, left:number, right:number -> screen:address:screen [ +recipe clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients row <- add row, 1 @@ -273,9 +273,9 @@ recipe clear-rest-of-screen screen:address:screen, row:number, left:number, righ scenario editor-initially-prints-multiple-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -288,8 +288,8 @@ def] scenario editor-initially-handles-offsets [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc] - new-editor s:address:array:character, screen:address:screen, 1/left, 5/right + s:address:shared:array:character <- new [abc] + new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -301,9 +301,9 @@ scenario editor-initially-handles-offsets [ scenario editor-initially-prints-multiple-lines-at-offset [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 1/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -316,8 +316,8 @@ def] scenario editor-initially-wraps-long-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + s:address:shared:array:character <- new [abc def] + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -336,8 +336,8 @@ scenario editor-initially-wraps-long-lines [ scenario editor-initially-wraps-barely-long-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abcde] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + s:address:shared:array:character <- new [abcde] + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -358,10 +358,10 @@ scenario editor-initially-wraps-barely-long-lines [ scenario editor-initializes-empty-text [ assume-screen 5/width, 5/height run [ - 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 + 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 ] screen-should-contain [ . . @@ -379,10 +379,10 @@ scenario editor-initializes-empty-text [ scenario render-colors-comments [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc # de f] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -460,10 +460,10 @@ recipe get-color color:number, c:character -> color:number [ scenario render-colors-assignment [ assume-screen 8/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc d <- e f] - new-editor s:address:array:character, screen:address:screen, 0/left, 8/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/edit/002-typing.mu b/edit/002-typing.mu index 037c222b..f3f6b321 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -2,16 +2,16 @@ # temporary main: interactive editor # hit ctrl-c to exit -recipe! main text:address:array:character [ +recipe! main text:address:shared:array:character [ local-scope load-ingredients open-console - editor:address:editor-data <- new-editor text, 0/screen, 5/left, 45/right + editor:address:shared:editor-data <- new-editor text, 0/screen, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] -recipe editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data -> screen:address:screen, console:address:console, editor:address:editor-data [ +recipe 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 [ local-scope load-ingredients { @@ -20,7 +20,7 @@ recipe editor-event-loop screen:address:screen, console:address:console, editor: 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:console, found?:boolean, quit?:boolean <- read-event console + e:event, console:address:shared: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 @@ recipe editor-event-loop screen:address:screen, console:address:console, editor: ] # process click, return if it was on current editor -recipe move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event -> in-focus?:boolean, editor:address:editor-data [ +recipe move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor, 0/false @@ -70,7 +70,7 @@ recipe move-cursor-in-editor screen:address:screen, editor:address:editor-data, # 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. -recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number -> editor:address:editor-data [ +recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor @@ -78,8 +78,8 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row right:number <- get *editor, right:offset screen-height:number <- screen-height screen # count newlines until screen row - 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: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 <- next curr row:number <- copy 1/top column:number <- copy left @@ -87,7 +87,7 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row *cursor-row <- copy target-row cursor-column:address:number <- get-address *editor, cursor-column:offset *cursor-column <- copy target-column - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset { +next-character break-unless curr @@ -155,7 +155,7 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row # 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. -recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event -> screen:address:screen, editor:address:editor-data, go-render?:boolean [ +recipe 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 [ local-scope load-ingredients go-render? <- copy 0/false @@ -164,7 +164,7 @@ recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, screen-height:number <- screen-height screen left:number <- get *editor, left:offset right:number <- get *editor, right:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset save-row:number <- copy *cursor-row @@ -195,10 +195,10 @@ recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, reply ] -recipe insert-at-cursor editor:address:editor-data, c:character, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +recipe 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 [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset insert c, *before-cursor *before-cursor <- next *before-cursor cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -213,7 +213,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: <insert-character-special-case> # but mostly we'll just move the cursor right *cursor-column <- add *cursor-column, 1 - next:address:duplex-list:character <- next *before-cursor + next:address:shared: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 @@ -233,7 +233,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: break-unless next at-right?:boolean <- greater-or-equal *cursor-column, screen-width break-if at-right? - curr:address:duplex-list:character <- copy *before-cursor + curr:address:shared:duplex-list:character <- copy *before-cursor move-cursor screen, save-row, save-column curr-column:number <- copy save-column { @@ -259,7 +259,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: ] # helper for tests -recipe editor-render screen:address:screen, editor:address:editor-data -> screen:address:screen, editor:address:editor-data [ +recipe editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients left:number <- get *editor, left:offset @@ -274,12 +274,12 @@ recipe editor-render screen:address:screen, editor:address:editor-data -> screen scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height - 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 + 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 assume-console [] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -291,17 +291,17 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -318,16 +318,16 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 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 $clear-trace assume-console [ left-click 1, 7 # last line, to the right of text ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 1 # cursor row @@ -338,17 +338,17 @@ scenario editor-handles-mouse-clicks-outside-text [ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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: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 + 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 ] memory-should-contain [ 3 <- 1 # cursor row @@ -359,17 +359,17 @@ def] scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 2 # cursor row @@ -380,19 +380,19 @@ def] scenario editor-handles-mouse-clicks-outside-column [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] + 1:address:shared:array:character <- new [abc] # editor occupies only left half of screen - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -409,18 +409,18 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - 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 + 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 ] # no change to cursor memory-should-contain [ @@ -431,15 +431,15 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -452,9 +452,9 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace # type two letters at different places assume-console [ @@ -463,7 +463,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -476,16 +476,16 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -498,17 +498,17 @@ scenario editor-inserts-characters-at-cursor-2 [ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -522,16 +522,16 @@ d] scenario editor-inserts-characters-at-cursor-3 [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -544,17 +544,17 @@ scenario editor-inserts-characters-at-cursor-3 [ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -568,17 +568,17 @@ d] scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -592,14 +592,14 @@ d] scenario editor-moves-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 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 + 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 assume-console [ type [01] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -613,15 +613,15 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ assume-screen 5/width, 5/height - 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 + 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 # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # no wrap yet screen-should-contain [ @@ -636,7 +636,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # now wrap screen-should-contain [ @@ -651,19 +651,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:array:character <- new [abcdefg + 1:address:shared:array:character <- new [abcdefg defg] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 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 # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - 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 + 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 ] # cursor is not wrapped memory-should-contain [ @@ -703,16 +703,16 @@ after <insert-character-special-case> [ scenario editor-wraps-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 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 assume-console [ left-click 1, 4 # line is full; no wrap icon yet type [f] ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -729,16 +729,16 @@ scenario editor-wraps-cursor-after-inserting-characters [ scenario editor-wraps-cursor-after-inserting-characters-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 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 assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -755,16 +755,16 @@ scenario editor-wraps-cursor-after-inserting-characters-2 [ scenario editor-wraps-cursor-to-left-margin [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 2/left, 7/right + 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 assume-console [ left-click 1, 5 # line is full; no wrap icon yet type [01] ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -792,14 +792,14 @@ after <editor-initialization> [ scenario editor-moves-cursor-down-after-inserting-newline [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 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 assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -822,12 +822,12 @@ after <handle-special-character> [ } ] -recipe insert-new-line-and-indent editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +recipe 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 [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset screen-height:number <- screen-height screen @@ -847,8 +847,8 @@ recipe insert-new-line-and-indent editor:address:editor-data, screen:address:scr # indent if necessary indent?:boolean <- get *editor, indent?:offset reply-unless indent? - d:address:duplex-list:character <- get *editor, data:offset - end-of-previous-line:address:duplex-list:character <- prev *before-cursor + d:address:shared:duplex-list:character <- get *editor, data:offset + end-of-previous-line:address:shared:duplex-list:character <- prev *before-cursor indent:number <- line-indent end-of-previous-line, d i:number <- copy 0 { @@ -862,7 +862,7 @@ recipe insert-new-line-and-indent editor:address:editor-data, screen:address:scr # 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'. -recipe line-indent curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +recipe line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -894,14 +894,14 @@ recipe line-indent curr:address:duplex-list:character, start:address:duplex-list scenario editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right + 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 assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -914,8 +914,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:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 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 assume-console [ press enter ] @@ -927,7 +927,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # line should be fully cleared screen-should-contain [ @@ -941,10 +941,10 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ scenario editor-inserts-indent-after-newline [ assume-screen 10/width, 10/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -952,9 +952,9 @@ ef] ] ] run [ - 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 + 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 ] # cursor should be below start of previous line memory-should-contain [ @@ -965,10 +965,10 @@ ef] scenario editor-skips-indent-around-paste [ assume-screen 10/width, 10/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -977,9 +977,9 @@ ef] press 65506 # end paste ] run [ - 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 + 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 ] # cursor should be below start of previous line memory-should-contain [ @@ -1012,7 +1012,7 @@ after <handle-special-key> [ ## helpers -recipe draw-horizontal screen:address:screen, row:number, x:number, right:number -> screen:address:screen [ +recipe draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared: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 feab04ea..b69bf2bd 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:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared: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: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 + 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 $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - 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 + 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 ] 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:duplex-list:character <- delete-before-cursor editor, screen + editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen <backspace-character-end> reply } @@ -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. -recipe 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 [ +recipe 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 [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + data:address:shared:duplex-list:character <- get *editor, data:offset # if at start of text (before-cursor at § sentinel), return - prev:address:duplex-list:character <- prev *before-cursor + prev:address:shared:duplex-list:character <- prev *before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted reply-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:duplex-list:character <- copy *before-cursor + backspaced-cell:address:shared: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 go-render? <- copy 1/true @@ -106,7 +106,7 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> reply-unless same-row? left:number <- get *editor, left:offset right:number <- get *editor, right:offset - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor screen <- move-cursor screen, cursor-row, cursor-column curr-column:number <- copy cursor-column { @@ -130,10 +130,10 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> go-render? <- copy 0/false ] -recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -165,7 +165,7 @@ recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address break-unless previous-character-is-newline? # compute length of previous line trace 10, [app], [switching to previous line] - d:address:duplex-list:character <- get *editor, data:offset + d:address:shared:duplex-list:character <- get *editor, data:offset end-of-line:number <- previous-line-length before-cursor, d *cursor-column <- add left, end-of-line reply @@ -178,7 +178,7 @@ recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -recipe previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +recipe previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -201,17 +201,17 @@ recipe previous-line-length curr:address:duplex-list:character, start:address:du scenario editor-clears-last-line-on-backspace [ assume-screen 10/width, 5/height # just one character in final line - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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: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 + 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 ] screen-should-contain [ . . @@ -228,10 +228,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:array:character <- new [abc def + 1:address:shared:array:character <- new [abc def ghi jkl] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -239,7 +239,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # resulting single line should wrap correctly screen-should-contain [ @@ -254,9 +254,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: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 + 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 # confirm that it wraps screen-should-contain [ . . @@ -271,7 +271,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -287,15 +287,15 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -309,7 +309,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -325,18 +325,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:duplex-list:character <- delete-at-cursor editor, screen + editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen <delete-character-end> reply } ] -recipe 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 [ +recipe 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 [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset - deleted-cell:address:duplex-list:character <- next *before-cursor + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + data:address:shared:duplex-list:character <- get *editor, data:offset + deleted-cell:address:shared:duplex-list:character <- next *before-cursor go-render? <- copy 0/false reply-unless deleted-cell currc:character <- get *deleted-cell, value:offset @@ -345,7 +345,7 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi go-render? <- copy 1/true reply-if deleted-newline? # wasn't a newline? render rest of line - curr:address:duplex-list:character <- next *before-cursor # refresh after remove above + curr:address:shared:duplex-list:character <- next *before-cursor # refresh after remove above cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset screen <- move-cursor screen, *cursor-row, *cursor-column @@ -376,16 +376,16 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi scenario editor-moves-cursor-right-with-key [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -401,7 +401,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:duplex-list:character <- next *before-cursor + next-cursor:address:shared:duplex-list:character <- next *before-cursor break-unless next-cursor # scan to next character <move-cursor-begin> @@ -414,10 +414,10 @@ after <handle-special-key> [ } ] -recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor before-cursor:offset + before-cursor:address:shared:duplex-list:character <- get *editor before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -444,7 +444,7 @@ recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:n at-wrap?:boolean <- equal *cursor-column, wrap-column break-unless at-wrap? # and if next character isn't newline - next:address:duplex-list:character <- next before-cursor + next:address:shared:duplex-list:character <- next before-cursor break-unless next next-character:character <- get *next, value:offset newline?:boolean <- equal next-character, 10/newline @@ -465,10 +465,10 @@ recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:n scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -478,7 +478,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -486,7 +486,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -500,10 +500,10 @@ d] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right - editor-render screen, 2:address:editor-data + 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 assume-console [ press right-arrow press right-arrow @@ -512,7 +512,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -525,18 +525,18 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -555,9 +555,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: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 + 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 $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -565,9 +565,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 2 @@ -578,9 +578,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 2 @@ -591,18 +591,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: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 + 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 $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - 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 + 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 ] screen-should-contain [ . . @@ -620,10 +620,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -632,7 +632,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # new character should be in next line screen-should-contain [ @@ -651,9 +651,9 @@ d] scenario editor-moves-cursor-left-with-key [ assume-screen 10/width, 5/height - 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 + 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 $clear-trace assume-console [ left-click 1, 2 @@ -661,7 +661,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -678,7 +678,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:duplex-list:character <- prev *before-cursor + prev:address:shared:duplex-list:character <- prev *before-cursor go-render? <- copy 0/false reply-unless prev <move-cursor-begin> @@ -693,10 +693,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -704,9 +704,9 @@ d] press left-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 1 @@ -718,11 +718,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -732,7 +732,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -746,11 +746,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -759,7 +759,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # left-arrow should have had no effect screen-should-contain [ @@ -775,11 +775,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # position cursor right after empty line assume-console [ @@ -788,7 +788,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -803,9 +803,9 @@ d] scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 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 + 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 $clear-trace screen-should-contain [ . . @@ -820,9 +820,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 1 # previous row @@ -837,19 +837,19 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 1 @@ -860,7 +860,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -883,12 +883,12 @@ after <handle-special-key> [ } ] -recipe move-to-previous-line editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +recipe move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *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 @@ -898,13 +898,13 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor # 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:duplex-list:character <- copy *before-cursor + curr:address:shared:duplex-list:character <- copy *before-cursor { - old:address:duplex-list:character <- copy curr + old:address:shared:duplex-list:character <- copy curr c2:character <- get *curr, value:offset at-newline?:boolean <- equal c2, 10/newline break-if at-newline? - curr:address:duplex-list:character <- before-previous-line curr, editor + curr:address:shared:duplex-list:character <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false reply-if no-motion? @@ -924,7 +924,7 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor { done?:boolean <- greater-or-equal *cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -948,19 +948,19 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 1 @@ -971,7 +971,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -984,19 +984,19 @@ def] scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 1 @@ -1007,7 +1007,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1021,11 +1021,11 @@ def] scenario editor-moves-to-previous-line-from-left-margin [ assume-screen 10/width, 5/height # start out with three lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1033,9 +1033,9 @@ ghi] press up-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 2 @@ -1046,7 +1046,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1061,19 +1061,19 @@ ghi] scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - 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 + 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 ] # ..and ends at (2, 0) memory-should-contain [ @@ -1085,7 +1085,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1108,12 +1108,12 @@ after <handle-special-key> [ } ] -recipe move-to-next-line editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +recipe move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset last-line:number <- subtract screen-height, 1 @@ -1123,7 +1123,7 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi 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:duplex-list:character <- before-start-of-next-line *before-cursor, max + next-line:address:shared: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) @@ -1141,7 +1141,7 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi { done?:boolean <- greater-or-equal *cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -1161,19 +1161,19 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - 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 + 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 ] memory-should-contain [ 3 <- 2 @@ -1184,7 +1184,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1199,10 +1199,10 @@ de] scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1210,9 +1210,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - 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 + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1248,7 +1248,7 @@ after <handle-special-key> [ } ] -recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor-data [ +recipe move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # update cursor column @@ -1256,8 +1256,8 @@ recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor cursor-column:address:number <- get-address *editor, cursor-column:offset *cursor-column <- copy left # update before-cursor - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - init:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + init:address:shared:duplex-list:character <- get *editor, data:offset # while not at start of line, move { at-start-of-text?:boolean <- equal *before-cursor, init @@ -1273,10 +1273,10 @@ recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1284,9 +1284,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - 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 + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1298,9 +1298,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1308,9 +1308,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - 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 + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1322,10 +1322,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1333,9 +1333,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - 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 + 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 ] # cursor moves to start of line memory-should-contain [ @@ -1349,10 +1349,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1360,9 +1360,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - 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 + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1375,9 +1375,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - 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 + 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 ] memory-should-contain [ 4 <- 1 @@ -1419,14 +1419,14 @@ after <handle-special-key> [ } ] -recipe move-to-end-of-line editor:address:editor-data -> editor:address:editor-data [ +recipe move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset cursor-column:address:number <- get-address *editor, cursor-column:offset # while not at start of line, move { - next:address:duplex-list:character <- next *before-cursor + next:address:shared: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 @@ -1439,10 +1439,10 @@ recipe move-to-end-of-line editor:address:editor-data -> editor:address:editor-d scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1450,9 +1450,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - 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 + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1464,10 +1464,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on first line, press 'end' assume-console [ @@ -1475,9 +1475,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - 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 + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1489,10 +1489,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1500,9 +1500,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - 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 + 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 ] # cursor moves to end of line memory-should-contain [ @@ -1516,16 +1516,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1542,21 +1542,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:duplex-list:character <- delete-to-start-of-line editor + deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor <delete-to-start-of-line-end> go-render? <- copy 1/true reply } ] -recipe delete-to-start-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +recipe delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete - init:address:duplex-list:character <- get *editor, data:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - start:address:duplex-list:character <- copy *before-cursor - end:address:duplex-list:character <- next *before-cursor + init:address:shared:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + start:address:shared:duplex-list:character <- copy *before-cursor + end:address:shared:duplex-list:character <- next *before-cursor { at-start-of-text?:boolean <- equal start, init break-if at-start-of-text? @@ -1568,7 +1568,7 @@ recipe delete-to-start-of-line editor:address:editor-data -> result:address:dupl loop } # snip it out - result:address:duplex-list:character <- next start + result:address:shared:duplex-list:character <- next start remove-between start, end # adjust cursor *before-cursor <- copy start @@ -1579,16 +1579,16 @@ recipe delete-to-start-of-line editor:address:editor-data -> result:address:dupl scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1602,16 +1602,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1625,16 +1625,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1650,16 +1650,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1676,19 +1676,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:duplex-list:character <- delete-to-end-of-line editor + deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor <delete-to-end-of-line-end> go-render? <- copy 1/true reply } ] -recipe delete-to-end-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +recipe delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete - start:address:duplex-list:character <- get *editor, before-cursor:offset - end:address:duplex-list:character <- next start + start:address:shared:duplex-list:character <- get *editor, before-cursor:offset + end:address:shared:duplex-list:character <- next start { at-end-of-text?:boolean <- equal end, 0/null break-if at-end-of-text? @@ -1705,16 +1705,16 @@ recipe delete-to-end-of-line editor:address:editor-data -> result:address:duplex scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1728,16 +1728,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes just last character screen-should-contain [ @@ -1751,16 +1751,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1774,16 +1774,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes just the final character screen-should-contain [ @@ -1797,16 +1797,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:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1824,11 +1824,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -1841,7 +1841,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -1854,11 +1854,11 @@ d] after <scroll-down> [ trace 10, [app], [scroll down] - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *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:duplex-list:character <- copy *top-of-screen + old-top:address:shared:duplex-list:character <- copy *top-of-screen *top-of-screen <- before-start-of-next-line *top-of-screen, max no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false @@ -1868,11 +1868,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. -recipe before-start-of-next-line original:address:duplex-list:character, max:number -> curr:address:duplex-list:character [ +recipe before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ local-scope load-ingredients count:number <- copy 0 - curr:address:duplex-list:character <- copy original + curr:address:shared:duplex-list:character <- copy original # skip the initial newline if it exists { c:character <- get *curr, value:offset @@ -1901,11 +1901,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:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -1918,7 +1918,7 @@ i] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -1933,18 +1933,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:array:character <- new [abcdefghij + 1:address:shared:array:character <- new [abcdefghij k l m] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line containing a wrap icon screen-should-contain [ @@ -1958,7 +1958,7 @@ m] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -1973,19 +1973,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:array:character <- new [a + 1:address:shared:array:character <- new [a b cdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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: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 + 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 ] # screen scrolls screen-should-contain [ @@ -2003,19 +2003,19 @@ cdef] scenario editor-scrolls-down-on-newline [ assume-screen 5/width, 4/height # position cursor after last line and type newline - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 3, 4 type [ ] ] run [ - 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 + 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 ] # screen scrolls screen-should-contain [ @@ -2034,19 +2034,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:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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: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 + 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 ] # screen scrolls screen-should-contain [ @@ -2065,20 +2065,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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: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 + 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 ] # screen scrolls screen-should-contain [ @@ -2095,10 +2095,10 @@ d] scenario editor-scrolls-at-end-on-down-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 $clear-trace # try to move down past end of text assume-console [ @@ -2106,9 +2106,9 @@ de] press down-arrow ] run [ - 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 + 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 ] # screen should scroll, moving cursor to end of text memory-should-contain [ @@ -2119,7 +2119,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2134,9 +2134,9 @@ de] press down-arrow ] run [ - 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 + 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 ] # screen stops scrolling because cursor is already at top memory-should-contain [ @@ -2148,7 +2148,7 @@ de] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2162,14 +2162,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # scroll down one page and one line assume-console [ press page-down @@ -2177,7 +2177,7 @@ g] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen scrolls down 3 lines screen-should-contain [ @@ -2194,11 +2194,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2211,7 +2211,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -2224,8 +2224,8 @@ d] after <scroll-up> [ trace 10, [app], [scroll up] - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen *top-of-screen <- before-previous-line *top-of-screen, editor no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false @@ -2235,7 +2235,7 @@ 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 -recipe before-previous-line curr:address:duplex-list:character, editor:address:editor-data -> curr:address:duplex-list:character [ +recipe before-previous-line curr:address:shared:duplex-list:character, editor:address:shared:editor-data -> curr:address:shared:duplex-list:character [ local-scope load-ingredients c:character <- get *curr, value:offset @@ -2245,12 +2245,12 @@ recipe before-previous-line curr:address:duplex-list:character, editor:address:e 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:duplex-list:character <- get *editor, data:offset + sentinel:address:shared: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:duplex-list:character <- prev curr + prev:address:shared:duplex-list:character <- prev curr reply-unless prev, curr reply prev } @@ -2266,7 +2266,7 @@ recipe before-previous-line curr:address:duplex-list:character, editor:address:e { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- prev curr + prev:address:shared:duplex-list:character <- prev curr break-unless prev curr <- copy prev count <- add count, 1 @@ -2280,11 +2280,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:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2296,7 +2296,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2309,7 +2309,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2324,17 +2324,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:array:character <- new [abcdefghij + 1:address:shared:array:character <- new [abcdefghij k l m] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2348,7 +2348,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2363,7 +2363,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2378,7 +2378,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2397,11 +2397,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:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right screen-should-contain [ . . .abcde↩ . @@ -2413,7 +2413,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2426,7 +2426,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2441,18 +2441,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2464,7 +2464,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2476,7 +2476,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2490,18 +2490,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2514,9 +2514,9 @@ e] press left-arrow ] run [ - 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 + 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 ] # screen scrolls screen-should-contain [ @@ -2535,11 +2535,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2554,7 +2554,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -2568,7 +2568,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen remains unchanged screen-should-contain [ @@ -2583,11 +2583,11 @@ d] scenario editor-can-scroll [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2599,7 +2599,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows next page screen-should-contain [ @@ -2614,8 +2614,8 @@ after <handle-special-character> [ { page-down?:boolean <- equal *c, 6/ctrl-f break-unless page-down? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never @@ -2630,8 +2630,8 @@ after <handle-special-key> [ { page-down?:boolean <- equal *k, 65518/page-down break-unless page-down? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never @@ -2644,14 +2644,14 @@ after <handle-special-key> [ # page-down skips entire wrapped lines, so it can't scroll past lines # taking up the entire screen -recipe page-down editor:address:editor-data -> editor:address:editor-data [ +recipe page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # if editor contents don't overflow screen, do nothing - bottom-of-screen:address:duplex-list:character <- get *editor, bottom-of-screen:offset + bottom-of-screen:address:shared:duplex-list:character <- get *editor, bottom-of-screen:offset reply-unless bottom-of-screen # if not, position cursor at final character - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset *before-cursor <- prev bottom-of-screen # keep one line in common with previous page { @@ -2662,16 +2662,16 @@ recipe page-down editor:address:editor-data -> editor:address:editor-data [ } # move cursor and top-of-screen to start of that line move-to-start-of-line editor - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top-of-screen <- copy *before-cursor ] scenario editor-does-not-scroll-past-end [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 screen-should-contain [ . . .a . @@ -2683,7 +2683,7 @@ b] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen remains unmodified screen-should-contain [ @@ -2698,11 +2698,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:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] # editor screen triggers wrap of last line - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2715,7 +2715,7 @@ cdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2731,9 +2731,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:array:character <- new [a + 1:address:shared:array:character <- new [a bcdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2746,7 +2746,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2761,11 +2761,11 @@ bcdefgh] scenario editor-can-scroll-up [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2777,7 +2777,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows next page screen-should-contain [ @@ -2791,7 +2791,7 @@ d] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows original page again screen-should-contain [ @@ -2806,8 +2806,8 @@ after <handle-special-character> [ { page-up?:boolean <- equal *c, 2/ctrl-b break-unless page-up? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never @@ -2822,8 +2822,8 @@ after <handle-special-key> [ { page-up?:boolean <- equal *k, 65519/page-up break-unless page-up? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never @@ -2835,16 +2835,16 @@ after <handle-special-key> [ } ] -recipe page-up editor:address:editor-data, screen-height:number -> editor:address:editor-data [ +recipe page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared: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:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- before-previous-line *top-of-screen, editor + prev:address:shared:duplex-list:character <- before-previous-line *top-of-screen, editor break-unless prev *top-of-screen <- copy prev count <- add count, 1 @@ -2856,7 +2856,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:array:character <- new [a + 1:address:shared:array:character <- new [a b c d @@ -2864,7 +2864,7 @@ e f g h] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2877,7 +2877,7 @@ h] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows third page screen-should-contain [ @@ -2891,7 +2891,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows second page screen-should-contain [ @@ -2905,7 +2905,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows original page again screen-should-contain [ @@ -2920,7 +2920,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:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh i @@ -2931,7 +2931,7 @@ m n o] # editor screen triggers wrap of last line - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2948,7 +2948,7 @@ o] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2964,7 +2964,7 @@ o] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen resets screen-should-contain [ @@ -2982,9 +2982,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:array:character <- new [a + 1:address:shared:array:character <- new [a bcdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2997,7 +2997,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -3011,7 +3011,7 @@ bcdefgh] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen resets screen-should-contain [ @@ -3025,7 +3025,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:array:character <- new [axx + 1:address:shared:array:character <- new [axx bxx cxx dxx @@ -3034,7 +3034,7 @@ fxx gxx hxx ] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right screen-should-contain [ . . .axx . @@ -3045,7 +3045,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3057,7 +3057,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3070,7 +3070,7 @@ hxx press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3083,7 +3083,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:array:character <- new [axy + 1:address:shared:array:character <- new [axy bxy cxy @@ -3092,7 +3092,7 @@ exy fxy gxy ] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right screen-should-contain [ . . .axy . @@ -3103,7 +3103,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3115,7 +3115,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3128,7 +3128,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 7ed6376e..99cefbb4 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -6,22 +6,22 @@ recipe! main [ local-scope open-console - initial-recipe:address:array:character <- restore [recipes.mu] - initial-sandbox:address:array:character <- new [] + initial-recipe:address:shared:array:character <- restore [recipes.mu] + initial-sandbox:address:shared:array:character <- new [] hide-screen 0/screen - env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox + env:address:shared: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:editor-data - current-sandbox:address:editor-data + recipes:address:shared:editor-data + current-sandbox:address:shared:editor-data sandbox-in-focus?:boolean # false => cursor in recipes; true => cursor in current-sandbox ] -recipe 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 [ +recipe 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 [ local-scope load-ingredients width:number <- screen-width screen @@ -33,25 +33,25 @@ recipe new-programming-environment screen:address:screen, initial-recipe-content button-on-screen?:boolean <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start - run-button:address:array:character <- new [ run (F4) ] + run-button:address:shared:array:character <- new [ run (F4) ] print screen, run-button, 255/white, 161/reddish # dotted line down the middle divider:number, _ <- divide-with-remainder width, 2 draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted # recipe editor on the left - recipes:address:address:editor-data <- get-address *result, recipes:offset + recipes:address:address:shared:editor-data <- get-address *result, recipes:offset *recipes <- new-editor initial-recipe-contents, screen, 0/left, divider/right # sandbox editor on the right new-left:number <- add divider, 1 - current-sandbox:address:address:editor-data <- get-address *result, current-sandbox:offset + current-sandbox:address:address:shared:editor-data <- get-address *result, current-sandbox:offset *current-sandbox <- new-editor initial-sandbox-contents, screen, new-left, width/right ] -recipe event-loop screen:address:screen, console:address:console, env:address:programming-environment-data -> screen:address:screen, console:address:console, env:address:programming-environment-data [ +recipe 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 [ local-scope load-ingredients - recipes:address:editor-data <- get *env, recipes:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + recipes:address:shared:editor-data <- get *env, recipes:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset sandbox-in-focus?:address:boolean <- get-address *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. @@ -179,14 +179,14 @@ recipe event-loop screen:address:screen, console:address:console, env:address:pr } ] -recipe resize screen:address:screen, env:address:programming-environment-data -> env:address:programming-environment-data, screen:address:screen [ +recipe resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared: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:editor-data <- get *env, recipes:offset + recipes:address:shared:editor-data <- get *env, recipes:offset right:address:number <- get-address *recipes, right:offset *right <- subtract divider, 1 # reset cursor (later we'll try to preserve its position) @@ -195,7 +195,7 @@ recipe resize screen:address:screen, env:address:programming-environment-data -> cursor-column:address:number <- get-address *recipes, cursor-column:offset *cursor-column <- copy 0 # update sandbox editor - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset left:address:number <- get-address *current-sandbox, left:offset right:address:number <- get-address *current-sandbox, right:offset *left <- add divider, 1 @@ -211,9 +211,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: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 + 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 # focus on both sides assume-console [ left-click 1, 1 @@ -221,11 +221,11 @@ scenario point-at-multiple-editors [ ] # check cursor column in each run [ - 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 + 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 ] memory-should-contain [ 5 <- 1 @@ -237,10 +237,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: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 + 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 # type one letter in each of them assume-console [ left-click 1, 1 @@ -249,11 +249,11 @@ scenario edit-multiple-editors [ type [1] ] run [ - 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 + 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 ] screen-should-contain [ . run (F4) . # this line has a different background, but we don't test that yet @@ -268,7 +268,7 @@ scenario edit-multiple-editors [ # show the cursor at the right window run [ 8:character/cursor <- copy 9251/␣ - print screen:address:screen, 8:character/cursor + print screen:address:shared:screen, 8:character/cursor ] screen-should-contain [ . run (F4) . @@ -282,10 +282,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: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 + 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 ] # divider isn't messed up screen-should-contain [ @@ -300,16 +300,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: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 + 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 # initialize programming environment and highlight cursor assume-console [] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] # is cursor at the right place? screen-should-contain [ @@ -323,9 +323,9 @@ scenario editor-in-focus-keeps-cursor [ type [z] ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] # cursor should still be right screen-should-contain [ @@ -340,11 +340,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:array:character <- new [] - 2:address:array:character <- new [abc + 1:address:shared:array:character <- new [] + 2:address:shared:array:character <- new [abc 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 + 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 screen-should-contain [ . run (F4) . . ┊abc . @@ -358,9 +358,9 @@ def] press backspace ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] # cursor moves to end of old line screen-should-contain [ @@ -371,7 +371,7 @@ def] ] ] -recipe render-all screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients trace 10, [app], [render all] @@ -384,7 +384,7 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat button-on-screen?:boolean <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start - run-button:address:array:character <- new [ run (F4) ] + run-button:address:shared:array:character <- new [ run (F4) ] print screen, run-button, 255/white, 161/reddish # dotted line down the middle trace 11, [app], [render divider] @@ -396,19 +396,19 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat screen <- render-sandbox-side screen, env <render-components-end> # - recipes:address:editor-data <- get *env, recipes:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + recipes:address:shared:editor-data <- get *env, recipes:offset + current-sandbox:address:shared: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? # show-screen screen ] -recipe render-recipes screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients trace 11, [app], [render recipes] - recipes:address:editor-data <- get *env, recipes:offset + recipes:address:shared:editor-data <- get *env, recipes:offset # render recipes left:number <- get *recipes, left:offset right:number <- get *recipes, right:offset @@ -423,10 +423,10 @@ recipe render-recipes screen:address:screen, env:address:programming-environment ] # replaced in a later layer -recipe render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared: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 @@ -438,7 +438,7 @@ recipe render-sandbox-side screen:address:screen, env:address:programming-enviro clear-screen-from screen, row, left, left, right ] -recipe update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean -> screen:address:screen [ +recipe update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean -> screen:address:shared:screen [ local-scope load-ingredients { @@ -456,7 +456,7 @@ recipe update-cursor screen:address:screen, recipes:address:editor-data, current # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ +recipe render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless s @@ -517,7 +517,7 @@ recipe render screen:address:screen, s:address:array:character, left:number, rig ] # like 'render' for texts, but with colorization for comments like in the editor -recipe render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ +recipe render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless s @@ -585,7 +585,7 @@ after <global-type> [ { redraw-screen?:boolean <- equal *c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:address:programming-environment-data + screen <- render-all screen, env:address:shared:programming-environment-data sync-screen screen loop +next-event:label } @@ -606,7 +606,7 @@ after <global-type> [ ## helpers -recipe draw-vertical screen:address:screen, col:number, y:number, bottom:number -> screen:address:screen [ +recipe draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number -> screen:address:shared: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 3929fb76..3095e865 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -7,10 +7,10 @@ recipe! main [ local-scope open-console - initial-recipe:address:array:character <- restore [recipes.mu] - initial-sandbox:address:array:character <- new [] + initial-recipe:address:shared:array:character <- restore [recipes.mu] + initial-sandbox:address:shared:array:character <- new [] hide-screen 0/screen - env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox + env:address:shared: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,35 +18,35 @@ recipe! main [ ] container programming-environment-data [ - sandbox:address:sandbox-data # list of sandboxes, from top to bottom + sandbox:address:shared:sandbox-data # list of sandboxes, from top to bottom ] container sandbox-data [ - data:address:array:character - response:address:array:character - expected-response:address:array:character + data:address:shared:array:character + response:address:shared:array:character + expected-response:address:shared:array:character # coordinates to track clicks starting-row-on-screen:number code-ending-row-on-screen:number # past end of code response-starting-row-on-screen:number - screen:address:screen # prints in the sandbox go here - next-sandbox:address:sandbox-data + screen:address:shared:screen # prints in the sandbox go here + next-sandbox:address:shared: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:array:character <- new [] + 1:address:shared:array:character <- new [] # sandbox editor contains an instruction without storing outputs - 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 + 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 # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -89,7 +89,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -115,14 +115,14 @@ after <global-keypress> [ do-run?:boolean <- equal *k, 65532/F4 break-unless do-run? #? $log [F4 pressed] - status:address:array:character <- new [running... ] + status:address:shared:array:character <- new [running... ] screen <- update-status screen, status, 245/grey error?:boolean, env, screen <- run-sandboxes env, screen # F4 might update warnings and results on both sides screen <- render-all screen, env { break-if error? - status:address:array:character <- new [ ] + status:address:shared:array:character <- new [ ] screen <- update-status screen, status, 245/grey } screen <- update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? @@ -130,36 +130,36 @@ after <global-keypress> [ } ] -recipe run-sandboxes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe 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 [ local-scope load-ingredients errors-found?:boolean, env, screen <- update-recipes env, screen reply-if errors-found? # check contents of right editor (sandbox) - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset { - sandbox-contents:address:array:character <- editor-contents current-sandbox + sandbox-contents:address:shared: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:sandbox-data <- new sandbox-data:type - data:address:address:array:character <- get-address *new-sandbox, data:offset + new-sandbox:address:shared:sandbox-data <- new sandbox-data:type + data:address:address:shared:array:character <- get-address *new-sandbox, data:offset *data <- copy sandbox-contents # push to head of sandbox list - dest:address:address:sandbox-data <- get-address *env, sandbox:offset - next:address:address:sandbox-data <- get-address *new-sandbox, next-sandbox:offset + dest:address:address:shared:sandbox-data <- get-address *env, sandbox:offset + next:address:address:shared:sandbox-data <- get-address *new-sandbox, next-sandbox:offset *next <- copy *dest *dest <- copy new-sandbox # clear sandbox editor - init:address:address:duplex-list:character <- get-address *current-sandbox, data:offset + init:address:address:shared:duplex-list:character <- get-address *current-sandbox, data:offset *init <- push 167/§, 0/tail - top-of-screen:address:address:duplex-list:character <- get-address *current-sandbox, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *current-sandbox, top-of-screen:offset *top-of-screen <- copy *init } # save all sandboxes before running, just in case we die when running save-sandboxes env # run all sandboxes - curr:address:sandbox-data <- get *env, sandbox:offset + curr:address:shared:sandbox-data <- get *env, sandbox:offset { break-unless curr curr <- update-sandbox curr @@ -171,49 +171,49 @@ recipe run-sandboxes env:address:programming-environment-data, screen:address:sc # copy code from recipe editor, persist, load into mu # replaced in a later layer (whereupon errors-found? will actually be set) -recipe update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe 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 [ local-scope load-ingredients - recipes:address:editor-data <- get *env, recipes:offset - in:address:array:character <- editor-contents recipes + recipes:address:shared:editor-data <- get *env, recipes:offset + in:address:shared:array:character <- editor-contents recipes save [recipes.mu], in # newlayer: persistence reload in errors-found? <- copy 0/false ] # replaced in a later layer -recipe update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset *response, _, *fake-screen <- run-interactive data ] -recipe update-status screen:address:screen, msg:address:array:character, color:number -> screen:address:screen [ +recipe update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -recipe save-sandboxes env:address:programming-environment-data [ +recipe save-sandboxes env:address:shared:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared: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:sandbox-data <- get *env, sandbox:offset - suffix:address:array:character <- new [.out] + curr:address:shared:sandbox-data <- get *env, sandbox:offset + suffix:address:shared:array:character <- new [.out] idx:number <- copy 0 { break-unless curr - data:address:array:character <- get *curr, data:offset - filename:address:array:character <- to-text idx + data:address:shared:array:character <- get *curr, data:offset + filename:address:shared:array:character <- to-text idx save filename, data { - expected-response:address:array:character <- get *curr, expected-response:offset + expected-response:address:shared:array:character <- get *curr, expected-response:offset break-unless expected-response filename <- append filename, suffix save filename, expected-response @@ -224,24 +224,24 @@ recipe save-sandboxes env:address:programming-environment-data [ } ] -recipe! render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients #? $log [render sandbox side] trace 11, [app], [render sandbox side] - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared: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 clear-screen-from screen, row, column, left, right row <- add row, 1 draw-horizontal screen, row, left, right, 9473/horizontal-double - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:address:shared:sandbox-data <- get *env, sandbox:offset row, screen <- render-sandboxes screen, sandbox, left, right, row clear-rest-of-screen screen, row, left, left, right ] -recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number -> row:number, screen:address:screen, sandbox:address:sandbox-data [ +recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ local-scope load-ingredients #? $log [render sandbox] @@ -261,16 +261,16 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef # render sandbox contents row <- add row, 1 screen <- move-cursor screen, row, left - sandbox-data:address:array:character <- get *sandbox, data:offset + sandbox-data:address:shared:array:character <- get *sandbox, data:offset row, screen <- render-code screen, sandbox-data, left, right, row code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - sandbox-response:address:array:character <- get *sandbox, response:offset + sandbox-response:address:shared:array:character <- get *sandbox, response:offset <render-sandbox-results> { - sandbox-screen:address:screen <- get *sandbox, screen:offset + sandbox-screen:address:shared: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 @@ -287,32 +287,32 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double # draw next sandbox - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset row, screen <- render-sandboxes screen, next-sandbox, left, right, row ] # assumes programming environment has no sandboxes; restores them from previous session -recipe restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ +recipe restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios - suffix:address:array:character <- new [.out] + suffix:address:shared:array:character <- new [.out] idx:number <- copy 0 - curr:address:address:sandbox-data <- get-address *env, sandbox:offset + curr:address:address:shared:sandbox-data <- get-address *env, sandbox:offset { - filename:address:array:character <- to-text idx - contents:address:array:character <- restore filename + filename:address:shared:array:character <- to-text idx + contents:address:shared: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 - data:address:address:array:character <- get-address **curr, data:offset + data:address:address:shared:array:character <- get-address **curr, data:offset *data <- copy contents # restore expected output for sandbox if it exists { filename <- append filename, suffix contents <- restore filename break-unless contents - expected-response:address:address:array:character <- get-address **curr, expected-response:offset + expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset *expected-response <- copy contents } +continue @@ -324,19 +324,19 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -recipe render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number -> row:number, screen:address:screen [ +recipe render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless sandbox-screen # print 'screen:' - header:address:array:character <- new [screen:] + header:address:shared:array:character <- new [screen:] row <- render screen, header, left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left s-width:number <- screen-width sandbox-screen s-height:number <- screen-height sandbox-screen - buf:address:array:screen-cell <- get *sandbox-screen, data:offset + buf:address:shared: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 @@ -394,19 +394,19 @@ 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:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ z:number <- add 2, 2 reply z ]] # sandbox editor contains an instruction without storing outputs - 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 + 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 # run the code in the editors assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -425,7 +425,7 @@ reply z press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen updates the result on the right screen-should-contain [ @@ -444,16 +444,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:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an instruction - 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 + 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 # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that it prints a little toy screen screen-should-contain [ @@ -473,11 +473,11 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -recipe editor-contents editor:address:editor-data -> result:address:array:character [ +recipe editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ local-scope load-ingredients - buf:address:buffer <- new-buffer 80 - curr:address:duplex-list:character <- get *editor, data:offset + buf:address:shared:buffer <- new-buffer 80 + curr:address:shared: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 @@ -494,16 +494,16 @@ recipe editor-contents editor:address:editor-data -> result:address:array:charac scenario editor-provides-edited-contents [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 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 assume-console [ left-click 1, 2 type [def] ] run [ - 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 + 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 ] memory-should-contain [ 4:array:character <- [abdefc] diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu index 0e294be3..80ceb2b9 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:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 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 + 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 screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 3, 30 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # it pops back into editor screen-should-contain [ @@ -48,7 +48,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared: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:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset @@ -78,8 +78,8 @@ 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:sandbox-data <- extract-sandbox env, click-row - text:address:array:character <- get *sandbox, data:offset + sandbox:address:shared:sandbox-data <- extract-sandbox env, click-row + text:address:shared:array:character <- get *sandbox, data:offset current-sandbox <- insert-text current-sandbox, text hide-screen screen screen <- render-sandbox-side screen, env @@ -89,24 +89,24 @@ after <global-touch> [ } ] -recipe empty-editor? editor:address:editor-data -> result:boolean [ +recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ local-scope load-ingredients - head:address:duplex-list:character <- get *editor, data:offset - first:address:duplex-list:character <- next head + head:address:shared:duplex-list:character <- get *editor, data:offset + first:address:shared:duplex-list:character <- next head result <- not first ] -recipe extract-sandbox env:address:programming-environment-data, click-row:number -> result:address:sandbox-data, env:address:programming-environment-data [ +recipe extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:address:sandbox-data <- get-address *env, sandbox:offset + sandbox:address:address:shared:sandbox-data <- get-address *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] { - next-sandbox:address:sandbox-data <- get **sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get **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 @@ -127,15 +127,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:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an instruction - 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 + 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 # run the sandbox assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -156,7 +156,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 70 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu index e9d28ffa..95b6042f 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: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 + 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 # 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:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -35,7 +35,7 @@ scenario deleting-sandboxes [ left-click 7, 99 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -53,7 +53,7 @@ scenario deleting-sandboxes [ left-click 3, 99 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -77,17 +77,17 @@ after <global-touch> [ } ] -recipe delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean, env:address:programming-environment-data [ +recipe delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ local-scope load-ingredients click-column:number <- get t, column:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset right:number <- get *current-sandbox, right:offset at-right?:boolean <- equal click-column, right reply-unless at-right?, 0/false click-row:number <- get t, row:offset - prev:address:address:sandbox-data <- get-address *env, sandbox:offset - curr:address:sandbox-data <- get *env, sandbox:offset + prev:address:address:shared:sandbox-data <- get-address *env, sandbox:offset + curr:address:shared:sandbox-data <- get *env, sandbox:offset { break-unless curr # more sandboxes to check diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu index 77cac2ce..b15eb37e 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:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 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 + 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 screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 5, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared: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:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] screen-should-contain [ . run (F4) . @@ -67,7 +67,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # result turns red screen-should-contain-in-color 1/red, [ @@ -90,14 +90,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:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset 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:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:address:shared: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 @@ -111,17 +111,17 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:address:shared: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:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared: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 @@ -137,10 +137,10 @@ recipe find-click-in-sandbox-output env:address:programming-environment-data, cl reply sandbox ] -recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - expected-response:address:address:array:character <- get-address *sandbox, expected-response:offset + expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset { # if expected-response is set, reset break-unless *expected-response @@ -148,7 +148,7 @@ recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address: reply sandbox/same-as-ingredient:0 } # if not, current response is the expected response - response:address:array:character <- get *sandbox, response:offset + response:address:shared:array:character <- get *sandbox, response:offset *expected-response <- copy response ] @@ -156,7 +156,7 @@ recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address: after <render-sandbox-response> [ { break-unless sandbox-response - expected-response:address:array:character <- get *sandbox, expected-response:offset + expected-response:address:shared: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 03bde749..92d46bc0 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:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ stash [abc] ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 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 + 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 screen-should-contain [ . run (F4) . . ┊ . @@ -29,9 +29,9 @@ recipe foo [ left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor-icon <- copy 9251/␣ - print screen:address:screen, 4:character/cursor-icon + print screen:address:shared: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:screen, console:address:console, 3:address:programming-environment-data - print screen:address:screen, 4:character/cursor-icon + 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 ] # 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:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ stash [abc] reply 4 ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 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 + 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 screen-should-contain [ . run (F4) . . ┊ . @@ -105,7 +105,7 @@ recipe foo [ left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # trace now printed above result screen-should-contain [ @@ -122,18 +122,18 @@ recipe foo [ ] container sandbox-data [ - trace:address:array:character + trace:address:shared:array:character display-trace?:boolean ] # replaced in a later layer -recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe! update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - trace:address:address:array:character <- get-address *sandbox, trace:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + trace:address:address:shared:array:character <- get-address *sandbox, trace:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset *response, _, *fake-screen, *trace <- run-interactive data ] @@ -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:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset 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:sandbox-data <- find-click-in-sandbox-code env, click-row + sandbox:address:shared:sandbox-data <- find-click-in-sandbox-code env, click-row break-unless sandbox # toggle its display-trace? property x:address:boolean <- get-address *sandbox, display-trace?:offset @@ -166,7 +166,7 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-code env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +recipe find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -176,7 +176,7 @@ recipe find-click-in-sandbox-code env:address:programming-environment-data, clic 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:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared: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 @@ -202,7 +202,7 @@ after <render-sandbox-results> [ { display-trace?:boolean <- get *sandbox, display-trace?:offset break-unless display-trace? - sandbox-trace:address:array:character <- get *sandbox, trace:offset + sandbox-trace:address:shared: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-warnings.mu b/edit/010-warnings.mu index 6bfa3e3e..61cac2d2 100644 --- a/edit/010-warnings.mu +++ b/edit/010-warnings.mu @@ -1,23 +1,23 @@ ## handling malformed programs container programming-environment-data [ - recipe-warnings:address:array:character + recipe-warnings:address:shared:array:character ] # copy code from recipe editor, persist, load into mu, save any warnings -recipe! update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe! 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 [ local-scope load-ingredients #? $log [update recipes] - recipes:address:editor-data <- get *env, recipes:offset - in:address:array:character <- editor-contents recipes + recipes:address:shared:editor-data <- get *env, recipes:offset + in:address:shared:array:character <- editor-contents recipes save [recipes.mu], in - recipe-warnings:address:address:array:character <- get-address *env, recipe-warnings:offset + recipe-warnings:address:address:shared:array:character <- get-address *env, recipe-warnings:offset *recipe-warnings <- reload in # if recipe editor has errors, stop { break-unless *recipe-warnings - status:address:array:character <- new [errors found] + status:address:shared:array:character <- new [errors found] update-status screen, status, 1/red errors-found? <- copy 1/true reply @@ -27,35 +27,35 @@ recipe! update-recipes env:address:programming-environment-data, screen:address: before <render-components-end> [ trace 11, [app], [render status] - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset { break-unless recipe-warnings - status:address:array:character <- new [errors found] + status:address:shared:array:character <- new [errors found] update-status screen, status, 1/red } ] before <render-recipe-components-end> [ { - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset break-unless recipe-warnings row, screen <- render screen, recipe-warnings, left, right, 1/red, row } ] container sandbox-data [ - warnings:address:array:character + warnings:address:shared:array:character ] -recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe! update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients #? $log [update sandbox] - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - warnings:address:address:array:character <- get-address *sandbox, warnings:offset - trace:address:address:array:character <- get-address *sandbox, trace:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + warnings:address:address:shared:array:character <- get-address *sandbox, warnings:offset + trace:address:address:shared:array:character <- get-address *sandbox, trace:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset #? $print [run-interactive], 10/newline *response, *warnings, *fake-screen, *trace, completed?:boolean <- run-interactive data { @@ -70,7 +70,7 @@ recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-d # make sure we render any trace after <render-sandbox-trace-done> [ { - sandbox-warnings:address:array:character <- get *sandbox, warnings:offset + sandbox-warnings:address:shared:array:character <- get *sandbox, warnings:offset break-unless sandbox-warnings *response-starting-row <- copy 0 # no response row, screen <- render screen, sandbox-warnings, left, right, 1/red, row @@ -82,17 +82,17 @@ after <render-sandbox-trace-done> [ scenario run-shows-warnings-in-get [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ get 123:number, foo:offset ]] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -122,14 +122,14 @@ recipe foo [ scenario run-hides-warnings-from-past-sandboxes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 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 + 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 assume-console [ press F4 # generate error ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] assume-console [ left-click 3, 80 @@ -138,7 +138,7 @@ scenario run-hides-warnings-from-past-sandboxes [ press F4 # error should disappear ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -156,18 +156,18 @@ scenario run-updates-warnings-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:array:character <- new [recipe foo x:_elem -> z:_elem [ + 1:address:shared:array:character <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients z <- add x, [a] ]] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -185,7 +185,7 @@ z <- add x, [a] press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # error should remain unchanged screen-should-contain [ @@ -205,24 +205,24 @@ scenario run-avoids-spurious-warnings-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:array:character <- new [recipe length l:address:list:_elem -> n:number [ + 1:address:shared:array:character <- new [recipe length l:address:shared:list:_elem -> n:number [ ]] # call code that uses other variants of it, but not it itself - 2:address:array:character <- new [x:address:list:number <- copy 0 + 2:address:shared:array:character <- new [x:address:shared:list:number <- copy 0 to-text x] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run it once assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared: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, [ . . . . . . . . - . <- . + . <- . . . . . . . @@ -239,7 +239,7 @@ to-text x] press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # still no errors screen-should-contain-in-color 1/red, [ @@ -247,7 +247,7 @@ to-text x] . . . . . . - . <- . + . <- . . . . . . . @@ -264,17 +264,17 @@ to-text x] scenario run-shows-missing-type-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ x <- copy 0 ]] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -290,18 +290,18 @@ scenario run-shows-unbalanced-bracket-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe is incomplete (unbalanced '[') - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo « x <- copy 0 ] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -318,28 +318,28 @@ recipe foo « scenario run-shows-get-on-non-container-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ - x:address:point <- new point:type - get x:address:point, 1:offset + x:address:shared:point <- new point:type + get x:address:shared:point, 1:offset ]] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . . ┊foo . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - . x:address:point <- new point:type ┊ . - . get x:address:point, 1:offset ┊ . + . x:address:shared:point <- new point:type ┊ . + . get x:address:shared:point, 1:offset ┊ . .] ┊ . .foo: first ingredient of 'get' should be a contai↩┊ . - .ner, but got x:address:point ┊ . + .ner, but got x:address:shared:point ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . . ┊ . ] @@ -348,27 +348,27 @@ recipe foo [ scenario run-shows-non-literal-get-argument-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ x:number <- copy 0 - y:address:point <- new point:type - get *y:address:point, x:number + y:address:shared:point <- new point:type + get *y:address:shared:point, x:number ]] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . . ┊foo . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . x:number <- copy 0 ┊ . - . y:address:point <- new point:type ┊ . - . get *y:address:point, x:number ┊ . + . y:address:shared:point <- new point:type ┊ . + . get *y:address:shared:point, x:number ┊ . .] ┊ . .foo: expected ingredient 1 of 'get' to have type ↩┊ . .'offset'; got x:number ┊ . @@ -383,17 +383,17 @@ scenario run-shows-warnings-everytime [ trace-until 100/app # trace too long # try to run a file with an error assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ x:number <- copy y:number ]] - 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 + 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 assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -410,7 +410,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -428,16 +428,16 @@ scenario run-instruction-and-print-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # left editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an illegal instruction - 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 + 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 # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints error message in red screen-should-contain [ @@ -491,17 +491,17 @@ scenario run-instruction-and-print-warnings-only-once [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # left editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an illegal instruction - 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 + 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 # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints error message just once screen-should-contain [ @@ -522,20 +522,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:array:character <- new [recipe foo [ + 1:address:shared:array:character <- new [recipe foo [ { loop } ]] # right editor contains an instruction - 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 + 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 # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -553,7 +553,7 @@ scenario sandbox-with-warnings-shows-trace [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # generate a stash and a warning - 1:address:array:character <- new [recipe foo [ + 1:address:shared:array:character <- new [recipe foo [ local-scope a:number <- next-ingredient b:number <- next-ingredient @@ -561,13 +561,13 @@ stash [dividing by], b _, c:number <- divide-with-remainder a, b reply b ]] - 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 + 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 # run assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data # screen prints error message screen-should-contain [ . run (F4) . @@ -585,7 +585,7 @@ reply b left-click 4, 55 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared: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 4939013e..82362dd9 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:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate - insert-from:address:duplex-list:character - insert-until:address:duplex-list:character + insert-from:address:shared:duplex-list:character + insert-until:address:shared: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:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared: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:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - 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 + 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 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:list:address:operation - redo:address:list:address:operation + undo:address:shared:list:address:shared:operation + redo:address:shared:list:address:shared:operation ] # ctrl-z - undo operation @@ -65,11 +65,11 @@ after <handle-special-character> [ { undo?:boolean <- equal *c, 26/ctrl-z break-unless undo? - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset break-unless *undo - op:address:operation <- first *undo + op:address:shared:operation <- first *undo *undo <- rest *undo - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- push op, *redo <handle-undo> reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render @@ -81,11 +81,11 @@ after <handle-special-character> [ { redo?:boolean <- equal *c, 25/ctrl-y break-unless redo? - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset break-unless *redo - op:address:operation <- first *redo + op:address:shared:operation <- first *redo *redo <- rest *redo - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op, *undo <handle-redo> reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render @@ -97,19 +97,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: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 + 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 assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # character should be gone screen-should-contain [ @@ -123,7 +123,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -135,34 +135,34 @@ scenario editor-can-undo-typing [ # save operation to undo after <insert-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- copy *before-cursor + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:shared:duplex-list:character <- copy *before-cursor ] before <insert-character-end> [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - typing:address:insert-operation <- maybe-convert *op, typing:variant + op:address:shared:operation <- first *undo + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing previous-coalesce-tag:number <- get *typing, tag:offset break-unless previous-coalesce-tag - insert-until:address:address:duplex-list:character <- get-address *typing, insert-until:offset + insert-until:address:address:shared:duplex-list:character <- get-address *typing, insert-until:offset *insert-until <- next *before-cursor after-row:address:number <- get-address *typing, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *typing, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *typing, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *typing, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-insert-operation:label } # if not, create a new operation - insert-from:address:duplex-list:character <- next cursor-before - insert-to:address:duplex-list:character <- next insert-from - op:address:operation <- new operation:type + 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 *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 @@ -172,15 +172,15 @@ 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:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- copy *before-cursor + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:shared:duplex-list:character <- copy *before-cursor ] before <insert-enter-end> [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset # never coalesce - insert-from:address:duplex-list:character <- next cursor-before - insert-to:address:duplex-list:character <- next *before-cursor - op:address:operation <- new operation:type + insert-from:address:shared:duplex-list:character <- next cursor-before + insert-to:address:shared:duplex-list:character <- next *before-cursor + op:address:shared: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 ] @@ -189,28 +189,28 @@ 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. -recipe add-operation editor:address:editor-data, op:address:operation -> editor:address:editor-data [ +recipe add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ local-scope load-ingredients - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op *undo - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- copy 0 reply editor/same-as-ingredient:0 ] after <handle-undo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing - start:address:duplex-list:character <- get *typing, insert-from:offset - end:address:duplex-list:character <- get *typing, insert-until:offset + start:address:shared:duplex-list:character <- get *typing, insert-from:offset + end:address:shared:duplex-list:character <- get *typing, insert-until:offset # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *before-cursor <- prev start remove-between *before-cursor, end *cursor-row <- get *typing, before-row:offset *cursor-column <- get *typing, before-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *typing, before-top-of-screen:offset } ] @@ -218,19 +218,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: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 + 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 assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be gone screen-should-contain [ @@ -244,14 +244,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: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 + 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 # type some characters assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .012a . @@ -263,7 +263,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # back to original text screen-should-contain [ @@ -277,7 +277,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -290,15 +290,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: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 + 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 # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . abc . @@ -307,8 +307,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -318,10 +318,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -338,7 +338,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -353,14 +353,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: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 + 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 assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -372,7 +372,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be back screen-should-contain [ @@ -386,7 +386,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -398,15 +398,15 @@ scenario editor-redo-typing [ after <handle-redo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing - insert-from:address:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away + insert-from:address:shared:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away # assert insert-to matches next(*before-cursor) insert-range *before-cursor, insert-from # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *typing, after-row:offset *cursor-column <- get *typing, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *typing, after-top-of-screen:offset } ] @@ -414,14 +414,14 @@ after <handle-redo> [ scenario editor-redo-typing-empty [ # create an editor, type something, undo assume-screen 10/width, 5/height - 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 + 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 assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . . @@ -433,7 +433,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be back screen-should-contain [ @@ -447,7 +447,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -460,21 +460,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # do some more work assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .0abc . @@ -487,7 +487,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # nothing should happen screen-should-contain [ @@ -502,9 +502,9 @@ ghi] scenario editor-can-redo-typing-and-enter-and-tab [ # create an editor assume-screen 10/width, 5/height - 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 + 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 # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -515,7 +515,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . ab cd . @@ -523,8 +523,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -534,11 +534,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # typing in second line deleted, but not indent - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -555,11 +555,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # indent and newline deleted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -575,11 +575,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # empty screen - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -595,11 +595,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -615,11 +615,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # newline and indent inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -636,11 +636,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # indent and newline deleted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -659,24 +659,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # click undone memory-should-contain [ @@ -688,7 +688,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -702,20 +702,20 @@ ghi] after <move-cursor-begin> [ before-cursor-row:number <- get *editor, cursor-row:offset before-cursor-column:number <- get *editor, cursor-column:offset - before-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + before-top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <move-cursor-end> [ after-cursor-row:number <- get *editor, cursor-row:offset after-cursor-column:number <- get *editor, cursor-column:offset - after-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + after-top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen: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:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset break-unless *undo - op:address:operation <- first *undo - move:address:move-operation <- maybe-convert *op, move:variant + op:address:shared:operation <- first *undo + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move previous-coalesce-tag:number <- get *move, tag:offset coalesce?:boolean <- equal undo-coalesce-tag, previous-coalesce-tag @@ -724,11 +724,11 @@ before <move-cursor-end> [ *after-row <- copy after-cursor-row after-column:address:number <- get-address *move, after-column:offset *after-column <- copy after-cursor-column - after-top:address:address:duplex-list:character <- get-address *move, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *move, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-move-operation:label } - op:address:operation <- new operation:type + op:address:shared:operation <- new operation:type *op <- merge 1/move-operation, before-cursor-row, before-cursor-column, before-top-of-screen, after-cursor-row, after-cursor-column, after-top-of-screen, undo-coalesce-tag editor <- add-operation editor, op +done-adding-move-operation @@ -736,10 +736,10 @@ before <move-cursor-end> [ after <handle-undo> [ { - move:address:move-operation <- maybe-convert *op, move:variant + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *cursor-row <- get *move, before-row:offset *cursor-column <- get *move, before-column:offset *top <- get *move, before-top-of-screen:offset @@ -750,18 +750,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:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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: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 + 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 # screen scrolls screen-should-contain [ . . @@ -778,9 +778,9 @@ cdefgh] press ctrl-z ] run [ - 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 + 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 ] # cursor moved back memory-should-contain [ @@ -799,7 +799,7 @@ cdefgh] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -812,25 +812,25 @@ cdefgh] scenario editor-can-undo-left-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -842,7 +842,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -856,19 +856,19 @@ ghi] scenario editor-can-undo-up-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - 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 + 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 memory-should-contain [ 3 <- 2 4 <- 1 @@ -878,9 +878,9 @@ ghi] press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -892,7 +892,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -906,25 +906,25 @@ ghi] scenario editor-can-undo-down-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -936,7 +936,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -950,27 +950,27 @@ ghi] scenario editor-can-undo-ctrl-f [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # scroll the page assume-console [ press ctrl-f ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # screen should again show page 1 screen-should-contain [ @@ -985,27 +985,27 @@ f] scenario editor-can-undo-page-down [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # scroll the page assume-console [ press page-down ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # screen should again show page 1 screen-should-contain [ @@ -1020,28 +1020,28 @@ f] scenario editor-can-undo-ctrl-b [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # scroll the page down and up assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # screen should again show page 2 screen-should-contain [ @@ -1056,28 +1056,28 @@ f] scenario editor-can-undo-page-up [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # scroll the page down and up assume-console [ press page-down press page-up ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # screen should again show page 2 screen-should-contain [ @@ -1092,25 +1092,25 @@ f] scenario editor-can-undo-ctrl-a [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -1122,7 +1122,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1136,25 +1136,25 @@ ghi] scenario editor-can-undo-home [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -1166,7 +1166,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1180,25 +1180,25 @@ ghi] scenario editor-can-undo-ctrl-e [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -1210,7 +1210,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1224,25 +1224,25 @@ ghi] scenario editor-can-undo-end [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - 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 + 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 ] # cursor moves back memory-should-contain [ @@ -1254,7 +1254,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1268,17 +1268,17 @@ ghi] 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: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 + 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 assume-console [ type [abc] left-click 1, 1 type [d] ] - 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 + 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 screen-should-contain [ . . .adbc . @@ -1294,9 +1294,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - 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 + 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 ] # last letter typed is deleted screen-should-contain [ @@ -1314,9 +1314,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - 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 + 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 ] # no change to screen; cursor moves screen-should-contain [ @@ -1334,9 +1334,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - 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 + 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 ] # screen empty screen-should-contain [ @@ -1354,9 +1354,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - 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 + 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 ] # first insert screen-should-contain [ @@ -1374,9 +1374,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - 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 + 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 ] # cursor moves screen-should-contain [ @@ -1394,9 +1394,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - 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 + 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 ] # second insert screen-should-contain [ @@ -1414,11 +1414,11 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ scenario editor-can-undo-multiple-arrows-in-the-same-direction [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # move the cursor assume-console [ left-click 2, 1 @@ -1426,9 +1426,9 @@ ghi] press right-arrow press up-arrow ] - 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 + 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 memory-should-contain [ 3 <- 1 4 <- 3 @@ -1438,9 +1438,9 @@ ghi] press ctrl-z ] run [ - 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 + 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 ] # up-arrow is undone memory-should-contain [ @@ -1452,9 +1452,9 @@ ghi] press ctrl-z ] run [ - 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 + 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 ] # both right-arrows are undone memory-should-contain [ @@ -1468,24 +1468,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # redo assume-console [ press ctrl-y ] run [ - 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 + 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 ] # cursor moves to left-click memory-should-contain [ @@ -1497,7 +1497,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1510,12 +1510,12 @@ ghi] after <handle-redo> [ { - move:address:move-operation <- maybe-convert *op, move:variant + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *move, after-row:offset *cursor-column <- get *move, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *move, after-top-of-screen:offset } ] @@ -1525,24 +1525,24 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-backspace [ # create an editor assume-screen 10/width, 5/height - 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 + 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 # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1552,10 +1552,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1571,10 +1571,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1589,38 +1589,38 @@ scenario editor-can-undo-and-redo-backspace [ # save operation to undo after <backspace-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared: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:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant + op:address:shared:operation <- first *undo + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion previous-coalesce-tag:number <- get *deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace break-unless coalesce? - delete-from:address:address:duplex-list:character <- get-address *deletion, delete-from:offset + delete-from:address:address:shared:duplex-list:character <- get-address *deletion, delete-from:offset *delete-from <- copy *before-cursor - backspaced-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset + backspaced-so-far:address:address:shared:duplex-list:character <- get-address *deletion, deleted-text:offset insert-range backspaced-cell, *backspaced-so-far *backspaced-so-far <- copy backspaced-cell after-row:address:number <- get-address *deletion, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *deletion, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *deletion, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-backspace-operation:label } # if not, create a new operation - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type + deleted-until:address:shared: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 @@ -1629,34 +1629,34 @@ before <backspace-character-end> [ after <handle-undo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion - start2:address:address:duplex-list:character <- get-address *editor, data:offset - anchor:address:duplex-list:character <- get *deletion, delete-from:offset + start2:address:address:shared:duplex-list:character <- get-address *editor, data:offset + anchor:address:shared:duplex-list:character <- get *deletion, delete-from:offset break-unless anchor - deleted:address:duplex-list:character <- get *deletion, deleted-text:offset - old-cursor:address:duplex-list:character <- last deleted + deleted:address:shared:duplex-list:character <- get *deletion, deleted-text:offset + old-cursor:address:shared:duplex-list:character <- last deleted insert-range anchor, deleted # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *before-cursor <- copy old-cursor *cursor-row <- get *deletion, before-row:offset *cursor-column <- get *deletion, before-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *deletion, before-top-of-screen:offset } ] after <handle-redo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion - start:address:duplex-list:character <- get *deletion, delete-from:offset - end:address:duplex-list:character <- get *deletion, delete-until:offset + start:address:shared:duplex-list:character <- get *deletion, delete-from:offset + end:address:shared:duplex-list:character <- get *deletion, delete-until:offset remove-between start, end # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *deletion, after-row:offset *cursor-column <- get *deletion, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *deletion, after-top-of-screen:offset } ] @@ -1666,9 +1666,9 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-delete [ # create an editor assume-screen 10/width, 5/height - 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 + 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 # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1678,15 +1678,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1696,10 +1696,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1715,10 +1715,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1734,10 +1734,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1753,11 +1753,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1773,11 +1773,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1793,11 +1793,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1811,37 +1811,37 @@ scenario editor-can-undo-and-redo-delete [ ] after <delete-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared: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:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant + op:address:shared:operation <- first *undo + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion previous-coalesce-tag:number <- get *deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete break-unless coalesce? - delete-until:address:address:duplex-list:character <- get-address *deletion, delete-until:offset + delete-until:address:address:shared:duplex-list:character <- get-address *deletion, delete-until:offset *delete-until <- next *before-cursor - deleted-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset + deleted-so-far:address:address:shared:duplex-list:character <- get-address *deletion, deleted-text:offset *deleted-so-far <- append *deleted-so-far, deleted-cell after-row:address:number <- get-address *deletion, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *deletion, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *deletion, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-delete-operation:label } # if not, create a new operation - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type + deleted-until:address:shared: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 @@ -1853,16 +1853,16 @@ before <delete-character-end> [ scenario editor-can-undo-and-redo-ctrl-k [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # 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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -1870,8 +1870,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1881,7 +1881,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1890,8 +1890,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1901,7 +1901,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted screen-should-contain [ @@ -1911,8 +1911,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1922,7 +1922,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1934,15 +1934,15 @@ def] ] after <delete-to-end-of-line-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared: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:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset + op:address:shared:operation <- new operation:type + deleted-until:address:shared: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-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -1954,16 +1954,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:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 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 # 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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .c . @@ -1971,8 +1971,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1982,7 +1982,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1991,8 +1991,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -2002,7 +2002,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted screen-should-contain [ @@ -2012,8 +2012,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2023,7 +2023,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2035,15 +2035,15 @@ def] ] after <delete-to-start-of-line-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared: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:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset + op:address:shared:operation <- new operation:type + deleted-until:address:shared: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-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -2053,16 +2053,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: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 + 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 # 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:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .abc . |