diff options
33 files changed, 2359 insertions, 2226 deletions
diff --git a/050scenario.cc b/050scenario.cc index 57516569..aa914163 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -1,9 +1,8 @@ //: Mu scenarios. This will get long, but these are the tests we want to //: support in this layer. -//: You can use variable names in scenarios, but for the most part we'll use -//: raw location numbers, because that lets us make assertions on memory. -//: Tests should avoid abstraction as far as possible. +//: We avoid raw numeric locations in Mu -- except in scenarios, where they're +//: handy to check the values of specific variables :(scenarios run_mu_scenario) :(scenario scenario_block) scenario foo [ @@ -257,7 +256,8 @@ def scenario-foo [ //:: The special instructions we want to support inside scenarios. //: In a compiler for the mu VM these will require more work. -//: 'run' interprets a string as a set of instructions +//: 'run' is a purely lexical convenience to separate the code actually being +//: tested from any setup or teardown :(scenario run) def main [ @@ -267,34 +267,14 @@ def main [ ] +mem: storing 13 in location 1 -:(before "End Primitive Recipe Declarations") -RUN, -:(before "End Primitive Recipe Numbers") -put(Recipe_ordinal, "run", RUN); -:(before "End Primitive Recipe Checks") -case RUN: { - break; -} -:(before "End Primitive Recipe Implementations") -case RUN: { - assert(Name[Next_recipe_ordinal].empty()); - ostringstream tmp; - tmp << "recipe run_" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]"; - vector<recipe_ordinal> tmp_recipe = load(tmp.str()); - mark_autogenerated(tmp_recipe.at(0)); - bind_special_scenario_names(tmp_recipe.at(0)); - transform_all(); - if (Trace_stream) { - ++Trace_stream->callstack_depth; - trace(9998, "trace") << "run: incrementing callstack depth to " << Trace_stream->callstack_depth << end(); - assert(Trace_stream->callstack_depth < 9000); // 9998-101 plus cushion - } - Current_routine->calls.push_front(call(tmp_recipe.at(0))); - continue; // not done with caller; don't increment current_step_index() +:(before "End Rewrite Instruction(curr, recipe result)") +if (curr.name == "run") { + // Just inline all instructions inside the run block in the containing + // recipe. 'run' is basically a comment; pretend it doesn't exist. + istringstream in2("[\n"+curr.ingredients.at(0).name+"\n]\n"); + slurp_body(in2, result); + curr.clear(); } -:(before "End maybe_make_raw") -if (starts_with(caller.name, "run_")) - r.properties.push_back(pair<string, string_tree*>("raw", NULL)); :(scenario run_multiple) def main [ diff --git a/061text.mu b/061text.mu index 21d9f98d..f01c4c58 100644 --- a/061text.mu +++ b/061text.mu @@ -32,9 +32,9 @@ def equal a:text, b:text -> result:bool [ ] scenario text-equal-reflexive [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] 10:bool/raw <- equal x, x ] memory-should-contain [ @@ -43,10 +43,10 @@ scenario text-equal-reflexive [ ] scenario text-equal-identical [ + local-scope + x:text <- new [abc] + y:text <- new [abc] run [ - local-scope - x:text <- new [abc] - y:text <- new [abc] 10:bool/raw <- equal x, y ] memory-should-contain [ @@ -55,10 +55,10 @@ scenario text-equal-identical [ ] scenario text-equal-distinct-lengths [ + local-scope + x:text <- new [abc] + y:text <- new [abcd] run [ - local-scope - x:text <- new [abc] - y:text <- new [abcd] 10:bool/raw <- equal x, y ] memory-should-contain [ @@ -73,10 +73,10 @@ scenario text-equal-distinct-lengths [ ] scenario text-equal-with-empty [ + local-scope + x:text <- new [] + y:text <- new [abcd] run [ - local-scope - x:text <- new [] - y:text <- new [abcd] 10:bool/raw <- equal x, y ] memory-should-contain [ @@ -85,10 +85,10 @@ scenario text-equal-with-empty [ ] scenario text-equal-common-lengths-but-distinct [ + local-scope + x:text <- new [abc] + y:text <- new [abd] run [ - local-scope - x:text <- new [abc] - y:text <- new [abd] 10:bool/raw <- equal x, y ] memory-should-contain [ @@ -205,18 +205,53 @@ def append buf:&:buffer, t:text -> buf:&:buffer [ } ] -scenario buffer-append-works [ +scenario append-to-empty-buffer [ + local-scope + x:&:buffer <- new-buffer run [ - local-scope - x:&:buffer <- new-buffer 3 - s1:text <- get *x, data:offset c:char <- copy 97/a x <- append x, c - c:char <- copy 98/b - x <- append x, c - c:char <- copy 99/c + 10:num/raw <- get *x, length:offset + s:text <- get *x, data:offset + 11:char/raw <- index *s, 0 + 12:char/raw <- index *s, 1 + ] + memory-should-contain [ + 10 <- 1 # buffer length + 11 <- 97 # a + 12 <- 0 # rest of buffer is empty + ] +] + +scenario append-to-buffer [ + local-scope + x:&:buffer <- new-buffer + c:char <- copy 97/a + x <- append x, c + run [ + c <- copy 98/b x <- append x, c - s2:text <- get *x, data:offset + 10:num/raw <- get *x, length:offset + s:text <- get *x, data:offset + 11:char/raw <- index *s, 0 + 12:char/raw <- index *s, 1 + 13:char/raw <- index *s, 2 + ] + memory-should-contain [ + 10 <- 2 # buffer length + 11 <- 97 # a + 12 <- 98 # b + 13 <- 0 # rest of buffer is empty + ] +] + +scenario append-grows-buffer [ + local-scope + x:&:buffer <- new-buffer 3 + s1:text <- get *x, data:offset + x <- append x, [abc] # buffer is now full + s2:text <- get *x, data:offset + run [ 10:bool/raw <- equal s1, s2 11:@:char/raw <- copy *s2 +buffer-filled @@ -229,13 +264,13 @@ scenario buffer-append-works [ ] memory-should-contain [ # before +buffer-filled - 10 <- 1 # no change in data pointer + 10 <- 1 # no change in data pointer after original append 11 <- 3 # size of data 12 <- 97 # data 13 <- 98 14 <- 99 # in the end - 20 <- 0 # data pointer has grown + 20 <- 0 # data pointer has grown after second append 21 <- 4 # final length 30 <- 6 # but data's capacity has doubled 31 <- 97 # data @@ -247,23 +282,11 @@ scenario buffer-append-works [ ] ] -scenario buffer-append-to-empty [ - run [ - local-scope - x:&:buffer <- new-buffer - c:char <- copy 97/a - x <- append x, c - ] -] - scenario buffer-append-handles-backspace [ + local-scope + x:&:buffer <- new-buffer + x <- append x, [ab] run [ - local-scope - x:&:buffer <- new-buffer 3 - c:char <- copy 97/a - x <- append x, c - c:char <- copy 98/b - x <- append x, c c:char <- copy 8/backspace x <- append x, c s:text <- buffer-to-array x @@ -328,10 +351,10 @@ def append first:text -> result:text [ ] scenario text-append-1 [ + local-scope + x:text <- new [hello,] + y:text <- new [ world!] run [ - local-scope - x:text <- new [hello,] - y:text <- new [ world!] z:text <- append x, y 10:@:char/raw <- copy *z ] @@ -341,10 +364,10 @@ scenario text-append-1 [ ] scenario text-append-null [ + local-scope + x:text <- copy 0 + y:text <- new [ world!] run [ - local-scope - x:text <- copy 0 - y:text <- new [ world!] z:text <- append x, y 10:@:char/raw <- copy *z ] @@ -354,10 +377,10 @@ scenario text-append-null [ ] scenario text-append-null-2 [ + local-scope + x:text <- new [hello,] + y:text <- copy 0 run [ - local-scope - x:text <- new [hello,] - y:text <- copy 0 z:text <- append x, y 10:@:char/raw <- copy *z ] @@ -367,11 +390,11 @@ scenario text-append-null-2 [ ] scenario text-append-multiary [ + local-scope + x:text <- new [hello, ] + y:text <- new [world] + z:text <- new [!] run [ - local-scope - x:text <- new [hello, ] - y:text <- new [world] - z:text <- new [!] z:text <- append x, y, z 10:@:char/raw <- copy *z ] @@ -381,9 +404,9 @@ scenario text-append-multiary [ ] scenario replace-character-in-text [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] x <- replace x, 98/b, 122/z 10:@:char/raw <- copy *x ] @@ -405,9 +428,9 @@ def replace s:text, oldc:char, newc:char, from:num/optional -> s:text [ ] scenario replace-character-at-start [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] x <- replace x, 97/a, 122/z 10:@:char/raw <- copy *x ] @@ -417,9 +440,9 @@ scenario replace-character-at-start [ ] scenario replace-character-at-end [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] x <- replace x, 99/c, 122/z 10:@:char/raw <- copy *x ] @@ -429,9 +452,9 @@ scenario replace-character-at-end [ ] scenario replace-character-missing [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] x <- replace x, 100/d, 122/z 10:@:char/raw <- copy *x ] @@ -441,9 +464,9 @@ scenario replace-character-missing [ ] scenario replace-all-characters [ + local-scope + x:text <- new [banana] run [ - local-scope - x:text <- new [banana] x <- replace x, 97/a, 122/z 10:@:char/raw <- copy *x ] @@ -527,10 +550,10 @@ def interpolate template:text -> result:text [ ] scenario interpolate-works [ + local-scope + x:text <- new [abc_ghi] + y:text <- new [def] run [ - local-scope - x:text <- new [abc_ghi] - y:text <- new [def] z:text <- interpolate x, y 10:@:char/raw <- copy *z ] @@ -540,10 +563,10 @@ scenario interpolate-works [ ] scenario interpolate-at-start [ + local-scope + x:text <- new [_, hello!] + y:text <- new [abc] run [ - local-scope - x:text <- new [_, hello!] - y:text <- new [abc] z:text <- interpolate x, y 10:@:char/raw <- copy *z ] @@ -554,9 +577,10 @@ scenario interpolate-at-start [ ] scenario interpolate-at-end [ + local-scope + x:text <- new [hello, _] + y:text <- new [abc] run [ - x:text <- new [hello, _] - y:text <- new [abc] z:text <- interpolate x, y 10:@:char/raw <- copy *z ] @@ -677,9 +701,9 @@ def trim s:text -> result:text [ ] scenario trim-unmodified [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] y:text <- trim x 1:@:char/raw <- copy *y ] @@ -689,9 +713,9 @@ scenario trim-unmodified [ ] scenario trim-left [ + local-scope + x:text <- new [ abc] run [ - local-scope - x:text <- new [ abc] y:text <- trim x 1:@:char/raw <- copy *y ] @@ -701,9 +725,9 @@ scenario trim-left [ ] scenario trim-right [ + local-scope + x:text <- new [abc ] run [ - local-scope - x:text <- new [abc ] y:text <- trim x 1:@:char/raw <- copy *y ] @@ -713,9 +737,9 @@ scenario trim-right [ ] scenario trim-left-right [ + local-scope + x:text <- new [ abc ] run [ - local-scope - x:text <- new [ abc ] y:text <- trim x 1:@:char/raw <- copy *y ] @@ -725,10 +749,10 @@ scenario trim-left-right [ ] scenario trim-newline-tab [ - run [ - local-scope - x:text <- new [ abc + local-scope + x:text <- new [ abc ] + run [ y:text <- trim x 1:@:char/raw <- copy *y ] @@ -754,9 +778,9 @@ def find-next text:text, pattern:char, idx:num -> next-index:num [ ] scenario text-find-next [ + local-scope + x:text <- new [a/b] run [ - local-scope - x:text <- new [a/b] 10:num/raw <- find-next x, 47/slash, 0/start-index ] memory-should-contain [ @@ -765,9 +789,9 @@ scenario text-find-next [ ] scenario text-find-next-empty [ + local-scope + x:text <- new [] run [ - local-scope - x:text <- new [] 10:num/raw <- find-next x, 47/slash, 0/start-index ] memory-should-contain [ @@ -776,9 +800,9 @@ scenario text-find-next-empty [ ] scenario text-find-next-initial [ + local-scope + x:text <- new [/abc] run [ - local-scope - x:text <- new [/abc] 10:num/raw <- find-next x, 47/slash, 0/start-index ] memory-should-contain [ @@ -787,9 +811,9 @@ scenario text-find-next-initial [ ] scenario text-find-next-final [ + local-scope + x:text <- new [abc/] run [ - local-scope - x:text <- new [abc/] 10:num/raw <- find-next x, 47/slash, 0/start-index ] memory-should-contain [ @@ -798,9 +822,9 @@ scenario text-find-next-final [ ] scenario text-find-next-missing [ + local-scope + x:text <- new [abcd] run [ - local-scope - x:text <- new [abcd] 10:num/raw <- find-next x, 47/slash, 0/start-index ] memory-should-contain [ @@ -809,9 +833,9 @@ scenario text-find-next-missing [ ] scenario text-find-next-invalid-index [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] 10:num/raw <- find-next x, 47/slash, 4/start-index ] memory-should-contain [ @@ -820,9 +844,9 @@ scenario text-find-next-invalid-index [ ] scenario text-find-next-first [ + local-scope + x:text <- new [ab/c/] run [ - local-scope - x:text <- new [ab/c/] 10:num/raw <- find-next x, 47/slash, 0/start-index ] memory-should-contain [ @@ -831,9 +855,9 @@ scenario text-find-next-first [ ] scenario text-find-next-second [ + local-scope + x:text <- new [ab/c/] run [ - local-scope - x:text <- new [ab/c/] 10:num/raw <- find-next x, 47/slash, 3/start-index ] memory-should-contain [ @@ -864,10 +888,10 @@ def find-next text:text, pattern:text, idx:num -> next-index:num [ ] scenario find-next-text-1 [ + local-scope + x:text <- new [abc] + y:text <- new [bc] run [ - local-scope - x:text <- new [abc] - y:text <- new [bc] 10:num/raw <- find-next x, y, 0 ] memory-should-contain [ @@ -876,10 +900,10 @@ scenario find-next-text-1 [ ] scenario find-next-text-2 [ + local-scope + x:text <- new [abcd] + y:text <- new [bc] run [ - local-scope - x:text <- new [abcd] - y:text <- new [bc] 10:num/raw <- find-next x, y, 1 ] memory-should-contain [ @@ -888,10 +912,10 @@ scenario find-next-text-2 [ ] scenario find-next-no-match [ + local-scope + x:text <- new [abc] + y:text <- new [bd] run [ - local-scope - x:text <- new [abc] - y:text <- new [bd] 10:num/raw <- find-next x, y, 0 ] memory-should-contain [ @@ -900,10 +924,10 @@ scenario find-next-no-match [ ] scenario find-next-suffix-match [ + local-scope + x:text <- new [abcd] + y:text <- new [cd] run [ - local-scope - x:text <- new [abcd] - y:text <- new [cd] 10:num/raw <- find-next x, y, 0 ] memory-should-contain [ @@ -912,10 +936,10 @@ scenario find-next-suffix-match [ ] scenario find-next-suffix-match-2 [ + local-scope + x:text <- new [abcd] + y:text <- new [cde] run [ - local-scope - x:text <- new [abcd] - y:text <- new [cde] 10:num/raw <- find-next x, y, 0 ] memory-should-contain [ @@ -956,10 +980,10 @@ def match-at text:text, pattern:text, idx:num -> result:bool [ ] scenario match-at-checks-pattern-at-index [ + local-scope + x:text <- new [abc] + y:text <- new [ab] run [ - local-scope - x:text <- new [abc] - y:text <- new [ab] 10:bool/raw <- match-at x, y, 0 ] memory-should-contain [ @@ -968,9 +992,9 @@ scenario match-at-checks-pattern-at-index [ ] scenario match-at-reflexive [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] 10:bool/raw <- match-at x, x, 0 ] memory-should-contain [ @@ -979,10 +1003,10 @@ scenario match-at-reflexive [ ] scenario match-at-outside-bounds [ + local-scope + x:text <- new [abc] + y:text <- new [a] run [ - local-scope - x:text <- new [abc] - y:text <- new [a] 10:bool/raw <- match-at x, y, 4 ] memory-should-contain [ @@ -991,10 +1015,10 @@ scenario match-at-outside-bounds [ ] scenario match-at-empty-pattern [ + local-scope + x:text <- new [abc] + y:text <- new [] run [ - local-scope - x:text <- new [abc] - y:text <- new [] 10:bool/raw <- match-at x, y, 0 ] memory-should-contain [ @@ -1003,10 +1027,10 @@ scenario match-at-empty-pattern [ ] scenario match-at-empty-pattern-outside-bound [ + local-scope + x:text <- new [abc] + y:text <- new [] run [ - local-scope - x:text <- new [abc] - y:text <- new [] 10:bool/raw <- match-at x, y, 4 ] memory-should-contain [ @@ -1015,10 +1039,10 @@ scenario match-at-empty-pattern-outside-bound [ ] scenario match-at-empty-text [ + local-scope + x:text <- new [] + y:text <- new [abc] run [ - local-scope - x:text <- new [] - y:text <- new [abc] 10:bool/raw <- match-at x, y, 0 ] memory-should-contain [ @@ -1027,9 +1051,9 @@ scenario match-at-empty-text [ ] scenario match-at-empty-against-empty [ + local-scope + x:text <- new [] run [ - local-scope - x:text <- new [] 10:bool/raw <- match-at x, x, 0 ] memory-should-contain [ @@ -1038,10 +1062,10 @@ scenario match-at-empty-against-empty [ ] scenario match-at-inside-bounds [ + local-scope + x:text <- new [abc] + y:text <- new [bc] run [ - local-scope - x:text <- new [abc] - y:text <- new [bc] 10:bool/raw <- match-at x, y, 1 ] memory-should-contain [ @@ -1050,10 +1074,10 @@ scenario match-at-inside-bounds [ ] scenario match-at-inside-bounds-2 [ + local-scope + x:text <- new [abc] + y:text <- new [bc] run [ - local-scope - x:text <- new [abc] - y:text <- new [bc] 10:bool/raw <- match-at x, y, 0 ] memory-should-contain [ @@ -1104,9 +1128,9 @@ def split s:text, delim:char -> result:&:@:text [ ] scenario text-split-1 [ + local-scope + x:text <- new [a/b] run [ - local-scope - x:text <- new [a/b] y:&:@:text <- split x, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 @@ -1122,9 +1146,9 @@ scenario text-split-1 [ ] scenario text-split-2 [ + local-scope + x:text <- new [a/b/c] run [ - local-scope - x:text <- new [a/b/c] y:&:@:text <- split x, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 @@ -1143,9 +1167,9 @@ scenario text-split-2 [ ] scenario text-split-missing [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] y:&:@:text <- split x, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 @@ -1158,9 +1182,9 @@ scenario text-split-missing [ ] scenario text-split-empty [ + local-scope + x:text <- new [] run [ - local-scope - x:text <- new [] y:&:@:text <- split x, 47/slash 10:num/raw <- length *y ] @@ -1170,9 +1194,9 @@ scenario text-split-empty [ ] scenario text-split-empty-piece [ + local-scope + x:text <- new [a/b//c] run [ - local-scope - x:text <- new [a/b//c] y:&:@:text <- split x:text, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 @@ -1212,9 +1236,9 @@ def split-first text:text, delim:char -> x:text, y:text [ ] scenario text-split-first [ + local-scope + x:text <- new [a/b] run [ - local-scope - x:text <- new [a/b] y:text, z:text <- split-first x, 47/slash 10:@:char/raw <- copy *y 20:@:char/raw <- copy *z @@ -1248,10 +1272,10 @@ def copy-range buf:text, start:num, end:num -> result:text [ } ] -scenario text-copy-copies-partial-text [ +scenario copy-range-works [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] y:text <- copy-range x, 1, 3 1:@:char/raw <- copy *y ] @@ -1260,10 +1284,10 @@ scenario text-copy-copies-partial-text [ ] ] -scenario text-copy-out-of-bounds [ +scenario copy-range-out-of-bounds [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] y:text <- copy-range x, 2, 4 1:@:char/raw <- copy *y ] @@ -1272,10 +1296,10 @@ scenario text-copy-out-of-bounds [ ] ] -scenario text-copy-out-of-bounds-2 [ +scenario copy-range-out-of-bounds-2 [ + local-scope + x:text <- new [abc] run [ - local-scope - x:text <- new [abc] y:text <- copy-range x, 3, 3 1:@:char/raw <- copy *y ] diff --git a/063array.mu b/063array.mu index 001ff7a4..f0679c6d 100644 --- a/063array.mu +++ b/063array.mu @@ -58,9 +58,9 @@ recipe fill array:&:@:num -> array:&:@:num [ ] scenario fill-on-an-empty-array [ + local-scope + array:&:@:num <- new number:type, 3 run [ - local-scope - array:&:@:num <- new number:type, 3 array <- fill array, 1 2 3 10:@:num/raw <- copy *array ] @@ -73,10 +73,10 @@ scenario fill-on-an-empty-array [ ] scenario fill-overwrites-existing-values [ + local-scope + array:&:@:num <- new number:type, 3 + *array <- put-index *array, 0, 4 run [ - local-scope - array:&:@:num <- new number:type, 3 - *array <- put-index *array, 0, 4 array <- fill array, 1 2 3 10:@:num/raw <- copy *array ] @@ -89,9 +89,9 @@ scenario fill-overwrites-existing-values [ ] scenario fill-exits-gracefully-when-given-no-ingredients [ + local-scope + array:&:@:num <- new number:type, 3 run [ - local-scope - array:&:@:num <- new number:type, 3 array <- fill array 10:@:num/raw <- copy *array ] @@ -115,10 +115,10 @@ recipe swap array:&:@:num, index1:num, index2:num -> array:&:@:num [ ] scenario swap-works [ + local-scope + array:&:@:num <- new number:type, 4 + array <- fill array, 4 3 2 1 run [ - local-scope - array:&:@:num <- new number:type, 4 - array <- fill array, 4 3 2 1 array <- swap array, 0, 2 10:num/raw <- index *array, 0 11:num/raw <- index *array, 2 @@ -148,10 +148,10 @@ def reverse array:&:@:_elem -> array:&:@:_elem [ ] scenario reverse-array-odd-length [ + local-scope + array:&:@:num <- new number:type, 3 + array <- fill array, 3 2 1 run [ - local-scope - array:&:@:num <- new number:type, 3 - array <- fill array, 3 2 1 array <- reverse array 10:@:num/raw <- copy *array ] @@ -164,10 +164,10 @@ scenario reverse-array-odd-length [ ] scenario reverse-array-even-length [ + local-scope + array:&:@:num <- new number:type, 4 + array <- fill array, 4 3 2 1 run [ - local-scope - array:&:@:num <- new number:type, 4 - array <- fill array, 4 3 2 1 array <- reverse array 10:@:num/raw <- copy *array ] diff --git a/064list.mu b/064list.mu index 4c48f8e2..cf7be09c 100644 --- a/064list.mu +++ b/064list.mu @@ -69,11 +69,11 @@ def insert x:_elem, in:&:list:_elem -> in:&:list:_elem [ ] scenario inserting-into-list [ + local-scope + list:&:list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list2:&:list:char <- rest list # inside list list2 <- insert 6, list2 # check structure @@ -95,11 +95,11 @@ scenario inserting-into-list [ ] scenario inserting-at-end-of-list [ + local-scope + list:&:list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list2:&:list:char <- rest list # inside list list2 <- rest list2 # now at end of list list2 <- insert 6, list2 @@ -122,11 +122,11 @@ scenario inserting-at-end-of-list [ ] scenario inserting-after-start-of-list [ + local-scope + list:&:list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list <- insert 6, list # check structure like before list2:&:list:char <- copy list @@ -176,11 +176,11 @@ def remove x:&:list:_elem/contained-in:in, in:&:list:_elem -> in:&:list:_elem [ ] scenario removing-from-list [ + local-scope + list:&:list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list2:&:list:char <- rest list # second element list <- remove list2, list 10:bool/raw <- equal list2, 0 @@ -200,11 +200,11 @@ scenario removing-from-list [ ] scenario removing-from-start-of-list [ + local-scope + list:&:list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list <- remove list, list # check structure like before list2:&:list:char <- copy list @@ -221,11 +221,11 @@ scenario removing-from-start-of-list [ ] scenario removing-from-end-of-list [ + local-scope + list:&:list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list # delete last element list2:&:list:char <- rest list list2 <- rest list2 @@ -247,9 +247,9 @@ scenario removing-from-end-of-list [ ] scenario removing-from-singleton-list [ + local-scope + list:&:list:char <- push 3, 0 run [ - local-scope - list:&:list:char <- push 3, 0 list <- remove list, list 1:num/raw <- copy list ] @@ -271,11 +271,11 @@ def reverse list:&:list:_elem temp:&:list:_elem -> result:&:list:_elem [ ] scenario reverse-list [ + local-scope + list:&:list:number <- push 1, 0 + list <- push 2, list + list <- push 3, list run [ - local-scope - list:&:list:number <- push 1, 0 - list <- push 2, list - list <- push 3, list stash [list:], list list <- reverse list stash [reversed:], list @@ -339,8 +339,11 @@ def to-buffer in:&:list:_elem, buf:&:buffer -> buf:&:buffer [ ] scenario stash-empty-list [ + local-scope x:&:list:num <- copy 0 - stash x + run [ + stash x + ] trace-should-contain [ app: [] ] diff --git a/065duplex_list.mu b/065duplex_list.mu index a668c86e..fa3527fe 100644 --- a/065duplex_list.mu +++ b/065duplex_list.mu @@ -99,11 +99,11 @@ def insert x:_elem, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [ ] scenario inserting-into-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:duplex-list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list2:&:duplex-list:char <- next list # inside list list2 <- insert 6, list2 # check structure like before @@ -136,11 +136,11 @@ scenario inserting-into-duplex-list [ ] scenario inserting-at-end-of-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:duplex-list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list2:&:duplex-list:char <- next list # inside list list2 <- next list2 # now at end of list list2 <- insert 6, list2 @@ -174,11 +174,11 @@ scenario inserting-at-end-of-duplex-list [ ] scenario inserting-after-start-of-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:duplex-list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list <- insert 6, list # check structure like before list2:&:duplex-list:char <- copy list @@ -240,11 +240,11 @@ def remove x:&:duplex-list:_elem/contained-in:in, in:&:duplex-list:_elem -> in:& ] scenario removing-from-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:duplex-list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list2:&:duplex-list:char <- next list # second element list <- remove list2, list 10:bool/raw <- equal list2, 0 @@ -269,11 +269,11 @@ scenario removing-from-duplex-list [ ] scenario removing-from-start-of-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:duplex-list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list list <- remove list, list # check structure like before list2:&:duplex-list:char <- copy list @@ -295,11 +295,11 @@ scenario removing-from-start-of-duplex-list [ ] scenario removing-from-end-of-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 + list <- push 4, list + list <- push 5, list run [ - local-scope - list:&:duplex-list:char <- push 3, 0 - list <- push 4, list - list <- push 5, list # delete last element list2:&:duplex-list:char <- next list list2 <- next list2 @@ -326,9 +326,9 @@ scenario removing-from-end-of-duplex-list [ ] scenario removing-from-singleton-duplex-list [ + local-scope + list:&:duplex-list:char <- push 3, 0 run [ - local-scope - list:&:duplex-list:char <- push 3, 0 list <- remove list, list 1:num/raw <- copy list ] @@ -371,10 +371,7 @@ scenario remove-range [ list <- push 15, list list <- push 14, list list <- push 13, list - 1:&:duplex-list:char/raw <- copy list # save list run [ - local-scope - list:&:duplex-list:char <- copy 1:&:duplex-list:char/raw # restore list # delete 16 onwards # first pointer: to the third element list2:&:duplex-list:char <- next list @@ -405,10 +402,7 @@ scenario remove-range-to-final [ list <- push 15, list list <- push 14, list list <- push 13, list - 1:&:duplex-list:char/raw <- copy list # save list run [ - local-scope - list:&:duplex-list:char <- copy 1:&:duplex-list:char/raw # restore list # delete 15, 16 and 17 # start pointer: to the second element list2:&:duplex-list:char <- next list @@ -440,10 +434,7 @@ scenario remove-range-empty [ list:&:duplex-list:char <- push 15, 0 list <- push 14, list list <- push 13, list - 1:&:duplex-list:char/raw <- copy list # save list run [ - local-scope - list:&:duplex-list:char <- copy 1:&:duplex-list:char/raw # restore list # delete between first and second element (i.e. nothing) list2:&:duplex-list:char <- next list remove-between list, list2 @@ -473,10 +464,7 @@ scenario remove-range-to-end [ list <- push 15, list list <- push 14, list list <- push 13, list - 1:&:duplex-list:char/raw <- copy list # save list run [ - local-scope - list:&:duplex-list:char <- copy 1:&:duplex-list:char/raw # restore list # remove the third element and beyond list2:&:duplex-list:char <- next list remove-between list2, 0 diff --git a/070table.mu b/070table.mu index 0efaadf0..6879e2e0 100644 --- a/070table.mu +++ b/070table.mu @@ -2,9 +2,9 @@ # arbitrary types. scenario table-read-write [ + local-scope + tab:&:table:num:num <- new-table 30 run [ - local-scope - tab:&:table:num:num <- new-table 30 put-index tab, 12, 34 1:num/raw <- index tab, 12 ] @@ -14,10 +14,10 @@ scenario table-read-write [ ] scenario table-read-write-non-integer [ + local-scope + key:text <- new [abc def] + {tab: (address table text number)} <- new-table 30 run [ - local-scope - key:text <- new [abc def] - {tab: (address table text number)} <- new-table 30 put-index tab, key, 34 1:num/raw <- index tab, key ] diff --git a/075channel.mu b/075channel.mu index ebac99a6..7819f787 100644 --- a/075channel.mu +++ b/075channel.mu @@ -177,9 +177,9 @@ scenario channel-initialization [ ] scenario channel-write-increments-free [ + local-scope + _, sink:&:sink:num <- new-channel 3/capacity run [ - local-scope - _, sink:&:sink:num <- new-channel 3/capacity sink <- write sink, 34 chan:&:channel:num <- get *sink, chan:offset 10:num/raw <- get *chan, first-full:offset @@ -192,10 +192,10 @@ scenario channel-write-increments-free [ ] scenario channel-read-increments-full [ + local-scope + source:&:source:num, sink:&:sink:num <- new-channel 3/capacity + sink <- write sink, 34 run [ - local-scope - source:&:source:num, sink:&:sink:num <- new-channel 3/capacity - sink <- write sink, 34 _, _, source <- read source chan:&:channel:num <- get *source, chan:offset 10:num/raw <- get *chan, first-full:offset @@ -208,14 +208,14 @@ scenario channel-read-increments-full [ ] scenario channel-wrap [ + local-scope + # channel with just 1 slot + source:&:source:num, sink:&:sink:num <- new-channel 1/capacity + chan:&:channel:num <- get *source, chan:offset + # write and read a value + sink <- write sink, 34 + _, _, source <- read source run [ - local-scope - # channel with just 1 slot - source:&:source:num, sink:&:sink:num <- new-channel 1/capacity - chan:&:channel:num <- get *source, chan:offset - # write and read a value - sink <- write sink, 34 - _, _, source <- read source # first-free will now be 1 10:num/raw <- get *chan, first-free:offset 11:num/raw <- get *chan, first-free:offset @@ -249,9 +249,10 @@ scenario channel-new-empty-not-full [ ] scenario channel-write-not-empty [ + local-scope + source:&:source:num, sink:&:sink:num <- new-channel 3/capacity + chan:&:channel:num <- get *source, chan:offset run [ - source:&:source:num, sink:&:sink:num <- new-channel 3/capacity - chan:&:channel:num <- get *source, chan:offset sink <- write sink, 34 10:bool/raw <- channel-empty? chan 11:bool/raw <- channel-full? chan @@ -263,10 +264,10 @@ scenario channel-write-not-empty [ ] scenario channel-write-full [ + local-scope + source:&:source:num, sink:&:sink:num <- new-channel 1/capacity + chan:&:channel:num <- get *source, chan:offset run [ - local-scope - source:&:source:num, sink:&:sink:num <- new-channel 1/capacity - chan:&:channel:num <- get *source, chan:offset sink <- write sink, 34 10:bool/raw <- channel-empty? chan 11:bool/raw <- channel-full? chan @@ -278,11 +279,11 @@ scenario channel-write-full [ ] scenario channel-read-not-full [ + local-scope + source:&:source:num, sink:&:sink:num <- new-channel 1/capacity + chan:&:channel:num <- get *source, chan:offset + sink <- write sink, 34 run [ - local-scope - source:&:source:num, sink:&:sink:num <- new-channel 1/capacity - chan:&:channel:num <- get *source, chan:offset - sink <- write sink, 34 _, _, source <- read source 10:bool/raw <- channel-empty? chan 11:bool/raw <- channel-full? chan diff --git a/081print.mu b/081print.mu index 1c42828b..e9cad56e 100644 --- a/081print.mu +++ b/081print.mu @@ -172,9 +172,9 @@ def print screen:&:screen, c:char -> screen:&:screen [ ] scenario print-character-at-top-left [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height a:char <- copy 97/a fake-screen <- print fake-screen, a:char cell:&:@:screen-cell <- get *fake-screen, data:offset @@ -190,9 +190,9 @@ scenario print-character-at-top-left [ ] scenario print-character-in-color [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height a:char <- copy 97/a fake-screen <- print fake-screen, a:char, 1/red cell:&:@:screen-cell <- get *fake-screen, data:offset @@ -208,11 +208,11 @@ scenario print-character-in-color [ ] scenario print-backspace-character [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height + a:char <- copy 97/a + fake-screen <- print fake-screen, a run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height - a:char <- copy 97/a - fake-screen <- print fake-screen, a backspace:char <- copy 8/backspace fake-screen <- print fake-screen, backspace 10:num/raw <- get *fake-screen, cursor-column:offset @@ -230,14 +230,14 @@ scenario print-backspace-character [ ] scenario print-extra-backspace-character [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height + a:char <- copy 97/a + fake-screen <- print fake-screen, a run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height - a:char <- copy 97/a - fake-screen <- print fake-screen, a backspace:char <- copy 8/backspace fake-screen <- print fake-screen, backspace - fake-screen <- print fake-screen, backspace + fake-screen <- print fake-screen, backspace # cursor already at left margin 1:num/raw <- get *fake-screen, cursor-column:offset cell:&:@:screen-cell <- get *fake-screen, data:offset 3:@:screen-cell/raw <- copy *cell @@ -253,13 +253,15 @@ scenario print-extra-backspace-character [ ] scenario print-character-at-right-margin [ + # fill top row of screen with text + local-scope + fake-screen:&:screen <- new-fake-screen 2/width, 2/height + a:char <- copy 97/a + fake-screen <- print fake-screen, a + b:char <- copy 98/b + fake-screen <- print fake-screen, b run [ - local-scope - fake-screen:&:screen <- new-fake-screen 2/width, 2/height - a:char <- copy 97/a - fake-screen <- print fake-screen, a - b:char <- copy 98/b - fake-screen <- print fake-screen, b + # cursor now at right margin c:char <- copy 99/c fake-screen <- print fake-screen, c 10:num/raw <- get *fake-screen, cursor-column:offset @@ -279,12 +281,12 @@ scenario print-character-at-right-margin [ ] scenario print-newline-character [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height + a:char <- copy 97/a + fake-screen <- print fake-screen, a run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height newline:char <- copy 10/newline - a:char <- copy 97/a - fake-screen <- print fake-screen, a fake-screen <- print fake-screen, newline 10:num/raw <- get *fake-screen, cursor-row:offset 11:num/raw <- get *fake-screen, cursor-column:offset @@ -303,16 +305,18 @@ scenario print-newline-character [ ] scenario print-newline-at-bottom-line [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height + newline:char <- copy 10/newline + fake-screen <- print fake-screen, newline + fake-screen <- print fake-screen, newline run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height - newline:char <- copy 10/newline - fake-screen <- print fake-screen, newline - fake-screen <- print fake-screen, newline + # cursor now at bottom of screen fake-screen <- print fake-screen, newline 10:num/raw <- get *fake-screen, cursor-row:offset 11:num/raw <- get *fake-screen, cursor-column:offset ] + # doesn't move further down memory-should-contain [ 10 <- 1 # cursor row 11 <- 0 # cursor column @@ -320,18 +324,19 @@ scenario print-newline-at-bottom-line [ ] scenario print-character-at-bottom-right [ + local-scope + fake-screen:&:screen <- new-fake-screen 2/width, 2/height + newline:char <- copy 10/newline + fake-screen <- print fake-screen, newline + a:char <- copy 97/a + fake-screen <- print fake-screen, a + b:char <- copy 98/b + fake-screen <- print fake-screen, b + c:char <- copy 99/c + fake-screen <- print fake-screen, c + fake-screen <- print fake-screen, newline run [ - local-scope - fake-screen:&:screen <- new-fake-screen 2/width, 2/height - newline:char <- copy 10/newline - fake-screen <- print fake-screen, newline - a:char <- copy 97/a - fake-screen <- print fake-screen, a - b:char <- copy 98/b - fake-screen <- print fake-screen, b - c:char <- copy 99/c - fake-screen <- print fake-screen, c - fake-screen <- print fake-screen, newline + # cursor now at bottom right d:char <- copy 100/d fake-screen <- print fake-screen, d 10:num/raw <- get *fake-screen, cursor-row:offset @@ -431,15 +436,14 @@ def move-cursor screen:&:screen, new-row:num, new-column:num -> screen:&:screen ] scenario clear-line-erases-printed-characters [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height + # print a character + a:char <- copy 97/a + fake-screen <- print fake-screen, a + # move cursor to start of line + fake-screen <- move-cursor fake-screen, 0/row, 0/column run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height - # print a character - a:char <- copy 97/a - fake-screen <- print fake-screen, a - # move cursor to start of line - fake-screen <- move-cursor fake-screen, 0/row, 0/column - # clear line fake-screen <- clear-line fake-screen cell:&:@:screen-cell <- get *fake-screen, data:offset 10:@:screen-cell/raw <- copy *cell @@ -672,11 +676,10 @@ def print screen:&:screen, s:text -> screen:&:screen [ ] scenario print-text-stops-at-right-margin [ + local-scope + fake-screen:&:screen <- new-fake-screen 3/width, 2/height run [ - local-scope - fake-screen:&:screen <- new-fake-screen 3/width, 2/height - s:text <- new [abcd] - fake-screen <- print fake-screen, s:text + fake-screen <- print fake-screen, [abcd] cell:&:@:screen-cell <- get *fake-screen, data:offset 10:@:screen-cell/raw <- copy *cell ] diff --git a/082scenario_screen.cc b/082scenario_screen.cc index 3e248044..b99982bb 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -12,10 +12,11 @@ recipes_taking_literal_strings.insert("screen-should-contain-in-color"); :(scenarios run_mu_scenario) :(scenario screen_in_scenario) scenario screen-in-scenario [ + local-scope assume-screen 5/width, 3/height run [ - 1:char <- copy 97/a - screen:&:screen <- print screen:&:screen, 1:char/a + a:char <- copy 97/a + screen:&:screen <- print screen:&:screen, a ] screen-should-contain [ # 01234 @@ -28,12 +29,13 @@ scenario screen-in-scenario [ :(scenario screen_in_scenario_unicode) scenario screen-in-scenario-unicode-color [ + local-scope assume-screen 5/width, 3/height run [ - 1:char <- copy 955/greek-small-lambda - screen:&:screen <- print screen:&:screen, 1:char/lambda, 1/red - 2:char <- copy 97/a - screen:&:screen <- print screen:&:screen, 2:char/a + lambda:char <- copy 955/greek-small-lambda + screen:&:screen <- print screen:&:screen, lambda, 1/red + a:char <- copy 97/a + screen:&:screen <- print screen:&:screen, a ] screen-should-contain [ # 01234 @@ -47,12 +49,13 @@ scenario screen-in-scenario-unicode-color [ :(scenario screen_in_scenario_color) # screen-should-contain can check unicode characters in the fake screen scenario screen-in-scenario-color [ + local-scope assume-screen 5/width, 3/height run [ - 1:char <- copy 955/greek-small-lambda - screen:&:screen <- print screen:&:screen, 1:char/lambda, 1/red - 2:char <- copy 97/a - screen:&:screen <- print screen:&:screen, 2:char/a, 7/white + lambda:char <- copy 955/greek-small-lambda + screen:&:screen <- print screen:&:screen, lambda, 1/red + a:char <- copy 97/a + screen:&:screen <- print screen:&:screen, a, 7/white ] # screen-should-contain shows everything screen-should-contain [ @@ -83,10 +86,11 @@ scenario screen-in-scenario-color [ % Scenario_testing_scenario = true; % Hide_errors = true; scenario screen-in-scenario-error [ + local-scope assume-screen 5/width, 3/height run [ - 1:char <- copy 97/a - screen:&:screen <- print screen:&:screen, 1:char/a + a:char <- copy 97/a + screen:&:screen <- print screen:&:screen, a ] screen-should-contain [ # 01234 @@ -102,10 +106,11 @@ scenario screen-in-scenario-error [ % Hide_errors = true; # screen-should-contain can check unicode characters in the fake screen scenario screen-in-scenario-color [ + local-scope assume-screen 5/width, 3/height run [ - 1:char <- copy 97/a - screen:&:screen <- print screen:&:screen, 1:char/a, 1/red + a:char <- copy 97/a + screen:&:screen <- print screen:&:screen, a, 1/red ] screen-should-contain-in-color 2/green, [ # 01234 @@ -137,11 +142,6 @@ extern const int Max_variables_in_scenarios = Reserved_for_tests-100; int Next_predefined_global_for_scenarios = Max_variables_in_scenarios; :(before "End Setup") assert(Next_predefined_global_for_scenarios < Reserved_for_tests); -:(after "transform_all()" following "case RUN:") -// There's a restriction on the number of variables 'run' can use, so that -// it can avoid colliding with the dynamic allocator in case it doesn't -// initialize a default-space. -assert(Name[tmp_recipe.at(0)][""] < Max_variables_in_scenarios); :(before "End Globals") // Scenario Globals. diff --git a/083scenario_screen_test.mu b/083scenario_screen_test.mu index c10da8e6..a21a9fdf 100644 --- a/083scenario_screen_test.mu +++ b/083scenario_screen_test.mu @@ -1,9 +1,9 @@ # To check our support for screens in scenarios, rewrite tests from print.mu scenario print-character-at-top-left-2 [ + local-scope assume-screen 3/width, 2/height run [ - local-scope a:char <- copy 97/a screen:&:screen <- print screen:&:screen, a ] @@ -14,15 +14,14 @@ scenario print-character-at-top-left-2 [ ] scenario clear-line-erases-printed-characters-2 [ + local-scope assume-screen 5/width, 3/height + # print a character + a:char <- copy 97/a + screen:&:screen <- print screen:&:screen, a + # move cursor to start of line + screen:&:screen <- move-cursor screen:&:screen, 0/row, 0/column run [ - local-scope - # print a character - a:char <- copy 97/a - screen:&:screen <- print screen:&:screen, a - # move cursor to start of line - screen:&:screen <- move-cursor screen:&:screen, 0/row, 0/column - # clear line screen:&:screen <- clear-line screen:&:screen ] screen-should-contain [ diff --git a/edit/001-editor.mu b/edit/001-editor.mu index 0b5aaa4a..bbe16390 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -14,10 +14,10 @@ def! main text:text [ ] scenario editor-initially-prints-text-to-screen [ + local-scope assume-screen 10/width, 5/height run [ - 1:text <- new [abc] - new-editor 1:text, screen:&:screen, 0/left, 10/right + new-editor [abc], screen:&:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -95,10 +95,11 @@ def insert-text editor:&:editor, text:text -> editor:&:editor [ ] scenario editor-initializes-without-data [ + local-scope assume-screen 5/width, 3/height run [ - 1:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right - 2:editor <- copy *1:&:editor + e:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right + 2:editor/raw <- copy *e ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -255,11 +256,12 @@ def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen ] scenario editor-initially-prints-multiple-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -270,10 +272,11 @@ def] ] scenario editor-initially-handles-offsets [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc] - new-editor s:text, screen:&:screen, 1/left, 5/right + new-editor s, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -283,11 +286,12 @@ scenario editor-initially-handles-offsets [ ] scenario editor-initially-prints-multiple-lines-at-offset [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 1/left, 5/right + new-editor s, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -298,10 +302,11 @@ def] ] scenario editor-initially-wraps-long-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -318,10 +323,11 @@ scenario editor-initially-wraps-long-lines [ ] scenario editor-initially-wraps-barely-long-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abcde] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -340,12 +346,12 @@ scenario editor-initially-wraps-barely-long-lines [ ] scenario editor-initializes-empty-text [ + local-scope assume-screen 5/width, 5/height run [ - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + e:&:editor <- new-editor [], screen:&:screen, 0/left, 5/right + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -361,12 +367,13 @@ scenario editor-initializes-empty-text [ # just a little color for mu code scenario render-colors-comments [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc # de f] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -442,12 +449,13 @@ 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 d <- e f] - new-editor s:text, screen:&:screen, 0/left, 8/right + new-editor s, screen:&:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/edit/002-typing.mu b/edit/002-typing.mu index 68af65ee..07466d38 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -281,13 +281,13 @@ def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&: ] scenario editor-handles-empty-event-queue [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -298,18 +298,18 @@ scenario editor-handles-empty-event-queue [ ] scenario editor-handles-mouse-clicks [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -325,17 +325,17 @@ scenario editor-handles-mouse-clicks [ ] scenario editor-handles-mouse-clicks-outside-text [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # last line, to the right of text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -345,18 +345,19 @@ scenario editor-handles-mouse-clicks-outside-text [ ] scenario editor-handles-mouse-clicks-outside-text-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # interior line, to the right of text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -366,18 +367,19 @@ def] ] scenario editor-handles-mouse-clicks-outside-text-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -387,20 +389,20 @@ def] ] scenario editor-handles-mouse-clicks-outside-column [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] # editor occupies only left half of screen - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -416,19 +418,19 @@ scenario editor-handles-mouse-clicks-outside-column [ ] scenario editor-handles-mouse-clicks-in-menu-area [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -438,16 +440,16 @@ scenario editor-handles-mouse-clicks-in-menu-area [ ] scenario editor-inserts-characters-into-empty-editor [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -459,10 +461,10 @@ scenario editor-inserts-characters-into-empty-editor [ ] scenario editor-inserts-characters-at-cursor [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # type two letters at different places assume-console [ @@ -471,7 +473,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -483,17 +485,17 @@ scenario editor-inserts-characters-at-cursor [ ] scenario editor-inserts-characters-at-cursor-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -505,18 +507,19 @@ scenario editor-inserts-characters-at-cursor-2 [ ] scenario editor-inserts-characters-at-cursor-5 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -529,17 +532,17 @@ d] ] scenario editor-inserts-characters-at-cursor-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -551,18 +554,19 @@ scenario editor-inserts-characters-at-cursor-3 [ ] scenario editor-inserts-characters-at-cursor-4 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -575,18 +579,19 @@ d] ] scenario editor-inserts-characters-at-cursor-6 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -599,15 +604,15 @@ d] ] scenario editor-moves-cursor-after-inserting-characters [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ab] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [ab], screen:&:screen, 0/left, 5/right + editor-render screen, e assume-console [ type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -620,16 +625,16 @@ scenario editor-moves-cursor-after-inserting-characters [ # if the cursor reaches the right margin, wrap the line scenario editor-wraps-line-on-insert [ + local-scope assume-screen 5/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # no wrap yet screen-should-contain [ @@ -644,7 +649,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # now wrap screen-should-contain [ @@ -657,21 +662,22 @@ scenario editor-wraps-line-on-insert [ ] scenario editor-wraps-line-on-insert-2 [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abcdefg + s:text <- new [abcdefg defg] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -740,17 +746,17 @@ after <insert-character-special-case> [ ] scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -769,9 +775,9 @@ scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ local-scope assume-screen 10/width, 5/height # create an editor containing two lines - contents:text <- new [abc + s:text <- new [abc xyz] - 1:&:editor/raw <- new-editor contents, screen, 0/left, 5/right + e:&:editor <- new-editor s, screen, 0/left, 5/right screen-should-contain [ . . .abc . @@ -783,7 +789,7 @@ xyz] type [de] # trigger wrap ] run [ - editor-event-loop screen:&:screen, console:&:console, 1:&:editor/raw + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -795,17 +801,17 @@ xyz] ] scenario editor-wraps-cursor-to-left-margin [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 2/left, 7/right + e:&:editor <- new-editor [abcde], screen:&:screen, 2/left, 7/right assume-console [ left-click 1, 5 # line is full; no wrap icon yet type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -831,15 +837,15 @@ after <editor-initialization> [ ] scenario editor-moves-cursor-down-after-inserting-newline [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -855,14 +861,14 @@ after <handle-special-character> [ newline?:bool <- equal c, 10/newline break-unless newline? <insert-enter-begin> - editor <- insert-newline-and-indent editor, screen + editor <- insert-new-line-and-indent editor, screen <insert-enter-end> go-render? <- copy 1/true return } ] -def insert-newline-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ +def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ local-scope load-ingredients cursor-row:num <- get *editor, cursor-row:offset @@ -937,15 +943,15 @@ 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 - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -957,9 +963,9 @@ 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 - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right assume-console [ press enter ] @@ -971,7 +977,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # line should be fully cleared screen-should-contain [ @@ -984,11 +990,12 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ ] scenario editor-inserts-indent-after-newline [ + local-scope assume-screen 10/width, 10/height - 1:text <- new [ab + s:text <- new [ab cd ef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -996,9 +1003,9 @@ ef] ] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1008,11 +1015,12 @@ ef] ] scenario editor-skips-indent-around-paste [ + local-scope assume-screen 10/width, 10/height - 1:text <- new [ab + s:text <- new [ab cd ef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -1021,9 +1029,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index 70917808..2058aadd 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -5,16 +5,17 @@ # tab - insert two spaces scenario editor-inserts-two-spaces-on-tab [ + local-scope assume-screen 10/width, 5/height # just one character in final line - 1:text <- new [ab + s:text <- new [ab cd] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -39,19 +40,19 @@ after <handle-special-character> [ # backspace - delete character before cursor scenario editor-handles-backspace-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -216,19 +217,20 @@ def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> re ] scenario editor-clears-last-line-on-backspace [ + local-scope assume-screen 10/width, 5/height # just one character in final line - 1:text <- new [ab + s:text <- new [ab cd] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right assume-console [ left-click 2, 0 # cursor at only character in final line press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -243,12 +245,13 @@ cd] ] scenario editor-joins-and-wraps-lines-on-backspace [ + local-scope assume-screen 10/width, 5/height # initialize editor with two long-ish but non-wrapping lines - 1:text <- new [abc def + s:text <- new [abc def ghi jkl] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -256,7 +259,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # resulting single line should wrap correctly screen-should-contain [ @@ -269,11 +272,11 @@ ghi jkl] ] 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 - 1:text <- new [abc def ghij] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 8/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc def ghij], screen:&:screen, 0/left, 8/right + editor-render screen, e # confirm that it wraps screen-should-contain [ . . @@ -288,7 +291,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -303,16 +306,16 @@ scenario editor-wraps-long-lines-on-backspace [ # delete - delete character at cursor scenario editor-handles-delete-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -326,7 +329,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -392,17 +395,17 @@ def delete-at-cursor editor:&:editor, screen:&:screen -> editor:&:editor, screen # right arrow scenario editor-moves-cursor-right-with-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -489,11 +492,12 @@ def move-cursor-coordinates-right editor:&:editor, screen-height:num -> editor:& ] scenario editor-moves-cursor-to-next-line-with-right-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -503,7 +507,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -511,7 +515,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -524,11 +528,12 @@ d] ] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 1/left, 10/right + editor-render screen, e assume-console [ press right-arrow press right-arrow @@ -537,7 +542,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -549,19 +554,19 @@ d] ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -578,11 +583,11 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ + local-scope assume-screen 10/width, 5/height # line just barely wrapping - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -590,9 +595,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -603,9 +608,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -615,19 +620,19 @@ 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 - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 6/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 1/left, 6/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -644,11 +649,12 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ ] scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -657,7 +663,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # new character should be in next line screen-should-contain [ @@ -675,10 +681,10 @@ d] # left arrow scenario editor-moves-cursor-left-with-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 2 @@ -686,7 +692,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -717,12 +723,13 @@ after <handle-special-key> [ ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ + local-scope assume-screen 10/width, 5/height # initialize editor with two lines - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -730,9 +737,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -742,13 +749,14 @@ d] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ + local-scope assume-screen 10/width, 5/height # initialize editor with three lines - 1:text <- new [abc + s:text <- new [abc def g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s:text, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -758,7 +766,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -771,12 +779,13 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -785,7 +794,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # left-arrow should have had no effect screen-should-contain [ @@ -799,13 +808,14 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ + local-scope assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e:&:editor $clear-trace # position cursor right after empty line assume-console [ @@ -814,7 +824,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -827,11 +837,11 @@ d] ] 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 - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -846,9 +856,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -858,12 +868,13 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ ] scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a wrapping line followed by a second line - 1:text <- new [abcdef + s:text <- new [abcdef g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -878,9 +889,9 @@ g] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 # previous row @@ -890,12 +901,13 @@ g] ] scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a line on the verge of wrapping, followed by a second line - 1:text <- new [abcd + s:text <- new [abcd e] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -910,9 +922,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -926,20 +938,21 @@ e] # up arrow scenario editor-moves-to-previous-line-with-up-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -950,7 +963,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1042,20 +1055,21 @@ def move-to-previous-line editor:&:editor -> editor:&:editor, go-render?:bool [ ] scenario editor-adjusts-column-at-previous-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ab + s:text <- new [ab def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1066,7 +1080,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1078,20 +1092,21 @@ def] ] scenario editor-adjusts-column-at-empty-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ + s:text <- new [ def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1102,7 +1117,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1114,13 +1129,14 @@ def] ] scenario editor-moves-to-previous-line-from-left-margin [ + local-scope assume-screen 10/width, 5/height # start out with three lines - 1:text <- new [abc + s:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 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 assume-console [ @@ -1128,9 +1144,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1141,7 +1157,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1155,20 +1171,21 @@ ghi] # down arrow scenario editor-moves-to-next-line-with-down-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1180,7 +1197,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1260,20 +1277,21 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor, go- ] scenario editor-adjusts-column-at-next-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc de] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1284,7 +1302,7 @@ de] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1298,11 +1316,12 @@ de] # ctrl-a/home - move cursor to start of line scenario editor-moves-to-start-of-line-with-ctrl-a [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1310,9 +1329,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1373,11 +1392,12 @@ def move-to-start-of-line editor:&:editor -> editor:&:editor [ ] scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1385,9 +1405,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1398,10 +1418,11 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ ] scenario editor-moves-to-start-of-line-with-home [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1409,9 +1430,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1422,11 +1443,12 @@ scenario editor-moves-to-start-of-line-with-home [ ] scenario editor-moves-to-start-of-line-with-home-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1434,9 +1456,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1449,11 +1471,12 @@ scenario editor-moves-to-start-of-line-with-home-2 [ # ctrl-e/end - move cursor to end of line scenario editor-moves-to-end-of-line-with-ctrl-e [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1461,9 +1484,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1476,9 +1499,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1541,11 +1564,12 @@ def move-to-end-of-line editor:&:editor -> editor:&:editor [ ] scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1553,9 +1577,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1566,11 +1590,12 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ ] scenario editor-moves-to-end-of-line-with-end [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line, press 'end' assume-console [ @@ -1578,9 +1603,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1591,11 +1616,12 @@ scenario editor-moves-to-end-of-line-with-end [ ] scenario editor-moves-to-end-of-line-with-end-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1603,9 +1629,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1618,17 +1644,18 @@ scenario editor-moves-to-end-of-line-with-end-2 [ # ctrl-u - delete text from start of line until (but not at) cursor scenario editor-deletes-to-start-of-line-with-ctrl-u [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on second line, press ctrl-u assume-console [ left-click 2, 2 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1681,17 +1708,18 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor ] scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on first line (no newline before), press ctrl-u assume-console [ left-click 1, 2 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1704,17 +1732,18 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ ] scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of line, press ctrl-u assume-console [ left-click 1, 3 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1727,17 +1756,18 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ ] scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of final line, press ctrl-u assume-console [ left-click 2, 3 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1752,17 +1782,18 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ # ctrl-k - delete text from cursor to end of line (but not the newline) scenario editor-deletes-to-end-of-line-with-ctrl-k [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on first line, press ctrl-k assume-console [ left-click 1, 1 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to end of line screen-should-contain [ @@ -1807,17 +1838,18 @@ def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:& ] scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on second line (no newline after), press ctrl-k assume-console [ left-click 2, 1 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to end of line screen-should-contain [ @@ -1830,17 +1862,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes just last character screen-should-contain [ @@ -1853,17 +1886,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes nothing screen-should-contain [ @@ -1876,17 +1910,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes just the final character screen-should-contain [ @@ -1899,17 +1934,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes nothing screen-should-contain [ @@ -1924,14 +1960,15 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ # cursor-down can scroll if necessary scenario editor-can-scroll-down-using-arrow-keys [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:text <- new [a + s:text <- new [a b c d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -1944,7 +1981,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen slides by one line screen-should-contain [ @@ -2001,15 +2038,16 @@ def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:dup ] scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:text <- new [abcdef + s:text <- new [abcdef g h i] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2022,7 +2060,7 @@ i] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2034,21 +2072,22 @@ i] ] scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # editor starts with a long line wrapping twice - 1:text <- new [abcdefghij + s:text <- new [abcdefghij k l m] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # position cursor at last line, then try to move further down assume-console [ left-click 3, 0 press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line containing a wrap icon screen-should-contain [ @@ -2062,7 +2101,7 @@ m] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2074,22 +2113,23 @@ m] ] scenario editor-scrolls-down-when-line-wraps [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a long line in the third line - 1:text <- new [a + s:text <- new [a b cdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # position cursor at end, type a character assume-console [ left-click 3, 4 type [g] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2105,21 +2145,22 @@ cdef] ] scenario editor-scrolls-down-on-newline [ + local-scope assume-screen 5/width, 4/height # position cursor after last line and type newline - 1:text <- new [a + s:text <- new [a b c] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right assume-console [ left-click 3, 4 type [ ] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2135,22 +2176,23 @@ c] ] scenario editor-scrolls-down-on-right-arrow [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:text <- new [a + s:text <- new [a b cdefgh] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # position cursor at end of screen and try to move right assume-console [ left-click 3, 3 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2166,23 +2208,24 @@ cdefgh] ] scenario editor-scrolls-down-on-right-arrow-2 [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains more lines than can fit on screen - 1:text <- new [a + s:text <- new [a b c d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # position cursor at end of screen and try to move right assume-console [ left-click 3, 3 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2198,11 +2241,12 @@ d] ] scenario editor-scrolls-at-end-on-down-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc de] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # try to move down past end of text assume-console [ @@ -2210,9 +2254,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen should scroll, moving cursor to end of text memory-should-contain [ @@ -2223,7 +2267,7 @@ de] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2238,9 +2282,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen stops scrolling because cursor is already at top memory-should-contain [ @@ -2252,7 +2296,7 @@ de] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2263,17 +2307,18 @@ de] ] scenario editor-combines-page-and-line-scroll [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a few pages of lines - 1:text <- new [a + s:text <- new [a b c d e f g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # scroll down one page and one line assume-console [ press page-down @@ -2281,7 +2326,7 @@ g] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen scrolls down 3 lines screen-should-contain [ @@ -2295,14 +2340,15 @@ g] # cursor-up can scroll if necessary scenario editor-can-scroll-up-using-arrow-keys [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:text <- new [a + s:text <- new [a b c d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2315,7 +2361,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen slides by one line screen-should-contain [ @@ -2382,15 +2428,16 @@ def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex- ] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:text <- new [abcdef + s:text <- new [abcdef g h i] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2402,7 +2449,7 @@ i] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2415,7 +2462,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2427,20 +2474,21 @@ i] ] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [ + local-scope # screen has 1 line for menu + 4 lines assume-screen 10/width, 5/height # editor starts with a long line wrapping twice, occupying 3 of the 4 lines - 1:text <- new [abcdefghij + s:text <- new [abcdefghij k l m] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2454,7 +2502,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2469,7 +2517,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2484,7 +2532,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2499,15 +2547,16 @@ m] # same as editor-scrolls-up-past-wrapped-line-using-arrow-keys but length # slightly off, just to prevent over-training scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-3 [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:text <- new [abcdef + s:text <- new [abcdef g h i] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 6/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 6/right screen-should-contain [ . . .abcde↩ . @@ -2519,7 +2568,7 @@ i] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2532,7 +2581,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows partial wrapped line screen-should-contain [ @@ -2545,20 +2594,21 @@ i] # check empty lines scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ + local-scope assume-screen 10/width, 4/height # initialize editor with some lines around an empty line - 1:text <- new [a + s:text <- new [a b c d e] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 6/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 6/right assume-console [ press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2570,7 +2620,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2582,7 +2632,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2593,21 +2643,22 @@ e] ] scenario editor-scrolls-up-on-left-arrow [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains >3 lines - 1:text <- new [a + s:text <- new [a b c d e] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2620,9 +2671,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2638,14 +2689,15 @@ e] ] scenario editor-can-scroll-up-to-start-of-file [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:text <- new [a + s:text <- new [a b c d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2660,7 +2712,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen slides by one line screen-should-contain [ @@ -2674,7 +2726,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen remains unchanged screen-should-contain [ @@ -2688,12 +2740,13 @@ d] # ctrl-f/page-down - render next page if it exists scenario editor-can-scroll [ + local-scope assume-screen 10/width, 4/height - 1:text <- new [a + s:text <- new [a b c d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2705,7 +2758,7 @@ d] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows next page screen-should-contain [ @@ -2775,11 +2828,12 @@ def page-down editor:&:editor -> editor:&:editor [ ] scenario editor-does-not-scroll-past-end [ + local-scope assume-screen 10/width, 4/height - 1:text <- new [a + s:text <- new [a b] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e screen-should-contain [ . . .a . @@ -2791,7 +2845,7 @@ b] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen remains unmodified screen-should-contain [ @@ -2803,14 +2857,15 @@ b] ] scenario editor-starts-next-page-at-start-of-wrapped-line [ + local-scope # screen has 1 line for menu + 3 lines for text assume-screen 10/width, 4/height # editor contains a long last line - 1:text <- new [a + s:text <- new [a b cdefgh] # editor screen triggers wrap of last line - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 4/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2823,7 +2878,7 @@ cdefgh] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows entire wrapped line screen-should-contain [ @@ -2835,13 +2890,14 @@ cdefgh] ] scenario editor-starts-next-page-at-start-of-wrapped-line-2 [ + local-scope # screen has 1 line for menu + 3 lines for text assume-screen 10/width, 4/height # editor contains a very long line that occupies last two lines of screen # and still has something left over - 1:text <- new [a + s:text <- new [a bcdefgh] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 4/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2854,7 +2910,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows entire wrapped line screen-should-contain [ @@ -2868,12 +2924,13 @@ bcdefgh] # ctrl-b/page-up - render previous page if it exists scenario editor-can-scroll-up [ + local-scope assume-screen 10/width, 4/height - 1:text <- new [a + s:text <- new [a b c d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2885,7 +2942,7 @@ d] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows next page screen-should-contain [ @@ -2899,7 +2956,7 @@ d] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows original page again screen-should-contain [ @@ -2962,10 +3019,11 @@ def page-up editor:&:editor, screen-height:num -> editor:&:editor [ ] scenario editor-can-scroll-up-multiple-pages [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with 8 lines - 1:text <- new [a + s:text <- new [a b c d @@ -2973,7 +3031,7 @@ e f g h] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2986,7 +3044,7 @@ h] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows third page screen-should-contain [ @@ -3000,7 +3058,7 @@ h] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows second page screen-should-contain [ @@ -3014,7 +3072,7 @@ h] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows original page again screen-should-contain [ @@ -3026,10 +3084,11 @@ h] ] scenario editor-can-scroll-up-wrapped-lines [ + local-scope # screen has 1 line for menu + 5 lines for text assume-screen 10/width, 6/height # editor contains a long line in the first page - 1:text <- new [a + s:text <- new [a b cdefgh i @@ -3040,7 +3099,7 @@ m n o] # editor screen triggers wrap of last line - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 4/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -3057,7 +3116,7 @@ o] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows entire wrapped line screen-should-contain [ @@ -3073,7 +3132,7 @@ o] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen resets screen-should-contain [ @@ -3087,13 +3146,14 @@ o] ] scenario editor-can-scroll-up-wrapped-lines-2 [ + local-scope # screen has 1 line for menu + 3 lines for text assume-screen 10/width, 4/height # editor contains a very long line that occupies last two lines of screen # and still has something left over - 1:text <- new [a + s:text <- new [a bcdefgh] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 4/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -3106,7 +3166,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen shows entire wrapped line screen-should-contain [ @@ -3120,7 +3180,7 @@ bcdefgh] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # screen resets screen-should-contain [ @@ -3132,9 +3192,10 @@ bcdefgh] ] scenario editor-can-scroll-up-past-nonempty-lines [ + local-scope assume-screen 10/width, 4/height # text with empty line in second screen - 1:text <- new [axx + s:text <- new [axx bxx cxx dxx @@ -3143,7 +3204,7 @@ fxx gxx hxx ] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 4/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 4/right screen-should-contain [ . . .axx . @@ -3154,7 +3215,7 @@ hxx press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -3166,7 +3227,7 @@ hxx press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -3179,7 +3240,7 @@ hxx press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -3190,9 +3251,10 @@ hxx ] scenario editor-can-scroll-up-past-empty-lines [ + local-scope assume-screen 10/width, 4/height # text with empty line in second screen - 1:text <- new [axy + s:text <- new [axy bxy cxy @@ -3201,7 +3263,7 @@ exy fxy gxy ] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 4/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 4/right screen-should-contain [ . . .axy . @@ -3212,7 +3274,7 @@ gxy press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -3224,7 +3286,7 @@ gxy press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -3237,7 +3299,7 @@ gxy press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index c22dbeea..4c956b15 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -293,12 +293,11 @@ def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:nu scenario point-at-multiple-editors [ + local-scope trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize both halves of screen - 1:text <- new [abc] - 2:text <- new [def] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [abc], [def] # focus on both sides assume-console [ left-click 1, 1 @@ -306,11 +305,11 @@ scenario point-at-multiple-editors [ ] # check cursor column in each run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:&:editor <- get *3:&:environment, recipes:offset - 5:num <- get *4:&:editor, cursor-column:offset - 6:&:editor <- get *3:&:environment, current-sandbox:offset - 7:num <- get *6:&:editor, cursor-column:offset + event-loop screen:&:screen, console:&:console, env + recipes:&:editor <- get *env, recipes:offset + 5:num/raw <- get *recipes, cursor-column:offset + sandbox:&:editor <- get *env, current-sandbox:offset + 7:num/raw <- get *sandbox, cursor-column:offset ] memory-should-contain [ 5 <- 1 @@ -319,13 +318,12 @@ scenario point-at-multiple-editors [ ] scenario edit-multiple-editors [ + local-scope trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize both halves of screen - 1:text <- new [abc] - 2:text <- new [def] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [abc], [def] + render-all screen, env, render # type one letter in each of them assume-console [ left-click 1, 1 @@ -334,11 +332,11 @@ scenario edit-multiple-editors [ type [1] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:&:editor <- get *3:&:environment, recipes:offset - 5:num <- get *4:&:editor, cursor-column:offset - 6:&:editor <- get *3:&:environment, current-sandbox:offset - 7:num <- get *6:&:editor, cursor-column:offset + event-loop screen:&:screen, console:&:console, env + recipes:&:editor <- get *env, recipes:offset + 5:num/raw <- get *recipes, cursor-column:offset + sandbox:&:editor <- get *env, current-sandbox:offset + 7:num/raw <- get *sandbox, cursor-column:offset ] screen-should-contain [ . run (F4) . # this line has a different background, but we don't test that yet @@ -352,8 +350,8 @@ scenario edit-multiple-editors [ ] # show the cursor at the right window run [ - 8:char/cursor <- copy 9251/␣ - print screen:&:screen, 8:char/cursor + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] screen-should-contain [ . run (F4) . @@ -364,13 +362,12 @@ scenario edit-multiple-editors [ ] scenario multiple-editors-cover-only-their-own-areas [ + local-scope trace-until 100/app # trace too long assume-screen 60/width, 10/height run [ - 1:text <- new [abc] - 2:text <- new [def] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [abc], [def] + render-all screen, env, render ] # divider isn't messed up screen-should-contain [ @@ -383,18 +380,17 @@ scenario multiple-editors-cover-only-their-own-areas [ ] scenario editor-in-focus-keeps-cursor [ + local-scope trace-until 100/app # trace too long assume-screen 30/width, 5/height - 1:text <- new [abc] - 2:text <- new [def] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [abc], [def] + render-all screen, env, render # initialize programming environment and highlight cursor assume-console [] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # is cursor at the right place? screen-should-contain [ @@ -408,9 +404,9 @@ scenario editor-in-focus-keeps-cursor [ type [z] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # cursor should still be right screen-should-contain [ @@ -422,14 +418,14 @@ scenario editor-in-focus-keeps-cursor [ ] scenario backspace-in-sandbox-editor-joins-lines [ -#? trace-until 100/app # trace too long + local-scope + trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize sandbox side with two lines - 1:text <- new [] - 2:text <- new [abc + s:text <- new [abc def] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], s:text + render-all screen, env, render screen-should-contain [ . run (F4) . . ┊abc . @@ -443,9 +439,9 @@ def] press backspace ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # cursor moves to end of old line screen-should-contain [ diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 7962aa2a..661b6582 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -42,19 +42,18 @@ container sandbox [ ] scenario run-and-show-results [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe editor is empty - 1:text <- new [] # sandbox editor contains an instruction without storing outputs - 2:text <- new [divide-with-remainder 11, 3] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [divide-with-remainder 11, 3] # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints the results screen-should-contain [ @@ -104,9 +103,9 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] - # check that screen prints the results + # check that screen prints both sandboxes screen-should-contain [ . run (F4) . . ┊ . @@ -516,23 +515,23 @@ def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, ] scenario run-updates-results [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) - 1:text <- new [ + recipes:text <- new [ recipe foo [ local-scope z:num <- add 2, 2 reply z ]] # sandbox editor contains an instruction without storing outputs - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run the code in the editors assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -552,7 +551,7 @@ reply z press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen updates the result on the right screen-should-contain [ @@ -569,19 +568,18 @@ reply z ] scenario run-instruction-manages-screen-per-sandbox [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:text <- new [] # right editor contains an instruction - 2:text <- new [print-integer screen, 4] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [print-integer screen, 4] # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that it prints a little toy screen screen-should-contain [ @@ -621,20 +619,20 @@ def editor-contents editor:&:editor -> result:text [ ] scenario editor-provides-edited-contents [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:text <- editor-contents 2:&:editor - 4:@:char <- copy *3:text + editor-event-loop screen:&:screen, console:&:console, e + s:text <- editor-contents e + 1:@:char/raw <- copy *s ] memory-should-contain [ - 4:array:character <- [abdefc] + 1:array:character <- [abdefc] ] ] @@ -795,18 +793,17 @@ cd] # scrolling through sandboxes scenario scrolling-down-past-bottom-of-sandbox-editor [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize sandbox side - 1:text <- new [] - 2:text <- new [add 2, 2] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [add 2, 2] + render-all screen, env, render assume-console [ # create a sandbox press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -820,9 +817,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -838,9 +835,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor displays again, cursor is in editor screen-should-contain [ @@ -928,27 +925,27 @@ def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ ] scenario scrolling-down-on-recipe-side [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize sandbox side and create a sandbox - 1:text <- new [ + recipes:text <- new [ ] # create a sandbox - 2:text <- new [add 2, 2] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, recipes:text, [add 2, 2] + render-all screen, env, render assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env # hit 'down' in recipe editor assume-console [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # cursor moves down on recipe side screen-should-contain [ @@ -961,13 +958,12 @@ scenario scrolling-down-on-recipe-side [ ] scenario scrolling-through-multiple-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -976,9 +972,9 @@ scenario scrolling-through-multiple-sandboxes [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor screen-should-contain [ . run (F4) . . ┊␣ . @@ -996,9 +992,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -1018,7 +1014,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # just second sandbox displayed screen-should-contain [ @@ -1035,7 +1031,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change screen-should-contain [ @@ -1052,7 +1048,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # back to displaying both sandboxes without editor screen-should-contain [ @@ -1071,9 +1067,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -1093,9 +1089,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # no change screen-should-contain [ @@ -1113,20 +1109,19 @@ scenario scrolling-through-multiple-sandboxes [ ] scenario scrolling-manages-sandbox-index-correctly [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create a sandbox assume-console [ press ctrl-n type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -1142,7 +1137,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -1160,7 +1155,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -1178,7 +1173,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox diff --git a/edit/006-sandbox-copy.mu b/edit/006-sandbox-copy.mu index f5c9f4cc..a2425858 100644 --- a/edit/006-sandbox-copy.mu +++ b/edit/006-sandbox-copy.mu @@ -2,20 +2,20 @@ ## see code operate in multiple situations scenario copy-a-sandbox-to-editor [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -31,7 +31,7 @@ recipe foo [ left-click 3, 69 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # it copies into editor screen-should-contain [ @@ -49,7 +49,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -64,20 +64,20 @@ recipe foo [ ] scenario copy-a-sandbox-to-editor-2 [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -93,7 +93,7 @@ recipe foo [ left-click 3, 84 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # it copies into editor screen-should-contain [ @@ -111,7 +111,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -221,20 +221,20 @@ def within-range? x:num, low:num, high:num -> result:bool [ ] scenario copy-fails-if-sandbox-editor-not-empty [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -252,7 +252,7 @@ recipe foo [ left-click 3, 70 # click 'copy' button ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # copy doesn't happen screen-should-contain [ @@ -270,7 +270,7 @@ recipe foo [ type [1] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu index 1eb2c904..141c1528 100644 --- a/edit/007-sandbox-delete.mu +++ b/edit/007-sandbox-delete.mu @@ -1,11 +1,10 @@ ## deleting sandboxes scenario deleting-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [] # run a few commands assume-console [ left-click 1, 80 @@ -14,7 +13,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -35,7 +34,7 @@ scenario deleting-sandboxes [ left-click 7, 85 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -53,7 +52,7 @@ scenario deleting-sandboxes [ left-click 3, 99 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -148,13 +147,12 @@ def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ ] scenario deleting-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -164,7 +162,7 @@ scenario deleting-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -179,7 +177,7 @@ scenario deleting-sandbox-after-scroll [ left-click 6, 99 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -194,13 +192,12 @@ scenario deleting-sandbox-after-scroll [ ] scenario deleting-top-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -210,7 +207,7 @@ scenario deleting-top-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -225,7 +222,7 @@ scenario deleting-top-sandbox-after-scroll [ left-click 2, 99 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -240,13 +237,12 @@ scenario deleting-top-sandbox-after-scroll [ ] scenario deleting-final-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -257,7 +253,7 @@ scenario deleting-final-sandbox-after-scroll [ press page-down press page-down ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -272,7 +268,7 @@ scenario deleting-final-sandbox-after-scroll [ left-click 2, 99 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # implicitly scroll up to first sandbox screen-should-contain [ @@ -288,13 +284,12 @@ scenario deleting-final-sandbox-after-scroll [ ] scenario deleting-updates-sandbox-count [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -303,7 +298,7 @@ scenario deleting-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -323,7 +318,7 @@ scenario deleting-updates-sandbox-count [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # shouldn't go past last sandbox screen-should-contain [ diff --git a/edit/008-sandbox-edit.mu b/edit/008-sandbox-edit.mu index 034c1a37..5b2dfe9a 100644 --- a/edit/008-sandbox-edit.mu +++ b/edit/008-sandbox-edit.mu @@ -1,20 +1,20 @@ ## editing sandboxes after they've been created scenario clicking-on-a-sandbox-moves-it-to-editor [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 3, 55 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # it pops back into editor screen-should-contain [ @@ -47,7 +47,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -61,20 +61,20 @@ recipe foo [ ] scenario clicking-on-a-sandbox-moves-it-to-editor-2 [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -90,7 +90,7 @@ recipe foo [ left-click 3, 68 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # it pops back into editor screen-should-contain [ @@ -107,7 +107,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -174,18 +174,17 @@ def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button? ] scenario sandbox-with-print-can-be-edited [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:text <- new [] # right editor contains an instruction - 2:text <- new [print-integer screen, 4] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [print-integer screen, 4] # run the sandbox assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -206,7 +205,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 65 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -218,13 +217,12 @@ scenario sandbox-with-print-can-be-edited [ ] scenario editing-sandbox-after-scrolling-resets-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -235,7 +233,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ press page-down press page-down ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -250,7 +248,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ left-click 2, 55 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -266,13 +264,12 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ ] scenario editing-sandbox-updates-sandbox-count [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # initialize environment - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - render-all screen, 3:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [], [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -281,7 +278,7 @@ scenario editing-sandbox-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -300,7 +297,7 @@ scenario editing-sandbox-updates-sandbox-count [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change in contents screen-should-contain [ @@ -322,7 +319,7 @@ scenario editing-sandbox-updates-sandbox-count [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # screen should show just final sandbox with the right index (1) screen-should-contain [ diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu index 7b1f1f18..d5d67f57 100644 --- a/edit/009-sandbox-test.mu +++ b/edit/009-sandbox-test.mu @@ -1,20 +1,20 @@ ## clicking on sandbox results to 'fix' them and turn sandboxes into tests scenario sandbox-click-on-result-toggles-color-to-green [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes:text, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 5, 51 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -45,8 +45,8 @@ recipe foo [ ] # cursor should remain unmoved run [ - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] screen-should-contain [ . run (F4) . @@ -69,7 +69,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # result turns red screen-should-contain-in-color 1/red, [ diff --git a/edit/010-sandbox-trace.mu b/edit/010-sandbox-trace.mu index 195d0fd5..21a3aec2 100644 --- a/edit/010-sandbox-trace.mu +++ b/edit/010-sandbox-trace.mu @@ -1,20 +1,20 @@ ## clicking on the code typed into a sandbox toggles its trace scenario sandbox-click-on-code-toggles-app-trace [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ stash [abc] ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -29,9 +29,9 @@ recipe foo [ left-click 4, 51 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - 4:char/cursor-icon <- copy 9251/␣ - print screen:&:screen, 4:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -55,8 +55,8 @@ recipe foo [ left-click 4, 55 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment - print screen:&:screen, 4:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + print screen:&:screen, cursor ] # trace hidden again screen-should-contain [ @@ -71,21 +71,21 @@ recipe foo [ ] scenario sandbox-shows-app-trace-and-result [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # basic recipe - 1:text <- new [ + recipes:text <- new [ recipe foo [ stash [abc] reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -101,7 +101,7 @@ recipe foo [ left-click 4, 51 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # trace now printed above result screen-should-contain [ @@ -119,17 +119,16 @@ recipe foo [ ] scenario clicking-on-app-trace-does-nothing [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height - 1:text <- new [] + env:&:environment <- new-programming-environment screen:&:screen, [], [stash 123456789] # create and expand the trace - 2:text <- new [stash 123456789] assume-console [ press F4 left-click 4, 51 ] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . ┊ . @@ -143,7 +142,7 @@ scenario clicking-on-app-trace-does-nothing [ left-click 5, 57 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change; doesn't die screen-should-contain [ diff --git a/edit/011-errors.mu b/edit/011-errors.mu index 2764de7d..1483a1af 100644 --- a/edit/011-errors.mu +++ b/edit/011-errors.mu @@ -115,19 +115,19 @@ after <render-sandbox-trace-done> [ ] scenario run-shows-errors-in-get [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [ + recipes:text <- new [ recipe foo [ get 123:num, foo:offset ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found run (F4) . @@ -155,11 +155,10 @@ recipe foo [ ] scenario run-updates-status-with-first-erroneous-sandbox [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [] assume-console [ left-click 3, 80 # create invalid sandbox 1 @@ -170,7 +169,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # status line shows that error is in first sandbox screen-should-contain [ @@ -179,11 +178,10 @@ scenario run-updates-status-with-first-erroneous-sandbox [ ] scenario run-updates-status-with-first-erroneous-sandbox-2 [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [] assume-console [ left-click 3, 80 # create invalid sandbox 2 @@ -197,7 +195,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # status line shows that error is in second sandbox screen-should-contain [ @@ -206,16 +204,15 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ ] scenario run-hides-errors-from-past-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [] - 2:text <- new [get foo, x:offset] # invalid - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [], [get foo, x:offset] # invalid assume-console [ press F4 # generate error ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] assume-console [ left-click 3, 58 @@ -224,7 +221,7 @@ scenario run-hides-errors-from-past-sandboxes [ press F4 # update sandbox ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # error should disappear screen-should-contain [ @@ -240,21 +237,21 @@ scenario run-hides-errors-from-past-sandboxes [ ] scenario run-updates-errors-for-shape-shifting-recipes [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height # define a shape-shifting recipe with an error - 1:text <- new [recipe foo x:_elem -> z:_elem [ + recipes:text <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients y:&:num <- copy 0 z <- add x, y ]] - 2:text <- new [foo 2] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo 2] assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . errors found (0) run (F4) . .recipe foo x:_elem -> z:_elem [ ┊ . @@ -271,7 +268,7 @@ z <- add x, y press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # error should remain unchanged screen-should-contain [ @@ -288,20 +285,21 @@ z <- add x, y ] scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height # overload a well-known shape-shifting recipe - 1:text <- new [recipe length l:&:list:_elem -> n:num [ + recipes:text <- new [recipe length l:&:list:_elem -> n:num [ ]] # call code that uses other variants of it, but not it itself - 2:text <- new [x:&:list:num <- copy 0 + sandbox:text <- new [x:&:list:num <- copy 0 to-text x] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, sandbox # run it once assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env # no errors anywhere on screen (can't check anything else, since to-text will return an address) screen-should-contain-in-color 1/red, [ . . @@ -325,7 +323,7 @@ to-text x] press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # still no errors screen-should-contain-in-color 1/red, [ @@ -348,19 +346,19 @@ to-text x] ] scenario run-shows-missing-type-errors [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [ + recipes:text <- new [ recipe foo [ x <- copy 0 ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found run (F4) . @@ -373,20 +371,20 @@ recipe foo [ ] scenario run-shows-unbalanced-bracket-errors [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe is incomplete (unbalanced '[') - 1:text <- new [ + recipes:text <- new [ recipe foo \\[ x <- copy 0 ] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found run (F4) . @@ -401,21 +399,21 @@ recipe foo \\[ ] scenario run-shows-get-on-non-container-errors [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [ + recipes:text <- new [ recipe foo [ local-scope x:&:point <- new point:type get x:&:point, 1:offset ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found run (F4) . @@ -433,22 +431,22 @@ recipe foo [ ] scenario run-shows-non-literal-get-argument-errors [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:text <- new [ + recipes:text <- new [ recipe foo [ local-scope x:num <- copy 0 y:&:point <- new point:type get *y:&:point, x:num ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found run (F4) . @@ -467,20 +465,20 @@ recipe foo [ ] scenario run-shows-errors-everytime [ + local-scope trace-until 100/app # trace too long # try to run a file with an error assume-screen 100/width, 15/height - 1:text <- new [ + recipes:text <- new [ recipe foo [ local-scope x:num <- copy y:num ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . errors found run (F4) . . ┊foo . @@ -497,7 +495,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found run (F4) . @@ -513,19 +511,18 @@ recipe foo [ ] scenario run-instruction-and-print-errors [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height - # left editor is empty - 1:text <- new [] # right editor contains an illegal instruction - 2:text <- new [get 1234:num, foo:offset] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + sandbox:text <- new [get 1234:num, foo:offset] + env:&:environment <- new-programming-environment screen:&:screen, [], sandbox # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints error message in red screen-should-contain [ @@ -576,20 +573,19 @@ scenario run-instruction-and-print-errors [ ] scenario run-instruction-and-print-errors-only-once [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height - # left editor is empty - 1:text <- new [] # right editor contains an illegal instruction - 2:text <- new [get 1234:num, foo:offset] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + sandbox:text <- new [get 1234:num, foo:offset] + env:&:environment <- new-programming-environment screen:&:screen, [], sandbox # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints error message just once screen-should-contain [ @@ -607,23 +603,23 @@ scenario run-instruction-and-print-errors-only-once [ ] scenario sandbox-can-handle-infinite-loop [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:text <- new [recipe foo [ + recipes:text <- new [recipe foo [ { loop } ]] # right editor contains an instruction - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo] # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found (0) run (F4) . @@ -638,10 +634,11 @@ scenario sandbox-can-handle-infinite-loop [ ] scenario sandbox-with-errors-shows-trace [ + local-scope trace-until 100/app # trace too long assume-screen 100/width, 10/height # generate a stash and a error - 1:text <- new [recipe foo [ + recipes:text <- new [recipe foo [ local-scope a:num <- next-ingredient b:num <- next-ingredient @@ -649,13 +646,12 @@ stash [dividing by], b _, c:num <- divide-with-remainder a, b reply b ]] - 2:text <- new [foo 4, 0] - 3:&:environment <- new-programming-environment screen:&:screen, 1:text, 2:text + env:&:environment <- new-programming-environment screen:&:screen, recipes, [foo 4, 0] # run assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env # screen prints error message screen-should-contain [ . errors found (0) run (F4) . @@ -673,7 +669,7 @@ reply b left-click 4, 55 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # screen should expand trace screen-should-contain [ diff --git a/edit/012-editor-undo.mu b/edit/012-editor-undo.mu index 428d51ca..48179c63 100644 --- a/edit/012-editor-undo.mu +++ b/edit/012-editor-undo.mu @@ -99,21 +99,21 @@ after <handle-special-character> [ # undo typing scenario editor-can-undo-typing [ + local-scope # create an editor and type a character assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # character should be gone screen-should-contain [ @@ -127,7 +127,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -229,21 +229,21 @@ after <handle-undo> [ ] scenario editor-can-undo-typing-multiple [ + local-scope # create an editor and type multiple characters assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be gone screen-should-contain [ @@ -255,16 +255,16 @@ scenario editor-can-undo-typing-multiple [ ] scenario editor-can-undo-typing-multiple-2 [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [a] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right + editor-render screen, e # type some characters assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .012a . @@ -276,7 +276,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # back to original text screen-should-contain [ @@ -290,7 +290,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -301,17 +301,17 @@ scenario editor-can-undo-typing-multiple-2 [ ] scenario editor-can-undo-typing-enter [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [ abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [ abc], screen:&:screen, 0/left, 10/right + editor-render screen, e # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . abc . @@ -320,8 +320,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -331,10 +331,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -351,7 +351,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -364,16 +364,16 @@ scenario editor-can-undo-typing-enter [ # redo typing scenario editor-redo-typing [ + local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - 1:text <- new [a] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . @@ -385,7 +385,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be back screen-should-contain [ @@ -399,7 +399,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -428,16 +428,16 @@ after <handle-redo> [ ] scenario editor-redo-typing-empty [ + local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . . @@ -449,7 +449,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be back screen-should-contain [ @@ -463,7 +463,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -474,23 +474,24 @@ scenario editor-redo-typing-empty [ ] scenario editor-work-clears-redo-stack [ + local-scope # create an editor with some text, do some work, undo assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # do some more work assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .0abc . @@ -503,7 +504,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # nothing should happen screen-should-contain [ @@ -516,11 +517,11 @@ ghi] ] scenario editor-can-redo-typing-and-enter-and-tab [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -531,7 +532,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . ab cd . @@ -539,8 +540,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -550,11 +551,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # typing in second line deleted, but not indent - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -571,11 +572,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # indent and newline deleted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -591,11 +592,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # empty screen - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -611,11 +612,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -631,11 +632,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # newline and indent inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -652,11 +653,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # indent and newline deleted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -673,28 +674,29 @@ scenario editor-can-redo-typing-and-enter-and-tab [ # undo cursor movement and scroll scenario editor-can-undo-touch [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # click undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -704,7 +706,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -763,21 +765,22 @@ after <handle-undo> [ ] scenario editor-can-undo-scroll [ + local-scope # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:text <- new [a + contents:text <- new [a b cdefgh] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 5/right # position cursor at end of screen and try to move right assume-console [ left-click 3, 3 press right-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset # screen scrolls screen-should-contain [ . . @@ -794,11 +797,11 @@ cdefgh] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moved back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 3 @@ -815,7 +818,7 @@ cdefgh] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -826,29 +829,30 @@ cdefgh] ] scenario editor-can-undo-left-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -858,7 +862,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -870,21 +874,22 @@ ghi] ] scenario editor-can-undo-up-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -894,11 +899,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -908,7 +913,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -920,29 +925,30 @@ ghi] ] scenario editor-can-undo-down-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -952,7 +958,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -964,29 +970,28 @@ ghi] ] scenario editor-can-undo-ctrl-f [ + local-scope # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:text <- new [a + contents:text <- new [a b c d e f] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # scroll the page assume-console [ press ctrl-f ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # screen should again show page 1 screen-should-contain [ @@ -999,29 +1004,28 @@ f] ] scenario editor-can-undo-page-down [ + local-scope # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:text <- new [a + contents:text <- new [a b c d e f] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # scroll the page assume-console [ press page-down ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # screen should again show page 1 screen-should-contain [ @@ -1034,30 +1038,29 @@ f] ] scenario editor-can-undo-ctrl-b [ + local-scope # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:text <- new [a + contents:text <- new [a b c d e f] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # scroll the page down and up assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # screen should again show page 2 screen-should-contain [ @@ -1070,30 +1073,29 @@ f] ] scenario editor-can-undo-page-up [ + local-scope # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:text <- new [a + contents:text <- new [a b c d e f] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # scroll the page down and up assume-console [ press page-down press page-up ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # screen should again show page 2 screen-should-contain [ @@ -1106,29 +1108,30 @@ f] ] scenario editor-can-undo-ctrl-a [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1138,7 +1141,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1150,29 +1153,30 @@ ghi] ] scenario editor-can-undo-home [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1182,7 +1186,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1194,29 +1198,30 @@ ghi] ] scenario editor-can-undo-ctrl-e [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1226,7 +1231,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1238,29 +1243,30 @@ ghi] ] scenario editor-can-undo-end [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1270,7 +1276,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1282,13 +1288,14 @@ ghi] ] scenario editor-can-undo-multiple-arrows-in-the-same-direction [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 2, 1 @@ -1296,9 +1303,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1308,11 +1315,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # up-arrow is undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 3 @@ -1322,11 +1329,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # both right-arrows are undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1336,28 +1343,29 @@ ghi] # redo cursor movement and scroll scenario editor-redo-touch [ + local-scope # create an editor with some text, click on a character, undo assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves to left-click + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -1367,7 +1375,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1393,19 +1401,19 @@ after <handle-redo> [ ] 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 - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1421,9 +1429,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1441,9 +1449,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1461,9 +1469,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1481,9 +1489,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # first insert screen-should-contain [ @@ -1501,9 +1509,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1522,9 +1530,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # second insert screen-should-contain [ @@ -1542,26 +1550,26 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ # undo backspace scenario editor-can-undo-and-redo-backspace [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1571,10 +1579,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1590,10 +1598,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1687,11 +1695,11 @@ after <handle-redo> [ # undo delete scenario editor-can-undo-and-redo-delete [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1701,15 +1709,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1719,10 +1727,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1738,10 +1746,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1757,10 +1765,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1776,11 +1784,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1796,11 +1804,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1816,11 +1824,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1876,18 +1884,19 @@ before <delete-character-end> [ # undo ctrl-k scenario editor-can-undo-and-redo-ctrl-k [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 1 press ctrl-k ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . @@ -1895,8 +1904,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1906,7 +1915,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1915,8 +1924,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1926,7 +1935,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted screen-should-contain [ @@ -1936,8 +1945,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1947,7 +1956,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1978,18 +1987,19 @@ before <delete-to-end-of-line-end> [ # undo ctrl-u scenario editor-can-undo-and-redo-ctrl-u [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 2 press ctrl-u ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .c . @@ -1997,8 +2007,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2008,7 +2018,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2017,8 +2027,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -2028,7 +2038,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted screen-should-contain [ @@ -2038,8 +2048,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2049,7 +2059,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -2079,18 +2089,18 @@ before <delete-to-start-of-line-end> [ ] scenario editor-can-undo-and-redo-ctrl-u-2 [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ type [abc] press ctrl-u press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .abc . diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 0b5aaa4a..bbe16390 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -14,10 +14,10 @@ def! main text:text [ ] scenario editor-initially-prints-text-to-screen [ + local-scope assume-screen 10/width, 5/height run [ - 1:text <- new [abc] - new-editor 1:text, screen:&:screen, 0/left, 10/right + new-editor [abc], screen:&:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -95,10 +95,11 @@ def insert-text editor:&:editor, text:text -> editor:&:editor [ ] scenario editor-initializes-without-data [ + local-scope assume-screen 5/width, 3/height run [ - 1:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right - 2:editor <- copy *1:&:editor + e:&:editor <- new-editor 0/data, screen:&:screen, 2/left, 5/right + 2:editor/raw <- copy *e ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -255,11 +256,12 @@ def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen ] scenario editor-initially-prints-multiple-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -270,10 +272,11 @@ def] ] scenario editor-initially-handles-offsets [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc] - new-editor s:text, screen:&:screen, 1/left, 5/right + new-editor s, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -283,11 +286,12 @@ scenario editor-initially-handles-offsets [ ] scenario editor-initially-prints-multiple-lines-at-offset [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 1/left, 5/right + new-editor s, screen:&:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -298,10 +302,11 @@ def] ] scenario editor-initially-wraps-long-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc def] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -318,10 +323,11 @@ scenario editor-initially-wraps-long-lines [ ] scenario editor-initially-wraps-barely-long-lines [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abcde] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -340,12 +346,12 @@ scenario editor-initially-wraps-barely-long-lines [ ] scenario editor-initializes-empty-text [ + local-scope assume-screen 5/width, 5/height run [ - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + e:&:editor <- new-editor [], screen:&:screen, 0/left, 5/right + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -361,12 +367,13 @@ scenario editor-initializes-empty-text [ # just a little color for mu code scenario render-colors-comments [ + local-scope assume-screen 5/width, 5/height run [ s:text <- new [abc # de f] - new-editor s:text, screen:&:screen, 0/left, 5/right + new-editor s, screen:&:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -442,12 +449,13 @@ 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 d <- e f] - new-editor s:text, screen:&:screen, 0/left, 8/right + new-editor s, screen:&:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 92ebb654..07466d38 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -281,13 +281,13 @@ def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&: ] scenario editor-handles-empty-event-queue [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -298,18 +298,18 @@ scenario editor-handles-empty-event-queue [ ] scenario editor-handles-mouse-clicks [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -325,17 +325,17 @@ scenario editor-handles-mouse-clicks [ ] scenario editor-handles-mouse-clicks-outside-text [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # last line, to the right of text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -345,18 +345,19 @@ scenario editor-handles-mouse-clicks-outside-text [ ] scenario editor-handles-mouse-clicks-outside-text-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 1, 7 # interior line, to the right of text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -366,18 +367,19 @@ def] ] scenario editor-handles-mouse-clicks-outside-text-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -387,20 +389,20 @@ def] ] scenario editor-handles-mouse-clicks-outside-column [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] # editor occupies only left half of screen - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -416,19 +418,19 @@ scenario editor-handles-mouse-clicks-outside-column [ ] scenario editor-handles-mouse-clicks-in-menu-area [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -438,16 +440,16 @@ scenario editor-handles-mouse-clicks-in-menu-area [ ] scenario editor-inserts-characters-into-empty-editor [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -459,10 +461,10 @@ scenario editor-inserts-characters-into-empty-editor [ ] scenario editor-inserts-characters-at-cursor [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # type two letters at different places assume-console [ @@ -471,7 +473,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -483,17 +485,17 @@ scenario editor-inserts-characters-at-cursor [ ] scenario editor-inserts-characters-at-cursor-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -505,18 +507,19 @@ scenario editor-inserts-characters-at-cursor-2 [ ] scenario editor-inserts-characters-at-cursor-5 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -529,17 +532,17 @@ d] ] scenario editor-inserts-characters-at-cursor-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -551,18 +554,19 @@ scenario editor-inserts-characters-at-cursor-3 [ ] scenario editor-inserts-characters-at-cursor-4 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -575,18 +579,19 @@ d] ] scenario editor-inserts-characters-at-cursor-6 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -599,15 +604,15 @@ d] ] scenario editor-moves-cursor-after-inserting-characters [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ab] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [ab], screen:&:screen, 0/left, 5/right + editor-render screen, e assume-console [ type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -620,16 +625,16 @@ scenario editor-moves-cursor-after-inserting-characters [ # if the cursor reaches the right margin, wrap the line scenario editor-wraps-line-on-insert [ + local-scope assume-screen 5/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 5/right + editor-render screen, e # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # no wrap yet screen-should-contain [ @@ -644,7 +649,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # now wrap screen-should-contain [ @@ -657,21 +662,22 @@ scenario editor-wraps-line-on-insert [ ] scenario editor-wraps-line-on-insert-2 [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abcdefg + s:text <- new [abcdefg defg] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -732,6 +738,7 @@ after <insert-character-special-case> [ { below-screen?:bool <- greater-or-equal cursor-row, screen-height break-unless below-screen? + <scroll-down> } go-render? <- copy 1/true return @@ -739,17 +746,17 @@ after <insert-character-special-case> [ ] scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -768,9 +775,9 @@ scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ local-scope assume-screen 10/width, 5/height # create an editor containing two lines - contents:text <- new [abc + s:text <- new [abc xyz] - 1:&:editor/raw <- new-editor contents, screen, 0/left, 5/right + e:&:editor <- new-editor s, screen, 0/left, 5/right screen-should-contain [ . . .abc . @@ -782,7 +789,7 @@ xyz] type [de] # trigger wrap ] run [ - editor-event-loop screen:&:screen, console:&:console, 1:&:editor/raw + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -794,17 +801,17 @@ xyz] ] scenario editor-wraps-cursor-to-left-margin [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 2/left, 7/right + e:&:editor <- new-editor [abcde], screen:&:screen, 2/left, 7/right assume-console [ left-click 1, 5 # line is full; no wrap icon yet type [01] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -830,15 +837,15 @@ after <editor-initialization> [ ] scenario editor-moves-cursor-down-after-inserting-newline [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -854,14 +861,14 @@ after <handle-special-character> [ newline?:bool <- equal c, 10/newline break-unless newline? <insert-enter-begin> - editor <- insert-newline-and-indent editor, screen + editor <- insert-new-line-and-indent editor, screen <insert-enter-end> go-render? <- copy 1/true return } ] -def insert-newline-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ +def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen, go-render?:bool [ local-scope load-ingredients cursor-row:num <- get *editor, cursor-row:offset @@ -882,6 +889,7 @@ def insert-newline-and-indent editor:&:editor, screen:&:screen -> editor:&:edito { below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal, never greater break-unless below-screen? + <scroll-down> go-render? <- copy 1/true cursor-row <- subtract cursor-row, 1 # bring back into screen range *editor <- put *editor, cursor-row:offset, cursor-row @@ -935,15 +943,15 @@ 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 - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -955,9 +963,9 @@ 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 - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right assume-console [ press enter ] @@ -969,7 +977,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # line should be fully cleared screen-should-contain [ @@ -982,11 +990,12 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ ] scenario editor-inserts-indent-after-newline [ + local-scope assume-screen 10/width, 10/height - 1:text <- new [ab + s:text <- new [ab cd ef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -994,9 +1003,9 @@ ef] ] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1006,11 +1015,12 @@ ef] ] scenario editor-skips-indent-around-paste [ + local-scope assume-screen 10/width, 10/height - 1:text <- new [ab + s:text <- new [ab cd ef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -1019,9 +1029,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index d4f124ae..3c0f36d5 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -5,16 +5,17 @@ # tab - insert two spaces scenario editor-inserts-two-spaces-on-tab [ + local-scope assume-screen 10/width, 5/height # just one character in final line - 1:text <- new [ab + s:text <- new [ab cd] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -39,19 +40,19 @@ after <handle-special-character> [ # backspace - delete character before cursor scenario editor-handles-backspace-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -210,19 +211,20 @@ def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> re ] scenario editor-clears-last-line-on-backspace [ + local-scope assume-screen 10/width, 5/height # just one character in final line - 1:text <- new [ab + s:text <- new [ab cd] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right assume-console [ left-click 2, 0 # cursor at only character in final line press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -237,12 +239,13 @@ cd] ] scenario editor-joins-and-wraps-lines-on-backspace [ + local-scope assume-screen 10/width, 5/height # initialize editor with two long-ish but non-wrapping lines - 1:text <- new [abc def + s:text <- new [abc def ghi jkl] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -250,7 +253,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # resulting single line should wrap correctly screen-should-contain [ @@ -263,11 +266,11 @@ ghi jkl] ] 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 - 1:text <- new [abc def ghij] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 8/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc def ghij], screen:&:screen, 0/left, 8/right + editor-render screen, e # confirm that it wraps screen-should-contain [ . . @@ -282,7 +285,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -297,16 +300,16 @@ scenario editor-wraps-long-lines-on-backspace [ # delete - delete character at cursor scenario editor-handles-delete-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -320,7 +323,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -386,17 +389,17 @@ def delete-at-cursor editor:&:editor, screen:&:screen -> editor:&:editor, screen # right arrow scenario editor-moves-cursor-right-with-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -481,11 +484,12 @@ def move-cursor-coordinates-right editor:&:editor, screen-height:num -> editor:& ] scenario editor-moves-cursor-to-next-line-with-right-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -495,7 +499,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -503,7 +507,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -516,11 +520,12 @@ d] ] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 1/left, 10/right + editor-render screen, e assume-console [ press right-arrow press right-arrow @@ -529,7 +534,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -541,19 +546,19 @@ d] ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -570,11 +575,11 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ ] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ + local-scope assume-screen 10/width, 5/height # line just barely wrapping - 1:text <- new [abcde] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcde], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -582,9 +587,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -595,9 +600,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -607,19 +612,19 @@ 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 - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 1/left, 6/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 1/left, 6/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] screen-should-contain [ . . @@ -636,11 +641,12 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ ] scenario editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -649,7 +655,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # new character should be in next line screen-should-contain [ @@ -667,10 +673,10 @@ d] # left arrow scenario editor-moves-cursor-left-with-key [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 2 @@ -678,7 +684,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -709,12 +715,13 @@ after <handle-special-key> [ ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ + local-scope assume-screen 10/width, 5/height # initialize editor with two lines - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -722,9 +729,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -734,13 +741,14 @@ d] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ + local-scope assume-screen 10/width, 5/height # initialize editor with three lines - 1:text <- new [abc + s:text <- new [abc def g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s:text, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -750,7 +758,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -763,12 +771,13 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -777,7 +786,7 @@ g] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # left-arrow should have had no effect screen-should-contain [ @@ -791,13 +800,14 @@ g] ] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ + local-scope assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:text <- new [abc + s:text <- new [abc d] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e:&:editor $clear-trace # position cursor right after empty line assume-console [ @@ -806,7 +816,7 @@ d] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -819,11 +829,11 @@ d] ] 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 - 1:text <- new [abcdef] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [abcdef], screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -838,9 +848,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -850,12 +860,13 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ ] scenario editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a wrapping line followed by a second line - 1:text <- new [abcdef + s:text <- new [abcdef g] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -870,9 +881,9 @@ g] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 # previous row @@ -882,12 +893,13 @@ g] ] scenario editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ + local-scope assume-screen 10/width, 5/height # initialize editor with a line on the verge of wrapping, followed by a second line - 1:text <- new [abcd + s:text <- new [abcd e] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 5/right + editor-render screen, e $clear-trace screen-should-contain [ . . @@ -902,9 +914,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -918,20 +930,21 @@ e] # up arrow scenario editor-moves-to-previous-line-with-up-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -942,7 +955,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1033,20 +1046,21 @@ def move-to-previous-line editor:&:editor -> editor:&:editor, go-render?:bool [ ] scenario editor-adjusts-column-at-previous-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ab + s:text <- new [ab def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1057,7 +1071,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1069,20 +1083,21 @@ def] ] scenario editor-adjusts-column-at-empty-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [ + s:text <- new [ def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1093,7 +1108,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1105,13 +1120,14 @@ def] ] scenario editor-moves-to-previous-line-from-left-margin [ + local-scope assume-screen 10/width, 5/height # start out with three lines - 1:text <- new [abc + s:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 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 assume-console [ @@ -1119,9 +1135,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1132,7 +1148,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1146,20 +1162,21 @@ ghi] # down arrow scenario editor-moves-to-next-line-with-down-arrow [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1171,7 +1188,7 @@ def] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1237,20 +1254,21 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [ ] scenario editor-adjusts-column-at-next-line [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc + s:text <- new [abc de] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1261,7 +1279,7 @@ de] type [0] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1275,11 +1293,12 @@ de] # ctrl-a/home - move cursor to start of line scenario editor-moves-to-start-of-line-with-ctrl-a [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1287,9 +1306,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1350,11 +1369,12 @@ def move-to-start-of-line editor:&:editor -> editor:&:editor [ ] scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1362,9 +1382,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1375,10 +1395,11 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ ] scenario editor-moves-to-start-of-line-with-home [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1386,9 +1407,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1399,11 +1420,12 @@ scenario editor-moves-to-start-of-line-with-home [ ] scenario editor-moves-to-start-of-line-with-home-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1411,9 +1433,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1426,11 +1448,12 @@ scenario editor-moves-to-start-of-line-with-home-2 [ # ctrl-e/end - move cursor to end of line scenario editor-moves-to-end-of-line-with-ctrl-e [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1438,9 +1461,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1453,9 +1476,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1518,11 +1541,12 @@ def move-to-end-of-line editor:&:editor -> editor:&:editor [ ] scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1530,9 +1554,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 4:num <- get *2:&:editor, cursor-row:offset - 5:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 4:num/raw <- get *e, cursor-row:offset + 5:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1543,11 +1567,12 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ ] scenario editor-moves-to-end-of-line-with-end [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on first line, press 'end' assume-console [ @@ -1555,9 +1580,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1568,11 +1593,12 @@ scenario editor-moves-to-end-of-line-with-end [ ] scenario editor-moves-to-end-of-line-with-end-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right + editor-render screen, e $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1580,9 +1606,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1595,17 +1621,18 @@ scenario editor-moves-to-end-of-line-with-end-2 [ # ctrl-u - delete text from start of line until (but not at) cursor scenario editor-deletes-to-start-of-line-with-ctrl-u [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on second line, press ctrl-u assume-console [ left-click 2, 2 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1658,17 +1685,18 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor ] scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on first line (no newline before), press ctrl-u assume-console [ left-click 1, 2 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1681,17 +1709,18 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ ] scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of line, press ctrl-u assume-console [ left-click 1, 3 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1704,17 +1733,18 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ ] scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of final line, press ctrl-u assume-console [ left-click 2, 3 press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to start of line screen-should-contain [ @@ -1729,17 +1759,18 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ # ctrl-k - delete text from cursor to end of line (but not the newline) scenario editor-deletes-to-end-of-line-with-ctrl-k [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on first line, press ctrl-k assume-console [ left-click 1, 1 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to end of line screen-should-contain [ @@ -1784,17 +1815,18 @@ def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:& ] scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start on second line (no newline after), press ctrl-k assume-console [ left-click 2, 1 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes to end of line screen-should-contain [ @@ -1807,17 +1839,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes just last character screen-should-contain [ @@ -1830,17 +1863,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes nothing screen-should-contain [ @@ -1853,17 +1887,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes just the final character screen-should-contain [ @@ -1876,17 +1911,18 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ ] scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [123 + s:text <- new [123 456] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor s, screen:&:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # cursor deletes nothing screen-should-contain [ diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 4d6e2bdc..c83e9f9c 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -29,17 +29,17 @@ container sandbox [ ] scenario run-and-show-results [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 15/height # sandbox editor contains an instruction without storing outputs - 1:text <- new [divide-with-remainder 11, 3] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [divide-with-remainder 11, 3] # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints the results screen-should-contain [ @@ -82,7 +82,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints both sandboxes screen-should-contain [ @@ -501,23 +501,23 @@ def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, ] scenario run-updates-results [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 12/height # define a recipe (no indent for the 'add' line below so column numbers are more obvious) - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope z:num <- add 2, 2 -return z +reply z ]] # sandbox editor contains an instruction without storing outputs - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] # run the code in the editors assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . run (F4) . . . @@ -529,7 +529,7 @@ return z . . ] # make a change (incrementing one of the args to 'add'), then rerun - 1:text <- new [ + recipes:text <- new [ def foo [ local-scope z:num <- add 2, 3 @@ -539,7 +539,7 @@ return z press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # check that screen updates the result on the right screen-should-contain [ @@ -555,17 +555,17 @@ return z ] scenario run-instruction-manages-screen-per-sandbox [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # editor contains an instruction - 1:text <- new [print-integer screen, 4] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [print-integer screen, 4] # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that it prints a little toy screen screen-should-contain [ @@ -605,37 +605,37 @@ def editor-contents editor:&:editor -> result:text [ ] scenario editor-provides-edited-contents [ + local-scope assume-screen 10/width, 5/height - 1:text <- new [abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right + e:&:editor <- new-editor [abc], screen:&:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:text <- editor-contents 2:&:editor - 4:@:char <- copy *3:text + editor-event-loop screen:&:screen, console:&:console, e + s:text <- editor-contents e + 1:@:char/raw <- copy *s ] memory-should-contain [ - 4:array:character <- [abdefc] + 1:array:character <- [abdefc] ] ] # scrolling through sandboxes scenario scrolling-down-past-bottom-of-sandbox-editor [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize - 1:text <- new [add 2, 2] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [add 2, 2] + render-all screen, env, render assume-console [ # create a sandbox press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -651,9 +651,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -671,9 +671,9 @@ scenario scrolling-down-past-bottom-of-sandbox-editor [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor displays again screen-should-contain [ @@ -761,12 +761,12 @@ def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ ] scenario scrolling-through-multiple-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -775,9 +775,9 @@ scenario scrolling-through-multiple-sandboxes [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor screen-should-contain [ . run (F4) . .␣ . @@ -797,9 +797,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -821,7 +821,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # just second sandbox displayed screen-should-contain [ @@ -838,7 +838,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change screen-should-contain [ @@ -855,7 +855,7 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # back to displaying both sandboxes without editor screen-should-contain [ @@ -876,9 +876,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -900,9 +900,9 @@ scenario scrolling-through-multiple-sandboxes [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 3:char/cursor <- copy 9251/␣ - print screen:&:screen, 3:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # no change screen-should-contain [ @@ -922,19 +922,19 @@ scenario scrolling-through-multiple-sandboxes [ ] scenario scrolling-manages-sandbox-index-correctly [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create a sandbox assume-console [ press ctrl-n type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -950,7 +950,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox @@ -968,7 +968,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-up ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # back to displaying both sandboxes as well as editor screen-should-contain [ @@ -986,7 +986,7 @@ scenario scrolling-manages-sandbox-index-correctly [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # sandbox editor hidden; first sandbox displayed # cursor moves to first sandbox diff --git a/sandbox/006-sandbox-copy.mu b/sandbox/006-sandbox-copy.mu index c6472841..ea7d86ab 100644 --- a/sandbox/006-sandbox-copy.mu +++ b/sandbox/006-sandbox-copy.mu @@ -2,14 +2,14 @@ ## see code operate in multiple situations scenario copy-a-sandbox-to-editor [ + local-scope trace-until 50/app # trace too long assume-screen 50/width, 10/height - 1:text <- new [add 1, 1] + env:&:environment <- new-programming-environment screen:&:screen, [add 1, 1] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -27,7 +27,7 @@ scenario copy-a-sandbox-to-editor [ left-click 3, 19 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # it copies into editor screen-should-contain [ @@ -47,7 +47,7 @@ scenario copy-a-sandbox-to-editor [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -64,14 +64,14 @@ scenario copy-a-sandbox-to-editor [ ] scenario copy-a-sandbox-to-editor-2 [ + local-scope trace-until 50/app # trace too long assume-screen 50/width, 10/height - 1:text <- new [add 1, 1] + env:&:environment <- new-programming-environment screen:&:screen, [add 1, 1] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -89,7 +89,7 @@ scenario copy-a-sandbox-to-editor-2 [ left-click 3, 33 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # it copies into editor screen-should-contain [ @@ -109,7 +109,7 @@ scenario copy-a-sandbox-to-editor-2 [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -215,14 +215,14 @@ def within-range? x:num, low:num, high:num -> result:bool [ ] scenario copy-fails-if-sandbox-editor-not-empty [ + local-scope trace-until 50/app # trace too long assume-screen 50/width, 10/height - 1:text <- new [add 1, 1] + env:&:environment <- new-programming-environment screen:&:screen, [add 1, 1] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -240,7 +240,7 @@ scenario copy-fails-if-sandbox-editor-not-empty [ left-click 3, 20 # click 'copy' button ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # copy doesn't happen screen-should-contain [ @@ -258,7 +258,7 @@ scenario copy-fails-if-sandbox-editor-not-empty [ type [1] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index 03dcb4ec..59fa2c6b 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -1,10 +1,10 @@ ## deleting sandboxes scenario deleting-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [] # run a few commands assume-console [ type [divide-with-remainder 11, 3] @@ -12,7 +12,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -33,7 +33,7 @@ scenario deleting-sandboxes [ left-click 7, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -50,7 +50,7 @@ scenario deleting-sandboxes [ left-click 3, 49 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -144,12 +144,12 @@ def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ ] scenario deleting-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -159,7 +159,7 @@ scenario deleting-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -177,7 +177,7 @@ scenario deleting-sandbox-after-scroll [ left-click 6, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -192,12 +192,12 @@ scenario deleting-sandbox-after-scroll [ ] scenario deleting-top-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -207,7 +207,7 @@ scenario deleting-top-sandbox-after-scroll [ press F4 press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -225,7 +225,7 @@ scenario deleting-top-sandbox-after-scroll [ left-click 2, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -240,12 +240,12 @@ scenario deleting-top-sandbox-after-scroll [ ] scenario deleting-final-sandbox-after-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -256,7 +256,7 @@ scenario deleting-final-sandbox-after-scroll [ press page-down press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -271,7 +271,7 @@ scenario deleting-final-sandbox-after-scroll [ left-click 2, 34 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # implicitly scroll up to first sandbox screen-should-contain [ @@ -287,12 +287,12 @@ scenario deleting-final-sandbox-after-scroll [ ] scenario deleting-updates-sandbox-count [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes assume-console [ press ctrl-n @@ -301,7 +301,7 @@ scenario deleting-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -321,7 +321,7 @@ scenario deleting-updates-sandbox-count [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # shouldn't go past last sandbox screen-should-contain [ diff --git a/sandbox/008-sandbox-edit.mu b/sandbox/008-sandbox-edit.mu index 515daa1b..7cf1ad53 100644 --- a/sandbox/008-sandbox-edit.mu +++ b/sandbox/008-sandbox-edit.mu @@ -1,15 +1,15 @@ ## editing sandboxes after they've been created scenario clicking-on-a-sandbox-moves-it-to-editor [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # run something - 1:text <- new [add 2, 2] + env:&:environment <- new-programming-environment screen:&:screen, [add 2, 2] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -25,7 +25,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ left-click 3, 4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # it pops back into editor screen-should-contain [ @@ -39,7 +39,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ type [0] ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -101,16 +101,16 @@ def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button? ] scenario sandbox-with-print-can-be-edited [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # run a print instruction - 1:text <- new [print-integer screen, 4] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [print-integer screen, 4] # run the sandbox assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -131,7 +131,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 18 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . run (F4) . @@ -143,12 +143,12 @@ scenario sandbox-with-print-can-be-edited [ ] scenario editing-sandbox-after-scrolling-resets-scroll [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -159,7 +159,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ press page-down press page-down ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -174,7 +174,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ left-click 2, 10 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # second sandbox shows in editor; scroll resets to display first sandbox screen-should-contain [ @@ -190,12 +190,12 @@ scenario editing-sandbox-after-scrolling-resets-scroll [ ] scenario editing-sandbox-updates-sandbox-count [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # initialize environment - 1:text <- new [] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - render-all screen, 2:&:environment, render + env:&:environment <- new-programming-environment screen:&:screen, [] + render-all screen, env, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -204,7 +204,7 @@ scenario editing-sandbox-updates-sandbox-count [ type [add 1, 1] press F4 ] - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -221,7 +221,7 @@ scenario editing-sandbox-updates-sandbox-count [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change in contents screen-should-contain [ @@ -241,7 +241,7 @@ scenario editing-sandbox-updates-sandbox-count [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # screen should show just final sandbox screen-should-contain [ diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index 3b2e91db..aebb34c2 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -1,20 +1,20 @@ ## clicking on sandbox results to 'fix' them and turn sandboxes into tests scenario sandbox-click-on-result-toggles-color-to-green [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # basic recipe - 1:text <- new [ -def foo [ - return 4 + recipes:text <- new [ +recipe foo [ + reply 4 ]] + env:&:environment <- new-programming-environment screen:&:screen, [foo] # run it - 2:text <- new [foo] assume-console [ press F4 ] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . run (F4) . . . @@ -30,7 +30,7 @@ def foo [ left-click 5, 21 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -44,8 +44,8 @@ def foo [ ] # cursor should remain unmoved run [ - 4:char/cursor <- copy 9251/␣ - print screen:&:screen, 4:char/cursor + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] screen-should-contain [ . run (F4) . @@ -58,16 +58,16 @@ def foo [ . . ] # now change the result - 1:text <- new [ -def foo [ - return 3 + new-recipes:text <- new [ +recipe foo [ + reply 3 ]] # then rerun assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/new-test-recipes + event-loop screen:&:screen, console:&:console, env, new-recipes ] # result turns red screen-should-contain-in-color 1/red, [ diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index dd1aed15..b921c15d 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -1,15 +1,15 @@ ## clicking on the code typed into a sandbox toggles its trace scenario sandbox-click-on-code-toggles-app-trace [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height + env:&:environment <- new-programming-environment screen:&:screen, [stash [abc]] # run a stash instruction - 1:text <- new [stash [abc]] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -24,9 +24,9 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 21 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - 4:char/cursor-icon <- copy 9251/␣ - print screen:&:screen, 4:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + cursor:char <- copy 9251/␣ + print screen:&:screen, cursor ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -50,8 +50,8 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 25 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment - print screen:&:screen, 4:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + print screen:&:screen, cursor ] # trace hidden again screen-should-contain [ @@ -66,16 +66,17 @@ scenario sandbox-click-on-code-toggles-app-trace [ ] scenario sandbox-shows-app-trace-and-result [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # run a stash instruction and some code - 1:text <- new [stash [abc] + sandbox:text <- new [stash [abc] add 2, 2] assume-console [ press F4 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + env:&:environment <- new-programming-environment screen:&:screen, sandbox + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -92,7 +93,7 @@ add 2, 2] left-click 4, 21 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # trace now printed above result screen-should-contain [ @@ -110,16 +111,16 @@ add 2, 2] ] scenario clicking-on-app-trace-does-nothing [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height + env:&:environment <- new-programming-environment screen:&:screen, [stash 123456789] # create and expand the trace - 1:text <- new [stash 123456789] assume-console [ press F4 left-click 4, 1 ] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ . run (F4) . . . @@ -133,7 +134,7 @@ scenario clicking-on-app-trace-does-nothing [ left-click 5, 7 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # no change; doesn't die screen-should-contain [ diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index 561b5309..9ca8ab6d 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -125,19 +125,19 @@ after <render-sandbox-trace-done> [ ] scenario run-shows-errors-in-get [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ get 123:num, foo:offset ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -156,11 +156,10 @@ def foo [ ] scenario run-updates-status-with-first-erroneous-sandbox [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [] assume-console [ # create invalid sandbox 1 type [get foo, x:offset] @@ -170,7 +169,7 @@ scenario run-updates-status-with-first-erroneous-sandbox [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, env, [] ] # status line shows that error is in first sandbox screen-should-contain [ @@ -179,11 +178,10 @@ scenario run-updates-status-with-first-erroneous-sandbox [ ] scenario run-updates-status-with-first-erroneous-sandbox-2 [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [] - 2:text <- new [] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [] assume-console [ # create invalid sandbox 2 type [get foo, x:offset] @@ -196,7 +194,7 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, env, [] ] # status line shows that error is in second sandbox screen-should-contain [ @@ -205,15 +203,14 @@ scenario run-updates-status-with-first-erroneous-sandbox-2 [ ] scenario run-hides-errors-from-past-sandboxes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [] - 2:text <- new [get foo, x:offset] # invalid - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [get foo, x:offset] # invalid assume-console [ press F4 # generate error ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/empty-test-recipes + event-loop screen:&:screen, console:&:console, env, [] assume-console [ left-click 3, 10 press ctrl-k @@ -221,7 +218,7 @@ scenario run-hides-errors-from-past-sandboxes [ press F4 # update sandbox ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment + event-loop screen:&:screen, console:&:console, env ] # error should disappear screen-should-contain [ @@ -237,21 +234,21 @@ scenario run-hides-errors-from-past-sandboxes [ ] scenario run-updates-errors-for-shape-shifting-recipes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # define a shape-shifting recipe with an error - 1:text <- new [recipe foo x:_elem -> z:_elem [ + recipes:text <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients y:&:num <- copy 0 z <- add x, y ]] - 2:text <- new [foo 2] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo 2] assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . errors found (0) run (F4) . . . @@ -268,7 +265,7 @@ z <- add x, y press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # error should remain unchanged screen-should-contain [ @@ -285,20 +282,21 @@ z <- add x, y ] scenario run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # overload a well-known shape-shifting recipe - 1:text <- new [recipe length l:&:list:_elem -> n:num [ + recipes:text <- new [recipe length l:&:list:_elem -> n:num [ ]] # call code that uses other variants of it, but not it itself - 2:text <- new [x:&:list:num <- copy 0 + sandbox:text <- new [x:&:list:num <- copy 0 to-text x] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, sandbox # run it once assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes # no errors anywhere on screen (can't check anything else, since to-text will return an address) screen-should-contain-in-color 1/red, [ . . @@ -316,7 +314,7 @@ to-text x] press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # still no errors screen-should-contain-in-color 1/red, [ @@ -333,19 +331,19 @@ to-text x] ] scenario run-shows-missing-type-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ x <- copy 0 ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -358,20 +356,20 @@ def foo [ ] scenario run-shows-unbalanced-bracket-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # recipe is incomplete (unbalanced '[') - 1:text <- new [ + recipes:text <- new [ recipe foo \\[ x <- copy 0 ] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -387,21 +385,21 @@ recipe foo \\[ ] scenario run-shows-get-on-non-container-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope x:&:point <- new point:type get x:&:point, 1:offset ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -415,22 +413,22 @@ def foo [ ] scenario run-shows-non-literal-get-argument-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope x:num <- copy 0 y:&:point <- new point:type get *y:&:point, x:num ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -444,20 +442,20 @@ def foo [ ] scenario run-shows-errors-everytime [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # try to run a file with an error - 1:text <- new [ -def foo [ + recipes:text <- new [ +recipe foo [ local-scope x:num <- copy y:num ]] - 2:text <- new [foo] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo] assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes screen-should-contain [ . errors found run (F4) . . . @@ -471,7 +469,7 @@ def foo [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] screen-should-contain [ . errors found run (F4) . @@ -484,16 +482,17 @@ def foo [ ] scenario run-instruction-and-print-errors [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:text <- new [get 1:&:point, 1:offset] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, [get 1:&:point, 1:offset] assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] + # check that screen prints error message in red screen-should-contain [ . errors found (0) run (F4) . . . @@ -519,18 +518,19 @@ scenario run-instruction-and-print-errors [ ] scenario run-instruction-and-print-errors-only-once [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 10/height # editor contains an illegal instruction - 1:text <- new [get 1234:num, foo:offset] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + sandbox:text <- new [get 1234:num, foo:offset] + env:&:environment <- new-programming-environment screen:&:screen, sandbox # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] # check that screen prints error message just once screen-should-contain [ @@ -548,19 +548,20 @@ scenario run-instruction-and-print-errors-only-once [ ] scenario sandbox-can-handle-infinite-loop [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # editor contains an infinite loop - 1:text <- new [{ + sandbox:text <- new [{ loop }] - 2:&:environment <- new-programming-environment screen:&:screen, 1:text + env:&:environment <- new-programming-environment screen:&:screen, sandbox # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, 2:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ . errors found (0) run (F4) . @@ -577,24 +578,24 @@ loop ] scenario sandbox-with-errors-shows-trace [ + local-scope trace-until 100/app # trace too long assume-screen 50/width, 20/height # generate a stash and a error - 1:text <- new [recipe foo [ + recipes:text <- new [recipe foo [ local-scope a:num <- next-ingredient b:num <- next-ingredient stash [dividing by], b _, c:num <- divide-with-remainder a, b -return b +reply b ]] - 2:text <- new [foo 4, 0] - 3:&:environment <- new-programming-environment screen:&:screen, 2:text + env:&:environment <- new-programming-environment screen:&:screen, [foo 4, 0] # run assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes # screen prints error message screen-should-contain [ . errors found (0) run (F4) . @@ -612,7 +613,7 @@ return b left-click 4, 15 ] run [ - event-loop screen:&:screen, console:&:console, 3:&:environment, 1:text/test-recipes + event-loop screen:&:screen, console:&:console, env, recipes ] # screen should expand trace screen-should-contain [ diff --git a/sandbox/012-editor-undo.mu b/sandbox/012-editor-undo.mu index 371a9ef1..0b13de25 100644 --- a/sandbox/012-editor-undo.mu +++ b/sandbox/012-editor-undo.mu @@ -99,21 +99,21 @@ after <handle-special-character> [ # undo typing scenario editor-can-undo-typing [ + local-scope # create an editor and type a character assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # character should be gone screen-should-contain [ @@ -127,7 +127,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -229,21 +229,21 @@ after <handle-undo> [ ] scenario editor-can-undo-typing-multiple [ + local-scope # create an editor and type multiple characters assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be gone screen-should-contain [ @@ -255,16 +255,16 @@ scenario editor-can-undo-typing-multiple [ ] scenario editor-can-undo-typing-multiple-2 [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [a] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right + editor-render screen, e # type some characters assume-console [ type [012] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .012a . @@ -276,7 +276,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # back to original text screen-should-contain [ @@ -290,7 +290,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -301,17 +301,17 @@ scenario editor-can-undo-typing-multiple-2 [ ] scenario editor-can-undo-typing-enter [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [ abc] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [ abc], screen:&:screen, 0/left, 10/right + editor-render screen, e # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . abc . @@ -320,8 +320,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -331,10 +331,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -351,7 +351,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -364,16 +364,16 @@ scenario editor-can-undo-typing-enter [ # redo typing scenario editor-redo-typing [ + local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - 1:text <- new [a] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . @@ -385,7 +385,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be back screen-should-contain [ @@ -399,7 +399,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -428,16 +428,16 @@ after <handle-redo> [ ] scenario editor-redo-typing-empty [ + local-scope # create an editor, type something, undo assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . . @@ -449,7 +449,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # all characters must be back screen-should-contain [ @@ -463,7 +463,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -474,23 +474,24 @@ scenario editor-redo-typing-empty [ ] scenario editor-work-clears-redo-stack [ + local-scope # create an editor with some text, do some work, undo assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # do some more work assume-console [ type [0] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .0abc . @@ -503,7 +504,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # nothing should happen screen-should-contain [ @@ -516,11 +517,11 @@ ghi] ] scenario editor-can-redo-typing-and-enter-and-tab [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -531,7 +532,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . . ab cd . @@ -539,8 +540,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -550,11 +551,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # typing in second line deleted, but not indent - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -571,11 +572,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # indent and newline deleted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -591,11 +592,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # empty screen - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -611,11 +612,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -631,11 +632,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # newline and indent inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -652,11 +653,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # indent and newline deleted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -673,28 +674,29 @@ scenario editor-can-redo-typing-and-enter-and-tab [ # undo cursor movement scenario editor-can-undo-touch [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # click undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -704,7 +706,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -763,29 +765,30 @@ after <handle-undo> [ ] scenario editor-can-undo-left-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -795,7 +798,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -807,21 +810,22 @@ ghi] ] scenario editor-can-undo-up-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -831,11 +835,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -845,7 +849,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -857,29 +861,30 @@ ghi] ] scenario editor-can-undo-down-arrow [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -889,7 +894,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -901,29 +906,30 @@ ghi] ] scenario editor-can-undo-ctrl-a [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -933,7 +939,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -945,29 +951,30 @@ ghi] ] scenario editor-can-undo-home [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -977,7 +984,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -989,29 +996,30 @@ ghi] ] scenario editor-can-undo-ctrl-e [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1021,7 +1029,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1033,29 +1041,30 @@ ghi] ] scenario editor-can-undo-end [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves back + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1065,7 +1074,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1077,13 +1086,14 @@ ghi] ] scenario editor-can-undo-multiple-arrows-in-the-same-direction [ + local-scope # create an editor with some text assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # move the cursor assume-console [ left-click 2, 1 @@ -1091,9 +1101,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1103,11 +1113,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # up-arrow is undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 3 @@ -1117,11 +1127,11 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # both right-arrows are undone + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -1131,28 +1141,29 @@ ghi] # redo cursor movement scenario editor-redo-touch [ + local-scope # create an editor with some text, click on a character, undo assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def ghi] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e ] # cursor moves to left-click + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 3 4 <- 1 @@ -1162,7 +1173,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1188,19 +1199,19 @@ after <handle-redo> [ ] 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 - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1216,9 +1227,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1236,9 +1247,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1256,9 +1267,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1276,9 +1287,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # first insert screen-should-contain [ @@ -1296,9 +1307,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1317,9 +1328,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + editor-event-loop screen:&:screen, console:&:console, e + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset ] # second insert screen-should-contain [ @@ -1337,26 +1348,26 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ # undo backspace scenario editor-can-undo-and-redo-backspace [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1366,10 +1377,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1385,10 +1396,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1482,11 +1493,11 @@ after <handle-redo> [ # undo delete scenario editor-can-undo-and-redo-delete [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1496,15 +1507,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1514,10 +1525,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1533,10 +1544,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1552,10 +1563,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1571,11 +1582,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1591,11 +1602,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1611,11 +1622,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1671,18 +1682,19 @@ before <delete-character-end> [ # undo ctrl-k scenario editor-can-undo-and-redo-ctrl-k [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 1 press ctrl-k ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .a . @@ -1690,8 +1702,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1701,7 +1713,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1710,8 +1722,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1721,7 +1733,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted screen-should-contain [ @@ -1731,8 +1743,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1742,7 +1754,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1773,18 +1785,19 @@ before <delete-to-end-of-line-end> [ # undo ctrl-u scenario editor-can-undo-and-redo-ctrl-u [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [abc + contents:text <- new [abc def] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 2 press ctrl-u ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .c . @@ -1792,8 +1805,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1803,7 +1816,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1812,8 +1825,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1823,7 +1836,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] # first line inserted screen-should-contain [ @@ -1833,8 +1846,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:num <- get *2:&:editor, cursor-row:offset - 4:num <- get *2:&:editor, cursor-column:offset + 3:num/raw <- get *e, cursor-row:offset + 4:num/raw <- get *e, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1844,7 +1857,7 @@ def] type [1] ] run [ - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ . . @@ -1874,18 +1887,18 @@ before <delete-to-start-of-line-end> [ ] scenario editor-can-undo-and-redo-ctrl-u-2 [ + local-scope # create an editor assume-screen 10/width, 5/height - 1:text <- new [] - 2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right - editor-render screen, 2:&:editor + e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right + editor-render screen, e # insert some text and hit delete and backspace a few times assume-console [ type [abc] press ctrl-u press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, 2:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ . . .abc . |