diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-12-03 23:25:40 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-12-03 23:25:40 -0800 |
commit | 4a48bedcd1d708a43d43dc6259a4e45c52ea3d00 (patch) | |
tree | 85c1b7310cca932797d727a3de8da96eb175d8da /sandbox | |
parent | ef7d834fdd826977cd8d43253052a7b8e1c5aa72 (diff) | |
download | mu-4a48bedcd1d708a43d43dc6259a4e45c52ea3d00.tar.gz |
4134 - 'input' = 'ingredient'
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/001-editor.mu | 14 | ||||
-rw-r--r-- | sandbox/002-typing.mu | 28 | ||||
-rw-r--r-- | sandbox/003-shortcuts.mu | 36 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 14 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 32 | ||||
-rw-r--r-- | sandbox/006-sandbox-copy.mu | 12 | ||||
-rw-r--r-- | sandbox/007-sandbox-delete.mu | 6 | ||||
-rw-r--r-- | sandbox/008-sandbox-edit.mu | 4 | ||||
-rw-r--r-- | sandbox/009-sandbox-test.mu | 6 | ||||
-rw-r--r-- | sandbox/010-sandbox-trace.mu | 4 | ||||
-rw-r--r-- | sandbox/011-errors.mu | 4 | ||||
-rw-r--r-- | sandbox/012-editor-undo.mu | 2 |
12 files changed, 81 insertions, 81 deletions
diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 807cf442..9f1adbe7 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/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 # if it's the real screen, use the optimized primitive { break-if screen @@ -221,7 +221,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 { @@ -395,7 +395,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/sandbox/002-typing.mu b/sandbox/002-typing.mu index f5bbeb6f..709e8d22 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/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/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index 919a1870..c152f504 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/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 @@ -154,7 +154,7 @@ def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, ba def move-cursor-coordinates-left editor:&:editor -> 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 @@ -215,7 +215,7 @@ def move-cursor-coordinates-left editor:&:editor -> editor:&:editor [ # 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 @@ -369,7 +369,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 @@ -449,7 +449,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 @@ -994,7 +994,7 @@ after <handle-special-key> [ def move-to-previous-line editor:&:editor -> 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 @@ -1340,7 +1340,7 @@ after <handle-special-key> [ def move-to-next-line editor:&:editor, screen-height:num -> 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 @@ -1486,7 +1486,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 @@ -1709,7 +1709,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 @@ -1892,7 +1892,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 @@ -1927,7 +1927,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 |