From 970df30262537492b5c60dc5c802f9bcca41a4ea Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 27 Nov 2016 22:21:18 -0800 Subject: 3698 Update sandbox/ with recent changes to edit/ (commit 3695 onwards). [Incidentally, this is the first commit to be made while running on OpenBSD. Simulated and host systems are going to blur together from now on.] --- sandbox/001-editor.mu | 73 ++++++++++++++------------- sandbox/002-typing.mu | 63 ++++++++++++------------ sandbox/003-shortcuts.mu | 90 +++++++++++++++++----------------- sandbox/004-programming-environment.mu | 2 +- sandbox/005-sandbox.mu | 14 +++--- sandbox/012-editor-undo.mu | 48 +++++++++--------- 6 files changed, 148 insertions(+), 142 deletions(-) (limited to 'sandbox') diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 54a35391..170468cd 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -7,17 +7,18 @@ def! main text:text [ load-ingredients open-console hide-screen 0/screen - new-editor text, 0/screen, 0/left, 5/right + new-editor text, 0/left, 5/right show-screen 0/screen wait-for-event 0/console close-console ] -scenario editor-initially-prints-text-to-screen [ +scenario editor-renders-text-to-screen [ local-scope assume-screen 10/width, 5/height + e:&:editor <- new-editor [abc], 0/left, 10/right run [ - new-editor [abc], screen, 0/left, 10/right + render screen, e ] screen-should-contain [ # top line of screen reserved for menu @@ -45,10 +46,9 @@ container editor [ cursor-column:num ] -# creates a new editor widget and renders its initial appearance to screen -# top/left/right constrain the screen area available to the new editor +# creates a new editor widget # right is exclusive -def new-editor s:text, screen:&:screen, left:num, right:num -> result:&:editor, screen:&:screen [ +def new-editor s:text, left:num, right:num -> result:&:editor [ local-scope load-ingredients # no clipping of bounds @@ -66,8 +66,6 @@ def new-editor s:text, screen:&:screen, left:num, right:num -> result:&:editor, *result <- put *result, top-of-screen:offset, init *result <- put *result, before-cursor:offset, init result <- insert-text result, s - # initial render to screen, just for some old tests - _, _, screen, result <- render screen, result ] @@ -98,7 +96,7 @@ scenario editor-initializes-without-data [ local-scope assume-screen 5/width, 3/height run [ - e:&:editor <- new-editor 0/data, screen, 2/left, 5/right + e:&:editor <- new-editor 0/data, 2/left, 5/right 2:editor/raw <- copy *e ] memory-should-contain [ @@ -108,7 +106,7 @@ scenario editor-initializes-without-data [ # 5 (before cursor) <- the § sentinel 6 <- 2 # left 7 <- 4 # right (inclusive) - 8 <- 1 # bottom + 8 <- 0 # bottom (not set until render) 9 <- 1 # cursor row 10 <- 2 # cursor column ] @@ -255,13 +253,14 @@ def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen } ] -scenario editor-initially-prints-multiple-lines [ +scenario editor-prints-multiple-lines [ local-scope assume-screen 5/width, 5/height - run [ - s:text <- new [abc + s:text <- new [abc def] - new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right + run [ + render screen, e ] screen-should-contain [ . . @@ -271,12 +270,12 @@ def] ] ] -scenario editor-initially-handles-offsets [ +scenario editor-handles-offsets [ local-scope assume-screen 5/width, 5/height + e:&:editor <- new-editor [abc], 1/left, 5/right run [ - s:text <- new [abc] - new-editor s, screen, 1/left, 5/right + render screen, e ] screen-should-contain [ . . @@ -285,13 +284,14 @@ scenario editor-initially-handles-offsets [ ] ] -scenario editor-initially-prints-multiple-lines-at-offset [ +scenario editor-prints-multiple-lines-at-offset [ local-scope assume-screen 5/width, 5/height - run [ - s:text <- new [abc + s:text <- new [abc def] - new-editor s, screen, 1/left, 5/right + e:&:editor <- new-editor s, 1/left, 5/right + run [ + render screen, e ] screen-should-contain [ . . @@ -301,12 +301,12 @@ def] ] ] -scenario editor-initially-wraps-long-lines [ +scenario editor-wraps-long-lines [ local-scope assume-screen 5/width, 5/height + e:&:editor <- new-editor [abc def], 0/left, 5/right run [ - s:text <- new [abc def] - new-editor s, screen, 0/left, 5/right + render screen, e ] screen-should-contain [ . . @@ -322,12 +322,12 @@ scenario editor-initially-wraps-long-lines [ ] ] -scenario editor-initially-wraps-barely-long-lines [ +scenario editor-wraps-barely-long-lines [ local-scope assume-screen 5/width, 5/height + e:&:editor <- new-editor [abcde], 0/left, 5/right run [ - s:text <- new [abcde] - new-editor s, screen, 0/left, 5/right + render screen, e ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -345,11 +345,12 @@ scenario editor-initially-wraps-barely-long-lines [ ] ] -scenario editor-initializes-empty-text [ +scenario editor-with-empty-text [ local-scope assume-screen 5/width, 5/height + e:&:editor <- new-editor [], 0/left, 5/right run [ - e:&:editor <- new-editor [], screen, 0/left, 5/right + render screen, e 3:num/raw <- get *e, cursor-row:offset 4:num/raw <- get *e, cursor-column:offset ] @@ -369,11 +370,12 @@ scenario editor-initializes-empty-text [ scenario render-colors-comments [ local-scope assume-screen 5/width, 5/height - run [ - s:text <- new [abc + s:text <- new [abc # de f] - new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right + run [ + render screen, e ] screen-should-contain [ . . @@ -451,11 +453,12 @@ def get-color color:num, c:char -> color:num [ scenario render-colors-assignment [ local-scope assume-screen 8/width, 5/height - run [ - s:text <- new [abc + s:text <- new [abc d <- e f] - new-editor s, screen, 0/left, 8/right + e:&:editor <- new-editor s, 0/left, 8/right + run [ + render screen, e ] screen-should-contain [ . . diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 906422f5..a584e6a3 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -6,7 +6,7 @@ def! main text:text [ local-scope load-ingredients open-console - editor:&:editor <- new-editor text, 0/screen, 5/left, 45/right + editor:&:editor <- new-editor text, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] @@ -283,7 +283,7 @@ def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&: scenario editor-handles-empty-event-queue [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e assume-console [] run [ @@ -300,7 +300,7 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -327,7 +327,7 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # last line, to the right of text @@ -349,7 +349,7 @@ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height s:text <- new [abc def] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # interior line, to the right of text @@ -371,7 +371,7 @@ scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height s:text <- new [abc def] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text @@ -392,7 +392,7 @@ scenario editor-handles-mouse-clicks-outside-column [ local-scope assume-screen 10/width, 5/height # editor occupies only left half of screen - e:&:editor <- new-editor [abc], screen, 0/left, 5/right + e:&:editor <- new-editor [abc], 0/left, 5/right editor-render screen, e $clear-trace assume-console [ @@ -420,7 +420,7 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 5/right + e:&:editor <- new-editor [abc], 0/left, 5/right editor-render screen, e $clear-trace assume-console [ @@ -442,7 +442,7 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 5/right + e:&:editor <- new-editor [], 0/left, 5/right editor-render screen, e $clear-trace assume-console [ @@ -463,7 +463,7 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace # type two letters at different places @@ -487,7 +487,7 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -511,7 +511,7 @@ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -534,7 +534,7 @@ d] scenario editor-inserts-characters-at-cursor-3 [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -558,7 +558,7 @@ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -583,7 +583,7 @@ scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -606,7 +606,7 @@ d] scenario editor-moves-cursor-after-inserting-characters [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [ab], screen, 0/left, 5/right + e:&:editor <- new-editor [ab], 0/left, 5/right editor-render screen, e assume-console [ type [01] @@ -627,7 +627,7 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ local-scope assume-screen 5/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 5/right + e:&:editor <- new-editor [abc], 0/left, 5/right editor-render screen, e # type a letter assume-console [ @@ -667,7 +667,7 @@ scenario editor-wraps-line-on-insert-2 [ assume-screen 10/width, 5/height s:text <- new [abcdefg defg] - e:&:editor <- new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right editor-render screen, e # type more text at the start assume-console [ @@ -748,7 +748,7 @@ after [ scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abcde], screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] @@ -777,11 +777,13 @@ scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ # create an editor containing two lines s:text <- new [abc xyz] - e:&:editor <- new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right + editor-render screen, e screen-should-contain [ . . .abc . .xyz . + .┈┈┈┈┈ . . . ] assume-console [ @@ -803,7 +805,7 @@ xyz] scenario editor-wraps-cursor-to-left-margin [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abcde], screen, 2/left, 7/right + e:&:editor <- new-editor [abcde], 2/left, 7/right assume-console [ left-click 1, 5 # line is full; no wrap icon yet type [01] @@ -839,7 +841,7 @@ after [ scenario editor-moves-cursor-down-after-inserting-newline [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right assume-console [ type [0 1] @@ -945,7 +947,7 @@ def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num scenario editor-moves-cursor-down-after-inserting-newline-2 [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 1/left, 10/right + e:&:editor <- new-editor [abc], 1/left, 10/right assume-console [ type [0 1] @@ -965,16 +967,17 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ scenario editor-clears-previous-line-completely-after-inserting-newline [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abcde], screen, 0/left, 5/right - assume-console [ - press enter - ] + e:&:editor <- new-editor [abcde], 0/left, 5/right + editor-render screen, e screen-should-contain [ . . .abcd↩ . .e . + .┈┈┈┈┈ . . . - . . + ] + assume-console [ + press enter ] run [ editor-event-loop screen, console, e @@ -995,7 +998,7 @@ scenario editor-inserts-indent-after-newline [ s:text <- new [ab cd ef] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -1020,7 +1023,7 @@ scenario editor-skips-indent-around-paste [ s:text <- new [ab cd ef] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index 7c5d0df2..248c2c64 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -10,7 +10,7 @@ scenario editor-inserts-two-spaces-on-tab [ # just one character in final line s:text <- new [ab cd] - e:&:editor <- new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right assume-console [ press tab ] @@ -42,7 +42,7 @@ after [ scenario editor-handles-backspace-key [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -216,7 +216,7 @@ scenario editor-clears-last-line-on-backspace [ # just one character in final line s:text <- new [ab cd] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right assume-console [ left-click 2, 0 # cursor at only character in final line press backspace @@ -244,7 +244,7 @@ scenario editor-joins-and-wraps-lines-on-backspace [ # initialize editor with two long-ish but non-wrapping lines s:text <- new [abc def ghi jkl] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # position the cursor at the start of the second and hit backspace @@ -269,7 +269,7 @@ scenario editor-wraps-long-lines-on-backspace [ local-scope assume-screen 10/width, 5/height # initialize editor in part of the screen with a long line - e:&:editor <- new-editor [abc def ghij], screen, 0/left, 8/right + e:&:editor <- new-editor [abc def ghij], 0/left, 8/right editor-render screen, e # confirm that it wraps screen-should-contain [ @@ -302,7 +302,7 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -391,7 +391,7 @@ def delete-at-cursor editor:&:editor, screen:&:screen -> editor:&:editor, screen scenario editor-moves-cursor-right-with-key [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -488,7 +488,7 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # type right-arrow a few times to get to start of second line @@ -524,7 +524,7 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 1/left, 10/right + e:&:editor <- new-editor s, 1/left, 10/right editor-render screen, e assume-console [ press right-arrow @@ -548,7 +548,7 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abcdef], screen, 0/left, 5/right + e:&:editor <- new-editor [abcdef], 0/left, 5/right editor-render screen, e $clear-trace assume-console [ @@ -578,7 +578,7 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ local-scope assume-screen 10/width, 5/height # line just barely wrapping - e:&:editor <- new-editor [abcde], screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], 0/left, 5/right editor-render screen, e $clear-trace # position cursor at last character before wrap and hit right-arrow @@ -614,7 +614,7 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abcdef], screen, 1/left, 6/right + e:&:editor <- new-editor [abcdef], 1/left, 6/right editor-render screen, e $clear-trace assume-console [ @@ -645,7 +645,7 @@ scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ assume-screen 10/width, 5/height s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # move to end of line, press right-arrow, type a character @@ -675,7 +675,7 @@ d] scenario editor-moves-cursor-left-with-key [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -720,7 +720,7 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ # initialize editor with two lines s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # position cursor at start of second line (so there's no previous newline) @@ -747,7 +747,7 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 s:text <- new [abc def g] - e:&:editor <- new-editor s:text, screen, 0/left, 10/right + e:&:editor <- new-editor s:text, 0/left, 10/right editor-render screen, e $clear-trace # position cursor further down (so there's a newline before the character at @@ -776,7 +776,7 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 s:text <- new [abc def g] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # position cursor at start of text, press left-arrow, then type a character @@ -806,7 +806,7 @@ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 s:text <- new [abc d] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e:&:editor $clear-trace # position cursor right after empty line @@ -832,7 +832,7 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ local-scope assume-screen 10/width, 5/height # initialize editor with a wrapping line - e:&:editor <- new-editor [abcdef], screen, 0/left, 5/right + e:&:editor <- new-editor [abcdef], 0/left, 5/right editor-render screen, e $clear-trace screen-should-contain [ @@ -865,7 +865,7 @@ scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ # initialize editor with a wrapping line followed by a second line s:text <- new [abcdef g] - e:&:editor <- new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right editor-render screen, e $clear-trace screen-should-contain [ @@ -898,7 +898,7 @@ scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ # initialize editor with a line on the verge of wrapping, followed by a second line s:text <- new [abcd e] - e:&:editor <- new-editor s, screen, 0/left, 5/right + e:&:editor <- new-editor s, 0/left, 5/right editor-render screen, e $clear-trace screen-should-contain [ @@ -934,7 +934,7 @@ scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height s:text <- new [abc def] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -1050,7 +1050,7 @@ scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height s:text <- new [ab def] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -1087,7 +1087,7 @@ scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height s:text <- new [ def] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -1126,7 +1126,7 @@ scenario editor-moves-to-previous-line-from-left-margin [ s:text <- new [abc def ghi] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline @@ -1166,7 +1166,7 @@ scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height s:text <- new [abc def] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # cursor starts out at (1, 0) @@ -1258,7 +1258,7 @@ scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height s:text <- new [abc de] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace assume-console [ @@ -1297,7 +1297,7 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on second line, press ctrl-a @@ -1373,7 +1373,7 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on first line (no newline before), press ctrl-a @@ -1399,7 +1399,7 @@ scenario editor-moves-to-start-of-line-with-home [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1424,7 +1424,7 @@ scenario editor-moves-to-start-of-line-with-home-2 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on first line (no newline before), press 'home' @@ -1452,7 +1452,7 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on first line, press ctrl-e @@ -1545,7 +1545,7 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on second line (no newline after), press ctrl-e @@ -1571,7 +1571,7 @@ scenario editor-moves-to-end-of-line-with-end [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on first line, press 'end' @@ -1597,7 +1597,7 @@ scenario editor-moves-to-end-of-line-with-end-2 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right editor-render screen, e $clear-trace # start on second line (no newline after), press 'end' @@ -1625,7 +1625,7 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start on second line, press ctrl-u assume-console [ left-click 2, 2 @@ -1689,7 +1689,7 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start on first line (no newline before), press ctrl-u assume-console [ left-click 1, 2 @@ -1713,7 +1713,7 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start past end of line, press ctrl-u assume-console [ left-click 1, 3 @@ -1737,7 +1737,7 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start past end of final line, press ctrl-u assume-console [ left-click 2, 3 @@ -1763,7 +1763,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start on first line, press ctrl-k assume-console [ left-click 1, 1 @@ -1819,7 +1819,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start on second line (no newline after), press ctrl-k assume-console [ left-click 2, 1 @@ -1843,7 +1843,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 @@ -1867,7 +1867,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 @@ -1891,7 +1891,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 @@ -1915,7 +1915,7 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen 10/width, 5/height s:text <- new [123 456] - e:&:editor <- new-editor s, screen, 0/left, 10/right + e:&:editor <- new-editor s, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 57eff09f..be55c7ee 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -33,7 +33,7 @@ def new-programming-environment screen:&:screen, initial-sandbox-contents:text - screen <- move-cursor screen, 0/row, button-start print screen, [ run (F4) ], 255/white, 161/reddish # sandbox editor - current-sandbox:&:editor <- new-editor initial-sandbox-contents, screen, 0, width/right + current-sandbox:&:editor <- new-editor initial-sandbox-contents, 0, width/right *result <- put *result, current-sandbox:offset, current-sandbox ] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 7787b50c..9fd2a08b 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -1,14 +1,14 @@ ## running code from the editor and creating sandboxes # # Running code in the sandbox editor prepends its contents to a list of -# (non-editable) sandboxes below the editor, showing the result and a maybe -# few other things. +# (non-editable) sandboxes below the editor, showing the result and maybe a +# few other things (later layers). # -# This layer draws the menubar buttons non-editable sandboxes but they don't -# do anything yet. Later layers implement each button. +# This layer draws the menubar buttons in non-editable sandboxes but they +# don't do anything yet. Later layers implement each button. container environment [ - sandbox:&:sandbox # list of sandboxes, from top to bottom + sandbox:&:sandbox # list of sandboxes, from top to bottom. TODO: switch to &:list:sandbox render-from:num number-of-sandboxes:num ] @@ -110,7 +110,7 @@ after [ screen <- update-status screen, [running... ], 245/grey test-recipes:text, _/optional <- next-ingredient error?:bool, env, screen <- run-sandboxes env, screen, test-recipes -#? test-recipes <- copy 0 # abandon + test-recipes <- copy 0 # abandon # F4 might update warnings and results on both sides screen <- render-all screen, env, render { @@ -607,7 +607,7 @@ def editor-contents editor:&:editor -> result:text [ scenario editor-provides-edited-contents [ local-scope assume-screen 10/width, 5/height - e:&:editor <- new-editor [abc], screen, 0/left, 10/right + e:&:editor <- new-editor [abc], 0/left, 10/right assume-console [ left-click 1, 2 type [def] diff --git a/sandbox/012-editor-undo.mu b/sandbox/012-editor-undo.mu index 27f49377..bc37f307 100644 --- a/sandbox/012-editor-undo.mu +++ b/sandbox/012-editor-undo.mu @@ -102,7 +102,7 @@ scenario editor-can-undo-typing [ local-scope # create an editor and type a character assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e assume-console [ type [0] @@ -232,7 +232,7 @@ scenario editor-can-undo-typing-multiple [ local-scope # create an editor and type multiple characters assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e assume-console [ type [012] @@ -258,7 +258,7 @@ scenario editor-can-undo-typing-multiple-2 [ local-scope # create an editor with some text assume-screen 10/width, 5/height - e:&:editor <- new-editor [a], screen, 0/left, 10/right + e:&:editor <- new-editor [a], 0/left, 10/right editor-render screen, e # type some characters assume-console [ @@ -304,7 +304,7 @@ scenario editor-can-undo-typing-enter [ local-scope # create an editor with some text assume-screen 10/width, 5/height - e:&:editor <- new-editor [ abc], screen, 0/left, 10/right + e:&:editor <- new-editor [ abc], 0/left, 10/right editor-render screen, e # new line assume-console [ @@ -367,7 +367,7 @@ scenario editor-redo-typing [ local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - e:&:editor <- new-editor [a], screen, 0/left, 10/right + e:&:editor <- new-editor [a], 0/left, 10/right editor-render screen, e assume-console [ type [012] @@ -431,7 +431,7 @@ scenario editor-redo-typing-empty [ local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e assume-console [ type [012] @@ -480,7 +480,7 @@ scenario editor-work-clears-redo-stack [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e assume-console [ type [1] @@ -520,7 +520,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ local-scope # create an editor assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e # insert some text and tabs, hit enter, some more text and tabs assume-console [ @@ -680,7 +680,7 @@ scenario editor-can-undo-touch [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor assume-console [ @@ -771,7 +771,7 @@ scenario editor-can-undo-left-arrow [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor assume-console [ @@ -816,7 +816,7 @@ scenario editor-can-undo-up-arrow [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor assume-console [ @@ -867,7 +867,7 @@ scenario editor-can-undo-down-arrow [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor assume-console [ @@ -912,7 +912,7 @@ scenario editor-can-undo-ctrl-a [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor, then to start of line assume-console [ @@ -957,7 +957,7 @@ scenario editor-can-undo-home [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor, then to start of line assume-console [ @@ -1002,7 +1002,7 @@ scenario editor-can-undo-ctrl-e [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor, then to start of line assume-console [ @@ -1047,7 +1047,7 @@ scenario editor-can-undo-end [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor, then to start of line assume-console [ @@ -1092,7 +1092,7 @@ scenario editor-can-undo-multiple-arrows-in-the-same-direction [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # move the cursor assume-console [ @@ -1147,7 +1147,7 @@ scenario editor-redo-touch [ contents:text <- new [abc def ghi] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e assume-console [ left-click 3, 1 @@ -1202,7 +1202,7 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ local-scope # create an editor, type some text, move the cursor, type some more text assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e assume-console [ type [abc] @@ -1351,7 +1351,7 @@ scenario editor-can-undo-and-redo-backspace [ local-scope # create an editor assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e # insert some text and hit backspace assume-console [ @@ -1496,7 +1496,7 @@ scenario editor-can-undo-and-redo-delete [ local-scope # create an editor assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ @@ -1687,7 +1687,7 @@ scenario editor-can-undo-and-redo-ctrl-k [ assume-screen 10/width, 5/height contents:text <- new [abc def] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ @@ -1790,7 +1790,7 @@ scenario editor-can-undo-and-redo-ctrl-u [ assume-screen 10/width, 5/height contents:text <- new [abc def] - e:&:editor <- new-editor contents, screen, 0/left, 10/right + e:&:editor <- new-editor contents, 0/left, 10/right editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ @@ -1890,7 +1890,7 @@ scenario editor-can-undo-and-redo-ctrl-u-2 [ local-scope # create an editor assume-screen 10/width, 5/height - e:&:editor <- new-editor [], screen, 0/left, 10/right + e:&:editor <- new-editor [], 0/left, 10/right editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ -- cgit 1.4.1-2-gfad0