diff options
Diffstat (limited to 'edit')
-rw-r--r-- | edit/001-editor.mu | 14 | ||||
-rw-r--r-- | edit/002-typing.mu | 28 | ||||
-rw-r--r-- | edit/003-shortcuts.mu | 46 | ||||
-rw-r--r-- | edit/004-programming-environment.mu | 22 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 30 | ||||
-rw-r--r-- | edit/006-sandbox-copy.mu | 16 | ||||
-rw-r--r-- | edit/007-sandbox-delete.mu | 6 | ||||
-rw-r--r-- | edit/008-sandbox-edit.mu | 4 | ||||
-rw-r--r-- | edit/009-sandbox-test.mu | 6 | ||||
-rw-r--r-- | edit/010-sandbox-trace.mu | 4 | ||||
-rw-r--r-- | edit/011-errors.mu | 6 | ||||
-rw-r--r-- | edit/012-editor-undo.mu | 2 |
12 files changed, 92 insertions, 92 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu index 9e136b7e..74f0ab20 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -4,7 +4,7 @@ # screen dimensions, then stop def main text:text [ local-scope - load-ingredients + load-inputs open-console clear-screen 0/screen # non-scrolling app e:&:editor <- new-editor text, 0/left, 5/right @@ -50,7 +50,7 @@ container editor [ # right is exclusive def new-editor s:text, left:num, right:num -> result:&:editor [ local-scope - load-ingredients + load-inputs # no clipping of bounds right <- subtract right, 1 result <- new editor:type @@ -71,7 +71,7 @@ def new-editor s:text, left:num, right:num -> result:&:editor [ def insert-text editor:&:editor, text:text -> editor:&:editor [ local-scope - load-ingredients + load-inputs curr:&:duplex-list:char <- get *editor, data:offset insert curr, text ] @@ -106,7 +106,7 @@ scenario editor-initializes-without-data [ # outside text. def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ local-scope - load-ingredients + load-inputs return-unless editor, 1/top, 0/left left:num <- get *editor, left:offset screen-height:num <- screen-height screen @@ -206,7 +206,7 @@ def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, sc def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ local-scope - load-ingredients + load-inputs #? stash [clear-screen-from] row column [between] left [and] right # if it's the real screen, use the optimized primitive { @@ -222,7 +222,7 @@ def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ local-scope - load-ingredients + load-inputs row <- add row, 1 # if it's the real screen, use the optimized primitive { @@ -396,7 +396,7 @@ after <character-c-received> [ # so far the previous color is all the information we need; that may change def get-color color:num, c:char -> color:num [ local-scope - load-ingredients + load-inputs color-is-white?:bool <- equal color, 7/white # if color is white and next character is '#', switch color to blue { diff --git a/edit/002-typing.mu b/edit/002-typing.mu index f5bbeb6f..709e8d22 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -4,7 +4,7 @@ # hit ctrl-c to exit def! main text:text [ local-scope - load-ingredients + load-inputs open-console clear-screen 0/screen # non-scrolling app editor:&:editor <- new-editor text, 5/left, 45/right @@ -15,7 +15,7 @@ def! main text:text [ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> screen:&:screen, console:&:console, editor:&:editor [ local-scope - load-ingredients + load-inputs { # looping over each (keyboard or touch) event as it occurs +next-event @@ -49,7 +49,7 @@ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> scr # process click, return if it was on current editor def move-cursor editor:&:editor, screen:&:screen, t:touch-event -> in-focus?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs return-unless editor, 0/false click-row:num <- get t, row:offset return-unless click-row, 0/false # ignore clicks on 'menu' @@ -74,7 +74,7 @@ def move-cursor editor:&:editor, screen:&:screen, t:touch-event -> in-focus?:boo # past the last line it positions at end of last line. def snap-cursor editor:&:editor, screen:&:screen, target-row:num, target-column:num -> editor:&:editor [ local-scope - load-ingredients + load-inputs return-unless editor left:num <- get *editor, left:offset right:num <- get *editor, right:offset @@ -165,7 +165,7 @@ def snap-cursor editor:&:editor, screen:&:screen, target-row:num, target-column: # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> go-render?:bool, screen:&:screen, editor:&:editor [ local-scope - load-ingredients + load-inputs return-unless editor, 0/don't-render screen-width:num <- screen-width screen screen-height:num <- screen-height screen @@ -202,7 +202,7 @@ def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> go-render def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool, editor:&:editor, screen:&:screen [ local-scope - load-ingredients + load-inputs before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset insert c, before-cursor before-cursor <- next before-cursor @@ -264,7 +264,7 @@ def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool # helper for tests def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:editor [ local-scope - load-ingredients + load-inputs old-top-idx:num <- save-top-idx screen left:num <- get *editor, left:offset right:num <- get *editor, right:offset @@ -867,7 +867,7 @@ after <handle-special-character> [ def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen [ local-scope - load-ingredients + load-inputs 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 @@ -913,7 +913,7 @@ def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:edit def at-start-of-wrapped-line? editor:&:editor -> result:bool [ local-scope - load-ingredients + load-inputs left:num <- get *editor, left:offset cursor-column:num <- get *editor, cursor-column:offset cursor-at-left?:bool <- equal cursor-column, left @@ -933,7 +933,7 @@ def at-start-of-wrapped-line? editor:&:editor -> result:bool [ # the number of spaces at the start of the line containing 'curr'. def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ local-scope - load-ingredients + load-inputs result:num <- copy 0 return-unless curr at-start?:bool <- equal curr, start @@ -1115,22 +1115,22 @@ after <handle-special-key> [ def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [ local-scope - load-ingredients + load-inputs height:num <- screen-height screen past-bottom?:bool <- greater-or-equal row, height return-if past-bottom? - style:char, style-found?:bool <- next-ingredient + style:char, style-found?:bool <- next-input { break-if style-found? style <- copy 9472/horizontal } - color:num, color-found?:bool <- next-ingredient + color:num, color-found?:bool <- next-input { # default color to white break-if color-found? color <- copy 245/grey } - bg-color:num, bg-color-found?:bool <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-input { break-if bg-color-found? bg-color <- copy 0/black diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index df40a6e4..e24f7e72 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -108,7 +108,7 @@ after <handle-special-character> [ # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ local-scope - load-ingredients + load-inputs 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 @@ -155,7 +155,7 @@ def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, ba def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs go-render?:bool <- copy 0/false before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset cursor-row:num <- get *editor, cursor-row:offset @@ -218,7 +218,7 @@ def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:ed # the length of the previous line before the 'curr' pointer. def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ local-scope - load-ingredients + load-inputs result:num <- copy 0 return-unless curr at-start?:bool <- equal curr, start @@ -372,7 +372,7 @@ after <handle-special-key> [ def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ local-scope - load-ingredients + load-inputs 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 @@ -452,7 +452,7 @@ after <handle-special-key> [ def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs 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 @@ -999,7 +999,7 @@ after <handle-special-key> [ def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs go-render?:bool <- copy 0/false cursor-row:num <- get *editor, cursor-row:offset cursor-column:num <- get *editor, cursor-column:offset @@ -1353,7 +1353,7 @@ after <handle-special-key> [ def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs 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 @@ -1564,7 +1564,7 @@ after <handle-special-key> [ # precondition: cursor-column should be in a consistent state def move-to-start-of-screen-line editor:&:editor -> editor:&:editor [ local-scope - load-ingredients + load-inputs # update cursor column left:num <- get *editor, left:offset col:num <- get *editor, cursor-column:offset @@ -1787,7 +1787,7 @@ after <handle-special-key> [ def move-to-end-of-line editor:&:editor -> editor:&:editor [ local-scope - load-ingredients + load-inputs before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset cursor-column:num <- get *editor, cursor-column:offset right:num <- get *editor, right:offset @@ -1970,7 +1970,7 @@ after <handle-special-character> [ def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ local-scope - load-ingredients + load-inputs curr-column:num <- get *editor, cursor-column:offset # accumulate the current line as text and render it buf:&:buffer:char <- new-buffer 30 # accumulator for the text we need to render @@ -2005,7 +2005,7 @@ def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&: def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ local-scope - load-ingredients + load-inputs # compute range to delete init:&:duplex-list:char <- get *editor, data:offset top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset @@ -2061,7 +2061,7 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [ local-scope - load-ingredients + load-inputs return-unless s color:num <- copy 7/white column:num <- copy left @@ -2548,7 +2548,7 @@ after <handle-special-character> [ def minimal-render-for-ctrl-k screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ local-scope - load-ingredients + load-inputs # if we deleted nothing, there's nothing to render return-unless deleted-cells, 0/dont-render # if the line used to wrap before, give up and render the whole screen @@ -2566,7 +2566,7 @@ def minimal-render-for-ctrl-k screen:&:screen, editor:&:editor, deleted-cells:&: def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ local-scope - load-ingredients + load-inputs # compute range to delete start:&:duplex-list:char <- get *editor, before-cursor:offset end:&:duplex-list:char <- next start @@ -2803,7 +2803,7 @@ after <scroll-down> [ # Beware: never return null pointer. def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ local-scope - load-ingredients + load-inputs count:num <- copy 0 curr:&:duplex-list:char <- copy original # skip the initial newline if it exists @@ -3174,7 +3174,7 @@ after <scroll-up> [ # Beware: never return null pointer. def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ local-scope - load-ingredients + load-inputs curr:&:duplex-list:char <- copy in c:char <- get *curr, value:offset # compute max, number of characters to skip @@ -3596,7 +3596,7 @@ after <handle-special-key> [ # taking up the entire screen def page-down editor:&:editor -> editor:&:editor [ local-scope - load-ingredients + load-inputs # if editor contents don't overflow screen, do nothing bottom-of-screen:&:duplex-list:char <- get *editor, bottom-of-screen:offset return-unless bottom-of-screen @@ -3621,7 +3621,7 @@ def page-down editor:&:editor -> editor:&:editor [ # jump to previous newline def move-to-start-of-line editor:&:editor -> editor:&:editor [ local-scope - load-ingredients + load-inputs # update cursor column left:num <- get *editor, left:offset cursor-column:num <- copy left @@ -3819,7 +3819,7 @@ after <handle-special-key> [ def page-up editor:&:editor, screen-height:num -> editor:&:editor [ local-scope - load-ingredients + load-inputs max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line count:num <- copy 0 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset @@ -4148,7 +4148,7 @@ after <handle-special-character> [ def line-up editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs left:num <- get *editor, left:offset right:num <- get *editor, right:offset max:num <- subtract right, left @@ -4179,7 +4179,7 @@ after <handle-special-character> [ def line-down editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ local-scope - load-ingredients + load-inputs old-top:&:duplex-list:char <- get *editor, top-of-screen:offset new-top:&:duplex-list:char <- before-previous-screen-line old-top, editor movement?:bool <- not-equal old-top, new-top @@ -4249,7 +4249,7 @@ after <handle-special-character> [ # the caller to go-render? the entire screen. def render-line-from-start screen:&:screen, editor:&:editor, right-margin:num -> go-render?:bool, screen:&:screen [ local-scope - load-ingredients + load-inputs before-line-start:&:duplex-list:char <- before-start-of-screen-line editor line-start:&:duplex-list:char <- next before-line-start color:num <- copy 7/white @@ -4279,7 +4279,7 @@ def render-line-from-start screen:&:screen, editor:&:editor, right-margin:num -> def before-start-of-screen-line editor:&:editor -> result:&:duplex-list:char [ local-scope - load-ingredients + load-inputs cursor:&:duplex-list:char <- get *editor, before-cursor:offset { next:&:duplex-list:char <- next cursor diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 73d26d4d..cff42327 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -20,7 +20,7 @@ container environment [ def new-programming-environment resources:&:resources, screen:&:screen, test-sandbox-editor-contents:text -> result:&:environment [ local-scope - load-ingredients + load-inputs width:num <- screen-width screen result <- new environment:type # recipe editor on the left @@ -38,7 +38,7 @@ def new-programming-environment resources:&:resources, screen:&:screen, test-san def event-loop screen:&:screen, console:&:console, env:&:environment, resources:&:resources -> screen:&:screen, console:&:console, env:&:environment, resources:&:resources [ local-scope - load-ingredients + load-inputs recipes:&:editor <- get *env, recipes:offset current-sandbox:&:editor <- get *env, current-sandbox:offset sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset @@ -130,7 +130,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources: def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:screen [ local-scope - load-ingredients + load-inputs clear-screen screen # update screen dimensions width:num <- screen-width screen divider:num, _ <- divide-with-remainder width, 2 @@ -157,7 +157,7 @@ def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:scr # off-screen, it resets cursor-row and cursor-column. def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ local-scope - load-ingredients + load-inputs return-unless editor, 1/top, 0/left left:num <- get *editor, left:offset screen-height:num <- screen-height screen @@ -401,7 +401,7 @@ type render-recipe = (recipe (address screen) (address editor) -> number number def render-all screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [ local-scope - load-ingredients + load-inputs trace 10, [app], [render all] # top menu trace 11, [app], [render top menu] @@ -430,7 +430,7 @@ def render-all screen:&:screen, env:&:environment, render-editor:render-recipe - def render-recipes screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [ local-scope - load-ingredients + load-inputs trace 11, [app], [render recipes] old-top-idx:num <- save-top-idx screen recipes:&:editor <- get *env, recipes:offset @@ -452,7 +452,7 @@ def render-recipes screen:&:screen, env:&:environment, render-editor:render-reci # replaced in a later layer def render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [ local-scope - load-ingredients + load-inputs trace 11, [app], [render sandboxes] old-top-idx:num <- save-top-idx screen current-sandbox:&:editor <- get *env, current-sandbox:offset @@ -471,7 +471,7 @@ def render-sandbox-side screen:&:screen, env:&:environment, render-editor:render def update-cursor screen:&:screen, recipes:&:editor, current-sandbox:&:editor, sandbox-in-focus?:bool, env:&:environment -> screen:&:screen [ local-scope - load-ingredients + load-inputs <update-cursor-special-cases> { break-if sandbox-in-focus? @@ -505,13 +505,13 @@ after <global-type> [ def draw-vertical screen:&:screen, col:num, y:num, bottom:num -> screen:&:screen [ local-scope - load-ingredients - style:char, style-found?:bool <- next-ingredient + load-inputs + style:char, style-found?:bool <- next-input { break-if style-found? style <- copy 9474/vertical } - color:num, color-found?:bool <- next-ingredient + color:num, color-found?:bool <- next-input { # default color to white break-if color-found? diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 869b4ca4..bb991504 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -145,7 +145,7 @@ after <global-keypress> [ def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ local-scope - load-ingredients + load-inputs errors-found?:bool <- update-recipes env, resources, screen jump-if errors-found?, +return # check contents of right editor (sandbox) @@ -196,7 +196,7 @@ def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> e # replaced in a later layer (whereupon errors-found? will actually be set) def update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ local-scope - load-ingredients + load-inputs recipes:&:editor <- get *env, recipes:offset in:text <- editor-contents recipes resources <- dump resources, [lesson/recipes.mu], in @@ -207,7 +207,7 @@ def update-recipes env:&:environment, resources:&:resources, screen:&:screen -> # replaced in a later layer def update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ local-scope - load-ingredients + load-inputs data:text <- get *sandbox, data:offset response:text, _, fake-screen:&:screen <- run-sandboxed data *sandbox <- put *sandbox, response:offset, response @@ -216,14 +216,14 @@ def update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sa def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [ local-scope - load-ingredients + load-inputs screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [ local-scope - load-ingredients + load-inputs trace 11, [app], [save sandboxes] current-sandbox:&:editor <- get *env, current-sandbox:offset # first clear previous versions, in case we deleted some sandbox @@ -241,7 +241,7 @@ def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resou def save-sandbox resources:&:resources, sandbox:&:sandbox, sandbox-index:num -> resources:&:resources [ local-scope - load-ingredients + load-inputs data:text <- get *sandbox, data:offset filename:text <- append [lesson/], sandbox-index resources <- dump resources, filename, data @@ -250,7 +250,7 @@ def save-sandbox resources:&:resources, sandbox:&:sandbox, sandbox-index:num -> def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:render-recipe -> screen:&:screen, env:&:environment [ local-scope - load-ingredients + load-inputs trace 11, [app], [render sandbox side] old-top-idx:num <- save-top-idx screen current-sandbox:&:editor <- get *env, current-sandbox:offset @@ -277,7 +277,7 @@ def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:rende def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ local-scope - load-ingredients + load-inputs return-unless sandbox screen-height:num <- screen-height screen hidden?:bool <- lesser-than idx, render-from @@ -332,7 +332,7 @@ def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, ro def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [ local-scope - load-ingredients + load-inputs move-cursor-to-column screen, left edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right print screen, sandbox-index, 232/dark-grey, 245/grey @@ -377,7 +377,7 @@ scenario skip-rendering-sandbox-menu-past-bottom-row [ # all left/right pairs are inclusive def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, recipe-button-left:num, recipe-button-right:num, delete-button-left:num [ local-scope - load-ingredients + load-inputs 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, 4 # integer division @@ -397,7 +397,7 @@ def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-butto # like 'render-code' but without syntax-based colorization def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [ local-scope - load-ingredients + load-inputs return-unless s column:num <- copy left screen <- move-cursor screen, row, column @@ -474,7 +474,7 @@ scenario render-text-wraps-barely-long-lines [ # assumes programming environment has no sandboxes; restores them from previous session def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [ local-scope - load-ingredients + load-inputs # read all scenarios, pushing them to end of a list of scenarios idx:num <- copy 0 curr:&:sandbox <- copy 0 @@ -508,7 +508,7 @@ def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environm # leave cursor at start of next line def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [ local-scope - load-ingredients + load-inputs return-unless sandbox-screen # print 'screen:' row <- render-text screen, [screen:], left, right, 245/grey, row @@ -682,7 +682,7 @@ scenario run-instruction-manages-screen-per-sandbox [ def editor-contents editor:&:editor -> result:text [ local-scope - load-ingredients + load-inputs buf:&:buffer:char <- new-buffer 80 curr:&:duplex-list:char <- get *editor, data:offset # skip § sentinel @@ -944,7 +944,7 @@ after <global-keypress> [ # 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:&:environment, in:&:sandbox -> out:&:sandbox [ local-scope - load-ingredients + load-inputs curr:&:sandbox <- get *env, sandbox:offset return-unless curr, 0/nil next:&:sandbox <- get *curr, next-sandbox:offset diff --git a/edit/006-sandbox-copy.mu b/edit/006-sandbox-copy.mu index ef9bed24..72f320f6 100644 --- a/edit/006-sandbox-copy.mu +++ b/edit/006-sandbox-copy.mu @@ -139,7 +139,7 @@ after <global-touch> [ # some preconditions for attempting to copy a sandbox def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope - load-ingredients + load-inputs # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env return-unless click-sandbox-area?, 0/false @@ -158,7 +158,7 @@ def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> r def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button?:bool, env:&:environment [ local-scope - load-ingredients + load-inputs # identify the sandbox to copy, if the click was actually on the 'copy' button sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false @@ -174,7 +174,7 @@ def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button? def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [ local-scope - load-ingredients + load-inputs curr-sandbox:&:sandbox <- get *env, sandbox:offset { break-unless curr-sandbox @@ -189,7 +189,7 @@ def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [ def click-on-sandbox-area? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope - load-ingredients + load-inputs current-sandbox:&:editor <- get *env, current-sandbox:offset sandbox-left-margin:num <- get *current-sandbox, left:offset on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin @@ -202,7 +202,7 @@ def click-on-sandbox-area? click-row:num, click-column:num, env:&:environment -> def empty-editor? editor:&:editor -> result:bool [ local-scope - load-ingredients + load-inputs head:&:duplex-list:char <- get *editor, data:offset first:&:duplex-list:char <- next head result <- not first @@ -210,7 +210,7 @@ def empty-editor? editor:&:editor -> result:bool [ def within-range? x:num, low:num, high:num -> result:bool [ local-scope - load-ingredients + load-inputs 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? @@ -359,7 +359,7 @@ after <global-touch> [ # some preconditions for attempting to copy a sandbox into the recipe side def should-copy-to-recipe? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope - load-ingredients + load-inputs # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env return-unless click-sandbox-area?, 0/false @@ -374,7 +374,7 @@ def should-copy-to-recipe? click-row:num, click-column:num, env:&:environment -> def prepend-sandbox-into-recipe-side click-row:num, env:&:environment -> clicked-on-copy-to-recipe-button?:bool, env:&:environment [ local-scope - load-ingredients + load-inputs sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false recipe-editor:&:editor <- get *env, recipes:offset diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu index 2db88964..0e599758 100644 --- a/edit/007-sandbox-delete.mu +++ b/edit/007-sandbox-delete.mu @@ -82,7 +82,7 @@ after <global-touch> [ # some preconditions for attempting to delete a sandbox def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope - load-ingredients + load-inputs # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env return-unless click-sandbox-area?, 0/false @@ -97,7 +97,7 @@ def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [ local-scope - load-ingredients + load-inputs # identify the sandbox to delete, if the click was actually on the 'delete' button sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false @@ -107,7 +107,7 @@ def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-but def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ local-scope - load-ingredients + load-inputs curr-sandbox:&:sandbox <- get *env, sandbox:offset first-sandbox?:bool <- equal curr-sandbox, sandbox { diff --git a/edit/008-sandbox-edit.mu b/edit/008-sandbox-edit.mu index eeb0cd69..ab4f1f63 100644 --- a/edit/008-sandbox-edit.mu +++ b/edit/008-sandbox-edit.mu @@ -122,7 +122,7 @@ after <global-touch> [ # some preconditions for attempting to edit a sandbox def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [ local-scope - load-ingredients + load-inputs # are we below the sandbox editor? click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env return-unless click-sandbox-area?, 0/false @@ -141,7 +141,7 @@ def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> r def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [ local-scope - load-ingredients + load-inputs # identify the sandbox to edit, if the click was actually on the 'edit' button sandbox:&:sandbox <- find-sandbox env, click-row return-unless sandbox, 0/false diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu index 4893e1ea..b871107e 100644 --- a/edit/009-sandbox-test.mu +++ b/edit/009-sandbox-test.mu @@ -151,7 +151,7 @@ after <global-touch> [ def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox, sandbox-index:num [ local-scope - load-ingredients + load-inputs # assert click-row >= sandbox.starting-row-on-screen sandbox:&:sandbox <- get *env, sandbox:offset start:num <- get *sandbox, starting-row-on-screen:offset @@ -179,7 +179,7 @@ def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:s def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ local-scope - load-ingredients + load-inputs expected-response:text <- get *sandbox, expected-response:offset { # if expected-response is set, reset @@ -206,7 +206,7 @@ after <render-sandbox-response> [ def render-sandbox-response screen:&:screen, sandbox:&:sandbox, left:num, right:num -> row:num, screen:&:screen [ local-scope - load-ingredients + load-inputs sandbox-response:text <- get *sandbox, response:offset expected-response:text <- get *sandbox, expected-response:offset row:num <- get *sandbox response-starting-row-on-screen:offset diff --git a/edit/010-sandbox-trace.mu b/edit/010-sandbox-trace.mu index 2d681b8f..cc8b2805 100644 --- a/edit/010-sandbox-trace.mu +++ b/edit/010-sandbox-trace.mu @@ -174,7 +174,7 @@ container sandbox [ # replaced in a later layer def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ local-scope - load-ingredients + load-inputs data:text <- get *sandbox, data:offset response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed data *sandbox <- put *sandbox, response:offset, response @@ -211,7 +211,7 @@ after <global-touch> [ def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [ local-scope - load-ingredients + load-inputs # assert click-row >= sandbox.starting-row-on-screen sandbox <- get *env, sandbox:offset start:num <- get *sandbox, starting-row-on-screen:offset diff --git a/edit/011-errors.mu b/edit/011-errors.mu index 554130b5..af94c2ed 100644 --- a/edit/011-errors.mu +++ b/edit/011-errors.mu @@ -7,7 +7,7 @@ container environment [ # copy code from recipe editor, persist to disk, load, save any errors def! update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ local-scope - load-ingredients + load-inputs recipes:&:editor <- get *env, recipes:offset in:text <- editor-contents recipes resources <- dump resources, [lesson/recipes.mu], in @@ -41,7 +41,7 @@ before <end-render-recipe-components> [ def render-recipe-errors env:&:environment, screen:&:screen -> screen:&:screen [ local-scope - load-ingredients + load-inputs recipe-errors:text <- get *env, recipe-errors:offset return-unless recipe-errors recipes:&:editor <- get *env, recipes:offset @@ -96,7 +96,7 @@ container sandbox [ def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [ local-scope - load-ingredients + load-inputs data:text <- get *sandbox, data:offset response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data *sandbox <- put *sandbox, response:offset, response diff --git a/edit/012-editor-undo.mu b/edit/012-editor-undo.mu index 024a0398..161e6843 100644 --- a/edit/012-editor-undo.mu +++ b/edit/012-editor-undo.mu @@ -201,7 +201,7 @@ before <end-insert-enter> [ # moving the cursor can lose work on the undo stack. def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ local-scope - load-ingredients + load-inputs undo:&:list:&:operation <- get *editor, undo:offset undo <- push op undo *editor <- put *editor, undo:offset, undo |