From 3d8b137c879c6f5c01588c2dbbb35bc0ec028909 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 17 Sep 2016 13:25:40 -0700 Subject: 3391 - type abbreviations everywhere Well, almost. I can't use them in some places in C++ where I'm just creating a temporary reagent without passing it through transforms. Like in some unit tests. I can't use them in memory-should-contain. And there's one remaining bug: I can't use abbreviations in a couple of places in 075channel.mu. --- sandbox/001-editor.mu | 136 +++--- sandbox/002-typing.mu | 416 +++++++++---------- sandbox/003-shortcuts.mu | 736 ++++++++++++++++----------------- sandbox/004-programming-environment.mu | 150 +++---- sandbox/005-sandbox.mu | 326 +++++++-------- sandbox/006-sandbox-copy.mu | 74 ++-- sandbox/007-sandbox-delete.mu | 78 ++-- sandbox/008-sandbox-edit.mu | 56 +-- sandbox/009-sandbox-test.mu | 56 +-- sandbox/010-sandbox-trace.mu | 74 ++-- sandbox/011-errors.mu | 150 +++---- sandbox/012-editor-undo.mu | 718 ++++++++++++++++---------------- 12 files changed, 1485 insertions(+), 1485 deletions(-) (limited to 'sandbox') diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 83bd5edf..5f6f7361 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -17,7 +17,7 @@ scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ 1:text <- new [abc] - new-editor 1:text, screen:address:screen, 0/left, 10/right + new-editor 1:text, screen:&:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -29,26 +29,26 @@ 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:&:duplex-list:char + top-of-screen:&:duplex-list:char + bottom-of-screen:&:duplex-list:char # location before cursor inside data - before-cursor:address:duplex-list:character + before-cursor:&:duplex-list:char # 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 - left:number - right:number - bottom:number + left:num + right:num + bottom:num # raw screen coordinates of cursor - cursor-row:number - cursor-column:number + cursor-row:num + cursor-column:num ] # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -def new-editor s:text, screen:address:screen, left:number, right:number -> result:address:editor-data, screen:address:screen [ +def new-editor s:text, screen:&:screen, left:num, right:num -> result:&:editor-data, screen:&:screen [ local-scope load-ingredients # no clipping of bounds @@ -61,7 +61,7 @@ def new-editor s:text, screen:address:screen, left:number, right:number -> resul *result <- put *result, cursor-row:offset, 1/top *result <- put *result, cursor-column:offset, left # initialize empty contents - init:address:duplex-list:character <- push 167/§, 0/tail + init:&:duplex-list:char <- push 167/§, 0/tail *result <- put *result, data:offset, init *result <- put *result, top-of-screen:offset, init *result <- put *result, before-cursor:offset, init @@ -71,20 +71,20 @@ def new-editor s:text, screen:address:screen, left:number, right:number -> resul ] -def insert-text editor:address:editor-data, text:text -> editor:address:editor-data [ +def insert-text editor:&:editor-data, text:text -> editor:&:editor-data [ local-scope load-ingredients # early exit if text is empty return-unless text, editor/same-as-ingredient:0 - len:number <- length *text + len:num <- length *text return-unless len, editor/same-as-ingredient:0 - idx:number <- copy 0 + idx:num <- copy 0 # now we can start appending the rest, character by character - curr:address:duplex-list:character <- get *editor, data:offset + curr:&:duplex-list:char <- get *editor, data:offset { - done?:boolean <- greater-or-equal idx, len + done?:bool <- greater-or-equal idx, len break-if done? - c:character <- index *text, idx + c:char <- index *text, idx insert c, curr # next iter curr <- next curr @@ -97,8 +97,8 @@ def insert-text editor:address:editor-data, text:text -> editor:address:editor-d 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:&:editor-data <- new-editor 0/data, screen:&:screen, 2/left, 5/right + 2:editor-data <- copy *1:&:editor-data ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -121,52 +121,52 @@ scenario editor-initializes-without-data [ # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -def render screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +def render screen:&:screen, editor:&:editor-data -> last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ local-scope load-ingredients return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 - left:number <- get *editor, left:offset - screen-height:number <- screen-height screen - right:number <- get *editor, right:offset + left:num <- get *editor, left:offset + screen-height:num <- screen-height screen + right:num <- 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:&:duplex-list:char <- get *editor, top-of-screen:offset + prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr # traversing screen +render-loop-initialization - color:number <- copy 7/white - row:number <- copy 1/top - column:number <- copy left - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + color:num <- copy 7/white + row:num <- copy 1/top + column:num <- copy left + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset screen <- move-cursor screen, row, column { +next-character break-unless curr - off-screen?:boolean <- greater-or-equal row, screen-height + off-screen?:bool <- greater-or-equal row, screen-height break-if off-screen? # update editor-data.before-cursor # Doing so at the start of each iteration ensures it stays one step behind # the current character. { - at-cursor-row?:boolean <- equal row, cursor-row + at-cursor-row?:bool <- equal row, cursor-row break-unless at-cursor-row? - at-cursor?:boolean <- equal column, cursor-column + at-cursor?:bool <- equal column, cursor-column break-unless at-cursor? before-cursor <- copy prev } - c:character <- get *curr, value:offset + c:char <- get *curr, value:offset { # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? # adjust cursor if necessary { - at-cursor-row?:boolean <- equal row, cursor-row + at-cursor-row?:bool <- equal row, cursor-row break-unless at-cursor-row? - left-of-cursor?:boolean <- lesser-than column, cursor-column + left-of-cursor?:bool <- lesser-than column, cursor-column break-unless left-of-cursor? cursor-column <- copy column before-cursor <- prev curr @@ -184,10 +184,10 @@ def render screen:address:screen, editor:address:editor-data -> last-row:number, { # at right? wrap. even if there's only one more letter left; we need # room for clicking on the cursor after it. - at-right?:boolean <- equal column, right + at-right?:bool <- equal column, right break-unless at-right? # print wrap icon - wrap-icon:character <- copy 8617/loop-back-to-left + wrap-icon:char <- copy 8617/loop-back-to-left print screen, wrap-icon, 245/grey column <- copy left row <- add row, 1 @@ -205,11 +205,11 @@ def render screen:address:screen, editor:address:editor-data -> last-row:number, *editor <- put *editor, bottom-of-screen:offset, curr # is cursor to the right of the last line? move to end { - at-cursor-row?:boolean <- equal row, cursor-row - cursor-outside-line?:boolean <- lesser-or-equal column, cursor-column - before-cursor-on-same-line?:boolean <- and at-cursor-row?, cursor-outside-line? - above-cursor-row?:boolean <- lesser-than row, cursor-row - before-cursor?:boolean <- or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool <- equal row, cursor-row + cursor-outside-line?:bool <- lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool <- lesser-than row, cursor-row + before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row? break-unless before-cursor? cursor-row <- copy row cursor-column <- copy column @@ -222,7 +222,7 @@ def render screen:address:screen, editor:address:editor-data -> last-row:number, return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -def clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number -> screen:address:screen [ +def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive @@ -238,14 +238,14 @@ def clear-screen-from screen:address:screen, row:number, column:number, left:num return screen/same-as-ingredient:0 ] -def clear-rest-of-screen screen:address:screen, row:number, left:number, right:number -> screen:address:screen [ +def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ local-scope load-ingredients row <- add row, 1 screen <- move-cursor screen, row, left - screen-height:number <- screen-height screen + screen-height:num <- screen-height screen { - at-bottom-of-screen?:boolean <- greater-or-equal row, screen-height + at-bottom-of-screen?:bool <- greater-or-equal row, screen-height break-if at-bottom-of-screen? screen <- move-cursor screen, row, left clear-line-until screen, right @@ -259,7 +259,7 @@ scenario editor-initially-prints-multiple-lines [ run [ s:text <- new [abc def] - new-editor s:text, screen:address:screen, 0/left, 5/right + new-editor s:text, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -273,7 +273,7 @@ scenario editor-initially-handles-offsets [ assume-screen 5/width, 5/height run [ s:text <- new [abc] - new-editor s:text, screen:address:screen, 1/left, 5/right + new-editor s:text, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -287,7 +287,7 @@ scenario editor-initially-prints-multiple-lines-at-offset [ run [ s:text <- new [abc def] - new-editor s:text, screen:address:screen, 1/left, 5/right + new-editor s:text, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -301,7 +301,7 @@ scenario editor-initially-wraps-long-lines [ assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:address:screen, 0/left, 5/right + new-editor s:text, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -321,7 +321,7 @@ scenario editor-initially-wraps-barely-long-lines [ assume-screen 5/width, 5/height run [ s:text <- new [abcde] - new-editor s:text, screen:address:screen, 0/left, 5/right + new-editor s:text, screen:&:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -343,9 +343,9 @@ scenario editor-initializes-empty-text [ assume-screen 5/width, 5/height run [ 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, 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 + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -366,7 +366,7 @@ scenario render-colors-comments [ s:text <- new [abc # de f] - new-editor s:text, screen:address:screen, 0/left, 5/right + new-editor s:text, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -396,14 +396,14 @@ after [ ] # so far the previous color is all the information we need; that may change -def get-color color:number, c:character -> color:number [ +def get-color color:num, c:char -> color:num [ local-scope load-ingredients - color-is-white?:boolean <- equal color, 7/white + color-is-white?:bool <- equal color, 7/white # if color is white and next character is '#', switch color to blue { break-unless color-is-white? - starting-comment?:boolean <- equal c, 35/# + starting-comment?:bool <- equal c, 35/# break-unless starting-comment? trace 90, [app], [switch color back to blue] color <- copy 12/lightblue @@ -411,9 +411,9 @@ def get-color color:number, c:character -> color:number [ } # if color is blue and next character is newline, switch color to white { - color-is-blue?:boolean <- equal color, 12/lightblue + color-is-blue?:bool <- equal color, 12/lightblue break-unless color-is-blue? - ending-comment?:boolean <- equal c, 10/newline + ending-comment?:bool <- equal c, 10/newline break-unless ending-comment? trace 90, [app], [switch color back to white] color <- copy 7/white @@ -422,16 +422,16 @@ def get-color color:number, c:character -> color:number [ # if color is white (no comments) and next character is '<', switch color to red { break-unless color-is-white? - starting-assignment?:boolean <- equal c, 60/< + starting-assignment?:bool <- equal c, 60/< break-unless starting-assignment? color <- copy 1/red jump +exit:label } # if color is red and next character is space, switch color to white { - color-is-red?:boolean <- equal color, 1/red + color-is-red?:bool <- equal color, 1/red break-unless color-is-red? - ending-assignment?:boolean <- equal c, 32/space + ending-assignment?:bool <- equal c, 32/space break-unless ending-assignment? color <- copy 7/white jump +exit:label @@ -447,7 +447,7 @@ scenario render-colors-assignment [ s:text <- new [abc d <- e f] - new-editor s:text, screen:address:screen, 0/left, 8/right + new-editor s:text, screen:&:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index a30b81ae..7d91a2c9 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -6,26 +6,26 @@ def! main text:text [ local-scope load-ingredients open-console - editor:address:editor-data <- new-editor text, 0/screen, 5/left, 45/right + editor:&:editor-data <- new-editor text, 0/screen, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] -def editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data -> screen:address:screen, console:address:console, editor:address:editor-data [ +def editor-event-loop screen:&:screen, console:&:console, editor:&:editor-data -> screen:&:screen, console:&:console, editor:&:editor-data [ local-scope load-ingredients { # looping over each (keyboard or touch) event as it occurs +next-event - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- 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:&:console, found?:bool, quit?:bool <- read-event console loop-unless found? break-if quit? # only in tests trace 10, [app], [next-event] # 'touch' event - t:touch-event, is-touch?:boolean <- maybe-convert e, touch:variant + t:touch-event, is-touch?:bool <- maybe-convert e, touch:variant { break-unless is-touch? move-cursor-in-editor screen, editor, t @@ -34,7 +34,7 @@ def editor-event-loop screen:address:screen, console:address:console, editor:add # keyboard events { break-if is-touch? - screen, editor, go-render?:boolean <- handle-keyboard-event screen, editor, e + screen, editor, go-render?:bool <- handle-keyboard-event screen, editor, e { break-unless go-render? screen <- editor-render screen, editor @@ -45,23 +45,23 @@ def editor-event-loop screen:address:screen, console:address:console, editor:add ] # process click, return if it was on current editor -def move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event -> in-focus?:boolean, editor:address:editor-data [ +def move-cursor-in-editor screen:&:screen, editor:&:editor-data, t:touch-event -> in-focus?:bool, editor:&:editor-data [ local-scope load-ingredients return-unless editor, 0/false - click-row:number <- get t, row:offset + click-row:num <- get t, row:offset return-unless click-row, 0/false # ignore clicks on 'menu' - click-column:number <- get t, column:offset - left:number <- get *editor, left:offset - too-far-left?:boolean <- lesser-than click-column, left + click-column:num <- get t, column:offset + left:num <- get *editor, left:offset + too-far-left?:bool <- lesser-than click-column, left return-if too-far-left?, 0/false - right:number <- get *editor, right:offset - too-far-right?:boolean <- greater-than click-column, right + right:num <- get *editor, right:offset + too-far-right?:bool <- greater-than click-column, right return-if too-far-right?, 0/false # position cursor editor <- snap-cursor screen, editor, click-row, click-column - undo-coalesce-tag:number <- copy 0/never + undo-coalesce-tag:num <- copy 0/never # gain focus return 1/true @@ -70,50 +70,50 @@ def move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:t # Variant of 'render' that only moves the cursor (coordinates and # before-cursor). If it's past the end of a line, it 'slides' it left. If it's # past the last line it positions at end of last line. -def snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number -> editor:address:editor-data [ +def snap-cursor screen:&:screen, editor:&:editor-data, target-row:num, target-column:num -> editor:&:editor-data [ local-scope load-ingredients return-unless editor - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - screen-height:number <- screen-height screen + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + screen-height:num <- 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:&:duplex-list:char <- get *editor, top-of-screen:offset + prev:&:duplex-list:char <- 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 + row:num <- copy 1/top + column:num <- copy left *editor <- put *editor, cursor-row:offset, target-row - cursor-row:number <- copy target-row + cursor-row:num <- copy target-row *editor <- put *editor, cursor-column:offset, target-column - cursor-column:number <- copy target-column - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + cursor-column:num <- copy target-column + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset { +next-character break-unless curr - off-screen?:boolean <- greater-or-equal row, screen-height + off-screen?:bool <- greater-or-equal row, screen-height break-if off-screen? # update editor-data.before-cursor # Doing so at the start of each iteration ensures it stays one step behind # the current character. { - at-cursor-row?:boolean <- equal row, cursor-row + at-cursor-row?:bool <- equal row, cursor-row break-unless at-cursor-row? - at-cursor?:boolean <- equal column, cursor-column + at-cursor?:bool <- equal column, cursor-column break-unless at-cursor? before-cursor <- copy prev *editor <- put *editor, before-cursor:offset, before-cursor } - c:character <- get *curr, value:offset + c:char <- get *curr, value:offset { # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? # adjust cursor if necessary { - at-cursor-row?:boolean <- equal row, cursor-row + at-cursor-row?:bool <- equal row, cursor-row break-unless at-cursor-row? - left-of-cursor?:boolean <- lesser-than column, cursor-column + left-of-cursor?:bool <- lesser-than column, cursor-column break-unless left-of-cursor? cursor-column <- copy column *editor <- put *editor, cursor-column:offset, cursor-column @@ -130,7 +130,7 @@ def snap-cursor screen:address:screen, editor:address:editor-data, target-row:nu { # at right? wrap. even if there's only one more letter left; we need # room for clicking on the cursor after it. - at-right?:boolean <- equal column, right + at-right?:bool <- equal column, right break-unless at-right? column <- copy left row <- add row, 1 @@ -144,11 +144,11 @@ def snap-cursor screen:address:screen, editor:address:editor-data, target-row:nu } # is cursor to the right of the last line? move to end { - at-cursor-row?:boolean <- equal row, cursor-row - cursor-outside-line?:boolean <- lesser-or-equal column, cursor-column - before-cursor-on-same-line?:boolean <- and at-cursor-row?, cursor-outside-line? - above-cursor-row?:boolean <- lesser-than row, cursor-row - before-cursor?:boolean <- or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool <- equal row, cursor-row + cursor-outside-line?:bool <- lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool <- lesser-than row, cursor-row + before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row? break-unless before-cursor? cursor-row <- copy row *editor <- put *editor, cursor-row:offset, cursor-row @@ -161,39 +161,39 @@ def snap-cursor screen:address:screen, editor:address:editor-data, target-row:nu # Process an event 'e' and try to minimally update the screen. # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. -def handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event -> screen:address:screen, editor:address:editor-data, go-render?:boolean [ +def handle-keyboard-event screen:&:screen, editor:&:editor-data, e:event -> screen:&:screen, editor:&:editor-data, go-render?:bool [ local-scope load-ingredients go-render? <- copy 0/false return-unless editor - screen-width:number <- screen-width screen - screen-height:number <- screen-height screen - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - save-row:number <- copy cursor-row - save-column:number <- copy cursor-column + screen-width:num <- screen-width screen + screen-height:num <- screen-height screen + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + save-row:num <- copy cursor-row + save-column:num <- copy cursor-column # character { - c:character, is-unicode?:boolean <- maybe-convert e, text:variant + c:char, is-unicode?:bool <- maybe-convert e, text:variant break-unless is-unicode? trace 10, [app], [handle-keyboard-event: special character] # exceptions for special characters go here # ignore any other special characters - regular-character?:boolean <- greater-or-equal c, 32/space + regular-character?:bool <- greater-or-equal c, 32/space go-render? <- copy 0/false return-unless regular-character? # otherwise type it in - editor, screen, go-render?:boolean <- insert-at-cursor editor, c, screen + editor, screen, go-render?:bool <- insert-at-cursor editor, c, screen return } # special key to modify the text or move the cursor - k:number, is-keycode?:boolean <- maybe-convert e:event, keycode:variant + k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant assert is-keycode?, [event was of unknown type; neither keyboard nor mouse] # handlers for each special key will go here @@ -201,35 +201,35 @@ def handle-keyboard-event screen:address:screen, editor:address:editor-data, e:e return ] -def insert-at-cursor editor:address:editor-data, c:character, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +def insert-at-cursor editor:&:editor-data, c:char, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset insert c, before-cursor before-cursor <- next before-cursor *editor <- put *editor, before-cursor:offset, before-cursor - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - save-row:number <- copy cursor-row - save-column:number <- copy cursor-column - screen-width:number <- screen-width screen - screen-height:number <- screen-height screen + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + save-row:num <- copy cursor-row + save-column:num <- copy cursor-column + screen-width:num <- screen-width screen + screen-height:num <- screen-height screen # occasionally we'll need to mess with the cursor # but mostly we'll just move the cursor right cursor-column <- add cursor-column, 1 *editor <- put *editor, cursor-column:offset, cursor-column - next:address:duplex-list:character <- next before-cursor + next:&:duplex-list:char <- 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 + at-end?:bool <- equal next, 0/null break-unless at-end? - bottom:number <- subtract screen-height, 1 - at-bottom?:boolean <- equal save-row, bottom - at-right?:boolean <- equal save-column, right - overflow?:boolean <- and at-bottom?, at-right? + bottom:num <- subtract screen-height, 1 + at-bottom?:bool <- equal save-row, bottom + at-right?:bool <- equal save-column, right + overflow?:bool <- and at-bottom?, at-right? break-if overflow? move-cursor screen, save-row, save-column print screen, c @@ -239,20 +239,20 @@ def insert-at-cursor editor:address:editor-data, c:character, screen:address:scr { # not at right margin? print the character and rest of line break-unless next - at-right?:boolean <- greater-or-equal cursor-column, screen-width + at-right?:bool <- greater-or-equal cursor-column, screen-width break-if at-right? - curr:address:duplex-list:character <- copy before-cursor + curr:&:duplex-list:char <- copy before-cursor move-cursor screen, save-row, save-column - curr-column:number <- copy save-column + curr-column:num <- copy save-column { # hit right margin? give up and let caller render go-render? <- copy 1/true - at-right?:boolean <- greater-than curr-column, right + at-right?:bool <- greater-than curr-column, right return-if at-right? break-unless curr # newline? done. - currc:character <- get *curr, value:offset - at-newline?:boolean <- equal currc, 10/newline + currc:char <- get *curr, value:offset + at-newline?:bool <- equal currc, 10/newline break-if at-newline? print screen, currc curr-column <- add curr-column, 1 @@ -267,12 +267,12 @@ def insert-at-cursor editor:address:editor-data, c:character, screen:address:scr ] # helper for tests -def editor-render screen:address:screen, editor:address:editor-data -> screen:address:screen, editor:address:editor-data [ +def editor-render screen:&:screen, editor:&:editor-data -> screen:&:screen, editor:&:editor-data [ local-scope load-ingredients - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - row:number, column:number <- render screen, editor + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + row:num, column:num <- render screen, editor clear-line-until screen, right row <- add row, 1 draw-horizontal screen, row, left, right, 9480/horizontal-dotted @@ -283,11 +283,11 @@ def editor-render screen:address:screen, editor:address:editor-data -> screen:ad scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data assume-console [] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -300,16 +300,16 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -327,15 +327,15 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # last line, to the right of text ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -348,15 +348,15 @@ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # interior line, to the right of text ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -369,15 +369,15 @@ scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -390,17 +390,17 @@ scenario editor-handles-mouse-clicks-outside-column [ assume-screen 10/width, 5/height 1:text <- new [abc] # editor occupies only left half of screen - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -418,17 +418,17 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -440,14 +440,14 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -461,8 +461,8 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # type two letters at different places assume-console [ @@ -471,7 +471,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -485,15 +485,15 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -508,15 +508,15 @@ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -531,15 +531,15 @@ d] scenario editor-inserts-characters-at-cursor-3 [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -554,15 +554,15 @@ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -578,15 +578,15 @@ scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -601,13 +601,13 @@ d] scenario editor-moves-cursor-after-inserting-characters [ assume-screen 10/width, 5/height 1:text <- new [ab] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor-data assume-console [ type [01] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -622,14 +622,14 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ assume-screen 5/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] # no wrap yet screen-should-contain [ @@ -644,7 +644,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # now wrap screen-should-contain [ @@ -661,17 +661,17 @@ scenario editor-wraps-line-on-insert-2 [ assume-screen 10/width, 5/height 1:text <- new [abcdefg defg] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -694,26 +694,26 @@ after [ # if either: # a) we're at the end of the line and at the column of the wrap indicator, or # b) we're not at end of line and just before the column of the wrap indicator - wrap-column:number <- copy right - before-wrap-column:number <- subtract wrap-column, 1 - at-wrap?:boolean <- greater-or-equal cursor-column, wrap-column - just-before-wrap?:boolean <- greater-or-equal cursor-column, before-wrap-column - next:address:duplex-list:character <- next before-cursor + wrap-column:num <- copy right + before-wrap-column:num <- subtract wrap-column, 1 + at-wrap?:bool <- greater-or-equal cursor-column, wrap-column + just-before-wrap?:bool <- greater-or-equal cursor-column, before-wrap-column + next:&:duplex-list:char <- next before-cursor # at end of line? next == 0 || next.value == 10/newline - at-end-of-line?:boolean <- equal next, 0 + at-end-of-line?:bool <- equal next, 0 { break-if at-end-of-line? - next-character:character <- get *next, value:offset + next-character:char <- get *next, value:offset at-end-of-line? <- equal next-character, 10/newline } # break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?)) - move-cursor-to-next-line?:boolean <- copy 0/false + move-cursor-to-next-line?:bool <- copy 0/false { break-if at-end-of-line? move-cursor-to-next-line? <- copy just-before-wrap? # if we're moving the cursor because it's in the middle of a wrapping # line, adjust it to left-most column - potential-new-cursor-column:number <- copy left + potential-new-cursor-column:num <- copy left } { break-unless at-end-of-line? @@ -721,7 +721,7 @@ after [ # if we're moving the cursor because it's at the end of a wrapping line, # adjust it to one past the left-most column to make room for the # newly-inserted wrap-indicator - potential-new-cursor-column:number <- add left, 1/make-room-for-wrap-indicator + potential-new-cursor-column:num <- add left, 1/make-room-for-wrap-indicator } break-unless move-cursor-to-next-line? cursor-column <- copy potential-new-cursor-column @@ -730,7 +730,7 @@ after [ *editor <- put *editor, cursor-row:offset, cursor-row # if we're out of the screen, scroll down { - below-screen?:boolean <- greater-or-equal cursor-row, screen-height + below-screen?:bool <- greater-or-equal cursor-row, screen-height break-unless below-screen? } go-render? <- copy 1/true @@ -741,15 +741,15 @@ after [ scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ assume-screen 10/width, 5/height 1:text <- new [abcde] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -770,7 +770,7 @@ scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ # create an editor containing two lines contents:text <- new [abc xyz] - 1:address:editor-data/raw <- new-editor contents, screen, 0/left, 5/right + 1:&:editor-data/raw <- new-editor contents, screen, 0/left, 5/right screen-should-contain [ . . .abc . @@ -782,7 +782,7 @@ xyz] type [de] # trigger wrap ] run [ - editor-event-loop screen:address:screen, console:address:console, 1:address:editor-data/raw + editor-event-loop screen:&:screen, console:&:console, 1:&:editor-data/raw ] screen-should-contain [ . . @@ -796,15 +796,15 @@ xyz] scenario editor-wraps-cursor-to-left-margin [ assume-screen 10/width, 5/height 1:text <- new [abcde] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 2/left, 7/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 2/left, 7/right assume-console [ left-click 1, 5 # line is full; no wrap icon yet type [01] ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -822,7 +822,7 @@ scenario editor-wraps-cursor-to-left-margin [ # if newline, move cursor to start of next line, and maybe align indent with previous line container editor-data [ - indent?:boolean + indent?:bool ] after [ @@ -832,13 +832,13 @@ after [ scenario editor-moves-cursor-down-after-inserting-newline [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -851,7 +851,7 @@ scenario editor-moves-cursor-down-after-inserting-newline [ after [ { - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? editor <- insert-new-line-and-indent editor, screen @@ -861,15 +861,15 @@ after [ } ] -def insert-new-line-and-indent editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +def insert-new-line-and-indent editor:&:editor-data, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool [ local-scope load-ingredients - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - screen-height:number <- screen-height screen + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + screen-height:num <- screen-height screen # insert newline insert 10/newline, before-cursor before-cursor <- next before-cursor @@ -880,23 +880,23 @@ def insert-new-line-and-indent editor:address:editor-data, screen:address:screen *editor <- put *editor, cursor-column:offset, cursor-column # maybe scroll { - below-screen?:boolean <- greater-or-equal cursor-row, screen-height # must be equal, never greater + below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal, never greater break-unless below-screen? go-render? <- copy 1/true cursor-row <- subtract cursor-row, 1 # bring back into screen range *editor <- put *editor, cursor-row:offset, cursor-row } # indent if necessary - indent?:boolean <- get *editor, indent?:offset + indent?:bool <- get *editor, indent?:offset return-unless indent? - d:address:duplex-list:character <- get *editor, data:offset - end-of-previous-line:address:duplex-list:character <- prev before-cursor - indent:number <- line-indent end-of-previous-line, d - i:number <- copy 0 + d:&:duplex-list:char <- get *editor, data:offset + end-of-previous-line:&:duplex-list:char <- prev before-cursor + indent:num <- line-indent end-of-previous-line, d + i:num <- copy 0 { - indent-done?:boolean <- greater-or-equal i, indent + indent-done?:bool <- greater-or-equal i, indent break-if indent-done? - editor, screen, go-render?:boolean <- insert-at-cursor editor, 32/space, screen + editor, screen, go-render?:bool <- insert-at-cursor editor, 32/space, screen i <- add i, 1 loop } @@ -904,23 +904,23 @@ def insert-new-line-and-indent editor:address:editor-data, screen:address:screen # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the number of spaces at the start of the line containing 'curr'. -def line-indent curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ local-scope load-ingredients - result:number <- copy 0 + result:num <- copy 0 return-unless curr - at-start?:boolean <- equal curr, start + at-start?:bool <- equal curr, start return-if at-start? { curr <- prev curr break-unless curr - at-start?:boolean <- equal curr, start + at-start?:bool <- equal curr, start break-if at-start? - c:character <- get *curr, value:offset - at-newline?:boolean <- equal c, 10/newline + c:char <- get *curr, value:offset + at-newline?:bool <- equal c, 10/newline break-if at-newline? # if c is a space, increment result - is-space?:boolean <- equal c, 32/space + is-space?:bool <- equal c, 32/space { break-unless is-space? result <- add result, 1 @@ -937,13 +937,13 @@ def line-indent curr:address:duplex-list:character, start:address:duplex-list:ch scenario editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 1/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -957,7 +957,7 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ scenario editor-clears-previous-line-completely-after-inserting-newline [ assume-screen 10/width, 5/height 1:text <- new [abcde] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right assume-console [ press enter ] @@ -969,7 +969,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # line should be fully cleared screen-should-contain [ @@ -986,7 +986,7 @@ scenario editor-inserts-indent-after-newline [ 1:text <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -994,9 +994,9 @@ ef] ] ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1010,7 +1010,7 @@ scenario editor-skips-indent-around-paste [ 1:text <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -1019,9 +1019,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1032,7 +1032,7 @@ ef] after [ { - paste-start?:boolean <- equal k, 65507/paste-start + paste-start?:bool <- equal k, 65507/paste-start break-unless paste-start? *editor <- put *editor, indent?:offset, 0/false go-render? <- copy 1/true @@ -1042,7 +1042,7 @@ after [ after [ { - paste-end?:boolean <- equal k, 65506/paste-end + paste-end?:bool <- equal k, 65506/paste-end break-unless paste-end? *editor <- put *editor, indent?:offset, 1/true go-render? <- copy 1/true @@ -1052,28 +1052,28 @@ after [ ## helpers -def draw-horizontal screen:address:screen, row:number, x:number, right:number -> screen:address:screen [ +def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [ local-scope load-ingredients - style:character, style-found?:boolean <- next-ingredient + style:char, style-found?:bool <- next-ingredient { break-if style-found? style <- copy 9472/horizontal } - color:number, color-found?:boolean <- next-ingredient + color:num, color-found?:bool <- next-ingredient { # default color to white break-if color-found? color <- copy 245/grey } - bg-color:number, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { break-if bg-color-found? bg-color <- copy 0/black } screen <- move-cursor screen, row, x { - continue?:boolean <- lesser-or-equal x, right # right is inclusive, to match editor-data semantics + continue?:bool <- lesser-or-equal x, right # right is inclusive, to match editor-data semantics break-unless continue? print screen, style, color, bg-color x <- add x, 1 diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index 05d42128..9ee6855b 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -9,12 +9,12 @@ scenario editor-inserts-two-spaces-on-tab [ # just one character in final line 1:text <- new [ab cd] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right + 2:&:editor-data <- new-editor 1:text, screen:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -25,11 +25,11 @@ cd] after [ { - tab?:boolean <- equal c, 9/tab + tab?:bool <- equal c, 9/tab break-unless tab? - editor, screen, go-render?:boolean <- insert-at-cursor editor, 32/space, screen - editor, screen, go-render?:boolean <- insert-at-cursor editor, 32/space, screen + editor, screen, go-render?:bool <- insert-at-cursor editor, 32/space, screen + editor, screen, go-render?:bool <- insert-at-cursor editor, 32/space, screen go-render? <- copy 1/true return @@ -41,17 +41,17 @@ after [ scenario editor-handles-backspace-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -68,10 +68,10 @@ scenario editor-handles-backspace-key [ after [ { - delete-previous-character?:boolean <- equal c, 8/backspace + delete-previous-character?:bool <- equal c, 8/backspace break-unless delete-previous-character? - editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character <- delete-before-cursor editor, screen + editor, screen, go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen return } @@ -80,42 +80,42 @@ after [ # return values: # go-render? - whether caller needs to update the screen # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. -def delete-before-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, backspaced-cell:address:duplex-list:character [ +def delete-before-cursor editor:&:editor-data, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool, backspaced-cell:&:duplex-list:char [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + data:&:duplex-list:char <- get *editor, data:offset # if at start of text (before-cursor at § sentinel), return - prev:address:duplex-list:character <- prev before-cursor + prev:&:duplex-list:char <- prev before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted return-unless prev go-render? <- copy 1/true trace 10, [app], [delete-before-cursor] - original-row:number <- get *editor, cursor-row:offset + original-row:num <- get *editor, cursor-row:offset editor <- move-cursor-coordinates-left editor - backspaced-cell:address:duplex-list:character <- copy before-cursor + backspaced-cell:&:duplex-list:char <- copy before-cursor data <- remove before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/before-cursor before-cursor <- copy prev *editor <- put *editor, before-cursor:offset, before-cursor - screen-width:number <- screen-width screen - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset + screen-width:num <- screen-width screen + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset # did we just backspace over a newline? - same-row?:boolean <- equal cursor-row, original-row + same-row?:bool <- equal cursor-row, original-row return-unless same-row? - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - curr:address:duplex-list:character <- next before-cursor + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + curr:&:duplex-list:char <- next before-cursor screen <- move-cursor screen, cursor-row, cursor-column - curr-column:number <- copy cursor-column + curr-column:num <- copy cursor-column { # hit right margin? give up and let caller render - at-right?:boolean <- greater-or-equal curr-column, right + at-right?:bool <- greater-or-equal curr-column, right return-if at-right? break-unless curr # newline? done. - currc:character <- get *curr, value:offset - at-newline?:boolean <- equal currc, 10/newline + currc:char <- get *curr, value:offset + at-newline?:bool <- equal currc, 10/newline break-if at-newline? screen <- print screen, currc curr-column <- add curr-column, 1 @@ -123,21 +123,21 @@ def delete-before-cursor editor:address:editor-data, screen:address:screen -> ed loop } # we're guaranteed not to be at the right margin - space:character <- copy 32/space + space:char <- copy 32/space screen <- print screen, space go-render? <- copy 0/false ] -def move-cursor-coordinates-left editor:address:editor-data -> editor:address:editor-data [ +def move-cursor-coordinates-left editor:&:editor-data -> editor:&:editor-data [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - left:number <- get *editor, left:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + left:num <- get *editor, left:offset # if not at left margin, move one character left { - at-left-margin?:boolean <- equal cursor-column, left + at-left-margin?:bool <- equal cursor-column, left break-if at-left-margin? trace 10, [app], [decrementing cursor column] cursor-column <- subtract cursor-column, 1 @@ -145,7 +145,7 @@ def move-cursor-coordinates-left editor:address:editor-data -> editor:address:ed return } # if at left margin, we must move to previous row: - top-of-screen?:boolean <- equal cursor-row, 1 # exclude menu bar + top-of-screen?:bool <- equal cursor-row, 1 # exclude menu bar { break-if top-of-screen? cursor-row <- subtract cursor-row, 1 @@ -157,19 +157,19 @@ def move-cursor-coordinates-left editor:address:editor-data -> editor:address:ed } { # case 1: if previous character was newline, figure out how long the previous line is - previous-character:character <- get *before-cursor, value:offset - previous-character-is-newline?:boolean <- equal previous-character, 10/newline + previous-character:char <- get *before-cursor, value:offset + previous-character-is-newline?:bool <- equal previous-character, 10/newline 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 - end-of-line:number <- previous-line-length before-cursor, d - right:number <- get *editor, right:offset - width:number <- subtract right, left - wrap?:boolean <- greater-than end-of-line, width + d:&:duplex-list:char <- get *editor, data:offset + end-of-line:num <- previous-line-length before-cursor, d + right:num <- get *editor, right:offset + width:num <- subtract right, left + wrap?:bool <- greater-than end-of-line, width { break-unless wrap? - _, column-offset:number <- divide-with-remainder end-of-line, width + _, column-offset:num <- divide-with-remainder end-of-line, width cursor-column <- add left, column-offset *editor <- put *editor, cursor-column:offset, cursor-column } @@ -182,27 +182,27 @@ def move-cursor-coordinates-left editor:address:editor-data -> editor:address:ed } # case 2: if previous-character was not newline, we're just at a wrapped line trace 10, [app], [wrapping to previous line] - right:number <- get *editor, right:offset + right:num <- get *editor, right:offset cursor-column <- subtract right, 1 # leave room for wrap icon *editor <- put *editor, cursor-column:offset, cursor-column ] # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -def previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ local-scope load-ingredients - result:number <- copy 0 + result:num <- copy 0 return-unless curr - at-start?:boolean <- equal curr, start + at-start?:bool <- equal curr, start return-if at-start? { curr <- prev curr break-unless curr - at-start?:boolean <- equal curr, start + at-start?:bool <- equal curr, start break-if at-start? - c:character <- get *curr, value:offset - at-newline?:boolean <- equal c, 10/newline + c:char <- get *curr, value:offset + at-newline?:bool <- equal c, 10/newline break-if at-newline? result <- add result, 1 loop @@ -214,15 +214,15 @@ scenario editor-clears-last-line-on-backspace [ # just one character in final line 1:text <- new [ab cd] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right assume-console [ left-click 2, 0 # cursor at only character in final line press backspace ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -241,8 +241,8 @@ scenario editor-joins-and-wraps-lines-on-backspace [ # initialize editor with two long-ish but non-wrapping lines 1:text <- new [abc def ghi jkl] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -250,7 +250,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # resulting single line should wrap correctly screen-should-contain [ @@ -266,8 +266,8 @@ scenario editor-wraps-long-lines-on-backspace [ assume-screen 10/width, 5/height # initialize editor in part of the screen with a long line 1:text <- new [abc def ghij] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 8/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 8/right + editor-render screen, 2:&:editor-data # confirm that it wraps screen-should-contain [ . . @@ -282,7 +282,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -299,14 +299,14 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -320,7 +320,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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -333,44 +333,44 @@ scenario editor-handles-delete-key [ after [ { - delete-next-character?:boolean <- equal k, 65522/delete + delete-next-character?:bool <- equal k, 65522/delete break-unless delete-next-character? - editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character <- delete-at-cursor editor, screen + editor, screen, go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen return } ] -def delete-at-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, deleted-cell:address:duplex-list:character [ +def delete-at-cursor editor:&:editor-data, screen:&:screen -> editor:&:editor-data, screen:&:screen, go-render?:bool, deleted-cell:&:duplex-list:char [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset - deleted-cell:address:duplex-list:character <- next before-cursor + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + data:&:duplex-list:char <- get *editor, data:offset + deleted-cell:&:duplex-list:char <- next before-cursor go-render? <- copy 0/false return-unless deleted-cell - currc:character <- get *deleted-cell, value:offset + currc:char <- get *deleted-cell, value:offset data <- remove deleted-cell, data - deleted-newline?:boolean <- equal currc, 10/newline + deleted-newline?:bool <- equal currc, 10/newline go-render? <- copy 1/true return-if deleted-newline? # wasn't a newline? render rest of line - curr:address:duplex-list:character <- next before-cursor # refresh after remove above - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset + curr:&:duplex-list:char <- next before-cursor # refresh after remove above + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column - curr-column:number <- copy cursor-column - screen-width:number <- screen-width screen + curr-column:num <- copy cursor-column + screen-width:num <- screen-width screen { # hit right margin? give up and let caller render - at-right?:boolean <- greater-or-equal curr-column, screen-width + at-right?:bool <- greater-or-equal curr-column, screen-width go-render? <- copy 1/true return-if at-right? break-unless curr # newline? done. - currc:character <- get *curr, value:offset - at-newline?:boolean <- equal currc, 10/newline + currc:char <- get *curr, value:offset + at-newline?:bool <- equal currc, 10/newline break-if at-newline? screen <- print screen, currc curr-column <- add curr-column, 1 @@ -378,7 +378,7 @@ def delete-at-cursor editor:address:editor-data, screen:address:screen -> editor loop } # we're guaranteed not to be at the right margin - space:character <- copy 32/space + space:char <- copy 32/space screen <- print screen, space go-render? <- copy 0/false ] @@ -388,15 +388,15 @@ def delete-at-cursor editor:address:editor-data, screen:address:screen -> editor scenario editor-moves-cursor-right-with-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -409,41 +409,41 @@ scenario editor-moves-cursor-right-with-key [ after [ { - move-to-next-character?:boolean <- equal k, 65514/right-arrow + move-to-next-character?:bool <- 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:&:duplex-list:char <- next before-cursor break-unless next-cursor # scan to next character before-cursor <- copy next-cursor *editor <- put *editor, before-cursor:offset, before-cursor - editor, go-render?:boolean <- move-cursor-coordinates-right editor, screen-height + editor, go-render?:bool <- move-cursor-coordinates-right editor, screen-height screen <- move-cursor screen, cursor-row, cursor-column - undo-coalesce-tag:number <- copy 2/right-arrow + undo-coalesce-tag:num <- copy 2/right-arrow return } ] -def move-cursor-coordinates-right editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +def move-cursor-coordinates-right editor:&:editor-data, screen-height:num -> editor:&:editor-data, go-render?:bool [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor before-cursor:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset + before-cursor:&:duplex-list:char <- get *editor before-cursor:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset # if crossed a newline, move cursor to start of next row { - old-cursor-character:character <- get *before-cursor, value:offset - was-at-newline?:boolean <- equal old-cursor-character, 10/newline + old-cursor-character:char <- get *before-cursor, value:offset + was-at-newline?:bool <- equal old-cursor-character, 10/newline break-unless was-at-newline? cursor-row <- add cursor-row, 1 *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- copy left *editor <- put *editor, cursor-column:offset, cursor-column - below-screen?:boolean <- greater-or-equal cursor-row, screen-height # must be equal + below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal go-render? <- copy 0/false return-unless below-screen? cursor-row <- subtract cursor-row, 1 # bring back into screen range @@ -454,20 +454,20 @@ def move-cursor-coordinates-right editor:address:editor-data, screen-height:numb # if the line wraps, move cursor to start of next row { # if we're at the column just before the wrap indicator - wrap-column:number <- subtract right, 1 - at-wrap?:boolean <- equal cursor-column, wrap-column + wrap-column:num <- subtract right, 1 + at-wrap?:bool <- 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:&:duplex-list:char <- next before-cursor break-unless next - next-character:character <- get *next, value:offset - newline?:boolean <- equal next-character, 10/newline + next-character:char <- get *next, value:offset + newline?:bool <- equal next-character, 10/newline break-if newline? cursor-row <- add cursor-row, 1 *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- copy left *editor <- put *editor, cursor-column:offset, cursor-column - below-screen?:boolean <- greater-or-equal cursor-row, screen-height # must be equal + below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal return-unless below-screen?, editor/same-as-ingredient:0, 0/no-more-render cursor-row <- subtract cursor-row, 1 # bring back into screen range *editor <- put *editor, cursor-row:offset, cursor-row @@ -484,8 +484,8 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -495,7 +495,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -503,7 +503,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -519,8 +519,8 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 1/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 1/left, 10/right + editor-render screen, 2:&:editor-data assume-console [ press right-arrow press right-arrow @@ -529,7 +529,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -543,17 +543,17 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen 10/width, 5/height 1:text <- new [abcdef] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -573,8 +573,8 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen 10/width, 5/height # line just barely wrapping 1:text <- new [abcde] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor-data $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -582,9 +582,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -595,9 +595,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -609,17 +609,17 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ assume-screen 10/width, 5/height 1:text <- new [abcdef] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 1/left, 6/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 1/left, 6/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -639,8 +639,8 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen 10/width, 5/height 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -649,7 +649,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # new character should be in next line screen-should-contain [ @@ -669,8 +669,8 @@ d] scenario editor-moves-cursor-left-with-key [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace assume-console [ left-click 1, 2 @@ -678,7 +678,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -691,18 +691,18 @@ scenario editor-moves-cursor-left-with-key [ after [ { - move-to-previous-character?:boolean <- equal k, 65515/left-arrow + move-to-previous-character?:bool <- equal k, 65515/left-arrow break-unless move-to-previous-character? trace 10, [app], [left arrow] # if not at start of text (before-cursor at § sentinel) - prev:address:duplex-list:character <- prev before-cursor + prev:&:duplex-list:char <- prev before-cursor go-render? <- copy 0/false return-unless prev editor <- move-cursor-coordinates-left editor before-cursor <- copy prev *editor <- put *editor, before-cursor:offset, before-cursor - undo-coalesce-tag:number <- copy 1/left-arrow + undo-coalesce-tag:num <- copy 1/left-arrow return } @@ -713,8 +713,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ # initialize editor with two lines 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -722,9 +722,9 @@ d] press left-arrow ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -739,8 +739,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 1:text <- new [abc def g] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -750,7 +750,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -767,8 +767,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 1:text <- new [abc def g] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -777,7 +777,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # left-arrow should have had no effect screen-should-contain [ @@ -796,8 +796,8 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 1:text <- new [abc d] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # position cursor right after empty line assume-console [ @@ -806,7 +806,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -822,8 +822,8 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with a wrapping line 1:text <- new [abcdef] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor-data $clear-trace screen-should-contain [ . . @@ -838,9 +838,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -854,8 +854,8 @@ scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ # initialize editor with a wrapping line followed by a second line 1:text <- new [abcdef g] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor-data $clear-trace screen-should-contain [ . . @@ -870,9 +870,9 @@ g] 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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 # previous row @@ -886,8 +886,8 @@ scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ # initialize editor with a line on the verge of wrapping, followed by a second line 1:text <- new [abcd e] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 5/right + editor-render screen, 2:&:editor-data $clear-trace screen-should-contain [ . . @@ -902,9 +902,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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -921,17 +921,17 @@ scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -942,7 +942,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -955,46 +955,46 @@ def] after [ { - move-to-previous-line?:boolean <- equal k, 65517/up-arrow + move-to-previous-line?:bool <- equal k, 65517/up-arrow break-unless move-to-previous-line? editor, go-render? <- move-to-previous-line editor - undo-coalesce-tag:number <- copy 3/up-arrow + undo-coalesce-tag:num <- copy 3/up-arrow return } ] -def move-to-previous-line editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +def move-to-previous-line editor:&:editor-data -> editor:&:editor-data, go-render?:bool [ local-scope load-ingredients - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - already-at-top?:boolean <- lesser-or-equal cursor-row, 1/top + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + already-at-top?:bool <- lesser-or-equal cursor-row, 1/top { # if cursor not at top, move it break-if already-at-top? # 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:&:duplex-list:char <- copy before-cursor { - old:address:duplex-list:character <- copy curr - c2:character <- get *curr, value:offset - at-newline?:boolean <- equal c2, 10/newline + old:&:duplex-list:char <- copy curr + c2:char <- get *curr, value:offset + at-newline?:bool <- equal c2, 10/newline break-if at-newline? - curr:address:duplex-list:character <- before-previous-line curr, editor - no-motion?:boolean <- equal curr, old + curr:&:duplex-list:char <- before-previous-line curr, editor + no-motion?:bool <- equal curr, old go-render? <- copy 0/false return-if no-motion? } { old <- copy curr curr <- before-previous-line curr, editor - no-motion?:boolean <- equal curr, old + no-motion?:bool <- equal curr, old go-render? <- copy 0/false return-if no-motion? } @@ -1003,16 +1003,16 @@ def move-to-previous-line editor:address:editor-data -> editor:address:editor-da cursor-row <- subtract cursor-row, 1 *editor <- put *editor, cursor-row:offset, cursor-row # scan ahead to right column or until end of line - target-column:number <- copy cursor-column + target-column:num <- copy cursor-column cursor-column <- copy left *editor <- put *editor, cursor-column:offset, cursor-column { - done?:boolean <- greater-or-equal cursor-column, target-column + done?:bool <- greater-or-equal cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next before-cursor + curr:&:duplex-list:char <- next before-cursor break-unless curr - currc:character <- get *curr, value:offset - at-newline?:boolean <- equal currc, 10/newline + currc:char <- get *curr, value:offset + at-newline?:bool <- equal currc, 10/newline break-if at-newline? # before-cursor <- copy curr @@ -1036,17 +1036,17 @@ scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height 1:text <- new [ab def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1057,7 +1057,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1072,17 +1072,17 @@ scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height 1:text <- new [ def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1093,7 +1093,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1110,8 +1110,8 @@ scenario editor-moves-to-previous-line-from-left-margin [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1119,9 +1119,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1132,7 +1132,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1149,17 +1149,17 @@ scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1171,7 +1171,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1184,48 +1184,48 @@ def] after [ { - move-to-next-line?:boolean <- equal k, 65516/down-arrow + move-to-next-line?:bool <- equal k, 65516/down-arrow break-unless move-to-next-line? editor <- move-to-next-line editor, screen-height - undo-coalesce-tag:number <- copy 4/down-arrow + undo-coalesce-tag:num <- copy 4/down-arrow return } ] -def move-to-next-line editor:address:editor-data, screen-height:number -> editor:address:editor-data [ +def move-to-next-line editor:&:editor-data, screen-height:num -> editor:&:editor-data [ local-scope load-ingredients - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - left:number <- get *editor, left:offset - right:number <- get *editor, right:offset - last-line:number <- subtract screen-height, 1 - already-at-bottom?:boolean <- greater-or-equal cursor-row, last-line + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + last-line:num <- subtract screen-height, 1 + already-at-bottom?:bool <- greater-or-equal cursor-row, last-line # if cursor not at bottom return-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 + max:num <- subtract right, left + next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max # already at end of buffer? do nothing - no-motion?:boolean <- equal next-line, before-cursor + no-motion?:bool <- equal next-line, before-cursor return-if no-motion? cursor-row <- add cursor-row, 1 *editor <- put *editor, cursor-row:offset, cursor-row before-cursor <- copy next-line *editor <- put *editor, before-cursor:offset, before-cursor - target-column:number <- copy cursor-column + target-column:num <- copy cursor-column cursor-column <- copy left *editor <- put *editor, cursor-column:offset, cursor-column { - done?:boolean <- greater-or-equal cursor-column, target-column + done?:bool <- greater-or-equal cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next before-cursor + curr:&:duplex-list:char <- next before-cursor break-unless curr - currc:character <- get *curr, value:offset - at-newline?:boolean <- equal currc, 10/newline + currc:char <- get *curr, value:offset + at-newline?:bool <- equal currc, 10/newline break-if at-newline? # before-cursor <- copy curr @@ -1240,17 +1240,17 @@ scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height 1:text <- new [abc de] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1261,7 +1261,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1278,8 +1278,8 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1287,9 +1287,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1301,11 +1301,11 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ after [ { - move-to-start-of-line?:boolean <- equal c, 1/ctrl-a + move-to-start-of-line?:bool <- equal c, 1/ctrl-a break-unless move-to-start-of-line? move-to-start-of-line editor - undo-coalesce-tag:number <- copy 0/never + undo-coalesce-tag:num <- copy 0/never go-render? <- copy 0/false return @@ -1314,33 +1314,33 @@ after [ after [ { - move-to-start-of-line?:boolean <- equal k, 65521/home + move-to-start-of-line?:bool <- equal k, 65521/home break-unless move-to-start-of-line? move-to-start-of-line editor - undo-coalesce-tag:number <- copy 0/never + undo-coalesce-tag:num <- copy 0/never go-render? <- copy 0/false return } ] -def move-to-start-of-line editor:address:editor-data -> editor:address:editor-data [ +def move-to-start-of-line editor:&:editor-data -> editor:&:editor-data [ local-scope load-ingredients # update cursor column - left:number <- get *editor, left:offset - cursor-column:number <- copy left + left:num <- get *editor, left:offset + cursor-column:num <- copy left *editor <- put *editor, cursor-column:offset, cursor-column # update before-cursor - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - init:address:duplex-list:character <- get *editor, data:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + init:&:duplex-list:char <- get *editor, data:offset # while not at start of line, move { - at-start-of-text?:boolean <- equal before-cursor, init + at-start-of-text?:bool <- equal before-cursor, init break-if at-start-of-text? - prev:character <- get *before-cursor, value:offset - at-start-of-line?:boolean <- equal prev, 10/newline + prev:char <- get *before-cursor, value:offset + at-start-of-line?:bool <- equal prev, 10/newline break-if at-start-of-line? before-cursor <- prev before-cursor *editor <- put *editor, before-cursor:offset, before-cursor @@ -1353,8 +1353,8 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1362,9 +1362,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1378,7 +1378,7 @@ scenario editor-moves-to-start-of-line-with-home [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1386,9 +1386,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1402,8 +1402,8 @@ scenario editor-moves-to-start-of-line-with-home-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1411,9 +1411,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1429,8 +1429,8 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1438,9 +1438,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1453,9 +1453,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1473,11 +1473,11 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ after [ { - move-to-end-of-line?:boolean <- equal c, 5/ctrl-e + move-to-end-of-line?:bool <- equal c, 5/ctrl-e break-unless move-to-end-of-line? move-to-end-of-line editor - undo-coalesce-tag:number <- copy 0/never + undo-coalesce-tag:num <- copy 0/never go-render? <- copy 0/false return @@ -1486,28 +1486,28 @@ after [ after [ { - move-to-end-of-line?:boolean <- equal k, 65520/end + move-to-end-of-line?:bool <- equal k, 65520/end break-unless move-to-end-of-line? move-to-end-of-line editor - undo-coalesce-tag:number <- copy 0/never + undo-coalesce-tag:num <- copy 0/never go-render? <- copy 0/false return } ] -def move-to-end-of-line editor:address:editor-data -> editor:address:editor-data [ +def move-to-end-of-line editor:&:editor-data -> editor:&:editor-data [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - cursor-column:number <- get *editor, cursor-column:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + cursor-column:num <- get *editor, cursor-column:offset # while not at start of line, move { - next:address:duplex-list:character <- next before-cursor + next:&:duplex-list:char <- next before-cursor break-unless next # end of text - nextc:character <- get *next, value:offset - at-end-of-line?:boolean <- equal nextc, 10/newline + nextc:char <- get *next, value:offset + at-end-of-line?:bool <- equal nextc, 10/newline break-if at-end-of-line? before-cursor <- copy next *editor <- put *editor, before-cursor:offset, before-cursor @@ -1521,8 +1521,8 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1530,9 +1530,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 4:num <- get *2:&:editor-data, cursor-row:offset + 5:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1546,8 +1546,8 @@ scenario editor-moves-to-end-of-line-with-end [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on first line, press 'end' assume-console [ @@ -1555,9 +1555,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1571,8 +1571,8 @@ scenario editor-moves-to-end-of-line-with-end-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1580,9 +1580,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1598,14 +1598,14 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start on second line, press ctrl-u assume-console [ left-click 2, 2 press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1619,41 +1619,41 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u [ after [ { - delete-to-start-of-line?:boolean <- equal c, 21/ctrl-u + delete-to-start-of-line?:bool <- equal c, 21/ctrl-u break-unless delete-to-start-of-line? - deleted-cells:address:duplex-list:character <- delete-to-start-of-line editor + deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor go-render? <- copy 1/true return } ] -def delete-to-start-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +def delete-to-start-of-line editor:&:editor-data -> result:&:duplex-list:char, editor:&:editor-data [ local-scope load-ingredients # compute range to delete - init:address:duplex-list:character <- get *editor, data:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - start:address:duplex-list:character <- copy before-cursor - end:address:duplex-list:character <- next before-cursor + init:&:duplex-list:char <- get *editor, data:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + start:&:duplex-list:char <- copy before-cursor + end:&:duplex-list:char <- next before-cursor { - at-start-of-text?:boolean <- equal start, init + at-start-of-text?:bool <- equal start, init break-if at-start-of-text? - curr:character <- get *start, value:offset - at-start-of-line?:boolean <- equal curr, 10/newline + curr:char <- get *start, value:offset + at-start-of-line?:bool <- equal curr, 10/newline break-if at-start-of-line? start <- prev start assert start, [delete-to-start-of-line tried to move before start of text] loop } # snip it out - result:address:duplex-list:character <- next start + result:&:duplex-list:char <- next start remove-between start, end # adjust cursor before-cursor <- copy start *editor <- put *editor, before-cursor:offset, before-cursor - left:number <- get *editor, left:offset + left:num <- get *editor, left:offset *editor <- put *editor, cursor-column:offset, left ] @@ -1661,14 +1661,14 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start on first line (no newline before), press ctrl-u assume-console [ left-click 1, 2 press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1684,14 +1684,14 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start past end of line, press ctrl-u assume-console [ left-click 1, 3 press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1707,14 +1707,14 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start past end of final line, press ctrl-u assume-console [ left-click 2, 3 press ctrl-u ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1732,14 +1732,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start on first line, press ctrl-k assume-console [ left-click 1, 1 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1753,27 +1753,27 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k [ after [ { - delete-to-end-of-line?:boolean <- equal c, 11/ctrl-k + delete-to-end-of-line?:bool <- equal c, 11/ctrl-k break-unless delete-to-end-of-line? - deleted-cells:address:duplex-list:character <- delete-to-end-of-line editor + deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor go-render? <- copy 1/true return } ] -def delete-to-end-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +def delete-to-end-of-line editor:&:editor-data -> result:&:duplex-list:char, editor:&: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:&:duplex-list:char <- get *editor, before-cursor:offset + end:&:duplex-list:char <- next start { - at-end-of-text?:boolean <- equal end, 0/null + at-end-of-text?:bool <- equal end, 0/null break-if at-end-of-text? - curr:character <- get *end, value:offset - at-end-of-line?:boolean <- equal curr, 10/newline + curr:char <- get *end, value:offset + at-end-of-line?:bool <- equal curr, 10/newline break-if at-end-of-line? end <- next end loop @@ -1787,14 +1787,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start on second line (no newline after), press ctrl-k assume-console [ left-click 2, 1 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1810,14 +1810,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes just last character screen-should-contain [ @@ -1833,14 +1833,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1856,14 +1856,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes just the final character screen-should-contain [ @@ -1879,14 +1879,14 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen 10/width, 5/height 1:text <- new [123 456] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1901,25 +1901,25 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline # beware: never return null pointer. -def before-start-of-next-line original:address:duplex-list:character, max:number -> curr:address:duplex-list:character [ +def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ local-scope load-ingredients - count:number <- copy 0 - curr:address:duplex-list:character <- copy original + count:num <- copy 0 + curr:&:duplex-list:char <- copy original # skip the initial newline if it exists { - c:character <- get *curr, value:offset - at-newline?:boolean <- equal c, 10/newline + c:char <- get *curr, value:offset + at-newline?:bool <- equal c, 10/newline break-unless at-newline? curr <- next curr count <- add count, 1 } { return-unless curr, original - done?:boolean <- greater-or-equal count, max + done?:bool <- greater-or-equal count, max break-if done? - c:character <- get *curr, value:offset - at-newline?:boolean <- equal c, 10/newline + c:char <- get *curr, value:offset + at-newline?:bool <- equal c, 10/newline break-if at-newline? curr <- next curr count <- add count, 1 @@ -1932,39 +1932,39 @@ def before-start-of-next-line original:address:duplex-list:character, max:number # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line # beware: never return null pointer -def before-previous-line in:address:duplex-list:character, editor:address:editor-data -> out:address:duplex-list:character [ +def before-previous-line in:&:duplex-list:char, editor:&:editor-data -> out:&:duplex-list:char [ local-scope load-ingredients - curr:address:duplex-list:character <- copy in - c:character <- get *curr, value:offset + curr:&:duplex-list:char <- copy in + c:char <- get *curr, value:offset # compute max, number of characters to skip # 1 + len%(width-1) # except rotate second term to vary from 1 to width-1 rather than 0 to width-2 - 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 - len:number <- previous-line-length curr, sentinel + left:num <- get *editor, left:offset + right:num <- get *editor, right:offset + max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon + sentinel:&:duplex-list:char <- get *editor, data:offset + len:num <- previous-line-length curr, sentinel { break-if len # empty line; just skip this newline - prev:address:duplex-list:character <- prev curr + prev:&:duplex-list:char <- prev curr return-unless prev, curr return prev } - _, max:number <- divide-with-remainder len, max-line-length + _, max:num <- divide-with-remainder len, max-line-length # remainder 0 => scan one width-worth { break-if max max <- copy max-line-length } max <- add max, 1 - count:number <- copy 0 + count:num <- copy 0 # skip 'max' characters { - done?:boolean <- greater-or-equal count, max + done?:bool <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- prev curr + prev:&:duplex-list:char <- prev curr break-unless prev curr <- copy prev count <- add count, 1 diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 01641410..51319340 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -5,10 +5,10 @@ def! main [ open-console initial-sandbox:text <- new [] hide-screen 0/screen - env:address:programming-environment-data <- new-programming-environment 0/screen, initial-sandbox + env:&:programming-environment-data <- new-programming-environment 0/screen, initial-sandbox env <- restore-sandboxes env render-sandbox-side 0/screen, env, render - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset update-cursor 0/screen, current-sandbox, env show-screen 0/screen event-loop 0/screen, 0/console, env @@ -16,66 +16,66 @@ def! main [ ] container programming-environment-data [ - current-sandbox:address:editor-data + current-sandbox:&:editor-data ] -def new-programming-environment screen:address:screen, initial-sandbox-contents:text -> result:address:programming-environment-data, screen:address:screen [ +def new-programming-environment screen:&:screen, initial-sandbox-contents:text -> result:&:programming-environment-data, screen:&:screen [ local-scope load-ingredients - width:number <- screen-width screen - height:number <- screen-height screen + width:num <- screen-width screen + height:num <- screen-height screen # top menu result <- new programming-environment-data:type draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey - button-start:number <- subtract width, 20 - button-on-screen?:boolean <- greater-or-equal button-start, 0 + button-start:num <- subtract width, 20 + button-on-screen?:bool <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start print screen, [ run (F4) ], 255/white, 161/reddish # sandbox editor - current-sandbox:address:editor-data <- new-editor initial-sandbox-contents, screen, 0, width/right + current-sandbox:&:editor-data <- new-editor initial-sandbox-contents, screen, 0, width/right *result <- put *result, current-sandbox:offset, current-sandbox ] -def event-loop screen:address:screen, console:address:console, env:address:programming-environment-data -> screen:address:screen, console:address:console, env:address:programming-environment-data [ +def event-loop screen:&:screen, console:&:console, env:&:programming-environment-data -> screen:&:screen, console:&:console, env:&:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset # if we fall behind we'll stop updating the screen, but then we have to # render the entire screen when we catch up. # todo: test this - render-all-on-no-more-events?:boolean <- copy 0/false + render-all-on-no-more-events?:bool <- copy 0/false { # looping over each (keyboard or touch) event as it occurs +next-event - e:event, console, found?:boolean, quit?:boolean <- read-event console + e:event, console, found?:bool, quit?:bool <- read-event console loop-unless found? break-if quit? # only in tests trace 10, [app], [next-event] # check for global events that will trigger regardless of which editor has focus { - k:number, is-keycode?:boolean <- maybe-convert e:event, keycode:variant + k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant break-unless is-keycode? } { - c:character, is-unicode?:boolean <- maybe-convert e:event, text:variant + c:char, is-unicode?:bool <- maybe-convert e:event, text:variant break-unless is-unicode? } # 'touch' event { - t:touch-event, is-touch?:boolean <- maybe-convert e:event, touch:variant + t:touch-event, is-touch?:bool <- maybe-convert e:event, touch:variant break-unless is-touch? # ignore all but 'left-click' events for now # todo: test this - touch-type:number <- get t, type:offset - is-left-click?:boolean <- equal touch-type, 65513/mouse-left + touch-type:num <- get t, type:offset + is-left-click?:bool <- equal touch-type, 65513/mouse-left loop-unless is-left-click?, +next-event:label - click-row:number <- get t, row:offset - click-column:number <- get t, column:offset + click-row:num <- get t, row:offset + click-column:num <- get t, column:offset # later exceptions for non-editor touches will go here move-cursor-in-editor screen, current-sandbox, t @@ -85,10 +85,10 @@ def event-loop screen:address:screen, console:address:console, env:address:progr # 'resize' event - redraw editor # todo: test this after supporting resize in assume-console { - r:resize-event, is-resize?:boolean <- maybe-convert e:event, resize:variant + r:resize-event, is-resize?:bool <- maybe-convert e:event, resize:variant break-unless is-resize? # if more events, we're still resizing; wait until we stop - more-events?:boolean <- has-more-events? console + more-events?:bool <- has-more-events? console { break-unless more-events? render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event @@ -104,10 +104,10 @@ def event-loop screen:address:screen, console:address:console, env:address:progr # if it's not global and not a touch event, send to appropriate editor { hide-screen screen - screen, current-sandbox, render?:boolean <- handle-keyboard-event screen, current-sandbox, e:event + screen, current-sandbox, render?:bool <- handle-keyboard-event screen, current-sandbox, e:event # refresh screen only if no more events # if there are more events to process, wait for them to clear up, then make sure you render-all afterward. - more-events?:boolean <- has-more-events? console + more-events?:bool <- has-more-events? console { break-unless more-events? render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event @@ -137,14 +137,14 @@ def event-loop screen:address:screen, console:address:console, env:address:progr } ] -def resize screen:address:screen, env:address:programming-environment-data -> env:address:programming-environment-data, screen:address:screen [ +def resize screen:&:screen, env:&:programming-environment-data -> env:&:programming-environment-data, screen:&:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions - width:number <- screen-width screen + width:num <- screen-width screen # update sandbox editor - current-sandbox:address:editor-data <- get *env, current-sandbox:offset - right:number <- subtract width, 1 + current-sandbox:&:editor-data <- get *env, current-sandbox:offset + right:num <- subtract width, 1 *current-sandbox <- put *current-sandbox right:offset, right # reset cursor *current-sandbox <- put *current-sandbox, cursor-row:offset, 1 @@ -154,49 +154,49 @@ def resize screen:address:screen, env:address:programming-environment-data -> en # Variant of 'render' that updates cursor-row and cursor-column based on # before-cursor (rather than the other way around). If before-cursor moves # off-screen, it resets cursor-row and cursor-column. -def render-without-moving-cursor screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +def render-without-moving-cursor screen:&:screen, editor:&:editor-data -> last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ local-scope load-ingredients return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 - left:number <- get *editor, left:offset - screen-height:number <- screen-height screen - right:number <- get *editor, right:offset - 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 + left:num <- get *editor, left:offset + screen-height:num <- screen-height screen + right:num <- get *editor, right:offset + curr:&:duplex-list:char <- get *editor, top-of-screen:offset + prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr +render-loop-initialization - color:number <- copy 7/white - row:number <- copy 1/top - column:number <- copy left + color:num <- copy 7/white + row:num <- copy 1/top + column:num <- copy left # save before-cursor - old-before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + old-before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset # initialze cursor-row/cursor-column/before-cursor to the top of the screen # by default *editor <- put *editor, cursor-row:offset, row *editor <- put *editor, cursor-column:offset, column - top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset *editor <- put *editor, before-cursor:offset, top-of-screen screen <- move-cursor screen, row, column { +next-character break-unless curr - off-screen?:boolean <- greater-or-equal row, screen-height + off-screen?:bool <- greater-or-equal row, screen-height break-if off-screen? # if we find old-before-cursor still on the new resized screen, update # editor-data.cursor-row and editor-data.cursor-column based on # old-before-cursor { - at-cursor?:boolean <- equal old-before-cursor, prev + at-cursor?:bool <- equal old-before-cursor, prev break-unless at-cursor? *editor <- put *editor, cursor-row:offset, row *editor <- put *editor, cursor-column:offset, column *editor <- put *editor, before-cursor:offset, old-before-cursor } - c:character <- get *curr, value:offset + c:char <- get *curr, value:offset { # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? # clear rest of line in this window clear-line-until screen, right @@ -211,10 +211,10 @@ def render-without-moving-cursor screen:address:screen, editor:address:editor-da { # at right? wrap. even if there's only one more letter left; we need # room for clicking on the cursor after it. - at-right?:boolean <- equal column, right + at-right?:bool <- equal column, right break-unless at-right? # print wrap icon - wrap-icon:character <- copy 8617/loop-back-to-left + wrap-icon:char <- copy 8617/loop-back-to-left print screen, wrap-icon, 245/grey column <- copy left row <- add row, 1 @@ -234,17 +234,17 @@ def render-without-moving-cursor screen:address:screen, editor:address:editor-da return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -def render-all screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ +def render-all screen:&:screen, env:&:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:&:screen, env:&:programming-environment-data [ local-scope load-ingredients trace 10, [app], [render all] hide-screen screen # top menu trace 11, [app], [render top menu] - width:number <- screen-width screen + width:num <- screen-width screen draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey - button-start:number <- subtract width, 20 - button-on-screen?:boolean <- greater-or-equal button-start, 0 + button-start:num <- subtract width, 20 + button-on-screen?:bool <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start print screen, [ run (F4) ], 255/white, 161/reddish @@ -252,20 +252,20 @@ def render-all screen:address:screen, env:address:programming-environment-data, screen <- render-sandbox-side screen, env, render-editor # - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset screen <- update-cursor screen, current-sandbox, env # show-screen screen ] # replaced in a later layer -def render-sandbox-side screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ +def render-sandbox-side screen:&:screen, env:&:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:&:screen, env:&:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset - left:number <- get *current-sandbox, left:offset - right:number <- get *current-sandbox, right:offset - row:number, column:number, screen, current-sandbox <- call render-editor, screen, current-sandbox + current-sandbox:&:editor-data <- get *env, current-sandbox:offset + left:num <- get *current-sandbox, left:offset + right:num <- get *current-sandbox, right:offset + row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox clear-line-until screen, right row <- add row, 1 # draw solid line after code (you'll see why in later layers) @@ -274,40 +274,40 @@ def render-sandbox-side screen:address:screen, env:address:programming-environme clear-screen-from screen, row, left, left, right ] -def update-cursor screen:address:screen, current-sandbox:address:editor-data, env:address:programming-environment-data -> screen:address:screen [ +def update-cursor screen:&:screen, current-sandbox:&:editor-data, env:&:programming-environment-data -> screen:&:screen [ local-scope load-ingredients - cursor-row:number <- get *current-sandbox, cursor-row:offset - cursor-column:number <- get *current-sandbox, cursor-column:offset + cursor-row:num <- get *current-sandbox, cursor-row:offset + cursor-column:num <- get *current-sandbox, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column ] # like 'render' for texts, but with colorization for comments like in the editor -def render-code screen:address:screen, s:text, left:number, right:number, row:number -> row:number, screen:address:screen [ +def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [ local-scope load-ingredients return-unless s - color:number <- copy 7/white - column:number <- copy left + color:num <- copy 7/white + column:num <- copy left screen <- move-cursor screen, row, column - screen-height:number <- screen-height screen - i:number <- copy 0 - len:number <- length *s + screen-height:num <- screen-height screen + i:num <- copy 0 + len:num <- length *s { +next-character - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? done? <- greater-or-equal row, screen-height break-if done? - c:character <- index *s, i + c:char <- index *s, i # only line different from render { # at right? wrap. - at-right?:boolean <- equal column, right + at-right?:bool <- equal column, right break-unless at-right? # print wrap icon - wrap-icon:character <- copy 8617/loop-back-to-left + wrap-icon:char <- copy 8617/loop-back-to-left print screen, wrap-icon, 245/grey column <- copy left row <- add row, 1 @@ -317,13 +317,13 @@ def render-code screen:address:screen, s:text, left:number, right:number, row:nu i <- add i, 1 { # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? # clear rest of line in this window { - done?:boolean <- greater-than column, right + done?:bool <- greater-than column, right break-if done? - space:character <- copy 32/space + space:char <- copy 32/space print screen, space column <- add column, 1 loop @@ -337,7 +337,7 @@ def render-code screen:address:screen, s:text, left:number, right:number, row:nu column <- add column, 1 loop } - was-at-left?:boolean <- equal column, left + was-at-left?:bool <- equal column, left clear-line-until screen, right { break-if was-at-left? @@ -350,15 +350,15 @@ def render-code screen:address:screen, s:text, left:number, right:number, row:nu after [ { - redraw-screen?:boolean <- equal c, 12/ctrl-l + redraw-screen?:bool <- equal c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:address:programming-environment-data, render + screen <- render-all screen, env:&:programming-environment-data, render sync-screen screen loop +next-event:label } ] # dummy -def restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ +def restore-sandboxes env:&:programming-environment-data -> env:&:programming-environment-data [ # do nothing; redefined later ] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 0573e238..a069df5e 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -8,9 +8,9 @@ # do anything yet. Later layers implement each button. container programming-environment-data [ - sandbox:address:sandbox-data # list of sandboxes, from top to bottom - render-from:number - number-of-sandboxes:number + sandbox:&:sandbox-data # list of sandboxes, from top to bottom + render-from:num + number-of-sandboxes:num ] after [ @@ -22,10 +22,10 @@ container sandbox-data [ response:text # coordinates to track clicks # constraint: will be 0 for sandboxes at positions before env.render-from - starting-row-on-screen:number - code-ending-row-on-screen:number # past end of code - screen:address:screen # prints in the sandbox go here - next-sandbox:address:sandbox-data + starting-row-on-screen:num + code-ending-row-on-screen:num # past end of code + screen:&:screen # prints in the sandbox go here + next-sandbox:&:sandbox-data ] scenario run-and-show-results [ @@ -33,13 +33,13 @@ scenario run-and-show-results [ assume-screen 50/width, 15/height # sandbox editor contains an instruction without storing outputs 1:text <- new [divide-with-remainder 11, 3] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -82,7 +82,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # check that screen prints both sandboxes screen-should-contain [ @@ -105,11 +105,11 @@ scenario run-and-show-results [ after [ # F4? load all code and run all sandboxes. { - do-run?:boolean <- equal k, 65532/F4 + do-run?:bool <- equal k, 65532/F4 break-unless do-run? screen <- update-status screen, [running... ], 245/grey test-recipes:text, _/optional <- next-ingredient - error?:boolean, env, screen <- run-sandboxes env, screen, test-recipes + error?:bool, env, screen <- run-sandboxes env, screen, test-recipes #? test-recipes <- copy 0 # abandon # F4 might update warnings and results on both sides screen <- render-all screen, env, render @@ -122,38 +122,38 @@ after [ } ] -def run-sandboxes env:address:programming-environment-data, screen:address:screen, test-recipes:text -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +def run-sandboxes env:&:programming-environment-data, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ local-scope load-ingredients - errors-found?:boolean, env, screen <- update-recipes env, screen, test-recipes + errors-found?:bool, env, screen <- update-recipes env, screen, test-recipes # check contents of editor - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset { sandbox-contents:text <- editor-contents current-sandbox break-unless sandbox-contents # if contents exist, first save them # run them and turn them into a new sandbox-data - new-sandbox:address:sandbox-data <- new sandbox-data:type + new-sandbox:&:sandbox-data <- new sandbox-data:type *new-sandbox <- put *new-sandbox, data:offset, sandbox-contents # push to head of sandbox list - dest:address:sandbox-data <- get *env, sandbox:offset + dest:&:sandbox-data <- get *env, sandbox:offset *new-sandbox <- put *new-sandbox, next-sandbox:offset, dest *env <- put *env, sandbox:offset, new-sandbox # update sandbox count - sandbox-count:number <- get *env, number-of-sandboxes:offset + sandbox-count:num <- get *env, number-of-sandboxes:offset sandbox-count <- add sandbox-count, 1 *env <- put *env, number-of-sandboxes:offset, sandbox-count # clear sandbox editor - init:address:duplex-list:character <- push 167/§, 0/tail + init:&:duplex-list:char <- push 167/§, 0/tail *current-sandbox <- put *current-sandbox, data:offset, init *current-sandbox <- put *current-sandbox, top-of-screen:offset, init } # save all sandboxes before running, just in case we die when running save-sandboxes env # run all sandboxes - curr:address:sandbox-data <- get *env, sandbox:offset - idx:number <- copy 0 + curr:&:sandbox-data <- get *env, sandbox:offset + idx:num <- copy 0 { break-unless curr curr <- update-sandbox curr, env, idx @@ -166,7 +166,7 @@ def run-sandboxes env:address:programming-environment-data, screen:address:scree # load code from recipes.mu, or from test-recipes in tests # replaced in a later layer (whereupon errors-found? will actually be set) -def update-recipes env:address:programming-environment-data, screen:address:screen, test-recipes:text -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +def update-recipes env:&:programming-environment-data, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ local-scope load-ingredients { @@ -182,30 +182,30 @@ def update-recipes env:address:programming-environment-data, screen:address:scre ] # replaced in a later layer -def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [ +def! update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num -> sandbox:&:sandbox-data, env:&:programming-environment-data [ local-scope load-ingredients data:text <- get *sandbox, data:offset - response:text, _, fake-screen:address:screen <- run-sandboxed data + response:text, _, fake-screen:&:screen <- run-sandboxed data *sandbox <- put *sandbox, response:offset, response *sandbox <- put *sandbox, screen:offset, fake-screen ] -def update-status screen:address:screen, msg:text, color:number -> screen:address:screen [ +def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -def save-sandboxes env:address:programming-environment-data [ +def save-sandboxes env:&:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&: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 - idx:number <- copy 0 + curr:&:sandbox-data <- get *env, sandbox:offset + idx:num <- copy 0 { break-unless curr data:text <- get *curr, data:offset @@ -218,18 +218,18 @@ def save-sandboxes env:address:programming-environment-data [ } ] -def! render-sandbox-side screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ +def! render-sandbox-side screen:&:screen, env:&:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:&:screen, env:&:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render sandbox side] - current-sandbox:address:editor-data <- get *env, current-sandbox:offset - row:number, column:number <- copy 1, 0 - left:number <- get *current-sandbox, left:offset - right:number <- get *current-sandbox, right:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset + row:num, column:num <- copy 1, 0 + left:num <- get *current-sandbox, left:offset + right:num <- get *current-sandbox, right:offset # render sandbox editor - render-from:number <- get *env, render-from:offset + render-from:num <- get *env, render-from:offset { - render-current-sandbox?:boolean <- equal render-from, -1 + render-current-sandbox?:bool <- equal render-from, -1 break-unless render-current-sandbox? row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox clear-screen-from screen, row, column, left, right @@ -237,20 +237,20 @@ def! render-sandbox-side screen:address:screen, env:address:programming-environm } # render sandboxes draw-horizontal screen, row, left, right, 9473/horizontal-double - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:&:sandbox-data <- get *env, sandbox:offset row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from, 0, env clear-rest-of-screen screen, row, left, right ] -def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:screen, sandbox:address:sandbox-data [ +def render-sandboxes screen:&:screen, sandbox:&:sandbox-data, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox-data [ local-scope load-ingredients - env:address:programming-environment-data, _/optional <- next-ingredient + env:&:programming-environment-data, _/optional <- next-ingredient return-unless sandbox - screen-height:number <- screen-height screen - at-bottom?:boolean <- greater-or-equal row, screen-height - return-if at-bottom?:boolean - hidden?:boolean <- lesser-than idx, render-from + screen-height:num <- screen-height screen + at-bottom?:bool <- greater-or-equal row, screen-height + return-if at-bottom?:bool + hidden?:bool <- lesser-than idx, render-from { break-if hidden? # render sandbox menu @@ -269,8 +269,8 @@ def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:n sandbox-response:text <- get *sandbox, response:offset { - sandbox-screen:address:screen <- get *sandbox, screen:offset - empty-screen?:boolean <- fake-screen-is-empty? sandbox-screen + sandbox-screen:&:screen <- get *sandbox, screen:offset + empty-screen?:bool <- fake-screen-is-empty? sandbox-screen break-if empty-screen? row, screen <- render-screen screen, sandbox-screen, left, right, row } @@ -280,7 +280,7 @@ def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:n row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row } +render-sandbox-end - at-bottom?:boolean <- greater-or-equal row, screen-height + at-bottom?:bool <- greater-or-equal row, screen-height return-if at-bottom? # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double @@ -293,28 +293,28 @@ def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:n } # draw next sandbox - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset - next-idx:number <- add idx, 1 + next-sandbox:&:sandbox-data <- get *sandbox, next-sandbox:offset + next-idx:num <- add idx, 1 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx, env ] -def render-sandbox-menu screen:address:screen, sandbox-index:number, left:number, right:number -> screen:address:screen [ +def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [ local-scope load-ingredients move-cursor-to-column screen, left - edit-button-left:number, edit-button-right:number, copy-button-left:number, copy-button-right:number, delete-button-left:number <- sandbox-menu-columns left, right + edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right print screen, sandbox-index, 232/dark-grey, 245/grey - start-buttons:number <- subtract edit-button-left, 1 + start-buttons:num <- subtract edit-button-left, 1 clear-line-until screen, start-buttons, 245/grey print screen, [edit], 232/black, 94/background-orange clear-line-until screen, edit-button-right, 94/background-orange - _, col:number <- cursor-position screen - at-start-of-copy-button?:boolean <- equal col, copy-button-left + _, col:num <- cursor-position screen + at-start-of-copy-button?:bool <- equal col, copy-button-left assert at-start-of-copy-button?, [aaa] print screen, [copy], 232/black, 58/background-green clear-line-until screen, copy-button-right, 58/background-green - _, col:number <- cursor-position screen - at-start-of-delete-button?:boolean <- equal col, delete-button-left + _, col:num <- cursor-position screen + at-start-of-delete-button?:bool <- equal col, delete-button-left assert at-start-of-delete-button?, [bbb] print screen, [delete], 232/black, 52/background-red clear-line-until screen, right, 52/background-red @@ -323,45 +323,45 @@ def render-sandbox-menu screen:address:screen, sandbox-index:number, left:number # divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons # delete-button-right == right # all left/right pairs are inclusive -def sandbox-menu-columns left:number, right:number -> edit-button-left:number, edit-button-right:number, copy-button-left:number, copy-button-right:number, delete-button-left:number [ +def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [ local-scope load-ingredients - start-buttons:number <- add left, 4/space-for-sandbox-index - buttons-space:number <- subtract right, start-buttons - button-width:number <- divide-with-remainder buttons-space, 3 # integer division - buttons-wide-enough?:boolean <- greater-or-equal button-width, 8 + start-buttons:num <- add left, 4/space-for-sandbox-index + buttons-space:num <- subtract right, start-buttons + button-width:num <- divide-with-remainder buttons-space, 3 # integer division + buttons-wide-enough?:bool <- greater-or-equal button-width, 8 assert buttons-wide-enough?, [sandbox must be at least 30 or so characters wide] - edit-button-left:number <- copy start-buttons - copy-button-left:number <- add start-buttons, button-width - edit-button-right:number <- subtract copy-button-left, 1 - delete-button-left:number <- subtract right, button-width - copy-button-right:number <- subtract delete-button-left, 1 + edit-button-left:num <- copy start-buttons + copy-button-left:num <- add start-buttons, button-width + edit-button-right:num <- subtract copy-button-left, 1 + delete-button-left:num <- subtract right, button-width + copy-button-right:num <- subtract delete-button-left, 1 ] # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -def render-text screen:address:screen, s:text, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ +def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [ local-scope load-ingredients return-unless s - column:number <- copy left + column:num <- copy left screen <- move-cursor screen, row, column - screen-height:number <- screen-height screen - i:number <- copy 0 - len:number <- length *s + screen-height:num <- screen-height screen + i:num <- copy 0 + len:num <- length *s { +next-character - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? done? <- greater-or-equal row, screen-height break-if done? - c:character <- index *s, i + c:char <- index *s, i { # at right? wrap. - at-right?:boolean <- equal column, right + at-right?:bool <- equal column, right break-unless at-right? # print wrap icon - wrap-icon:character <- copy 8617/loop-back-to-left + wrap-icon:char <- copy 8617/loop-back-to-left print screen, wrap-icon, 245/grey column <- copy left row <- add row, 1 @@ -371,13 +371,13 @@ def render-text screen:address:screen, s:text, left:number, right:number, color: i <- add i, 1 { # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? # clear rest of line in this window { - done?:boolean <- greater-than column, right + done?:bool <- greater-than column, right break-if done? - space:character <- copy 32/space + space:char <- copy 32/space print screen, space column <- add column, 1 loop @@ -391,7 +391,7 @@ def render-text screen:address:screen, s:text, left:number, right:number, color: column <- add column, 1 loop } - was-at-left?:boolean <- equal column, left + was-at-left?:bool <- equal column, left clear-line-until screen, right { break-if was-at-left? @@ -401,13 +401,13 @@ def render-text screen:address:screen, s:text, left:number, right:number, color: ] # assumes programming environment has no sandboxes; restores them from previous session -def! restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ +def! restore-sandboxes env:&:programming-environment-data -> env:&:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios - idx:number <- copy 0 - curr:address:sandbox-data <- copy 0 - prev:address:sandbox-data <- copy 0 + idx:num <- copy 0 + curr:&:sandbox-data <- copy 0 + prev:&:sandbox-data <- copy 0 { filename:text <- to-text idx contents:text <- restore filename @@ -435,7 +435,7 @@ def! restore-sandboxes env:address:programming-environment-data -> env:address:p # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -def render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number -> row:number, screen:address:screen [ +def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [ local-scope load-ingredients return-unless sandbox-screen @@ -443,39 +443,39 @@ def render-screen screen:address:screen, sandbox-screen:address:screen, left:num row <- render-text screen, [screen:], 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 - stop-printing:number <- add left, s-width, 3 - max-column:number <- min stop-printing, right - i:number <- copy 0 - len:number <- length *buf - screen-height:number <- screen-height screen + column:num <- copy left + s-width:num <- screen-width sandbox-screen + s-height:num <- screen-height sandbox-screen + buf:&:@:screen-cell <- get *sandbox-screen, data:offset + stop-printing:num <- add left, s-width, 3 + max-column:num <- min stop-printing, right + i:num <- copy 0 + len:num <- length *buf + screen-height:num <- screen-height screen { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? done? <- greater-or-equal row, screen-height break-if done? column <- copy left screen <- move-cursor screen, row, column # initial leader for each row: two spaces and a '.' - space:character <- copy 32/space + space:char <- copy 32/space print screen, space, 245/grey print screen, space, 245/grey - full-stop:character <- copy 46/period + full-stop:char <- copy 46/period print screen, full-stop, 245/grey column <- add left, 3 { # print row - row-done?:boolean <- greater-or-equal column, max-column + row-done?:bool <- greater-or-equal column, max-column break-if row-done? curr:screen-cell <- index *buf, i - c:character <- get curr, contents:offset - color:number <- get curr, color:offset + c:char <- get curr, contents:offset + color:num <- get curr, color:offset { # damp whites down to grey - white?:boolean <- equal color, 7/white + white?:bool <- equal color, 7/white break-unless white? color <- copy 245/grey } @@ -489,7 +489,7 @@ def render-screen screen:address:screen, sandbox-screen:address:screen, left:num column <- add column, 1 { # clear rest of current line - line-done?:boolean <- greater-than column, right + line-done?:bool <- greater-than column, right break-if line-done? print screen, space column <- add column, 1 @@ -507,17 +507,17 @@ scenario run-updates-results [ 1:text <- new [ def foo [ local-scope -z:number <- add 2, 2 +z:num <- add 2, 2 return z ]] # sandbox editor contains an instruction without storing outputs 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text # run the code in the editors assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/recipes screen-should-contain [ . run (F4) . . . @@ -532,14 +532,14 @@ return z 1:text <- new [ def foo [ local-scope -z:number <- add 2, 3 +z:num <- add 2, 3 return z ]] assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/recipes ] # check that screen updates the result on the right screen-should-contain [ @@ -559,13 +559,13 @@ scenario run-instruction-manages-screen-per-sandbox [ assume-screen 50/width, 20/height # editor contains an instruction 1:text <- new [print-integer screen, 4] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # check that it prints a little toy screen screen-should-contain [ @@ -585,18 +585,18 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -def editor-contents editor:address:editor-data -> result:text [ +def editor-contents editor:&:editor-data -> result:text [ local-scope load-ingredients - buf:address:buffer <- new-buffer 80 - curr:address:duplex-list:character <- get *editor, data:offset + buf:&:buffer <- new-buffer 80 + curr:&:duplex-list:char <- get *editor, data:offset # skip § sentinel assert curr, [editor without data is illegal; must have at least a sentinel] curr <- next curr return-unless curr, 0 { break-unless curr - c:character <- get *curr, value:offset + c:char <- get *curr, value:offset buf <- append buf, c curr <- next curr loop @@ -607,15 +607,15 @@ def editor-contents editor:address:editor-data -> result:text [ scenario editor-provides-edited-contents [ assume-screen 10/width, 5/height 1:text <- new [abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right + 2:&:editor-data <- new-editor 1:text, screen:&: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:text <- editor-contents 2:address:editor-data - 4:array:character <- copy *3:text + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data + 3:text <- editor-contents 2:&:editor-data + 4:@:char <- copy *3:text ] memory-should-contain [ 4:array:character <- [abdefc] @@ -629,13 +629,13 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ assume-screen 50/width, 20/height # initialize 1:text <- new [add 2, 2] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render assume-console [ # create a sandbox press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -651,9 +651,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 3:character/cursor <- copy 9251/␣ - print screen:address:screen, 3:character/cursor + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 3:char/cursor <- copy 9251/␣ + print screen:&:screen, 3:char/cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -671,9 +671,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-up ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 3:character/cursor <- copy 9251/␣ - print screen:address:screen, 3:character/cursor + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 3:char/cursor <- copy 9251/␣ + print screen:&:screen, 3:char/cursor ] # sandbox editor displays again screen-should-contain [ @@ -691,16 +691,16 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ # page-down updates render-from to scroll sandboxes after [ { - page-down?:boolean <- equal k, 65518/page-down + page-down?:bool <- equal k, 65518/page-down break-unless page-down? - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:&:sandbox-data <- get *env, sandbox:offset break-unless sandbox # slide down if possible { - render-from:number <- get *env, render-from:offset - number-of-sandboxes:number <- get *env, number-of-sandboxes:offset - max:number <- subtract number-of-sandboxes, 1 - at-end?:boolean <- greater-or-equal render-from, max + render-from:num <- get *env, render-from:offset + number-of-sandboxes:num <- get *env, number-of-sandboxes:offset + max:num <- subtract number-of-sandboxes, 1 + at-end?:bool <- greater-or-equal render-from, max break-if at-end? render-from <- add render-from, 1 *env <- put *env, render-from:offset, render-from @@ -715,10 +715,10 @@ after [ # update-cursor takes render-from into account after [ { - render-from:number <- get *env, render-from:offset - scrolling?:boolean <- greater-or-equal render-from, 0 + render-from:num <- get *env, render-from:offset + scrolling?:bool <- greater-or-equal render-from, 0 break-unless scrolling? - cursor-column:number <- get *current-sandbox, left:offset + cursor-column:num <- get *current-sandbox, left:offset screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 return } @@ -727,10 +727,10 @@ after [ # 'page-up' is like 'page-down': updates first-sandbox-to-render when necessary after [ { - page-up?:boolean <- equal k, 65519/page-up + page-up?:bool <- equal k, 65519/page-up break-unless page-up? - render-from:number <- get *env, render-from:offset - at-beginning?:boolean <- equal render-from, -1 + render-from:num <- get *env, render-from:offset + at-beginning?:bool <- equal render-from, -1 break-if at-beginning? render-from <- subtract render-from, 1 *env <- put *env, render-from:offset, render-from @@ -743,15 +743,15 @@ after [ # sandbox belonging to 'env' whose next-sandbox is 'in' # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox -def previous-sandbox env:address:programming-environment-data, in:address:sandbox-data -> out:address:sandbox-data [ +def previous-sandbox env:&:programming-environment-data, in:&:sandbox-data -> out:&:sandbox-data [ local-scope load-ingredients - curr:address:sandbox-data <- get *env, sandbox:offset + curr:&:sandbox-data <- get *env, sandbox:offset return-unless curr, 0/nil - next:address:sandbox-data <- get *curr, next-sandbox:offset + next:&:sandbox-data <- get *curr, next-sandbox:offset { return-unless next, 0/nil - found?:boolean <- equal next, in + found?:bool <- equal next, in break-if found? curr <- copy next next <- get *curr, next-sandbox:offset @@ -765,8 +765,8 @@ scenario scrolling-through-multiple-sandboxes [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes assume-console [ press ctrl-n @@ -775,9 +775,9 @@ scenario scrolling-through-multiple-sandboxes [ type [add 1, 1] press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 3:character/cursor <- copy 9251/␣ - print screen:address:screen, 3:character/cursor + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 3:char/cursor <- copy 9251/␣ + print screen:&:screen, 3:char/cursor screen-should-contain [ . run (F4) . .␣ . @@ -797,9 +797,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 3:character/cursor <- copy 9251/␣ - print screen:address:screen, 3:character/cursor + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 3:char/cursor <- copy 9251/␣ + print screen:&:screen, 3:char/cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -821,7 +821,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # just second sandbox displayed screen-should-contain [ @@ -838,7 +838,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # no change screen-should-contain [ @@ -855,7 +855,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # back to displaying both sandboxes without editor screen-should-contain [ @@ -876,9 +876,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 3:character/cursor <- copy 9251/␣ - print screen:address:screen, 3:character/cursor + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 3:char/cursor <- copy 9251/␣ + print screen:&:screen, 3:char/cursor ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -900,9 +900,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 3:character/cursor <- copy 9251/␣ - print screen:address:screen, 3:character/cursor + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 3:char/cursor <- copy 9251/␣ + print screen:&:screen, 3:char/cursor ] # no change screen-should-contain [ @@ -926,15 +926,15 @@ scenario scrolling-manages-sandbox-index-correctly [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create a sandbox assume-console [ press ctrl-n type [add 1, 1] press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -950,7 +950,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -968,7 +968,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-up ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -986,7 +986,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox diff --git a/sandbox/006-sandbox-copy.mu b/sandbox/006-sandbox-copy.mu index 754a4a3d..4a072b03 100644 --- a/sandbox/006-sandbox-copy.mu +++ b/sandbox/006-sandbox-copy.mu @@ -8,8 +8,8 @@ scenario copy-a-sandbox-to-editor [ assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -27,7 +27,7 @@ scenario copy-a-sandbox-to-editor [ left-click 3, 19 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # it copies into editor screen-should-contain [ @@ -47,7 +47,7 @@ scenario copy-a-sandbox-to-editor [ type [0] ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -70,8 +70,8 @@ scenario copy-a-sandbox-to-editor-2 [ assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -89,7 +89,7 @@ scenario copy-a-sandbox-to-editor-2 [ left-click 3, 33 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # it copies into editor screen-should-contain [ @@ -109,7 +109,7 @@ scenario copy-a-sandbox-to-editor-2 [ type [0] ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -128,7 +128,7 @@ scenario copy-a-sandbox-to-editor-2 [ after [ # support 'copy' button { - copy?:boolean <- should-attempt-copy? click-row, click-column, env + copy?:bool <- should-attempt-copy? click-row, click-column, env break-unless copy? copy?, env <- try-copy-sandbox click-row, env break-unless copy? @@ -141,47 +141,47 @@ after [ ] # some preconditions for attempting to copy a sandbox -def should-attempt-copy? click-row:number, click-column:number, env:address:programming-environment-data -> result:boolean [ +def should-attempt-copy? click-row:num, click-column:num, env:&:programming-environment-data -> result:bool [ local-scope load-ingredients # are we below the sandbox editor? - click-sandbox-area?:boolean <- click-on-sandbox-area? click-row, env + click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env reply-unless click-sandbox-area?, 0/false # narrower, is the click in the columns spanning the 'copy' button? - first-sandbox:address:editor-data <- get *env, current-sandbox:offset + first-sandbox:&:editor-data <- get *env, current-sandbox:offset assert first-sandbox, [!!] - sandbox-left-margin:number <- get *first-sandbox, left:offset - sandbox-right-margin:number <- get *first-sandbox, right:offset - _, _, copy-button-left:number, copy-button-right:number, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - copy-button-vertical-area?:boolean <- within-range? click-column, copy-button-left, copy-button-right + sandbox-left-margin:num <- get *first-sandbox, left:offset + sandbox-right-margin:num <- get *first-sandbox, right:offset + _, _, copy-button-left:num, copy-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right reply-unless copy-button-vertical-area?, 0/false # finally, is sandbox editor empty? - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset result <- empty-editor? current-sandbox ] -def try-copy-sandbox click-row:number, env:address:programming-environment-data -> clicked-on-copy-button?:boolean, env:address:programming-environment-data [ +def try-copy-sandbox click-row:num, env:&:programming-environment-data -> clicked-on-copy-button?:bool, env:&:programming-environment-data [ local-scope load-ingredients # identify the sandbox to copy, if the click was actually on the 'copy' button - sandbox:address:sandbox-data <- find-sandbox env, click-row + sandbox:&:sandbox-data <- find-sandbox env, click-row return-unless sandbox, 0/false clicked-on-copy-button? <- copy 1/true text:text <- get *sandbox, data:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset current-sandbox <- insert-text current-sandbox, text # reset scroll *env <- put *env, render-from:offset, -1 ] -def find-sandbox env:address:programming-environment-data, click-row:number -> result:address:sandbox-data [ +def find-sandbox env:&:programming-environment-data, click-row:num -> result:&:sandbox-data [ local-scope load-ingredients - curr-sandbox:address:sandbox-data <- get *env, sandbox:offset + curr-sandbox:&:sandbox-data <- get *env, sandbox:offset { break-unless curr-sandbox - start:number <- get *curr-sandbox, starting-row-on-screen:offset - found?:boolean <- equal click-row, start + start:num <- get *curr-sandbox, starting-row-on-screen:offset + found?:bool <- equal click-row, start return-if found?, curr-sandbox curr-sandbox <- get *curr-sandbox, next-sandbox:offset loop @@ -189,28 +189,28 @@ def find-sandbox env:address:programming-environment-data, click-row:number -> r return 0/not-found ] -def click-on-sandbox-area? click-row:number, env:address:programming-environment-data -> result:boolean [ +def click-on-sandbox-area? click-row:num, env:&:programming-environment-data -> result:bool [ local-scope load-ingredients - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:&:sandbox-data <- get *env, sandbox:offset return-unless first-sandbox, 0/false - first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset + first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset result <- greater-or-equal click-row, first-sandbox-begins ] -def empty-editor? editor:address:editor-data -> result:boolean [ +def empty-editor? editor:&:editor-data -> result:bool [ local-scope load-ingredients - head:address:duplex-list:character <- get *editor, data:offset - first:address:duplex-list:character <- next head + head:&:duplex-list:char <- get *editor, data:offset + first:&:duplex-list:char <- next head result <- not first ] -def within-range? x:number, low:number, high:number -> result:boolean [ +def within-range? x:num, low:num, high:num -> result:bool [ local-scope load-ingredients - not-too-far-left?:boolean <- greater-or-equal x, low - not-too-far-right?:boolean <- lesser-or-equal x, high + not-too-far-left?:bool <- greater-or-equal x, low + not-too-far-right?:bool <- lesser-or-equal x, high result <- and not-too-far-left? not-too-far-right? ] @@ -221,8 +221,8 @@ scenario copy-fails-if-sandbox-editor-not-empty [ assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -240,7 +240,7 @@ scenario copy-fails-if-sandbox-editor-not-empty [ left-click 3, 20 # click 'copy' button ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # copy doesn't happen screen-should-contain [ @@ -258,7 +258,7 @@ scenario copy-fails-if-sandbox-editor-not-empty [ type [1] ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index 74a50d3c..a3732d1c 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -4,7 +4,7 @@ scenario deleting-sandboxes [ trace-until 100/app # trace too long assume-screen 50/width, 15/height 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text # run a few commands assume-console [ type [divide-with-remainder 11, 3] @@ -12,7 +12,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -33,7 +33,7 @@ scenario deleting-sandboxes [ left-click 7, 34 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -50,7 +50,7 @@ scenario deleting-sandboxes [ left-click 3, 49 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -63,7 +63,7 @@ scenario deleting-sandboxes [ after [ # support 'delete' button { - delete?:boolean <- should-attempt-delete? click-row, click-column, env + delete?:bool <- should-attempt-delete? click-row, click-column, env break-unless delete? delete?, env <- try-delete-sandbox click-row, env break-unless delete? @@ -76,68 +76,68 @@ after [ ] # some preconditions for attempting to delete a sandbox -def should-attempt-delete? click-row:number, click-column:number, env:address:programming-environment-data -> result:boolean [ +def should-attempt-delete? click-row:num, click-column:num, env:&:programming-environment-data -> result:bool [ local-scope load-ingredients # are we below the sandbox editor? - click-sandbox-area?:boolean <- click-on-sandbox-area? click-row, env + click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env reply-unless click-sandbox-area?, 0/false # narrower, is the click in the columns spanning the 'copy' button? - first-sandbox:address:editor-data <- get *env, current-sandbox:offset + first-sandbox:&:editor-data <- get *env, current-sandbox:offset assert first-sandbox, [!!] - sandbox-left-margin:number <- get *first-sandbox, left:offset - sandbox-right-margin:number <- get *first-sandbox, right:offset - _, _, _, _, delete-button-left:number <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + sandbox-left-margin:num <- get *first-sandbox, left:offset + sandbox-right-margin:num <- get *first-sandbox, right:offset + _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin result <- within-range? click-column, delete-button-left, sandbox-right-margin ] -def try-delete-sandbox click-row:number, env:address:programming-environment-data -> clicked-on-delete-button?:boolean, env:address:programming-environment-data [ +def try-delete-sandbox click-row:num, env:&:programming-environment-data -> clicked-on-delete-button?:bool, env:&:programming-environment-data [ local-scope load-ingredients # identify the sandbox to delete, if the click was actually on the 'delete' button - sandbox:address:sandbox-data <- find-sandbox env, click-row + sandbox:&:sandbox-data <- find-sandbox env, click-row return-unless sandbox, 0/false clicked-on-delete-button? <- copy 1/true env <- delete-sandbox env, sandbox ] -def delete-sandbox env:address:programming-environment-data, sandbox:address:sandbox-data -> env:address:programming-environment-data [ +def delete-sandbox env:&:programming-environment-data, sandbox:&:sandbox-data -> env:&:programming-environment-data [ local-scope load-ingredients - curr-sandbox:address:sandbox-data <- get *env, sandbox:offset - first-sandbox?:boolean <- equal curr-sandbox, sandbox + curr-sandbox:&:sandbox-data <- get *env, sandbox:offset + first-sandbox?:bool <- equal curr-sandbox, sandbox { # first sandbox? pop break-unless first-sandbox? - next-sandbox:address:sandbox-data <- get *curr-sandbox, next-sandbox:offset + next-sandbox:&:sandbox-data <- get *curr-sandbox, next-sandbox:offset *env <- put *env, sandbox:offset, next-sandbox } { # not first sandbox? break-if first-sandbox? - prev-sandbox:address:sandbox-data <- copy curr-sandbox + prev-sandbox:&:sandbox-data <- copy curr-sandbox curr-sandbox <- get *curr-sandbox, next-sandbox:offset { assert curr-sandbox, [sandbox not found! something is wrong.] - found?:boolean <- equal curr-sandbox, sandbox + found?:bool <- equal curr-sandbox, sandbox break-if found? prev-sandbox <- copy curr-sandbox curr-sandbox <- get *curr-sandbox, next-sandbox:offset loop } # snip sandbox out of its list - next-sandbox:address:sandbox-data <- get *curr-sandbox, next-sandbox:offset + next-sandbox:&:sandbox-data <- get *curr-sandbox, next-sandbox:offset *prev-sandbox <- put *prev-sandbox, next-sandbox:offset, next-sandbox } # update sandbox count - sandbox-count:number <- get *env, number-of-sandboxes:offset + sandbox-count:num <- get *env, number-of-sandboxes:offset sandbox-count <- subtract sandbox-count, 1 *env <- put *env, number-of-sandboxes:offset, sandbox-count # reset scroll if deleted sandbox was last { break-if next-sandbox - render-from:number <- get *env, render-from:offset - reset-scroll?:boolean <- equal render-from, sandbox-count + render-from:num <- get *env, render-from:offset + reset-scroll?:bool <- equal render-from, sandbox-count break-unless reset-scroll? *env <- put *env, render-from:offset, -1 } @@ -148,8 +148,8 @@ scenario deleting-sandbox-after-scroll [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -159,7 +159,7 @@ scenario deleting-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -177,7 +177,7 @@ scenario deleting-sandbox-after-scroll [ left-click 6, 34 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -196,8 +196,8 @@ scenario deleting-top-sandbox-after-scroll [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -207,7 +207,7 @@ scenario deleting-top-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -225,7 +225,7 @@ scenario deleting-top-sandbox-after-scroll [ left-click 2, 34 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -244,8 +244,8 @@ scenario deleting-final-sandbox-after-scroll [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -256,7 +256,7 @@ scenario deleting-final-sandbox-after-scroll [ press page-down press page-down ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -271,7 +271,7 @@ scenario deleting-final-sandbox-after-scroll [ left-click 2, 34 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # implicitly scroll up to first sandbox screen-should-contain [ @@ -291,8 +291,8 @@ scenario deleting-updates-sandbox-count [ assume-screen 50/width, 10/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes assume-console [ press ctrl-n @@ -301,7 +301,7 @@ scenario deleting-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -321,7 +321,7 @@ scenario deleting-updates-sandbox-count [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # shouldn't go past last sandbox screen-should-contain [ diff --git a/sandbox/008-sandbox-edit.mu b/sandbox/008-sandbox-edit.mu index c92ec445..51a01b58 100644 --- a/sandbox/008-sandbox-edit.mu +++ b/sandbox/008-sandbox-edit.mu @@ -8,8 +8,8 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -25,7 +25,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ left-click 3, 4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # it pops back into editor screen-should-contain [ @@ -39,7 +39,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ type [0] ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -52,7 +52,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ after [ # support 'edit' button { - edit?:boolean <- should-attempt-edit? click-row, click-column, env + edit?:bool <- should-attempt-edit? click-row, click-column, env break-unless edit? edit?, env <- try-edit-sandbox click-row, env break-unless edit? @@ -65,35 +65,35 @@ after [ ] # some preconditions for attempting to edit a sandbox -def should-attempt-edit? click-row:number, click-column:number, env:address:programming-environment-data -> result:boolean [ +def should-attempt-edit? click-row:num, click-column:num, env:&:programming-environment-data -> result:bool [ local-scope load-ingredients # are we below the sandbox editor? - click-sandbox-area?:boolean <- click-on-sandbox-area? click-row, env + click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env reply-unless click-sandbox-area?, 0/false # narrower, is the click in the columns spanning the 'edit' button? - first-sandbox:address:editor-data <- get *env, current-sandbox:offset + first-sandbox:&:editor-data <- get *env, current-sandbox:offset assert first-sandbox, [!!] - sandbox-left-margin:number <- get *first-sandbox, left:offset - sandbox-right-margin:number <- get *first-sandbox, right:offset - edit-button-left:number, edit-button-right:number, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - edit-button-vertical-area?:boolean <- within-range? click-column, edit-button-left, edit-button-right + sandbox-left-margin:num <- get *first-sandbox, left:offset + sandbox-right-margin:num <- get *first-sandbox, right:offset + edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right reply-unless edit-button-vertical-area?, 0/false # finally, is sandbox editor empty? - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset result <- empty-editor? current-sandbox ] -def try-edit-sandbox click-row:number, env:address:programming-environment-data -> clicked-on-edit-button?:boolean, env:address:programming-environment-data [ +def try-edit-sandbox click-row:num, env:&:programming-environment-data -> clicked-on-edit-button?:bool, env:&:programming-environment-data [ local-scope load-ingredients # identify the sandbox to edit, if the click was actually on the 'edit' button - sandbox:address:sandbox-data <- find-sandbox env, click-row + sandbox:&:sandbox-data <- find-sandbox env, click-row return-unless sandbox, 0/false clicked-on-edit-button? <- copy 1/true # 'edit' button = 'copy' button + 'delete' button text:text <- get *sandbox, data:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:&:editor-data <- get *env, current-sandbox:offset current-sandbox <- insert-text current-sandbox, text env <- delete-sandbox env, sandbox # reset scroll @@ -105,12 +105,12 @@ scenario sandbox-with-print-can-be-edited [ assume-screen 50/width, 20/height # run a print instruction 1:text <- new [print-integer screen, 4] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text # run the sandbox assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -131,7 +131,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 18 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -147,8 +147,8 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -159,7 +159,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ press page-down press page-down ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -174,7 +174,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ left-click 2, 10 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -194,8 +194,8 @@ scenario editing-sandbox-updates-sandbox-count [ assume-screen 50/width, 20/height # initialize environment 1:text <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - render-all screen, 2:address:programming-environment-data, render + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + render-all screen, 2:&:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -204,7 +204,7 @@ scenario editing-sandbox-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -221,7 +221,7 @@ scenario editing-sandbox-updates-sandbox-count [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # no change in contents screen-should-contain [ @@ -241,7 +241,7 @@ scenario editing-sandbox-updates-sandbox-count [ press page-down ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # screen should show just final sandbox screen-should-contain [ diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index a0da09a8..7a2c5772 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -13,8 +13,8 @@ def foo [ assume-console [ press F4 ] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes screen-should-contain [ . run (F4) . . . @@ -30,7 +30,7 @@ def foo [ left-click 5, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -44,8 +44,8 @@ def foo [ ] # cursor should remain unmoved run [ - 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + 4:char/cursor <- copy 9251/␣ + print screen:&:screen, 4:char/cursor ] screen-should-contain [ . run (F4) . @@ -67,7 +67,7 @@ def foo [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/new-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/new-test-recipes ] # result turns red screen-should-contain-in-color 1/red, [ @@ -83,7 +83,7 @@ def foo [ # this requires tracking a couple more things container sandbox-data [ - response-starting-row-on-screen:number + response-starting-row-on-screen:num expected-response:text ] @@ -110,18 +110,18 @@ before [ after [ # check if it's inside the output of any sandbox { - sandbox-left-margin:number <- get *current-sandbox, left:offset - click-column:number <- get t, column:offset - on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num <- get *current-sandbox, left:offset + click-column:num <- get t, column:offset + on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:&: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 + first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset + click-row:num <- get t, row:offset + below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on - sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:&: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 @@ -135,33 +135,33 @@ after [ } ] -def find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +def find-click-in-sandbox-output env:&:programming-environment-data, click-row:num -> sandbox:&:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:sandbox-data <- get *env, sandbox:offset - start:number <- get *sandbox, starting-row-on-screen:offset - clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start + sandbox:&:sandbox-data <- get *env, sandbox:offset + start:num <- get *sandbox, starting-row-on-screen:offset + clicked-on-sandboxes?:bool <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:&: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 + next-start:num <- get *next-sandbox, starting-row-on-screen:offset + found?:bool <- lesser-than click-row, next-start break-if found? sandbox <- copy next-sandbox loop } # return sandbox if click is in its output region - response-starting-row:number <- get *sandbox, response-starting-row-on-screen:offset + response-starting-row:num <- get *sandbox, response-starting-row-on-screen:offset return-unless response-starting-row, 0/no-click-in-sandbox-output - click-in-response?:boolean <- greater-or-equal click-row, response-starting-row + click-in-response?:bool <- greater-or-equal click-row, response-starting-row return-unless click-in-response?, 0/no-click-in-sandbox-output return sandbox ] -def toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +def toggle-expected-response sandbox:&:sandbox-data -> sandbox:&:sandbox-data [ local-scope load-ingredients expected-response:text <- get *sandbox, expected-response:offset @@ -185,13 +185,13 @@ after [ *sandbox <- put *sandbox, response-starting-row-on-screen:offset, row expected-response:text <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey - response-is-expected?:boolean <- equal expected-response, sandbox-response + response-is-expected?:bool <- equal expected-response, sandbox-response { - break-if response-is-expected?:boolean + break-if response-is-expected?:bool row, screen <- render-text screen, sandbox-response, left, right, 1/red, row } { - break-unless response-is-expected?:boolean + break-unless response-is-expected?:bool row, screen <- render-text screen, sandbox-response, left, right, 2/green, row } jump +render-sandbox-end:label diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index 0fda5f15..96e346c8 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -8,8 +8,8 @@ scenario sandbox-click-on-code-toggles-app-trace [ assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -24,9 +24,9 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - 4:character/cursor-icon <- copy 9251/␣ - print screen:address:screen, 4:character/cursor-icon + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + 4:char/cursor-icon <- copy 9251/␣ + print screen:&:screen, 4:char/cursor-icon ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -50,8 +50,8 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 25 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - print screen:address:screen, 4:character/cursor-icon + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data + print screen:&:screen, 4:char/cursor-icon ] # trace hidden again screen-should-contain [ @@ -74,8 +74,8 @@ add 2, 2] assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -92,7 +92,7 @@ add 2, 2] left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # trace now printed above result screen-should-contain [ @@ -118,8 +118,8 @@ scenario clicking-on-app-trace-does-nothing [ press F4 left-click 4, 1 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -133,7 +133,7 @@ scenario clicking-on-app-trace-does-nothing [ left-click 5, 7 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # no change; doesn't die screen-should-contain [ @@ -148,15 +148,15 @@ scenario clicking-on-app-trace-does-nothing [ container sandbox-data [ trace:text - display-trace?:boolean + display-trace?:bool ] # replaced in a later layer -def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [ +def! update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num -> sandbox:&:sandbox-data, env:&:programming-environment-data [ local-scope load-ingredients data:text <- get *sandbox, data:offset - response:text, _, fake-screen:address:screen, trace:text <- run-sandboxed data + response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed data *sandbox <- put *sandbox, response:offset, response *sandbox <- put *sandbox, screen:offset, fake-screen *sandbox <- put *sandbox, trace:offset, trace @@ -166,21 +166,21 @@ def! update-sandbox sandbox:address:sandbox-data, env:address:programming-enviro after [ # check if it's inside the code of any sandbox { - sandbox-left-margin:number <- get *current-sandbox, left:offset - click-column:number <- get t, column:offset - on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num <- get *current-sandbox, left:offset + click-column:num <- get t, column:offset + on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:&: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 + first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset + click-row:num <- get t, row:offset + below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose code is being clicked on - sandbox:address:sandbox-data <- find-click-in-sandbox-code env, click-row + sandbox:&:sandbox-data <- find-click-in-sandbox-code env, click-row break-unless sandbox # toggle its display-trace? property - x:boolean <- get *sandbox, display-trace?:offset + x:bool <- get *sandbox, display-trace?:offset x <- not x *sandbox <- put *sandbox, display-trace?:offset, x hide-screen screen @@ -192,30 +192,30 @@ after [ } ] -def find-click-in-sandbox-code env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +def find-click-in-sandbox-code env:&:programming-environment-data, click-row:num -> sandbox:&:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen sandbox <- get *env, sandbox:offset - start:number <- get *sandbox, starting-row-on-screen:offset - clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start + start:num <- get *sandbox, starting-row-on-screen:offset + clicked-on-sandboxes?:bool <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:&: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 + next-start:num <- get *next-sandbox, starting-row-on-screen:offset + found?:bool <- lesser-than click-row, next-start break-if found? sandbox <- copy next-sandbox loop } # return sandbox if click is in its code region - code-ending-row:number <- get *sandbox, code-ending-row-on-screen:offset - click-above-response?:boolean <- lesser-than click-row, code-ending-row - start:number <- get *sandbox, starting-row-on-screen:offset - click-below-menu?:boolean <- greater-than click-row, start - click-on-sandbox-code?:boolean <- and click-above-response?, click-below-menu? + code-ending-row:num <- get *sandbox, code-ending-row-on-screen:offset + click-above-response?:bool <- lesser-than click-row, code-ending-row + start:num <- get *sandbox, starting-row-on-screen:offset + click-below-menu?:bool <- greater-than click-row, start + click-on-sandbox-code?:bool <- and click-above-response?, click-below-menu? { break-if click-on-sandbox-code? return 0/no-click-in-sandbox-output @@ -226,7 +226,7 @@ def find-click-in-sandbox-code env:address:programming-environment-data, click-r # when rendering a sandbox, dump its trace before response/warning if display-trace? property is set after [ { - display-trace?:boolean <- get *sandbox, display-trace?:offset + display-trace?:bool <- get *sandbox, display-trace?:offset break-unless display-trace? sandbox-trace:text <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index f30eeafc..ccdf0863 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -6,7 +6,7 @@ container programming-environment-data [ # copy code from recipe editor, persist, load into mu, save any errors # test-recipes is a hook for testing -def! update-recipes env:address:programming-environment-data, screen:address:screen, test-recipes:text -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +def! update-recipes env:&:programming-environment-data, screen:&:screen, test-recipes:text -> errors-found?:bool, env:&:programming-environment-data, screen:&:screen [ local-scope load-ingredients { @@ -40,7 +40,7 @@ before [ ] container programming-environment-data [ - error-index:number # index of first sandbox with an error (or -1 if none) + error-index:num # index of first sandbox with an error (or -1 if none) ] after [ @@ -53,8 +53,8 @@ after [ before [ { - error-index:number <- get *env, error-index:offset - sandboxes-completed-successfully?:boolean <- equal error-index, -1 + error-index:num <- get *env, error-index:offset + sandboxes-completed-successfully?:bool <- equal error-index, -1 break-if sandboxes-completed-successfully? errors-found? <- copy 1/true } @@ -63,8 +63,8 @@ before [ before [ { break-if recipe-errors - error-index:number <- get *env, error-index:offset - sandboxes-completed-successfully?:boolean <- equal error-index, -1 + error-index:num <- get *env, error-index:offset + sandboxes-completed-successfully?:bool <- equal error-index, -1 break-if sandboxes-completed-successfully? error-index-text:text <- to-text error-index status:text <- interpolate [errors found (_) ], error-index-text @@ -76,7 +76,7 @@ container sandbox-data [ errors:text ] -def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [ +def! update-sandbox sandbox:&:sandbox-data, env:&:programming-environment-data, idx:num -> sandbox:&:sandbox-data, env:&:programming-environment-data [ local-scope load-ingredients { @@ -86,22 +86,22 @@ def! update-sandbox sandbox:address:sandbox-data, env:address:programming-enviro return } data:text <- get *sandbox, data:offset - response:text, errors:text, fake-screen:address:screen, trace:text, completed?:boolean <- run-sandboxed data + response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data *sandbox <- put *sandbox, response:offset, response *sandbox <- put *sandbox, errors:offset, errors *sandbox <- put *sandbox, screen:offset, fake-screen *sandbox <- put *sandbox, trace:offset, trace { break-if errors - break-if completed?:boolean + break-if completed?:bool errors <- new [took too long! ] *sandbox <- put *sandbox, errors:offset, errors } { break-unless errors - error-index:number <- get *env, error-index:offset - error-not-set?:boolean <- equal error-index, -1 + error-index:num <- get *env, error-index:offset + error-not-set?:bool <- equal error-index, -1 break-unless error-not-set? *env <- put *env, error-index:offset, idx } @@ -129,15 +129,15 @@ scenario run-shows-errors-in-get [ assume-screen 50/width, 20/height 1:text <- new [ def foo [ - get 123:number, foo:offset + get 123:num, foo:offset ]] 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -147,7 +147,7 @@ def foo [ .foo . .foo: unknown element 'foo' in container 'number' . .foo: first ingredient of 'get' should be a contai↩. - .ner, but got '123:number' . + .ner, but got '123:num' . ] screen-should-contain-in-color 1/red, [ . errors found . @@ -160,7 +160,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ assume-screen 50/width, 20/height 1:text <- new [] 2:text <- new [] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ # create invalid sandbox 1 type [get foo, x:offset] @@ -170,7 +170,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/empty-test-recipes ] # status line shows that error is in first sandbox screen-should-contain [ @@ -183,7 +183,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ assume-screen 50/width, 20/height 1:text <- new [] 2:text <- new [] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ # create invalid sandbox 2 type [get foo, x:offset] @@ -196,7 +196,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/empty-test-recipes ] # status line shows that error is in second sandbox screen-should-contain [ @@ -209,11 +209,11 @@ scenario run-hides-errors-from-past-sandboxes [ assume-screen 50/width, 20/height 1:text <- new [] 2:text <- new [get foo, x:offset] # invalid - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 # generate error ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/empty-test-recipes assume-console [ left-click 3, 10 press ctrl-k @@ -221,7 +221,7 @@ scenario run-hides-errors-from-past-sandboxes [ press F4 # update sandbox ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data ] # error should disappear screen-should-contain [ @@ -243,15 +243,15 @@ scenario run-updates-errors-for-shape-shifting-recipes [ 1:text <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients -y:address:number <- copy 0 +y:&:num <- copy 0 z <- add x, y ]] 2:text <- new [foo 2] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes screen-should-contain [ . errors found (0) run (F4) . . . @@ -268,7 +268,7 @@ z <- add x, y press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] # error should remain unchanged screen-should-contain [ @@ -288,24 +288,24 @@ scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ trace-until 100/app # trace too long assume-screen 50/width, 20/height # overload a well-known shape-shifting recipe - 1:text <- new [recipe length l:address:list:_elem -> n:number [ + 1:text <- new [recipe length l:&:list:_elem -> n:num [ ]] # call code that uses other variants of it, but not it itself - 2:text <- new [x:address:list:number <- copy 0 + 2:text <- new [x:&:list:num <- copy 0 to-text x] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text # run it once assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes # no errors anywhere on screen (can't check anything else, since to-text will return an address) screen-should-contain-in-color 1/red, [ . . . . . . . . - . <- . + . <- . . . . . . . @@ -316,7 +316,7 @@ to-text x] press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] # still no errors screen-should-contain-in-color 1/red, [ @@ -324,7 +324,7 @@ to-text x] . . . . . . - . <- . + . <- . . . . . . . @@ -340,12 +340,12 @@ def foo [ x <- copy 0 ]] 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -366,12 +366,12 @@ recipe foo \\[ x <- copy 0 ] 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -392,16 +392,16 @@ scenario run-shows-get-on-non-container-errors [ 1:text <- new [ def foo [ local-scope - x:address:point <- new point:type - get x:address:point, 1:offset + x:&:point <- new point:type + get x:&:point, 1:offset ]] 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -410,7 +410,7 @@ def foo [ .0 edit copy delete . .foo . .foo: first ingredient of 'get' should be a contai↩. - .ner, but got 'x:address:point' . + .ner, but got 'x:&:point' . ] ] @@ -420,17 +420,17 @@ scenario run-shows-non-literal-get-argument-errors [ 1:text <- new [ def foo [ local-scope - x:number <- copy 0 - y:address:point <- new point:type - get *y:address:point, x:number + x:num <- copy 0 + y:&:point <- new point:type + get *y:&:point, x:num ]] 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -439,7 +439,7 @@ def foo [ .0 edit copy delete . .foo . .foo: second ingredient of 'get' should have type ↩. - .'offset', but got 'x:number' . + .'offset', but got 'x:num' . ] ] @@ -450,14 +450,14 @@ scenario run-shows-errors-everytime [ 1:text <- new [ def foo [ local-scope - x:number <- copy y:number + x:num <- copy y:num ]] 2:text <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes screen-should-contain [ . errors found run (F4) . . . @@ -471,7 +471,7 @@ def foo [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] screen-should-contain [ . errors found run (F4) . @@ -486,22 +486,22 @@ def foo [ scenario run-instruction-and-print-errors [ trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:text <- new [get 1:address:point, 1:offset] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 1:text <- new [get 1:&:point, 1:offset] + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . errors found (0) run (F4) . . . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. .0 edit copy delete . - .get 1:address:point, 1:offset . + .get 1:&:point, 1:offset . .first ingredient of 'get' should be a container, ↩. - .but got '1:address:point' . + .but got '1:&:point' . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . . ] @@ -512,7 +512,7 @@ scenario run-instruction-and-print-errors [ . . . . .first ingredient of 'get' should be a container, . - .but got '1:address:point' . + .but got '1:&:point' . . . . . ] @@ -522,15 +522,15 @@ scenario run-instruction-and-print-errors-only-once [ trace-until 100/app # trace too long assume-screen 50/width, 10/height # editor contains an illegal instruction - 1:text <- new [get 1234:number, foo:offset] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 1:text <- new [get 1234:num, foo:offset] + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] # check that screen prints error message just once screen-should-contain [ @@ -538,10 +538,10 @@ scenario run-instruction-and-print-errors-only-once [ . . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. .0 edit copy delete . - .get 1234:number, foo:offset . + .get 1234:num, foo:offset . .unknown element 'foo' in container 'number' . .first ingredient of 'get' should be a container, ↩. - .but got '1234:number' . + .but got '1234:num' . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . . ] @@ -554,13 +554,13 @@ scenario sandbox-can-handle-infinite-loop [ 1:text <- new [{ loop }] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:text + 2:&:programming-environment-data <- new-programming-environment screen:&:screen, 1:text # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:&:screen, console:&:console, 2:&:programming-environment-data ] screen-should-contain [ . errors found (0) run (F4) . @@ -582,19 +582,19 @@ scenario sandbox-with-errors-shows-trace [ # generate a stash and a error 1:text <- new [recipe foo [ local-scope -a:number <- next-ingredient -b:number <- next-ingredient +a:num <- next-ingredient +b:num <- next-ingredient stash [dividing by], b -_, c:number <- divide-with-remainder a, b +_, c:num <- divide-with-remainder a, b return b ]] 2:text <- new [foo 4, 0] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 2:text + 3:&:programming-environment-data <- new-programming-environment screen:&:screen, 2:text # run assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes # screen prints error message screen-should-contain [ . errors found (0) run (F4) . @@ -602,8 +602,8 @@ return b .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. .0 edit copy delete . .foo 4, 0 . - .foo: divide by zero in '_, c:number <- divide-wit↩. - .h-remainder a, b' . + .foo: divide by zero in '_, c:num <- divide-with-r↩. + .emainder a, b' . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . . ] @@ -612,7 +612,7 @@ return b left-click 4, 15 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, 3:&:programming-environment-data, 1:text/test-recipes ] # screen should expand trace screen-should-contain [ @@ -623,8 +623,8 @@ return b .foo 4, 0 . .dividing by 0 . .14 instructions run . - .foo: divide by zero in '_, c:number <- divide-wit↩. - .h-remainder a, b' . + .foo: divide by zero in '_, c:num <- divide-with-r↩. + .emainder a, b' . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . . ] diff --git a/sandbox/012-editor-undo.mu b/sandbox/012-editor-undo.mu index 2239560b..99ebecd9 100644 --- a/sandbox/012-editor-undo.mu +++ b/sandbox/012-editor-undo.mu @@ -9,28 +9,28 @@ exclusive-container operation [ ] container insert-operation [ - before-row:number - before-column:number - before-top-of-screen:address:duplex-list:character - after-row:number - after-column:number - after-top-of-screen:address:duplex-list:character + before-row:num + before-column:num + before-top-of-screen:&:duplex-list:char + after-row:num + after-column:num + after-top-of-screen:&:duplex-list:char # 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 - tag:number # event causing this operation; might be used to coalesce runs of similar events + insert-from:&:duplex-list:char + insert-until:&:duplex-list:char + tag:num # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (enter+indent) # 1: regular alphanumeric characters ] container move-operation [ - before-row:number - before-column:number - before-top-of-screen:address:duplex-list:character - after-row:number - after-column:number - after-top-of-screen:address:duplex-list:character - tag:number # event causing this operation; might be used to coalesce runs of similar events + before-row:num + before-column:num + before-top-of-screen:&:duplex-list:char + after-row:num + after-column:num + after-top-of-screen:&:duplex-list:char + tag:num # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (touch events, etc) # 1: left arrow # 2: right arrow @@ -39,16 +39,16 @@ container move-operation [ ] container delete-operation [ - before-row:number - before-column:number - before-top-of-screen:address: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 - tag:number # event causing this operation; might be used to coalesce runs of similar events + before-row:num + before-column:num + before-top-of-screen:&:duplex-list:char + after-row:num + after-column:num + after-top-of-screen:&:duplex-list:char + deleted-text:&:duplex-list:char + delete-from:&:duplex-list:char + delete-until:&:duplex-list:char + tag:num # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (ctrl-k, ctrl-u) # 1: backspace # 2: delete @@ -56,21 +56,21 @@ 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:&:list:&:operation + redo:&:list:&:operation ] # ctrl-z - undo operation after [ { - undo?:boolean <- equal c, 26/ctrl-z + undo?:bool <- equal c, 26/ctrl-z break-unless undo? - undo:address:list:address:operation <- get *editor, undo:offset + undo:&:list:&:operation <- get *editor, undo:offset break-unless undo - op:address:operation <- first undo + op:&:operation <- first undo undo <- rest undo *editor <- put *editor, undo:offset, undo - redo:address:list:address:operation <- get *editor, redo:offset + redo:&:list:&:operation <- get *editor, redo:offset redo <- push op, redo *editor <- put *editor, redo:offset, redo @@ -81,14 +81,14 @@ after [ # ctrl-y - redo operation after [ { - redo?:boolean <- equal c, 25/ctrl-y + redo?:bool <- equal c, 25/ctrl-y break-unless redo? - redo:address:list:address:operation <- get *editor, redo:offset + redo:&:list:&:operation <- get *editor, redo:offset break-unless redo - op:address:operation <- first redo + op:&:operation <- first redo redo <- rest redo *editor <- put *editor, redo:offset, redo - undo:address:list:address:operation <- get *editor, undo:offset + undo:&:list:&:operation <- get *editor, undo:offset undo <- push op, undo *editor <- put *editor, undo:offset, undo @@ -102,18 +102,18 @@ scenario editor-can-undo-typing [ # create an editor and type a character assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] # character should be gone screen-should-contain [ @@ -127,7 +127,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -139,24 +139,24 @@ scenario editor-can-undo-typing [ # save operation to undo after [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- get *editor, before-cursor:offset + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset ] before [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - undo:address:list:address:operation <- get *editor, undo:offset + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + undo:&:list:&:operation <- get *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless undo - op:address:operation <- first undo - typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant + op:&:operation <- first undo + typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant break-unless is-insert? - previous-coalesce-tag:number <- get typing, tag:offset + previous-coalesce-tag:num <- get typing, tag:offset break-unless previous-coalesce-tag - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - insert-until:address:duplex-list:character <- next before-cursor + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + insert-until:&:duplex-list:char <- next before-cursor typing <- put typing, insert-until:offset, insert-until typing <- put typing, after-row:offset, cursor-row typing <- put typing, after-column:offset, cursor-column @@ -165,9 +165,9 @@ before [ 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:&:duplex-list:char <- next cursor-before + insert-to:&:duplex-list:char <- next insert-from + op:&: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 @@ -175,20 +175,20 @@ before [ # enter operations never coalesce with typing before or after after [ - 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 <- get *editor, before-cursor:offset + cursor-row-before:num <- copy cursor-row + cursor-column-before:num <- copy cursor-column + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-before:&:duplex-list:char <- get *editor, before-cursor:offset ] before [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-row:offset + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-row:offset # never coalesce - insert-from:address:duplex-list:character <- next cursor-before - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - insert-to:address:duplex-list:character <- next before-cursor - op:address:operation <- new operation:type + insert-from:&:duplex-list:char <- next cursor-before + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + insert-to:&:duplex-list:char <- next before-cursor + op:&:operation <- new operation:type *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce editor <- add-operation editor, op ] @@ -197,13 +197,13 @@ before [ # redo stack, because it's now obsolete. # Beware: since we're counting cursor moves as operations, this means just # moving the cursor can lose work on the undo stack. -def add-operation editor:address:editor-data, op:address:operation -> editor:address:editor-data [ +def add-operation editor:&:editor-data, op:&:operation -> editor:&:editor-data [ local-scope load-ingredients - undo:address:list:address:operation <- get *editor, undo:offset + undo:&:list:&:operation <- get *editor, undo:offset undo <- push op undo *editor <- put *editor, undo:offset, undo - redo:address:list:address:operation <- get *editor, redo:offset + redo:&:list:&:operation <- get *editor, redo:offset redo <- copy 0 *editor <- put *editor, redo:offset, redo return editor/same-as-ingredient:0 @@ -211,19 +211,19 @@ def add-operation editor:address:editor-data, op:address:operation -> editor:add after [ { - typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant + typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant break-unless is-insert? - start:address:duplex-list:character <- get typing, insert-from:offset - end:address:duplex-list:character <- get typing, insert-until:offset + start:&:duplex-list:char <- get typing, insert-from:offset + end:&:duplex-list:char <- get typing, insert-until:offset # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - before-cursor:address:duplex-list:character <- prev start + before-cursor:&:duplex-list:char <- prev start *editor <- put *editor, before-cursor:offset, before-cursor remove-between before-cursor, end cursor-row <- get typing, before-row:offset *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get typing, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:duplex-list:character <- get typing, before-top-of-screen:offset + top:&:duplex-list:char <- get typing, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -232,18 +232,18 @@ scenario editor-can-undo-typing-multiple [ # create an editor and type multiple characters assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data ] # all characters must be gone screen-should-contain [ @@ -258,13 +258,13 @@ scenario editor-can-undo-typing-multiple-2 [ # create an editor with some text assume-screen 10/width, 5/height 1:text <- new [a] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . .012a . @@ -276,7 +276,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # back to original text screen-should-contain [ @@ -290,7 +290,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -304,14 +304,14 @@ scenario editor-can-undo-typing-enter [ # create an editor with some text assume-screen 10/width, 5/height 1:text <- new [ abc] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . . abc . @@ -320,8 +320,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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -331,10 +331,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -351,7 +351,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -367,13 +367,13 @@ scenario editor-redo-typing [ # create an editor, type something, undo assume-screen 10/width, 5/height 1:text <- new [a] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . .a . @@ -385,7 +385,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:&:screen, console:&:console, 2:&:editor-data ] # all characters must be back screen-should-contain [ @@ -399,7 +399,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -411,10 +411,10 @@ scenario editor-redo-typing [ after [ { - typing:insert-operation, is-insert?:boolean <- maybe-convert *op, typing:variant + typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant break-unless is-insert? before-cursor <- get *editor, before-cursor:offset - insert-from:address:duplex-list:character <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away + insert-from:&:duplex-list:char <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away # assert insert-to matches next(before-cursor) insert-range before-cursor, insert-from # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen @@ -422,7 +422,7 @@ after [ *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get typing, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:duplex-list:character <- get typing, after-top-of-screen:offset + top:&:duplex-list:char <- get typing, after-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -431,13 +431,13 @@ scenario editor-redo-typing-empty [ # create an editor, type something, undo assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . . . @@ -449,7 +449,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:&:screen, console:&:console, 2:&:editor-data ] # all characters must be back screen-should-contain [ @@ -463,7 +463,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -479,18 +479,18 @@ scenario editor-work-clears-redo-stack [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . .0abc . @@ -503,7 +503,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # nothing should happen screen-should-contain [ @@ -519,8 +519,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -531,7 +531,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . . ab cd . @@ -539,8 +539,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -550,11 +550,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -571,11 +571,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -591,11 +591,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -611,11 +611,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -631,11 +631,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -652,11 +652,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -678,21 +678,21 @@ scenario editor-can-undo-touch [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # click undone memory-should-contain [ @@ -704,7 +704,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -716,25 +716,25 @@ ghi] ] after [ - cursor-row-before:number <- get *editor, cursor-row:offset - cursor-column-before:number <- get *editor, cursor-column:offset - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + cursor-row-before:num <- get *editor, cursor-row:offset + cursor-column-before:num <- get *editor, cursor-column:offset + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset ] before [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset { break-unless undo-coalesce-tag # if previous operation was also a move, and also had the same coalesce # tag, coalesce with it - undo:address:list:address:operation <- get *editor, undo:offset + undo:&:list:&:operation <- get *editor, undo:offset break-unless undo - op:address:operation <- first undo - move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant + op:&:operation <- first undo + move:move-operation, is-move?:bool <- maybe-convert *op, move:variant break-unless is-move? - previous-coalesce-tag:number <- get move, tag:offset - coalesce?:boolean <- equal undo-coalesce-tag, previous-coalesce-tag + previous-coalesce-tag:num <- get move, tag:offset + coalesce?:bool <- equal undo-coalesce-tag, previous-coalesce-tag break-unless coalesce? move <- put move, after-row:offset, cursor-row move <- put move, after-column:offset, cursor-column @@ -742,7 +742,7 @@ before [ *op <- merge 1/move-operation, move break +done-adding-move-operation:label } - op:address:operation <- new operation:type + op:&:operation <- new operation:type *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag editor <- add-operation editor, op +done-adding-move-operation @@ -750,14 +750,14 @@ before [ after [ { - move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant + move:move-operation, is-move?:bool <- maybe-convert *op, move:variant break-unless is-move? # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen cursor-row <- get move, before-row:offset *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get move, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:duplex-list:character <- get move, before-top-of-screen:offset + top:&:duplex-list:char <- get move, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -768,22 +768,22 @@ scenario editor-can-undo-left-arrow [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -795,7 +795,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -812,16 +812,16 @@ scenario editor-can-undo-up-arrow [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -831,9 +831,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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -845,7 +845,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -862,22 +862,22 @@ scenario editor-can-undo-down-arrow [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -889,7 +889,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -906,22 +906,22 @@ scenario editor-can-undo-ctrl-a [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -933,7 +933,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -950,22 +950,22 @@ scenario editor-can-undo-home [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -977,7 +977,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -994,22 +994,22 @@ scenario editor-can-undo-ctrl-e [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1021,7 +1021,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1038,22 +1038,22 @@ scenario editor-can-undo-end [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1065,7 +1065,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1082,8 +1082,8 @@ scenario editor-can-undo-multiple-arrows-in-the-same-direction [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data # move the cursor assume-console [ left-click 2, 1 @@ -1091,9 +1091,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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1103,9 +1103,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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # up-arrow is undone memory-should-contain [ @@ -1117,9 +1117,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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # both right-arrows are undone memory-should-contain [ @@ -1136,21 +1136,21 @@ scenario editor-redo-touch [ 1:text <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves to left-click memory-should-contain [ @@ -1162,7 +1162,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1175,14 +1175,14 @@ ghi] after [ { - move:move-operation, is-move?:boolean <- maybe-convert *op, move:variant + move:move-operation, is-move?:bool <- maybe-convert *op, move:variant break-unless is-move? # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen cursor-row <- get move, after-row:offset *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get move, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:duplex-list:character <- get move, after-top-of-screen:offset + top:&:duplex-list:char <- get move, after-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1191,16 +1191,16 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ # create an editor, type some text, move the cursor, type some more text assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1216,9 +1216,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1236,9 +1236,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1256,9 +1256,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1276,9 +1276,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # first insert screen-should-contain [ @@ -1296,9 +1296,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1317,9 +1317,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen: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:&:screen, console:&:console, 2:&:editor-data + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset ] # second insert screen-should-contain [ @@ -1340,23 +1340,23 @@ scenario editor-can-undo-and-redo-backspace [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1366,10 +1366,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1385,10 +1385,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1403,27 +1403,27 @@ scenario editor-can-undo-and-redo-backspace [ # save operation to undo after [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset ] before [ { break-unless backspaced-cell # backspace failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-row:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - undo:address:list:address:operation <- get *editor, undo:offset + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-row:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + undo:&:list:&:operation <- get *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless undo - op:address:operation <- first undo - deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + op:&:operation <- first undo + deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant break-unless is-delete? - previous-coalesce-tag:number <- get deletion, tag:offset - coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace + previous-coalesce-tag:num <- get deletion, tag:offset + coalesce?:bool <- equal previous-coalesce-tag, 1/coalesce-backspace break-unless coalesce? deletion <- put deletion, delete-from:offset, before-cursor - backspaced-so-far:address:duplex-list:character <- get deletion, deleted-text:offset + backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset insert-range backspaced-cell, backspaced-so-far deletion <- put deletion, deleted-text:offset, backspaced-cell deletion <- put deletion, after-row:offset, cursor-row @@ -1433,8 +1433,8 @@ before [ 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:&:operation <- new operation:type + deleted-until:&:duplex-list:char <- 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 @@ -1443,12 +1443,12 @@ before [ after [ { - deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant break-unless is-delete? - anchor:address:duplex-list:character <- get deletion, delete-from:offset + anchor:&:duplex-list:char <- 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:&:duplex-list:char <- get deletion, deleted-text:offset + old-cursor:&:duplex-list:char <- 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 @@ -1456,25 +1456,25 @@ after [ *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get deletion, before-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:duplex-list:character <- get deletion, before-top-of-screen:offset + top:&:duplex-list:char <- get deletion, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] after [ { - deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant break-unless is-delete? - start:address:duplex-list:character <- get deletion, delete-from:offset - end:address:duplex-list:character <- get deletion, delete-until:offset - data:address:duplex-list:character <- get *editor, data:offset + start:&:duplex-list:char <- get deletion, delete-from:offset + end:&:duplex-list:char <- get deletion, delete-until:offset + data:&:duplex-list:char <- get *editor, data:offset remove-between start, end # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen cursor-row <- get deletion, after-row:offset *editor <- put *editor, cursor-row:offset, cursor-row cursor-column <- get deletion, after-column:offset *editor <- put *editor, cursor-column:offset, cursor-column - top:address:duplex-list:character <- get deletion, before-top-of-screen:offset + top:&:duplex-list:char <- get deletion, before-top-of-screen:offset *editor <- put *editor, top-of-screen:offset, top } ] @@ -1485,8 +1485,8 @@ scenario editor-can-undo-and-redo-delete [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&:editor-data # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1496,15 +1496,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1514,10 +1514,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1533,10 +1533,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1552,10 +1552,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1571,11 +1571,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1591,11 +1591,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1611,11 +1611,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&: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:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1629,28 +1629,28 @@ scenario editor-can-undo-and-redo-delete [ ] after [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset ] before [ { break-unless deleted-cell # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - undo:address:list:address:operation <- get *editor, undo:offset + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + undo:&:list:&:operation <- get *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless undo - op:address:operation <- first undo - deletion:delete-operation, is-delete?:boolean <- maybe-convert *op, delete:variant + op:&:operation <- first undo + deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant break-unless is-delete? - previous-coalesce-tag:number <- get deletion, tag:offset - coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete + previous-coalesce-tag:num <- get deletion, tag:offset + coalesce?:bool <- equal previous-coalesce-tag, 2/coalesce-delete break-unless coalesce? - delete-until:address:duplex-list:character <- next before-cursor + delete-until:&:duplex-list:char <- next before-cursor deletion <- put deletion, delete-until:offset, delete-until - deleted-so-far:address:duplex-list:character <- get deletion, deleted-text:offset + deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset deleted-so-far <- append deleted-so-far, deleted-cell deletion <- put deletion, deleted-text:offset, deleted-so-far deletion <- put deletion, after-row:offset, cursor-row @@ -1660,8 +1660,8 @@ before [ 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:&:operation <- new operation:type + deleted-until:&:duplex-list:char <- 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 @@ -1675,14 +1675,14 @@ scenario editor-can-undo-and-redo-ctrl-k [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . .a . @@ -1690,8 +1690,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1701,7 +1701,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1710,8 +1710,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1721,7 +1721,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # first line inserted screen-should-contain [ @@ -1731,8 +1731,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1742,7 +1742,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1754,16 +1754,16 @@ def] ] after [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset ] before [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset - deleted-until:address:duplex-list:character <- next before-cursor - op:address:operation <- new operation:type + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset + deleted-until:&:duplex-list:char <- next before-cursor + op:&:operation <- new operation:type *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -1777,14 +1777,14 @@ scenario editor-can-undo-and-redo-ctrl-u [ assume-screen 10/width, 5/height 1:text <- new [abc def] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . .c . @@ -1792,8 +1792,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1803,7 +1803,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1812,8 +1812,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1823,7 +1823,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] # first line inserted screen-should-contain [ @@ -1833,8 +1833,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:num <- get *2:&:editor-data, cursor-row:offset + 4:num <- get *2:&:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1844,7 +1844,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:&:screen, console:&:console, 2:&:editor-data ] screen-should-contain [ . . @@ -1856,17 +1856,17 @@ def] ] after [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:&:duplex-list:char <- get *editor, top-of-screen:offset ] before [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - op:address:operation <- new operation:type - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset - deleted-until:address:duplex-list:character <- next before-cursor - cursor-row:number <- get *editor, cursor-row:offset - cursor-column:number <- get *editor, cursor-column:offset + top-after:&:duplex-list:char <- get *editor, top-of-screen:offset + op:&:operation <- new operation:type + before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset + deleted-until:&:duplex-list:char <- next before-cursor + cursor-row:num <- get *editor, cursor-row:offset + cursor-column:num <- get *editor, cursor-column:offset *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -1877,15 +1877,15 @@ scenario editor-can-undo-and-redo-ctrl-u-2 [ # create an editor assume-screen 10/width, 5/height 1:text <- new [] - 2:address:editor-data <- new-editor 1:text, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:&:editor-data <- new-editor 1:text, screen:&:screen, 0/left, 10/right + editor-render screen, 2:&: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:&:screen, console:&:console, 2:&:editor-data screen-should-contain [ . . .abc . -- cgit 1.4.1-2-gfad0