diff options
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/001-editor.mu | 32 | ||||
-rw-r--r-- | sandbox/002-typing.mu | 62 | ||||
-rw-r--r-- | sandbox/003-shortcuts.mu | 126 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 24 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 48 | ||||
-rw-r--r-- | sandbox/006-sandbox-edit.mu | 6 | ||||
-rw-r--r-- | sandbox/007-sandbox-delete.mu | 8 | ||||
-rw-r--r-- | sandbox/008-sandbox-test.mu | 20 | ||||
-rw-r--r-- | sandbox/009-sandbox-trace.mu | 8 | ||||
-rw-r--r-- | sandbox/010-errors.mu | 22 | ||||
-rw-r--r-- | sandbox/011-editor-undo.mu | 8 |
11 files changed, 182 insertions, 182 deletions
diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index d338b4bb..818f3520 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -2,7 +2,7 @@ # temporary main for this layer: just render the given text at the given # screen dimensions, then stop -recipe! main text:address:shared:array:character [ +def! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -48,7 +48,7 @@ container editor-data [ # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -recipe new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ +def new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ local-scope load-ingredients # no clipping of bounds @@ -79,13 +79,13 @@ recipe new-editor s:address:shared:array:character, screen:address:shared:screen <editor-initialization> ] -recipe insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ +def insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ local-scope load-ingredients # early exit if text is empty - reply-unless text, editor/same-as-ingredient:0 + return-unless text, editor/same-as-ingredient:0 len:number <- length *text - reply-unless len, editor/same-as-ingredient:0 + return-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character curr:address:shared:duplex-list:character <- get *editor, data:offset @@ -99,7 +99,7 @@ recipe insert-text editor:address:shared:editor-data, text:address:shared:array: idx <- add idx, 1 loop } - reply editor/same-as-ingredient:0 + return editor/same-as-ingredient:0 ] scenario editor-initializes-without-data [ @@ -129,10 +129,10 @@ scenario editor-initializes-without-data [ # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -recipe render screen:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ +def render screen:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients - reply-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + 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 @@ -226,10 +226,10 @@ recipe render screen:address:shared:screen, editor:address:shared:editor-data -> } bottom:address:number <- get-address *editor, bottom:offset *bottom <- copy row - reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ +def clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients space:character <- copy 32/space @@ -248,23 +248,23 @@ recipe clear-line-delimited screen:address:shared:screen, column:number, right:n } ] -recipe clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ +def clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive { break-if screen clear-display-from row, column, left, right - reply screen/same-as-ingredient:0 + return screen/same-as-ingredient:0 } # if not, go the slower route screen <- move-cursor screen, row, column clear-line-delimited screen, column, right clear-rest-of-screen screen, row, left, right - reply screen/same-as-ingredient:0 + return screen/same-as-ingredient:0 ] -recipe clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ +def clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients row <- add row, 1 @@ -422,7 +422,7 @@ after <character-c-received> [ ] # so far the previous color is all the information we need; that may change -recipe get-color color:number, c:character -> color:number [ +def get-color color:number, c:character -> color:number [ local-scope load-ingredients color-is-white?:boolean <- equal color, 7/white @@ -464,7 +464,7 @@ recipe get-color color:number, c:character -> color:number [ } # otherwise no change +exit - reply color + return color ] scenario render-colors-assignment [ diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index f3f6b321..7a68bb64 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -2,7 +2,7 @@ # temporary main: interactive editor # hit ctrl-c to exit -recipe! main text:address:shared:array:character [ +def! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -11,7 +11,7 @@ recipe! main text:address:shared:array:character [ close-console ] -recipe editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ +def editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ local-scope load-ingredients { @@ -45,35 +45,35 @@ recipe editor-event-loop screen:address:shared:screen, console:address:shared:co ] # process click, return if it was on current editor -recipe move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ +def move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ local-scope load-ingredients - reply-unless editor, 0/false + return-unless editor, 0/false click-row:number <- get t, row:offset - reply-unless click-row, 0/false # ignore clicks on 'menu' + 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 - reply-if too-far-left?, 0/false + return-if too-far-left?, 0/false right:number <- get *editor, right:offset too-far-right?:boolean <- greater-than click-column, right - reply-if too-far-right?, 0/false + return-if too-far-right?, 0/false # position cursor <move-cursor-begin> editor <- snap-cursor screen, editor, click-row, click-column undo-coalesce-tag:number <- copy 0/never <move-cursor-end> # gain focus - reply 1/true + return 1/true ] # Variant of 'render' that only moves the cursor (coordinates and # before-cursor). If it's past the end of a line, it 'slides' it left. If it's # past the last line it positions at end of last line. -recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ +def snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ local-scope load-ingredients - reply-unless editor + return-unless editor left:number <- get *editor, left:offset right:number <- get *editor, right:offset screen-height:number <- screen-height screen @@ -155,11 +155,11 @@ recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-da # Process an event 'e' and try to minimally update the screen. # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. -recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ +def handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients go-render? <- copy 0/false - reply-unless editor + return-unless editor screen-width:number <- screen-width screen screen-height:number <- screen-height screen left:number <- get *editor, left:offset @@ -179,12 +179,12 @@ recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared # ignore any other special characters regular-character?:boolean <- greater-or-equal *c, 32/space go-render? <- copy 0/false - reply-unless regular-character? + return-unless regular-character? # otherwise type it in <insert-character-begin> editor, screen, go-render?:boolean <- insert-at-cursor editor, *c, screen <insert-character-end> - reply + return } # special key to modify the text or move the cursor k:address:number <- maybe-convert e:event, keycode:variant @@ -192,10 +192,10 @@ recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared # handlers for each special key will go here <handle-special-key> go-render? <- copy 1/true - reply + return ] -recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ +def insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset @@ -226,7 +226,7 @@ recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:a move-cursor screen, save-row, save-column print screen, c go-render? <- copy 0/false - reply + return } { # not at right margin? print the character and rest of line @@ -240,7 +240,7 @@ recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:a # hit right margin? give up and let caller render go-render? <- copy 1/true at-right?:boolean <- greater-than curr-column, right - reply-if at-right? + return-if at-right? break-unless curr # newline? done. currc:character <- get *curr, value:offset @@ -252,14 +252,14 @@ recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:a loop } go-render? <- copy 0/false - reply + return } go-render? <- copy 1/true - reply + return ] # helper for tests -recipe editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ +def editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients left:number <- get *editor, left:offset @@ -697,7 +697,7 @@ after <insert-character-special-case> [ <scroll-down> } go-render? <- copy 1/true - reply + return } ] @@ -818,11 +818,11 @@ after <handle-special-character> [ editor <- insert-new-line-and-indent editor, screen <insert-enter-end> go-render? <- copy 1/true - reply + return } ] -recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ +def insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -846,7 +846,7 @@ recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:addr } # indent if necessary indent?:boolean <- get *editor, indent?:offset - reply-unless indent? + return-unless indent? d:address:shared:duplex-list:character <- get *editor, data:offset end-of-previous-line:address:shared:duplex-list:character <- prev *before-cursor indent:number <- line-indent end-of-previous-line, d @@ -862,13 +862,13 @@ recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:addr # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the number of spaces at the start of the line containing 'curr'. -recipe line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ +def line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 - reply-unless curr + return-unless curr at-start?:boolean <- equal curr, start - reply-if at-start? + return-if at-start? { curr <- prev curr break-unless curr @@ -995,7 +995,7 @@ after <handle-special-key> [ indent?:address:boolean <- get-address *editor, indent?:offset *indent? <- copy 0/false go-render? <- copy 1/true - reply + return } ] @@ -1006,13 +1006,13 @@ after <handle-special-key> [ indent?:address:boolean <- get-address *editor, indent?:offset *indent? <- copy 1/true go-render? <- copy 1/true - reply + return } ] ## helpers -recipe draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ +def draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index f6c762a6..c09c3441 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -32,7 +32,7 @@ after <handle-special-character> [ editor, screen, go-render?:boolean <- insert-at-cursor editor, 32/space, screen <insert-character-end> go-render? <- copy 1/true - reply + return } ] @@ -73,14 +73,14 @@ after <handle-special-character> [ <backspace-character-begin> editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen <backspace-character-end> - reply + return } ] # return values: # go-render? - whether caller needs to update the screen # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. -recipe delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ +def delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset @@ -88,7 +88,7 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh # if at start of text (before-cursor at § sentinel), return prev:address:shared:duplex-list:character <- prev *before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted - reply-unless prev + return-unless prev trace 10, [app], [delete-before-cursor] original-row:number <- get *editor, cursor-row:offset editor, scroll?:boolean <- move-cursor-coordinates-left editor @@ -96,14 +96,14 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh data <- remove *before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/*before-cursor *before-cursor <- copy prev go-render? <- copy 1/true - reply-if scroll? + return-if scroll? screen-width:number <- screen-width screen cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset # did we just backspace over a newline? same-row?:boolean <- equal cursor-row, original-row go-render? <- copy 1/true - reply-unless same-row? + return-unless same-row? left:number <- get *editor, left:offset right:number <- get *editor, right:offset curr:address:shared:duplex-list:character <- next *before-cursor @@ -113,7 +113,7 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh # hit right margin? give up and let caller render at-right?:boolean <- greater-or-equal curr-column, right go-render? <- copy 1/true - reply-if at-right? + return-if at-right? break-unless curr # newline? done. currc:character <- get *curr, value:offset @@ -130,7 +130,7 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh go-render? <- copy 0/false ] -recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ +def move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset @@ -144,7 +144,7 @@ recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor: trace 10, [app], [decrementing cursor column] *cursor-column <- subtract *cursor-column, 1 go-render? <- copy 0/false - reply + return } # if at left margin, we must move to previous row: top-of-screen?:boolean <- equal *cursor-row, 1 # exclude menu bar @@ -179,7 +179,7 @@ recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor: break-if wrap? *cursor-column <- add left, end-of-line } - reply + return } # case 2: if previous-character was not newline, we're just at a wrapped line trace 10, [app], [wrapping to previous line] @@ -189,13 +189,13 @@ recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor: # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -recipe previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ +def previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 - reply-unless curr + return-unless curr at-start?:boolean <- equal curr, start - reply-if at-start? + return-if at-start? { curr <- prev curr break-unless curr @@ -338,23 +338,23 @@ after <handle-special-key> [ <delete-character-begin> editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen <delete-character-end> - reply + return } ] -recipe delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ +def delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset data:address:shared:duplex-list:character <- get *editor, data:offset deleted-cell:address:shared:duplex-list:character <- next *before-cursor go-render? <- copy 0/false - reply-unless deleted-cell + return-unless deleted-cell currc:character <- get *deleted-cell, value:offset data <- remove deleted-cell, data deleted-newline?:boolean <- equal currc, 10/newline go-render? <- copy 1/true - reply-if deleted-newline? + return-if deleted-newline? # wasn't a newline? render rest of line curr:address:shared:duplex-list:character <- next *before-cursor # refresh after remove above cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -366,7 +366,7 @@ recipe delete-at-cursor editor:address:shared:editor-data, screen:address:shared # hit right margin? give up and let caller render at-right?:boolean <- greater-or-equal curr-column, screen-width go-render? <- copy 1/true - reply-if at-right? + return-if at-right? break-unless curr # newline? done. currc:character <- get *curr, value:offset @@ -421,11 +421,11 @@ after <handle-special-key> [ screen <- move-cursor screen, *cursor-row, *cursor-column undo-coalesce-tag:number <- copy 2/right-arrow <move-cursor-end> - reply + return } ] -recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ +def move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients before-cursor:address:shared:duplex-list:character <- get *editor before-cursor:offset @@ -442,11 +442,11 @@ recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-h *cursor-column <- copy left below-screen?:boolean <- greater-or-equal *cursor-row, screen-height # must be equal go-render? <- copy 0/false - reply-unless below-screen? + return-unless below-screen? <scroll-down> *cursor-row <- subtract *cursor-row, 1 # bring back into screen range go-render? <- copy 1/true - reply + return } # if the line wraps, move cursor to start of next row { @@ -463,11 +463,11 @@ recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-h *cursor-row <- add *cursor-row, 1 *cursor-column <- copy left below-screen?:boolean <- greater-or-equal *cursor-row, screen-height # must be equal - reply-unless below-screen?, editor/same-as-ingredient:0, 0/no-more-render + return-unless below-screen?, editor/same-as-ingredient:0, 0/no-more-render <scroll-down> *cursor-row <- subtract *cursor-row, 1 # bring back into screen range go-render? <- copy 1/true - reply + return } # otherwise move cursor one character right *cursor-column <- add *cursor-column, 1 @@ -691,13 +691,13 @@ after <handle-special-key> [ # if not at start of text (before-cursor at § sentinel) prev:address:shared:duplex-list:character <- prev *before-cursor go-render? <- copy 0/false - reply-unless prev + return-unless prev <move-cursor-begin> editor, go-render? <- move-cursor-coordinates-left editor *before-cursor <- copy prev undo-coalesce-tag:number <- copy 1/left-arrow <move-cursor-end> - reply + return } ] @@ -954,11 +954,11 @@ after <handle-special-key> [ editor, go-render? <- move-to-previous-line editor undo-coalesce-tag:number <- copy 3/up-arrow <move-cursor-end> - reply + return } ] -recipe move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ +def move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -982,14 +982,14 @@ recipe move-to-previous-line editor:address:shared:editor-data -> editor:address curr:address:shared:duplex-list:character <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false - reply-if no-motion? + return-if no-motion? } { old <- copy curr curr <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false - reply-if no-motion? + return-if no-motion? } *before-cursor <- copy curr *cursor-row <- subtract *cursor-row, 1 @@ -1010,14 +1010,14 @@ recipe move-to-previous-line editor:address:shared:editor-data -> editor:address loop } go-render? <- copy 0/false - reply + return } { # if cursor already at top, scroll up break-unless already-at-top? <scroll-up> go-render? <- copy 1/true - reply + return } ] @@ -1179,11 +1179,11 @@ after <handle-special-key> [ editor, go-render? <- move-to-next-line editor, screen-height undo-coalesce-tag:number <- copy 4/down-arrow <move-cursor-end> - reply + return } ] -recipe move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ +def move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -1207,7 +1207,7 @@ recipe move-to-next-line editor:address:shared:editor-data, screen-height:number scroll?:boolean <- greater-than *cursor-row, 1 break-if scroll?, +try-to-scroll:label go-render? <- copy 0/false - reply + return } *cursor-row <- add *cursor-row, 1 *before-cursor <- copy next-line @@ -1227,7 +1227,7 @@ recipe move-to-next-line editor:address:shared:editor-data, screen-height:number loop } go-render? <- copy 0/false - reply + return } +try-to-scroll <scroll-down> @@ -1306,7 +1306,7 @@ after <handle-special-character> [ undo-coalesce-tag:number <- copy 0/never <move-cursor-end> go-render? <- copy 0/false - reply + return } ] @@ -1319,11 +1319,11 @@ after <handle-special-key> [ undo-coalesce-tag:number <- copy 0/never <move-cursor-end> go-render? <- copy 0/false - reply + return } ] -recipe move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # update cursor column @@ -1477,7 +1477,7 @@ after <handle-special-character> [ undo-coalesce-tag:number <- copy 0/never <move-cursor-end> go-render? <- copy 0/false - reply + return } ] @@ -1490,11 +1490,11 @@ after <handle-special-key> [ undo-coalesce-tag:number <- copy 0/never <move-cursor-end> go-render? <- copy 0/false - reply + return } ] -recipe move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset @@ -1620,11 +1620,11 @@ after <handle-special-character> [ deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor <delete-to-start-of-line-end> go-render? <- copy 1/true - reply + return } ] -recipe delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ +def delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete @@ -1754,11 +1754,11 @@ after <handle-special-character> [ deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor <delete-to-end-of-line-end> go-render? <- copy 1/true - reply + return } ] -recipe delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ +def delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete @@ -1937,13 +1937,13 @@ after <scroll-down> [ *top-of-screen <- before-start-of-next-line *top-of-screen, max no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false - reply-if no-movement? + return-if no-movement? ] # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline # beware: never return null pointer. -recipe before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ +def before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ local-scope load-ingredients count:number <- copy 0 @@ -1957,7 +1957,7 @@ recipe before-start-of-next-line original:address:shared:duplex-list:character, count <- add count, 1 } { - reply-unless curr, original + return-unless curr, original done?:boolean <- greater-or-equal count, max break-if done? c:character <- get *curr, value:offset @@ -1967,8 +1967,8 @@ recipe before-start-of-next-line original:address:shared:duplex-list:character, count <- add count, 1 loop } - reply-unless curr, original - reply curr + return-unless curr, original + return curr ] scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ @@ -2304,13 +2304,13 @@ after <scroll-up> [ *top-of-screen <- before-previous-line *top-of-screen, editor no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false - reply-if no-movement? + return-if no-movement? ] # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line # beware: never return null pointer -recipe before-previous-line in:address:shared:duplex-list:character, editor:address:shared:editor-data -> out:address:shared:duplex-list:character [ +def before-previous-line in:address:shared:duplex-list:character, editor:address:shared:editor-data -> out:address:shared:duplex-list:character [ local-scope load-ingredients curr:address:shared:duplex-list:character <- copy in @@ -2327,8 +2327,8 @@ recipe before-previous-line in:address:shared:duplex-list:character, editor:addr break-if len # empty line; just skip this newline prev:address:shared:duplex-list:character <- prev curr - reply-unless prev, curr - reply prev + return-unless prev, curr + return prev } _, max:number <- divide-with-remainder len, max-line-length # remainder 0 => scan one width-worth @@ -2348,7 +2348,7 @@ recipe before-previous-line in:address:shared:duplex-list:character, editor:addr count <- add count, 1 loop } - reply curr + return curr ] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ @@ -2698,7 +2698,7 @@ after <handle-special-character> [ <move-cursor-end> no-movement?:boolean <- equal *top-of-screen, old-top go-render? <- not no-movement? - reply + return } ] @@ -2714,18 +2714,18 @@ after <handle-special-key> [ <move-cursor-end> no-movement?:boolean <- equal *top-of-screen, old-top go-render? <- not no-movement? - reply + return } ] # page-down skips entire wrapped lines, so it can't scroll past lines # taking up the entire screen -recipe page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # if editor contents don't overflow screen, do nothing bottom-of-screen:address:shared:duplex-list:character <- get *editor, bottom-of-screen:offset - reply-unless bottom-of-screen + return-unless bottom-of-screen # if not, position cursor at final character before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset *before-cursor <- prev bottom-of-screen @@ -2890,7 +2890,7 @@ after <handle-special-character> [ <move-cursor-end> no-movement?:boolean <- equal *top-of-screen, old-top go-render? <- not no-movement? - reply + return } ] @@ -2907,11 +2907,11 @@ after <handle-special-key> [ no-movement?:boolean <- equal *top-of-screen, old-top # don't bother re-rendering if nothing changed. todo: test this go-render? <- not no-movement? - reply + return } ] -recipe page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ +def page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ local-scope load-ingredients max:number <- subtract screen-height, 1/menu-bar, 1/overlapping-line diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 78aca5ae..8c6e58cb 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -1,6 +1,6 @@ ## putting the environment together out of editors -recipe! main [ +def! main [ local-scope open-console initial-sandbox:address:shared:array:character <- new [] @@ -19,7 +19,7 @@ container programming-environment-data [ current-sandbox:address:shared:editor-data ] -recipe new-programming-environment screen:address:shared:screen, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ +def new-programming-environment screen:address:shared:screen, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients width:number <- screen-width screen @@ -39,7 +39,7 @@ recipe new-programming-environment screen:address:shared:screen, initial-sandbox <programming-environment-initialization> ] -recipe event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ +def event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ local-scope load-ingredients current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset @@ -136,7 +136,7 @@ recipe event-loop screen:address:shared:screen, console:address:shared:console, } ] -recipe resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ +def resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions @@ -152,7 +152,7 @@ recipe resize screen:address:shared:screen, env:address:shared:programming-envir *cursor-column <- copy 0 ] -recipe render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ +def render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients trace 10, [app], [render all] @@ -178,7 +178,7 @@ recipe render-all screen:address:shared:screen, env:address:shared:programming-e ] # replaced in a later layer -recipe render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ +def render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset @@ -193,7 +193,7 @@ recipe render-sandbox-side screen:address:shared:screen, env:address:shared:prog clear-screen-from screen, row, left, left, right ] -recipe update-cursor screen:address:shared:screen, current-sandbox:address:shared:editor-data, env:address:shared:programming-environment-data -> screen:address:shared:screen [ +def update-cursor screen:address:shared:screen, current-sandbox:address:shared:editor-data, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients <update-cursor-special-cases> @@ -204,10 +204,10 @@ recipe update-cursor screen:address:shared:screen, current-sandbox:address:share # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ +def render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients - reply-unless s + return-unless s column:number <- copy left screen <- move-cursor screen, row, column screen-height:number <- screen-height screen @@ -265,10 +265,10 @@ recipe render screen:address:shared:screen, s:address:shared:array:character, le ] # like 'render' for texts, but with colorization for comments like in the editor -recipe render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ +def render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients - reply-unless s + return-unless s color:number <- copy 7/white column:number <- copy left screen <- move-cursor screen, row, column @@ -340,6 +340,6 @@ after <global-type> [ ] # dummy -recipe restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ +def restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ # do nothing; redefined later ] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 31032eb3..a9c07e5e 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -129,7 +129,7 @@ after <global-keypress> [ } ] -recipe run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen, test-recipes:address:shared:array:character -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen, test-recipes:address:shared:array:character -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients errors-found?:boolean, env, screen <- update-recipes env, screen, test-recipes @@ -175,7 +175,7 @@ recipe run-sandboxes env:address:shared:programming-environment-data, screen:add # load code from recipes.mu, or from test-recipes in tests # replaced in a later layer (whereupon errors-found? will actually be set) -recipe update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen, test-recipes:address:shared:array:character -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen, test-recipes:address:shared:array:character -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients { @@ -191,7 +191,7 @@ recipe update-recipes env:address:shared:programming-environment-data, screen:ad ] # replaced in a later layer -recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients data:address:shared:array:character <- get *sandbox, data:offset @@ -200,14 +200,14 @@ recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:p *response, _, *fake-screen <- run-interactive data ] -recipe update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ +def update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -recipe save-sandboxes env:address:shared:programming-environment-data [ +def save-sandboxes env:address:shared:programming-environment-data [ local-scope load-ingredients current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset @@ -228,7 +228,7 @@ recipe save-sandboxes env:address:shared:programming-environment-data [ } ] -recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ +def! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render sandbox side] @@ -252,14 +252,14 @@ recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:pro clear-rest-of-screen screen, row, left, right ] -recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ +def render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ local-scope load-ingredients env:address:shared:programming-environment-data, _/optional <- next-ingredient - reply-unless sandbox + return-unless sandbox screen-height:number <- screen-height screen at-bottom?:boolean <- greater-or-equal row, screen-height - reply-if at-bottom?:boolean + return-if at-bottom?:boolean hidden?:boolean <- lesser-than idx, render-from { break-if hidden? @@ -296,7 +296,7 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height - reply-if at-bottom? + return-if at-bottom? # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double } @@ -316,7 +316,7 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san ] # assumes programming environment has no sandboxes; restores them from previous session -recipe! restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ +def! restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios @@ -350,10 +350,10 @@ recipe! restore-sandboxes env:address:shared:programming-environment-data -> env # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -recipe render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ +def render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients - reply-unless sandbox-screen + return-unless sandbox-screen # print 'screen:' header:address:shared:array:character <- new [screen:] row <- render screen, header, left, right, 245/grey, row @@ -421,10 +421,10 @@ scenario run-updates-results [ assume-screen 50/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ local-scope z:number <- add 2, 2 -reply z +return z ]] # sandbox editor contains an instruction without storing outputs 2:address:shared:array:character <- new [foo] @@ -446,10 +446,10 @@ reply z ] # make a change (incrementing one of the args to 'add'), then rerun 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ local-scope z:number <- add 2, 3 -reply z +return z ]] assume-console [ press F4 @@ -501,7 +501,7 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -recipe editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ +def editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ local-scope load-ingredients buf:address:shared:buffer <- new-buffer 80 @@ -509,7 +509,7 @@ recipe editor-contents editor:address:shared:editor-data -> result:address:share # skip § sentinel assert curr, [editor without data is illegal; must have at least a sentinel] curr <- next curr - reply-unless curr, 0 + return-unless curr, 0 { break-unless curr c:character <- get *curr, value:offset @@ -646,7 +646,7 @@ after <update-cursor-special-cases> [ break-unless scrolling? cursor-column:number <- get *current-sandbox, left:offset screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 - reply + return } ] @@ -668,21 +668,21 @@ after <global-keypress> [ # sandbox belonging to 'env' whose next-sandbox is 'in' # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox -recipe previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data -> out:address:shared:sandbox-data [ +def previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data -> out:address:shared:sandbox-data [ local-scope load-ingredients curr:address:shared:sandbox-data <- get *env, sandbox:offset - reply-unless curr, 0/nil + return-unless curr, 0/nil next:address:shared:sandbox-data <- get *curr, next-sandbox:offset { - reply-unless next, 0/nil + return-unless next, 0/nil found?:boolean <- equal next, in break-if found? curr <- copy next next <- get *curr, next-sandbox:offset loop } - reply curr + return curr ] scenario scrolling-through-multiple-sandboxes [ diff --git a/sandbox/006-sandbox-edit.mu b/sandbox/006-sandbox-edit.mu index e974034a..d39ec118 100644 --- a/sandbox/006-sandbox-edit.mu +++ b/sandbox/006-sandbox-edit.mu @@ -93,7 +93,7 @@ after <global-touch> [ } ] -recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ +def empty-editor? editor:address:shared:editor-data -> result:boolean [ local-scope load-ingredients head:address:shared:duplex-list:character <- get *editor, data:offset @@ -101,13 +101,13 @@ recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ result <- not first ] -recipe extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients sandbox:address:address:shared:sandbox-data <- get-address *env, sandbox:offset start:number <- get **sandbox, starting-row-on-screen:offset in-editor?:boolean <- lesser-than click-row, start - reply-if in-editor?, 0 + return-if in-editor?, 0 { next-sandbox:address:shared:sandbox-data <- get **sandbox, next-sandbox:offset break-unless next-sandbox diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index 35cf47cb..dbf5d70c 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -76,14 +76,14 @@ after <global-touch> [ } ] -recipe delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ +def delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ local-scope load-ingredients click-column:number <- get t, column:offset current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset right:number <- get *current-sandbox, right:offset at-right?:boolean <- equal click-column, right - reply-unless at-right?, 0/false + return-unless at-right?, 0/false click-row:number <- get t, row:offset prev:address:address:shared:sandbox-data <- get-address *env, sandbox:offset curr:address:shared:sandbox-data <- get *env, sandbox:offset @@ -107,13 +107,13 @@ recipe delete-sandbox t:touch-event, env:address:shared:programming-environment- break-unless reset-scroll? *render-from <- copy -1 } - reply 1/true # force rerender + return 1/true # force rerender } prev <- get-address *curr, next-sandbox:offset curr <- get *curr, next-sandbox:offset loop } - reply 0/false + return 0/false ] scenario deleting-sandbox-after-scroll [ diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu index b299f704..a7010190 100644 --- a/sandbox/008-sandbox-test.mu +++ b/sandbox/008-sandbox-test.mu @@ -5,8 +5,8 @@ scenario sandbox-click-on-result-toggles-color-to-green [ assume-screen 50/width, 20/height # basic recipe 1:address:shared:array:character <- new [ -recipe foo [ - reply 4 +def foo [ + return 4 ]] # run it 2:address:shared:array:character <- new [foo] @@ -59,8 +59,8 @@ recipe foo [ ] # now change the result 1:address:shared:array:character <- new [ -recipe foo [ - reply 3 +def foo [ + return 3 ]] # then rerun assume-console [ @@ -131,7 +131,7 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -151,13 +151,13 @@ recipe find-click-in-sandbox-output env:address:shared:programming-environment-d } # return sandbox if click is in its output region response-starting-row:number <- get *sandbox, response-starting-row-on-screen:offset - reply-unless response-starting-row, 0/no-click-in-sandbox-output + return-unless response-starting-row, 0/no-click-in-sandbox-output click-in-response?:boolean <- greater-or-equal click-row, response-starting-row - reply-unless click-in-response?, 0/no-click-in-sandbox-output - reply sandbox + return-unless click-in-response?, 0/no-click-in-sandbox-output + return sandbox ] -recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ +def toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset @@ -165,7 +165,7 @@ recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:a # if expected-response is set, reset break-unless *expected-response *expected-response <- copy 0 - reply sandbox/same-as-ingredient:0 + return sandbox/same-as-ingredient:0 } # if not, current response is the expected response response:address:shared:array:character <- get *sandbox, response:offset diff --git a/sandbox/009-sandbox-trace.mu b/sandbox/009-sandbox-trace.mu index c59ecbbf..feecf010 100644 --- a/sandbox/009-sandbox-trace.mu +++ b/sandbox/009-sandbox-trace.mu @@ -119,7 +119,7 @@ container sandbox-data [ ] # replaced in a later layer -recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients data:address:shared:array:character <- get *sandbox, data:offset @@ -158,7 +158,7 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -184,9 +184,9 @@ recipe find-click-in-sandbox-code env:address:shared:programming-environment-dat click-on-sandbox-code?:boolean <- and click-above-response?, click-below-menu? { break-if click-on-sandbox-code? - reply 0/no-click-in-sandbox-output + return 0/no-click-in-sandbox-output } - reply sandbox + return sandbox ] # when rendering a sandbox, dump its trace before response/warning if display-trace? property is set diff --git a/sandbox/010-errors.mu b/sandbox/010-errors.mu index 6794271d..ab2fb98b 100644 --- a/sandbox/010-errors.mu +++ b/sandbox/010-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 -recipe! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen, test-recipes:address:shared:array:character -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen, test-recipes:address:shared:array:character -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients recipe-errors:address:address:shared:array:character <- get-address *env, recipe-errors:offset @@ -25,7 +25,7 @@ recipe! update-recipes env:address:shared:programming-environment-data, screen:a status:address:shared:array:character <- new [errors found ] update-status screen, status, 1/red errors-found? <- copy 1/true - reply + return } errors-found? <- copy 0/false ] @@ -79,7 +79,7 @@ container sandbox-data [ errors:address:shared:array:character ] -recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients data:address:shared:array:character <- get *sandbox, data:offset @@ -91,7 +91,7 @@ recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:p { break-unless recipe-errors *errors <- copy recipe-errors - reply + return } *response, *errors, *fake-screen, *trace, completed?:boolean <- run-interactive data { @@ -131,7 +131,7 @@ scenario run-shows-errors-in-get [ trace-until 100/app # trace too long assume-screen 50/width, 20/height 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ get 123:number, foo:offset ]] 2:address:shared:array:character <- new [foo] @@ -379,7 +379,7 @@ scenario run-shows-missing-type-errors [ trace-until 100/app # trace too long assume-screen 50/width, 20/height 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ x <- copy 0 ]] 2:address:shared:array:character <- new [foo] @@ -410,7 +410,7 @@ scenario run-shows-unbalanced-bracket-errors [ assume-screen 50/width, 20/height # recipe is incomplete (unbalanced '[') 1:address:shared:array:character <- new [ -recipe foo « +def foo « x <- copy 0 ] replace 1:address:shared:array:character, 171/«, 91 # '[' @@ -439,7 +439,7 @@ scenario run-shows-get-on-non-container-errors [ trace-until 100/app # trace too long assume-screen 50/width, 20/height 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ local-scope x:address:shared:point <- new point:type get x:address:shared:point, 1:offset @@ -467,7 +467,7 @@ scenario run-shows-non-literal-get-argument-errors [ trace-until 100/app # trace too long assume-screen 50/width, 20/height 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ local-scope x:number <- copy 0 y:address:shared:point <- new point:type @@ -497,7 +497,7 @@ scenario run-shows-errors-everytime [ assume-screen 50/width, 20/height # try to run a file with an error 1:address:shared:array:character <- new [ -recipe foo [ +def foo [ local-scope x:number <- copy y:number ]] @@ -635,7 +635,7 @@ a:number <- next-ingredient b:number <- next-ingredient stash [dividing by], b _, c:number <- divide-with-remainder a, b -reply b +return b ]] 2:address:shared:array:character <- new [foo 4, 0] 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 2:address:shared:array:character diff --git a/sandbox/011-editor-undo.mu b/sandbox/011-editor-undo.mu index d79e056c..5866fb52 100644 --- a/sandbox/011-editor-undo.mu +++ b/sandbox/011-editor-undo.mu @@ -72,7 +72,7 @@ after <handle-special-character> [ redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- push op, *redo <handle-undo> - reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render + return screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render } ] @@ -88,7 +88,7 @@ after <handle-special-character> [ undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op, *undo <handle-redo> - reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render + return screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render } ] @@ -189,14 +189,14 @@ before <insert-enter-end> [ # redo stack, because it's now obsolete. # Beware: since we're counting cursor moves as operations, this means just # moving the cursor can lose work on the undo stack. -recipe add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ +def add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ local-scope load-ingredients undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op *undo redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- copy 0 - reply editor/same-as-ingredient:0 + return editor/same-as-ingredient:0 ] after <handle-undo> [ |