diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-01-19 23:18:03 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-01-19 23:18:03 -0800 |
commit | 455fbac64f101b05f7eaca89b84470569e4df3fd (patch) | |
tree | 32cfd5b092ad86086e4d15992bb10fd06a12bf13 | |
parent | 7163e18a774781c62f0c0542e4cb9037f6a71d22 (diff) | |
download | mu-455fbac64f101b05f7eaca89b84470569e4df3fd.tar.gz |
2576 - distinguish allocated addresses from others
This is the one major refinement on the C programming model I'm planning to introduce in mu. Instead of Rust's menagerie of pointer types and static checking, I want to introduce just one new type, and use it to perform ref-counting at runtime. So far all we're doing is updating new's interface. The actual ref-counting implementation is next. One implication: I might sometimes need duplicate implementations for a recipe with allocated vs vanilla addresses of the same type. So far it seems I can get away with just always passing in allocated addresses; the situations when you want to pass an unallocated address to a recipe should be few and far between.
56 files changed, 3364 insertions, 3300 deletions
diff --git a/031address.cc b/031address.cc index 7f2937e5..cc818a87 100644 --- a/031address.cc +++ b/031address.cc @@ -50,14 +50,17 @@ void canonize(reagent& x) { void lookup_memory(reagent& x) { if (!x.type || x.type->value != get(Type_ordinal, "address")) { raise_error << maybe(current_recipe_name()) << "tried to /lookup " << x.original_string << " but it isn't an address\n" << end(); + return; } // compute value if (x.value == 0) { raise_error << maybe(current_recipe_name()) << "tried to /lookup 0\n" << end(); + return; } trace(9999, "mem") << "location " << x.value << " is " << no_scientific(get_or_insert(Memory, x.value)) << end(); x.set_value(get_or_insert(Memory, x.value)); drop_from_type(x, "address"); + // End Drop Address In lookup_memory(x) drop_one_lookup(x); } @@ -89,6 +92,7 @@ bool canonize_type(reagent& r) { return false; } drop_from_type(r, "address"); + // End Drop Address In canonize_type(r) drop_one_lookup(r); } return true; diff --git a/032array.cc b/032array.cc index f5fe2775..dbc6a4dc 100644 --- a/032array.cc +++ b/032array.cc @@ -430,8 +430,10 @@ bool is_mu_string(const reagent& x) { return x.type && x.type->value == get(Type_ordinal, "address") && x.type->right - && x.type->right->value == get(Type_ordinal, "array") + && x.type->right->value == get(Type_ordinal, "shared") && x.type->right->right - && x.type->right->right->value == get(Type_ordinal, "character") - && x.type->right->right->right == NULL; + && x.type->right->right->value == get(Type_ordinal, "array") + && x.type->right->right->right + && x.type->right->right->right->value == get(Type_ordinal, "character") + && x.type->right->right->right->right == NULL; } diff --git a/038new.cc b/038new.cc index 2d7337a3..d0e4f988 100644 --- a/038new.cc +++ b/038new.cc @@ -1,12 +1,55 @@ -//: A simple memory allocator to create space for new variables at runtime. +//: Creating space for new variables at runtime. + +//: Mu has two primitives for managing allocations: +//: - 'allocate' reserves a specified amount of space +//: - 'abandon' returns allocated space to be reused by future calls to 'allocate' +//: +//: In practice it's useful to let programs copy addresses anywhere they want, +//: but a prime source of (particularly security) bugs is accessing memory +//: after it's been abandoned. To avoid this, mu programs use a safer +//: primitive called 'new', which performs two operations: +//: +//: - it takes a type rather than a size, to save you the trouble of +//: calculating sizes of different variables. +//: - it allocates an extra location where it tracks so-called 'reference +//: counts' or refcounts: the number of address variables in your program that +//: point to this allocation. The initial refcount of an allocation starts out +//: at 1 (the product of the 'new' instruction). When other variables are +//: copied from it the refcount is incremented. When a variable stops pointing +//: at it the refcount is decremented. When the refcount goes to 0 the +//: allocation is automatically abandoned. +//: +//: Mu programs guarantee you'll have no memory corruption bugs as long as you +//: use 'new' and never use 'allocate' or 'abandon'. However, they don't help +//: you at all to remember to abandon memory after you're done with it. To +//: minimize memory use, be sure to reset allocated addresses to 0 when you're +//: done with them. + +//: To help you distinguish addresses that point at allocations, 'new' returns +//: type address:shared:___. Think of 'shared' as a generic container that +//: contains one extra field: the refcount. However, lookup operations will +//: transparently drop the 'shared' and access to the refcount. Copying +//: between shared and non-shared addresses is forbidden. +:(before "End Mu Types Initialization") +type_ordinal shared = put(Type_ordinal, "shared", Next_type_ordinal++); +get_or_insert(Type, shared).name = "shared"; +:(before "End Drop Address In lookup_memory(x)") +if (x.properties.at(0).second->value == "shared") { + //x.set_value(x.value+1); // doesn't work yet + drop_from_type(x, "shared"); +} +:(before "End Drop Address In canonize_type(r)") +if (r.properties.at(0).second->value == "shared") { + drop_from_type(r, "shared"); +} :(scenarios run) :(scenario new) # call new two times with identical arguments; you should get back different results recipe main [ - 1:address:number/raw <- new number:type - 2:address:number/raw <- new number:type - 3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw + 1:address:shared:number/raw <- new number:type + 2:address:shared:number/raw <- new number:type + 3:boolean/raw <- equal 1:address:shared:number/raw, 2:address:shared:number/raw ] +mem: storing 0 in location 3 @@ -53,6 +96,7 @@ case NEW: { reagent product(inst.products.at(0)); canonize_type(product); drop_from_type(product, "address"); + drop_from_type(product, "shared"); if (SIZE(inst.ingredients) > 1) { // array allocation drop_from_type(product, "array"); @@ -174,29 +218,29 @@ void ensure_space(long long int size) { % Memory_allocated_until = 10; % put(Memory, Memory_allocated_until, 1); recipe main [ - 1:address:number <- new number:type - 2:number <- copy *1:address:number + 1:address:shared:number <- new number:type + 2:number <- copy *1:address:shared:number ] +mem: storing 0 in location 2 :(scenario new_array) recipe main [ - 1:address:array:number/raw <- new number:type, 5 - 2:address:number/raw <- new number:type - 3:number/raw <- subtract 2:address:number/raw, 1:address:array:number/raw + 1:address:shared:array:number/raw <- new number:type, 5 + 2:address:shared:number/raw <- new number:type + 3:number/raw <- subtract 2:address:shared:number/raw, 1:address:shared:array:number/raw ] -+run: 1:address:array:number/raw <- new number:type, 5 ++run: 1:address:shared:array:number/raw <- new number:type, 5 +mem: array size is 5 # don't forget the extra location for array size +mem: storing 6 in location 3 :(scenario new_empty_array) recipe main [ - 1:address:array:number/raw <- new number:type, 0 - 2:address:number/raw <- new number:type - 3:number/raw <- subtract 2:address:number/raw, 1:address:array:number/raw + 1:address:shared:array:number/raw <- new number:type, 0 + 2:address:shared:number/raw <- new number:type + 3:number/raw <- subtract 2:address:shared:number/raw, 1:address:shared:array:number/raw ] -+run: 1:address:array:number/raw <- new number:type, 0 ++run: 1:address:shared:array:number/raw <- new number:type, 0 +mem: array size is 0 +mem: storing 1 in location 3 @@ -204,8 +248,8 @@ recipe main [ :(scenario new_overflow) % Initial_memory_per_routine = 2; recipe main [ - 1:address:number/raw <- new number:type - 2:address:point/raw <- new point:type # not enough room in initial page + 1:address:shared:number/raw <- new number:type + 2:address:shared:point/raw <- new point:type # not enough room in initial page ] +new: routine allocated memory from 1000 to 1002 +new: routine allocated memory from 1002 to 1004 @@ -215,10 +259,10 @@ recipe main [ :(scenario new_reclaim) recipe main [ - 1:address:number <- new number:type - abandon 1:address:number - 2:address:number <- new number:type # must be same size as abandoned memory to reuse - 3:boolean <- equal 1:address:number, 2:address:number + 1:address:shared:number <- new number:type + abandon 1:address:shared:number + 2:address:shared:number <- new number:type # must be same size as abandoned memory to reuse + 3:boolean <- equal 1:address:shared:number, 2:address:shared:number ] # both allocations should have returned the same address +mem: storing 1 in location 3 @@ -240,8 +284,8 @@ case ABANDON: { } reagent types = inst.ingredients.at(0); canonize_type(types); - if (!types.type || types.type->value != get(Type_ordinal, "address")) { - raise_error << maybe(get(Recipe, r).name) << "first ingredient of 'abandon' should be an address, but got " << inst.ingredients.at(0).original_string << '\n' << end(); + if (!types.type || types.type->value != get(Type_ordinal, "address") || types.type->right->value != get(Type_ordinal, "shared")) { + raise_error << maybe(get(Recipe, r).name) << "first ingredient of 'abandon' should be an address:shared:___, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } break; @@ -254,6 +298,7 @@ case ABANDON: { // lookup_memory without drop_one_lookup { types.set_value(get_or_insert(Memory, types.value)); drop_from_type(types, "address"); + drop_from_type(types, "shared"); // } abandon(address, size_of(types)); break; @@ -293,20 +338,20 @@ if (Free_list[size]) { :(scenario new_differing_size_no_reclaim) recipe main [ - 1:address:number <- new number:type - abandon 1:address:number - 2:address:array:number <- new number:type, 2 # different size - 3:boolean <- equal 1:address:number, 2:address:array:number + 1:address:shared:number <- new number:type + abandon 1:address:shared:number + 2:address:shared:array:number <- new number:type, 2 # different size + 3:boolean <- equal 1:address:shared:number, 2:address:shared:array:number ] # no reuse +mem: storing 0 in location 3 :(scenario new_reclaim_array) recipe main [ - 1:address:array:number <- new number:type, 2 - abandon 1:address:array:number - 2:address:array:number <- new number:type, 2 - 3:boolean <- equal 1:address:array:number, 2:address:array:number + 1:address:shared:array:number <- new number:type, 2 + abandon 1:address:shared:array:number + 2:address:shared:array:number <- new number:type, 2 + 3:boolean <- equal 1:address:shared:array:number, 2:address:shared:array:number ] # reuse +mem: storing 1 in location 3 @@ -315,17 +360,17 @@ recipe main [ :(scenario new_string) recipe main [ - 1:address:array:character <- new [abc def] - 2:character <- index *1:address:array:character, 5 + 1:address:shared:array:character <- new [abc def] + 2:character <- index *1:address:shared:array:character, 5 ] # number code for 'e' +mem: storing 101 in location 2 :(scenario new_string_handles_unicode) recipe main [ - 1:address:array:character <- new [a«c] - 2:number <- length *1:address:array:character - 3:character <- index *1:address:array:character, 1 + 1:address:shared:array:character <- new [a«c] + 2:number <- length *1:address:shared:array:character + 3:character <- index *1:address:shared:array:character, 1 ] +mem: storing 3 in location 2 # unicode for '«' @@ -370,8 +415,8 @@ long long int new_mu_string(const string& contents) { :(scenario stash_string) recipe main [ - 1:address:array:character <- new [abc] - stash [foo:], 1:address:array:character + 1:address:shared:array:character <- new [abc] + stash [foo:], 1:address:shared:array:character ] +app: foo: abc @@ -383,15 +428,15 @@ if (is_mu_string(r)) { :(scenario unicode_string) recipe main [ - 1:address:array:character <- new [♠] - stash [foo:], 1:address:array:character + 1:address:shared:array:character <- new [♠] + stash [foo:], 1:address:shared:array:character ] +app: foo: ♠ :(scenario stash_space_after_string) recipe main [ - 1:address:array:character <- new [abc] - stash 1:address:array:character [foo] + 1:address:shared:array:character <- new [abc] + stash 1:address:shared:array:character, [foo] ] +app: abc foo @@ -399,8 +444,8 @@ recipe main [ :(scenario new_string_overflow) % Initial_memory_per_routine = 2; recipe main [ - 1:address:number/raw <- new number:type - 2:address:array:character/raw <- new [a] # not enough room in initial page, if you take the array size into account + 1:address:shared:number/raw <- new number:type + 2:address:shared:array:character/raw <- new [a] # not enough room in initial page, if you take the array size into account ] +new: routine allocated memory from 1000 to 1002 +new: routine allocated memory from 1002 to 1004 diff --git a/042name.cc b/042name.cc index 7ad45b89..4c855570 100644 --- a/042name.cc +++ b/042name.cc @@ -92,8 +92,10 @@ long long int lookup_name(const reagent& r, const recipe_ordinal default_recipe) } type_ordinal skip_addresses(type_tree* type, const string& recipe_name) { + type_ordinal address = get(Type_ordinal, "address"); + type_ordinal shared = get(Type_ordinal, "shared"); for (; type; type = type->right) { - if (type->value != get(Type_ordinal, "address")) + if (type->value != address && type->value != shared) return type->value; } raise_error << maybe(recipe_name) << "expected a container" << '\n' << end(); diff --git a/043space.cc b/043space.cc index 4f57ebd5..85db1840 100644 --- a/043space.cc +++ b/043space.cc @@ -7,7 +7,7 @@ # then location 0 is really location 11, location 1 is really location 12, and so on. recipe main [ 10:number <- copy 5 # pretend array; in practice we'll use new - default-space:address:array:location <- copy 10/unsafe + default-space:address:shared:array:location <- copy 10/unsafe 1:number <- copy 23 ] +mem: storing 23 in location 12 @@ -19,7 +19,7 @@ recipe main [ # pretend array 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000/unsafe + default-space:address:shared:array:location <- copy 1000/unsafe 1:address:number <- copy 3/unsafe 8:number/raw <- copy *1:address:number ] @@ -70,7 +70,7 @@ recipe main [ # pretend array 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000/unsafe + default-space:address:shared:array:location <- copy 1000/unsafe 1:address:point <- copy 12/unsafe 9:number/raw <- get *1:address:point, 1:offset ] @@ -90,7 +90,7 @@ recipe main [ # pretend array 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000/unsafe + default-space:address:shared:array:location <- copy 1000/unsafe 1:address:array:number <- copy 12/unsafe 9:number/raw <- index *1:address:array:number, 1 ] @@ -119,7 +119,7 @@ if (s == "number-of-locals") return true; :(before "End Rewrite Instruction(curr, recipe result)") // rewrite `new-default-space` to -// `default-space:address:array:location <- new location:type, number-of-locals:literal` +// `default-space:address:shared:array:location <- new location:type, number-of-locals:literal` // where N is Name[recipe][""] if (curr.name == "new-default-space") { rewrite_default_space_instruction(curr); @@ -150,7 +150,7 @@ recipe main [ recipe foo [ local-scope x:number <- copy 34 - reply default-space:address:array:location + reply default-space:address:shared:array:location ] # both calls to foo should have received the same default-space +mem: storing 1 in location 3 @@ -186,7 +186,7 @@ void rewrite_default_space_instruction(instruction& curr) { curr.ingredients.push_back(reagent("number-of-locals:literal")); if (!curr.products.empty()) raise_error << "new-default-space can't take any results\n" << end(); - curr.products.push_back(reagent("default-space:address:array:location")); + curr.products.push_back(reagent("default-space:address:shared:array:location")); } //:: helpers @@ -212,11 +212,13 @@ long long int address(long long int offset, long long int base) { || !x.type || x.type->value != get(Type_ordinal, "address") || !x.type->right - || x.type->right->value != get(Type_ordinal, "array") + || x.type->right->value != get(Type_ordinal, "shared") || !x.type->right->right - || x.type->right->right->value != get(Type_ordinal, "location") - || x.type->right->right->right) { - raise_error << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end(); + || x.type->right->right->value != get(Type_ordinal, "array") + || !x.type->right->right->right + || x.type->right->right->right->value != get(Type_ordinal, "location") + || x.type->right->right->right->right) { + raise_error << maybe(current_recipe_name()) << "'default-space' should be of type address:shared:array:location, but tried to write " << to_string(data) << '\n' << end(); } current_call().default_space = data.at(0); return; @@ -224,8 +226,8 @@ long long int address(long long int offset, long long int base) { :(scenario get_default_space) recipe main [ - default-space:address:array:location <- copy 10/unsafe - 1:address:array:location/raw <- copy default-space:address:array:location + default-space:address:shared:array:location <- copy 10/unsafe + 1:address:shared:array:location/raw <- copy default-space:address:shared:array:location ] +mem: storing 10 in location 1 diff --git a/044space_surround.cc b/044space_surround.cc index 821066cc..d645f1b4 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -9,8 +9,8 @@ recipe main [ 10:number <- copy 5 # pretend array 20:number <- copy 5 # pretend array - default-space:address:array:location <- copy 10/unsafe - 0:address:array:location/names:dummy <- copy 20/unsafe # later layers will explain the /names: property + default-space:address:shared:array:location <- copy 10/unsafe + 0:address:shared:array:location/names:dummy <- copy 20/unsafe # later layers will explain the /names: property 1:number <- copy 32 1:number/space:1 <- copy 33 ] diff --git a/045closure_name.cc b/045closure_name.cc index 682c163f..714d14d1 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -5,22 +5,22 @@ :(scenario closure) recipe main [ - default-space:address:array:location <- new location:type, 30 - 1:address:array:location/names:new-counter <- new-counter - 2:number/raw <- increment-counter 1:address:array:location/names:new-counter - 3:number/raw <- increment-counter 1:address:array:location/names:new-counter + default-space:address:shared:array:location <- new location:type, 30 + 1:address:shared:array:location/names:new-counter <- new-counter + 2:number/raw <- increment-counter 1:address:shared:array:location/names:new-counter + 3:number/raw <- increment-counter 1:address:shared:array:location/names:new-counter ] recipe new-counter [ - default-space:address:array:location <- new location:type, 30 + default-space:address:shared:array:location <- new location:type, 30 x:number <- copy 23 y:number <- copy 3 # variable that will be incremented - reply default-space:address:array:location + reply default-space:address:shared:array:location ] recipe increment-counter [ - default-space:address:array:location <- new location:type, 30 - 0:address:array:location/names:new-counter <- next-ingredient # outer space must be created by 'new-counter' above + default-space:address:shared:array:location <- new location:type, 30 + 0:address:shared:array:location/names:new-counter <- next-ingredient # outer space must be created by 'new-counter' above y:number/space:1 <- add y:number/space:1, 1 # increment y:number <- copy 234 # dummy reply y:number/space:1 @@ -52,11 +52,13 @@ void collect_surrounding_spaces(const recipe_ordinal r) { if (!type || type->value != get(Type_ordinal, "address") || !type->right - || type->right->value != get(Type_ordinal, "array") + || type->right->value != get(Type_ordinal, "shared") || !type->right->right - || type->right->right->value != get(Type_ordinal, "location") - || type->right->right->right) { - raise_error << "slot 0 should always have type address:array:location, but is " << inst.products.at(j).to_string() << '\n' << end(); + || type->right->right->value != get(Type_ordinal, "array") + || !type->right->right->right + || type->right->right->right->value != get(Type_ordinal, "location") + || type->right->right->right->right) { + raise_error << "slot 0 should always have type address:shared:array:location, but is " << inst.products.at(j).to_string() << '\n' << end(); continue; } string_tree* s = property(inst.products.at(j), "names"); diff --git a/046global.cc b/046global.cc index bd433af7..3393ed31 100644 --- a/046global.cc +++ b/046global.cc @@ -9,8 +9,8 @@ recipe main [ 10:number <- copy 5 20:number <- copy 5 # actual start of this recipe - global-space:address:array:location <- copy 20/unsafe - default-space:address:array:location <- copy 10/unsafe + global-space:address:shared:array:location <- copy 20/unsafe + default-space:address:shared:array:location <- copy 10/unsafe 1:number <- copy 23 1:number/space:global <- copy 24 ] @@ -35,11 +35,13 @@ global_space = 0; || !x.type || x.type->value != get(Type_ordinal, "address") || !x.type->right - || x.type->right->value != get(Type_ordinal, "array") + || x.type->right->value != get(Type_ordinal, "shared") || !x.type->right->right - || x.type->right->right->value != get(Type_ordinal, "location") - || x.type->right->right->right) { - raise_error << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end(); + || x.type->right->right->value != get(Type_ordinal, "array") + || !x.type->right->right->right + || x.type->right->right->right->value != get(Type_ordinal, "location") + || x.type->right->right->right->right) { + raise_error << maybe(current_recipe_name()) << "'global-space' should be of type address:shared:array:location, but tried to write " << to_string(data) << '\n' << end(); } if (Current_routine->global_space) raise_error << "routine already has a global-space; you can't over-write your globals" << end(); @@ -61,7 +63,7 @@ global_space = 0; :(scenario global_space_with_names) % Hide_errors = true; recipe main [ - global-space:address:array:location <- new location:type, 10 + global-space:address:shared:array:location <- new location:type, 10 x:number <- copy 23 1:number/space:global <- copy 24 ] diff --git a/047check_type_by_name.cc b/047check_type_by_name.cc index 4842e15c..b7686dc2 100644 --- a/047check_type_by_name.cc +++ b/047check_type_by_name.cc @@ -89,7 +89,7 @@ recipe main [ :(scenario typo_in_address_type_fails) % Hide_errors = true; recipe main [ - y:address:charcter <- new character:type + y:address:shared:charcter <- new character:type *y <- copy 67 ] -+error: main: unknown type charcter in 'y:address:charcter <- new character:type' ++error: main: unknown type charcter in 'y:address:shared:charcter <- new character:type' diff --git a/050scenario.cc b/050scenario.cc index 5753be73..0680266e 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -99,9 +99,9 @@ scenario foo [ :(scenario read_scenario_with_bracket_in_comment_in_nested_string) scenario foo [ - 1:address:array:character <- new [# not a comment] + 1:address:shared:array:character <- new [# not a comment] ] -+run: 1:address:array:character <- new [# not a comment] ++run: 1:address:shared:array:character <- new [# not a comment] //:: Run scenarios when we run 'mu test'. //: Treat the text of the scenario as a regular series of instructions. diff --git a/053rewrite_stash.cc b/053rewrite_stash.cc index b6602041..ae55ad9e 100644 --- a/053rewrite_stash.cc +++ b/053rewrite_stash.cc @@ -38,7 +38,7 @@ void rewrite_stashes_to_text_named(recipe& caller) { def.name = "to-text-line"; def.ingredients.push_back(inst.ingredients.at(j)); ostringstream ingredient_name; - ingredient_name << "stash_" << stash_instruction_idx << '_' << j << ":address:array:character"; + ingredient_name << "stash_" << stash_instruction_idx << '_' << j << ":address:shared:array:character"; def.products.push_back(reagent(ingredient_name.str())); new_instructions.push_back(def); inst.ingredients.at(j).clear(); // reclaim old memory diff --git a/055parse_tree.cc b/055parse_tree.cc index 947093b9..f9b15adb 100644 --- a/055parse_tree.cc +++ b/055parse_tree.cc @@ -71,7 +71,7 @@ container bar [ :(scenario dilated_reagent_with_new) recipe main [ - x:address:address:number <- new {(address number): type} + x:address:shared:address:number <- new {(address number): type} ] +new: size of <"address" : <"number" : <>>> is 1 diff --git a/057static_dispatch.cc b/057static_dispatch.cc index bad8c1d8..1034dc90 100644 --- a/057static_dispatch.cc +++ b/057static_dispatch.cc @@ -297,13 +297,13 @@ $error: 0 :(scenario static_dispatch_works_with_compound_type_containing_container_defined_after_first_use) % Hide_errors = true; recipe main [ - x:address:foo <- new foo:type + x:address:shared:foo <- new foo:type test x ] container foo [ x:number ] -recipe test a:address:foo -> z:number [ +recipe test a:address:shared:foo -> z:number [ local-scope load-ingredients z:number <- get *a, x:offset @@ -313,10 +313,10 @@ $error: 0 :(scenario static_dispatch_works_with_compound_type_containing_container_defined_after_second_use) % Hide_errors = true; recipe main [ - x:address:foo <- new foo:type + x:address:shared:foo <- new foo:type test x ] -recipe test a:address:foo -> z:number [ +recipe test a:address:shared:foo -> z:number [ local-scope load-ingredients z:number <- get *a, x:offset diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index 6cce844f..3811dd36 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -535,14 +535,14 @@ container foo:_t [ :(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient) recipe main [ - 1:address:foo:point <- bar 3 - 11:foo:point <- copy *1:address:foo:point + 1:address:shared:foo:point <- bar 3 + 11:foo:point <- copy *1:address:shared:foo:point ] container foo:_t [ x:_t y:number ] -recipe bar x:number -> result:address:foo:_t [ +recipe bar x:number -> result:address:shared:foo:_t [ local-scope load-ingredients # new refers to _t in its ingredient *value* @@ -554,10 +554,10 @@ recipe bar x:number -> result:address:foo:_t [ :(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient_2) recipe main [ - 1:address:foo:point <- bar 3 - 11:foo:point <- copy *1:address:foo:point + 1:address:shared:foo:point <- bar 3 + 11:foo:point <- copy *1:address:shared:foo:point ] -recipe bar x:number -> result:address:foo:_t [ +recipe bar x:number -> result:address:shared:foo:_t [ local-scope load-ingredients # new refers to _t in its ingredient *value* @@ -574,11 +574,11 @@ container foo:_t [ :(scenario shape_shifting_recipe_supports_compound_types) recipe main [ - 1:address:point <- new point:type - 2:address:number <- get-address *1:address:point, y:offset + 1:address:shared:point <- new point:type + 2:address:number <- get-address *1:address:shared:point, y:offset *2:address:number <- copy 34 - 3:address:point <- bar 1:address:point # specialize _t to address:point - 4:point <- copy *3:address:point + 3:address:shared:point <- bar 1:address:shared:point # specialize _t to address:shared:point + 4:point <- copy *3:address:shared:point ] recipe bar a:_t -> result:_t [ local-scope @@ -716,7 +716,7 @@ container d2:_elem [ # static dispatch between shape-shifting variants, _including pointer lookups_ recipe main [ e1:d1:number <- merge 3 - e2:address:d2:number <- new {(d2 number): type} + e2:address:shared:d2:number <- new {(d2 number): type} 1:number/raw <- foo e1 2:number/raw <- foo *e2 # different from previous scenario ] @@ -799,15 +799,15 @@ recipe foo x:_elem -> y:number [ :(scenarios run) :(scenario specialize_most_similar_variant) recipe main [ - 1:address:number <- new number:type - 2:number <- foo 1:address:number + 1:address:shared:number <- new number:type + 2:number <- foo 1:address:shared:number ] recipe foo x:_elem -> y:number [ local-scope load-ingredients reply 34 ] -recipe foo x:address:_elem -> y:number [ +recipe foo x:address:shared:_elem -> y:number [ local-scope load-ingredients reply 35 diff --git a/060immutable.cc b/060immutable.cc index 1ba5aa24..08660ab1 100644 --- a/060immutable.cc +++ b/060immutable.cc @@ -5,7 +5,7 @@ % Hide_warnings = true; recipe main [ local-scope - p:address:point <- new point:type + p:address:shared:point <- new point:type foo *p ] recipe foo p:point [ @@ -20,10 +20,10 @@ $warn: 0 % Hide_warnings = true; recipe main [ local-scope - p:address:point <- new point:type + p:address:shared:point <- new point:type p <- foo p ] -recipe foo p:address:point -> p:address:point [ +recipe foo p:address:shared:point -> p:address:shared:point [ local-scope load-ingredients x:address:number <- get-address *p, x:offset @@ -35,13 +35,13 @@ $warn: 0 % Hide_warnings = true; recipe main [ local-scope - p:address:d1 <- new d1:type + p:address:shared:d1 <- new d1:type q:number <- foo p ] -recipe foo p:address:d1 -> q:number [ +recipe foo p:address:shared:d1 -> q:number [ local-scope load-ingredients - x:address:d1 <- new d1:type + x:address:shared:d1 <- new d1:type y:address:number <- get-address *x, p:offset # ignore this 'p' q <- copy 34 ] @@ -55,10 +55,10 @@ $warn: 0 % Hide_warnings = true; recipe main [ local-scope - p:address:point <- new point:type + p:address:shared:point <- new point:type foo p ] -recipe foo p:address:point [ +recipe foo p:address:shared:point [ local-scope load-ingredients x:address:number <- get-address *p, x:offset @@ -70,15 +70,15 @@ recipe foo p:address:point [ % Hide_warnings = true; recipe main [ local-scope - p:address:point <- new point:type + p:address:shared:point <- new point:type foo p ] -recipe foo p:address:point [ +recipe foo p:address:shared:point [ local-scope load-ingredients bar p ] -recipe bar p:address:point -> p:address:point [ +recipe bar p:address:shared:point -> p:address:shared:point [ local-scope load-ingredients x:address:number <- get-address *p, x:offset @@ -90,13 +90,13 @@ recipe bar p:address:point -> p:address:point [ % Hide_warnings = true; recipe main [ local-scope - p:address:point <- new point:type + p:address:shared:point <- new point:type foo p ] -recipe foo p:address:point [ +recipe foo p:address:shared:point [ local-scope load-ingredients - q:address:point <- copy p + q:address:shared:point <- copy p x:address:number <- get-address *q, x:offset ] +warn: foo: cannot modify q after instruction 'x:address:number <- get-address *q, x:offset' because that would modify ingredient p which is not also a product of foo @@ -104,19 +104,19 @@ recipe foo p:address:point [ :(scenario can_traverse_immutable_ingredients) % Hide_warnings = true; container test-list [ - next:address:test-list + next:address:shared:test-list ] recipe main [ local-scope - p:address:test-list <- new test-list:type + p:address:shared:test-list <- new test-list:type foo p ] -recipe foo p:address:test-list [ +recipe foo p:address:shared:test-list [ local-scope load-ingredients - p2:address:test-list <- bar p + p2:address:shared:test-list <- bar p ] -recipe bar x:address:test-list -> y:address:test-list [ +recipe bar x:address:shared:test-list -> y:address:shared:test-list [ local-scope load-ingredients y <- get *x, next:offset @@ -126,11 +126,11 @@ $warn: 0 :(scenario handle_optional_ingredients_in_immutability_checks) % Hide_warnings = true; recipe main [ - k:address:number <- new number:type + k:address:shared:number <- new number:type test k ] # recipe taking an immutable address ingredient -recipe test k:address:number [ +recipe test k:address:shared:number [ local-scope load-ingredients foo k @@ -139,7 +139,7 @@ recipe test k:address:number [ recipe foo -> [ local-scope load-ingredients - k:address:number, found?:boolean <- next-ingredient + k:address:shared:number, found?:boolean <- next-ingredient ] $warn: 0 @@ -212,25 +212,25 @@ set<long long int> scan_contained_in_product_indices(const instruction& inst, se :(scenario immutability_infects_contained_in_variables) % Hide_warnings = true; container test-list [ - next:address:test-list + next:address:shared:test-list ] recipe main [ local-scope - p:address:test-list <- new test-list:type + p:address:shared:test-list <- new test-list:type foo p ] -recipe foo p:address:test-list [ # p is immutable +recipe foo p:address:shared:test-list [ # p is immutable local-scope load-ingredients - p2:address:test-list <- test-next p # p2 is immutable - p3:address:address:test-list <- get-address *p2, next:offset # signal modification of p2 + p2:address:shared:test-list <- test-next p # p2 is immutable + p3:address:address:shared:test-list <- get-address *p2, next:offset # signal modification of p2 ] -recipe test-next x:address:test-list -> y:address:test-list/contained-in:x [ +recipe test-next x:address:shared:test-list -> y:address:shared:test-list/contained-in:x [ local-scope load-ingredients y <- get *x, next:offset ] -+warn: foo: cannot modify p2 after instruction 'p3:address:address:test-list <- get-address *p2, next:offset' because that would modify ingredient p which is not also a product of foo ++warn: foo: cannot modify p2 after instruction 'p3:address:address:shared:test-list <- get-address *p2, next:offset' because that would modify ingredient p which is not also a product of foo :(code) void check_immutable_ingredient_in_instruction(const instruction& inst, const set<string>& current_ingredient_and_aliases, const string& original_ingredient_name, const recipe& caller) { @@ -315,28 +315,28 @@ set<long long int> ingredient_indices(const instruction& inst, const set<string> :(scenario can_modify_contained_in_addresses) % Hide_warnings = true; container test-list [ - next:address:test-list + next:address:shared:test-list ] recipe main [ local-scope - p:address:test-list <- new test-list:type + p:address:shared:test-list <- new test-list:type foo p ] -recipe foo p:address:test-list -> p:address:test-list [ +recipe foo p:address:shared:test-list -> p:address:shared:test-list [ local-scope load-ingredients - p2:address:test-list <- test-next p + p2:address:shared:test-list <- test-next p p <- test-remove p2, p ] -recipe test-next x:address:test-list -> y:address:test-list [ +recipe test-next x:address:shared:test-list -> y:address:shared:test-list [ local-scope load-ingredients y <- get *x, next:offset ] -recipe test-remove x:address:test-list/contained-in:from, from:address:test-list -> from:address:test-list [ +recipe test-remove x:address:shared:test-list/contained-in:from, from:address:shared:test-list -> from:address:shared:test-list [ local-scope load-ingredients - x2:address:address:test-list <- get-address *x, next:offset # pretend modification + x2:address:address:shared:test-list <- get-address *x, next:offset # pretend modification ] $warn: 0 diff --git a/062scheduler.cc b/062scheduler.cc index cd52f48c..a68646d7 100644 --- a/062scheduler.cc +++ b/062scheduler.cc @@ -517,16 +517,16 @@ case LIMIT_TIME: { :(scenario new_concurrent) recipe f1 [ start-running f2 - 1:address:number/raw <- new number:type + 1:address:shared:number/raw <- new number:type # wait for f2 to complete { loop-unless 4:number/raw } ] recipe f2 [ - 2:address:number/raw <- new number:type + 2:address:shared:number/raw <- new number:type # hack: assumes scheduler implementation - 3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw + 3:boolean/raw <- equal 1:address:shared:number/raw, 2:address:shared:number/raw # signal f2 complete 4:number/raw <- copy 1 ] diff --git a/070text.mu b/070text.mu index 37acdfd5..4dc138a7 100644 --- a/070text.mu +++ b/070text.mu @@ -2,21 +2,21 @@ # to-text-line gets called implicitly in various places # define it to be identical to 'to-text' by default -recipe to-text-line x:_elem -> y:address:array:character [ +recipe to-text-line x:_elem -> y:address:shared:array:character [ local-scope load-ingredients y <- to-text x ] # to-text on text is just the identity function -recipe to-text x:address:array:character -> y:address:array:character [ +recipe to-text x:address:shared:array:character -> y:address:shared:array:character [ local-scope load-ingredients #? $print [to-text text], 10/newline reply x ] -recipe equal a:address:array:character, b:address:array:character -> result:boolean [ +recipe equal a:address:shared:array:character, b:address:shared:array:character -> result:boolean [ local-scope load-ingredients a-len:number <- length *a @@ -49,8 +49,8 @@ recipe equal a:address:array:character, b:address:array:character -> result:bool scenario text-equal-reflexive [ run [ - default-space:address:array:location <- new location:type, 30 - x:address:array:character <- new [abc] + default-space:address:shared:array:location <- new location:type, 30 + x:address:shared:array:character <- new [abc] 3:boolean/raw <- equal x, x ] memory-should-contain [ @@ -60,9 +60,9 @@ scenario text-equal-reflexive [ scenario text-equal-identical [ run [ - default-space:address:array:location <- new location:type, 30 - x:address:array:character <- new [abc] - y:address:array:character <- new [abc] + default-space:address:shared:array:location <- new location:type, 30 + x:address:shared:array:character <- new [abc] + y:address:shared:array:character <- new [abc] 3:boolean/raw <- equal x, y ] memory-should-contain [ @@ -72,9 +72,9 @@ scenario text-equal-identical [ scenario text-equal-distinct-lengths [ run [ - default-space:address:array:location <- new location:type, 30 - x:address:array:character <- new [abc] - y:address:array:character <- new [abcd] + default-space:address:shared:array:location <- new location:type, 30 + x:address:shared:array:character <- new [abc] + y:address:shared:array:character <- new [abcd] 3:boolean/raw <- equal x, y ] memory-should-contain [ @@ -90,9 +90,9 @@ scenario text-equal-distinct-lengths [ scenario text-equal-with-empty [ run [ - default-space:address:array:location <- new location:type, 30 - x:address:array:character <- new [] - y:address:array:character <- new [abcd] + default-space:address:shared:array:location <- new location:type, 30 + x:address:shared:array:character <- new [] + y:address:shared:array:character <- new [abcd] 3:boolean/raw <- equal x, y ] memory-should-contain [ @@ -102,9 +102,9 @@ scenario text-equal-with-empty [ scenario text-equal-common-lengths-but-distinct [ run [ - default-space:address:array:location <- new location:type, 30 - x:address:array:character <- new [abc] - y:address:array:character <- new [abd] + default-space:address:shared:array:location <- new location:type, 30 + x:address:shared:array:character <- new [abc] + y:address:shared:array:character <- new [abd] 3:boolean/raw <- equal x, y ] memory-should-contain [ @@ -115,28 +115,28 @@ scenario text-equal-common-lengths-but-distinct [ # A new type to help incrementally construct texts. container buffer [ length:number - data:address:array:character + data:address:shared:array:character ] -recipe new-buffer capacity:number -> result:address:buffer [ +recipe new-buffer capacity:number -> result:address:shared:buffer [ local-scope load-ingredients result <- new buffer:type len:address:number <- get-address *result, length:offset *len:address:number <- copy 0 - s:address:address:array:character <- get-address *result, data:offset + s:address:address:shared:array:character <- get-address *result, data:offset *s <- new character:type, capacity reply result ] -recipe grow-buffer in:address:buffer -> in:address:buffer [ +recipe grow-buffer in:address:shared:buffer -> in:address:shared:buffer [ local-scope load-ingredients # double buffer size - x:address:address:array:character <- get-address *in, data:offset + x:address:address:shared:array:character <- get-address *in, data:offset oldlen:number <- length **x newlen:number <- multiply oldlen, 2 - olddata:address:array:character <- copy *x + olddata:address:shared:array:character <- copy *x *x <- new character:type, newlen # copy old contents i:number <- copy 0 @@ -151,21 +151,21 @@ recipe grow-buffer in:address:buffer -> in:address:buffer [ } ] -recipe buffer-full? in:address:buffer -> result:boolean [ +recipe buffer-full? in:address:shared:buffer -> result:boolean [ local-scope load-ingredients len:number <- get *in, length:offset - s:address:array:character <- get *in, data:offset + s:address:shared:array:character <- get *in, data:offset capacity:number <- length *s result <- greater-or-equal len, capacity ] # most broadly applicable definition of append to a buffer: just call to-text -recipe append buf:address:buffer, x:_elem -> buf:address:buffer [ +recipe append buf:address:shared:buffer, x:_elem -> buf:address:shared:buffer [ local-scope #? $print [append _elem to buffer], 10/newline load-ingredients - text:address:array:character <- to-text x + text:address:shared:array:character <- to-text x len:number <- length *text i:number <- copy 0 { @@ -178,7 +178,7 @@ recipe append buf:address:buffer, x:_elem -> buf:address:buffer [ } ] -recipe append in:address:buffer, c:character -> in:address:buffer [ +recipe append in:address:shared:buffer, c:character -> in:address:shared:buffer [ local-scope #? $print [append character to buffer], 10/newline load-ingredients @@ -198,7 +198,7 @@ recipe append in:address:buffer, c:character -> in:address:buffer [ break-unless full? in <- grow-buffer in } - s:address:array:character <- get *in, data:offset + s:address:shared:array:character <- get *in, data:offset dest:address:character <- index-address *s, *len *dest <- copy c *len <- add *len, 1 @@ -207,20 +207,20 @@ recipe append in:address:buffer, c:character -> in:address:buffer [ scenario buffer-append-works [ run [ local-scope - x:address:buffer <- new-buffer 3 - s1:address:array:character <- get *x:address:buffer, data:offset - x:address:buffer <- append x:address:buffer, 97 # 'a' - x:address:buffer <- append x:address:buffer, 98 # 'b' - x:address:buffer <- append x:address:buffer, 99 # 'c' - s2:address:array:character <- get *x:address:buffer, data:offset - 1:boolean/raw <- equal s1:address:array:character, s2:address:array:character - 2:array:character/raw <- copy *s2:address:array:character + x:address:shared:buffer <- new-buffer 3 + s1:address:shared:array:character <- get *x, data:offset + x <- append x, 97 # 'a' + x <- append x, 98 # 'b' + x <- append x, 99 # 'c' + s2:address:shared:array:character <- get *x, data:offset + 1:boolean/raw <- equal s1, s2 + 2:array:character/raw <- copy *s2 +buffer-filled - x:address:buffer <- append x:address:buffer, 100 # 'd' - s3:address:array:character <- get *x:address:buffer, data:offset - 10:boolean/raw <- equal s1:address:array:character, s3:address:array:character - 11:number/raw <- get *x:address:buffer, length:offset - 12:array:character/raw <- copy *s3:address:array:character + x <- append x, 100 # 'd' + s3:address:shared:array:character <- get *x, data:offset + 10:boolean/raw <- equal s1, s3 + 11:number/raw <- get *x, length:offset + 12:array:character/raw <- copy *s3 ] memory-should-contain [ # before +buffer-filled @@ -245,11 +245,11 @@ scenario buffer-append-works [ scenario buffer-append-handles-backspace [ run [ local-scope - x:address:buffer <- new-buffer 3 + x:address:shared:buffer <- new-buffer 3 x <- append x, 97 # 'a' x <- append x, 98 # 'b' x <- append x, 8/backspace - s:address:array:character <- buffer-to-array x + s:address:shared:array:character <- buffer-to-array x 1:array:character/raw <- copy *s ] memory-should-contain [ @@ -259,7 +259,7 @@ scenario buffer-append-handles-backspace [ ] ] -recipe to-text n:number -> result:address:array:character [ +recipe to-text n:number -> result:address:shared:array:character [ local-scope load-ingredients # is n zero? @@ -277,14 +277,14 @@ recipe to-text n:number -> result:address:array:character [ n <- multiply n, -1 } # add digits from right to left into intermediate buffer - tmp:address:buffer <- new-buffer 30 + tmp:address:shared:buffer <- new-buffer 30 digit-base:number <- copy 48 # '0' { done?:boolean <- equal n, 0 break-if done? n, digit:number <- divide-with-remainder n, 10 c:character <- add digit-base, digit - tmp:address:buffer <- append tmp, c + tmp:address:shared:buffer <- append tmp, c loop } # add sign @@ -294,7 +294,7 @@ recipe to-text n:number -> result:address:array:character [ } # reverse buffer into text result len:number <- get *tmp, length:offset - buf:address:array:character <- get *tmp, data:offset + buf:address:shared:array:character <- get *tmp, data:offset result <- new character:type, len i:number <- subtract len, 1 # source index, decreasing j:number <- copy 0 # destination index, increasing @@ -312,7 +312,7 @@ recipe to-text n:number -> result:address:array:character [ } ] -recipe buffer-to-array in:address:buffer -> result:address:array:character [ +recipe buffer-to-array in:address:shared:buffer -> result:address:shared:array:character [ local-scope load-ingredients { @@ -321,7 +321,7 @@ recipe buffer-to-array in:address:buffer -> result:address:array:character [ reply 0 } len:number <- get *in, length:offset - s:address:array:character <- get *in, data:offset + s:address:shared:array:character <- get *in, data:offset # we can't just return s because it is usually the wrong length result <- new character:type, len i:number <- copy 0 @@ -338,8 +338,8 @@ recipe buffer-to-array in:address:buffer -> result:address:array:character [ scenario integer-to-decimal-digit-zero [ run [ - 1:address:array:character/raw <- to-text 0 - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- to-text 0 + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [0] @@ -348,8 +348,8 @@ scenario integer-to-decimal-digit-zero [ scenario integer-to-decimal-digit-positive [ run [ - 1:address:array:character/raw <- to-text 234 - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- to-text 234 + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [234] @@ -358,8 +358,8 @@ scenario integer-to-decimal-digit-positive [ scenario integer-to-decimal-digit-negative [ run [ - 1:address:array:character/raw <- to-text -1 - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- to-text -1 + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2 <- 2 @@ -368,7 +368,7 @@ scenario integer-to-decimal-digit-negative [ ] ] -recipe append a:address:array:character, b:address:array:character -> result:address:array:character [ +recipe append a:address:shared:array:character, b:address:shared:array:character -> result:address:shared:array:character [ local-scope #? $print [append text to text], 10/newline load-ingredients @@ -410,10 +410,10 @@ recipe append a:address:array:character, b:address:array:character -> result:add scenario text-append-1 [ run [ - 1:address:array:character/raw <- new [hello,] - 2:address:array:character/raw <- new [ world!] - 3:address:array:character/raw <- append 1:address:array:character/raw, 2:address:array:character/raw - 4:array:character/raw <- copy *3:address:array:character/raw + 1:address:shared:array:character/raw <- new [hello,] + 2:address:shared:array:character/raw <- new [ world!] + 3:address:shared:array:character/raw <- append 1:address:shared:array:character/raw, 2:address:shared:array:character/raw + 4:array:character/raw <- copy *3:address:shared:array:character/raw ] memory-should-contain [ 4:array:character <- [hello, world!] @@ -422,16 +422,16 @@ scenario text-append-1 [ scenario replace-character-in-text [ run [ - 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- replace 1:address:array:character/raw, 98/b, 122/z - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- new [abc] + 1:address:shared:array:character/raw <- replace 1:address:shared:array:character/raw, 98/b, 122/z + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [azc] ] ] -recipe replace s:address:array:character, oldc:character, newc:character, from:number/optional -> s:address:array:character [ +recipe replace s:address:shared:array:character, oldc:character, newc:character, from:number/optional -> s:address:shared:array:character [ local-scope load-ingredients len:number <- length *s @@ -446,9 +446,9 @@ recipe replace s:address:array:character, oldc:character, newc:character, from:n scenario replace-character-at-start [ run [ - 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- replace 1:address:array:character/raw, 97/a, 122/z - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- new [abc] + 1:address:shared:array:character/raw <- replace 1:address:shared:array:character/raw, 97/a, 122/z + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [zbc] @@ -457,9 +457,9 @@ scenario replace-character-at-start [ scenario replace-character-at-end [ run [ - 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- replace 1:address:array:character/raw, 99/c, 122/z - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- new [abc] + 1:address:shared:array:character/raw <- replace 1:address:shared:array:character/raw, 99/c, 122/z + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [abz] @@ -468,9 +468,9 @@ scenario replace-character-at-end [ scenario replace-character-missing [ run [ - 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- replace 1:address:array:character/raw, 100/d, 122/z - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- new [abc] + 1:address:shared:array:character/raw <- replace 1:address:shared:array:character/raw, 100/d, 122/z + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [abc] @@ -479,9 +479,9 @@ scenario replace-character-missing [ scenario replace-all-characters [ run [ - 1:address:array:character/raw <- new [banana] - 1:address:array:character/raw <- replace 1:address:array:character/raw, 97/a, 122/z - 2:array:character/raw <- copy *1:address:array:character/raw + 1:address:shared:array:character/raw <- new [banana] + 1:address:shared:array:character/raw <- replace 1:address:shared:array:character/raw, 97/a, 122/z + 2:array:character/raw <- copy *1:address:shared:array:character/raw ] memory-should-contain [ 2:array:character <- [bznznz] @@ -489,7 +489,7 @@ scenario replace-all-characters [ ] # replace underscores in first with remaining args -recipe interpolate template:address:array:character -> result:address:array:character [ +recipe interpolate template:address:shared:array:character -> result:address:shared:array:character [ local-scope load-ingredients # consume just the template # compute result-len, space to allocate for result @@ -497,7 +497,7 @@ recipe interpolate template:address:array:character -> result:address:array:char result-len:number <- copy tem-len { # while ingredients remain - a:address:array:character, arg-received?:boolean <- next-ingredient + a:address:shared:array:character, arg-received?:boolean <- next-ingredient break-unless arg-received? # result-len = result-len + arg.length - 1 (for the 'underscore' being replaced) a-len:number <- length *a @@ -507,13 +507,13 @@ recipe interpolate template:address:array:character -> result:address:array:char } rewind-ingredients _ <- next-ingredient # skip template - result:address:array:character <- new character:type, result-len + result <- new character:type, result-len # repeatedly copy sections of template and 'holes' into result result-idx:number <- copy 0 i:number <- copy 0 { # while arg received - a:address:array:character, arg-received?:boolean <- next-ingredient + a:address:shared:array:character, arg-received?:boolean <- next-ingredient break-unless arg-received? # copy template into result until '_' { @@ -567,10 +567,10 @@ recipe interpolate template:address:array:character -> result:address:array:char scenario interpolate-works [ run [ - 1:address:array:character/raw <- new [abc _] - 2:address:array:character/raw <- new [def] - 3:address:array:character/raw <- interpolate 1:address:array:character/raw, 2:address:array:character/raw - 4:array:character/raw <- copy *3:address:array:character/raw + 1:address:shared:array:character/raw <- new [abc _] + 2:address:shared:array:character/raw <- new [def] + 3:address:shared:array:character/raw <- interpolate 1:address:shared:array:character/raw, 2:address:shared:array:character/raw + 4:array:character/raw <- copy *3:address:shared:array:character/raw ] memory-should-contain [ 4:array:character <- [abc def] @@ -579,10 +579,10 @@ scenario interpolate-works [ scenario interpolate-at-start [ run [ - 1:address:array:character/raw <- new [_, hello!] - 2:address:array:character/raw <- new [abc] - 3:address:array:character/raw <- interpolate 1:address:array:character/raw, 2:address:array:character/raw - 4:array:character/raw <- copy *3:address:array:character/raw + 1:address:shared:array:character/raw <- new [_, hello!] + 2:address:shared:array:character/raw <- new [abc] + 3:address:shared:array:character/raw <- interpolate 1:address:shared:array:character/raw, 2:address:shared:array:character/raw + 4:array:character/raw <- copy *3:address:shared:array:character/raw ] memory-should-contain [ 4:array:character <- [abc, hello!] @@ -592,10 +592,10 @@ scenario interpolate-at-start [ scenario interpolate-at-end [ run [ - 1:address:array:character/raw <- new [hello, _] - 2:address:array:character/raw <- new [abc] - 3:address:array:character/raw <- interpolate 1:address:array:character/raw, 2:address:array:character/raw - 4:array:character/raw <- copy *3:address:array:character/raw + 1:address:shared:array:character/raw <- new [hello, _] + 2:address:shared:array:character/raw <- new [abc] + 3:address:shared:array:character/raw <- interpolate 1:address:shared:array:character/raw, 2:address:shared:array:character/raw + 4:array:character/raw <- copy *3:address:shared:array:character/raw ] memory-should-contain [ 4:array:character <- [hello, abc] @@ -664,7 +664,7 @@ recipe space? c:character -> result:boolean [ result <- equal c, 12288/ideographic-space ] -recipe trim s:address:array:character -> result:address:array:character [ +recipe trim s:address:shared:array:character -> result:address:shared:array:character [ local-scope load-ingredients len:number <- length *s @@ -696,7 +696,7 @@ recipe trim s:address:array:character -> result:address:array:character [ } # result = new character[end+1 - start] new-len:number <- subtract end, start, -1 - result:address:array:character <- new character:type, new-len + result:address:shared:array:character <- new character:type, new-len # copy the untrimmed parts between start and end i:number <- copy start j:number <- copy 0 @@ -716,9 +716,9 @@ recipe trim s:address:array:character -> result:address:array:character [ scenario trim-unmodified [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- trim 1:address:array:character - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- trim 1:address:shared:array:character + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [abc] @@ -727,9 +727,9 @@ scenario trim-unmodified [ scenario trim-left [ run [ - 1:address:array:character <- new [ abc] - 2:address:array:character <- trim 1:address:array:character - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [ abc] + 2:address:shared:array:character <- trim 1:address:shared:array:character + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [abc] @@ -738,9 +738,9 @@ scenario trim-left [ scenario trim-right [ run [ - 1:address:array:character <- new [abc ] - 2:address:array:character <- trim 1:address:array:character - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [abc ] + 2:address:shared:array:character <- trim 1:address:shared:array:character + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [abc] @@ -749,9 +749,9 @@ scenario trim-right [ scenario trim-left-right [ run [ - 1:address:array:character <- new [ abc ] - 2:address:array:character <- trim 1:address:array:character - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [ abc ] + 2:address:shared:array:character <- trim 1:address:shared:array:character + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [abc] @@ -760,17 +760,17 @@ scenario trim-left-right [ scenario trim-newline-tab [ run [ - 1:address:array:character <- new [ abc + 1:address:shared:array:character <- new [ abc ] - 2:address:array:character <- trim 1:address:array:character - 3:array:character <- copy *2:address:array:character + 2:address:shared:array:character <- trim 1:address:shared:array:character + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [abc] ] ] -recipe find-next text:address:array:character, pattern:character, idx:number -> next-index:number [ +recipe find-next text:address:shared:array:character, pattern:character, idx:number -> next-index:number [ local-scope load-ingredients len:number <- length *text @@ -788,8 +788,8 @@ recipe find-next text:address:array:character, pattern:character, idx:number -> scenario text-find-next [ run [ - 1:address:array:character <- new [a/b] - 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index + 1:address:shared:array:character <- new [a/b] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 1 @@ -798,8 +798,8 @@ scenario text-find-next [ scenario text-find-next-empty [ run [ - 1:address:array:character <- new [] - 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index + 1:address:shared:array:character <- new [] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 0 @@ -808,8 +808,8 @@ scenario text-find-next-empty [ scenario text-find-next-initial [ run [ - 1:address:array:character <- new [/abc] - 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index + 1:address:shared:array:character <- new [/abc] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 0 # prefix match @@ -818,8 +818,8 @@ scenario text-find-next-initial [ scenario text-find-next-final [ run [ - 1:address:array:character <- new [abc/] - 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index + 1:address:shared:array:character <- new [abc/] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 3 # suffix match @@ -828,8 +828,8 @@ scenario text-find-next-final [ scenario text-find-next-missing [ run [ - 1:address:array:character <- new [abc] - 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index + 1:address:shared:array:character <- new [abc] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 3 # no match @@ -838,8 +838,8 @@ scenario text-find-next-missing [ scenario text-find-next-invalid-index [ run [ - 1:address:array:character <- new [abc] - 2:number <- find-next 1:address:array:character, 47/slash, 4/start-index + 1:address:shared:array:character <- new [abc] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 4/start-index ] memory-should-contain [ 2 <- 4 # no change @@ -848,8 +848,8 @@ scenario text-find-next-invalid-index [ scenario text-find-next-first [ run [ - 1:address:array:character <- new [ab/c/] - 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index + 1:address:shared:array:character <- new [ab/c/] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 0/start-index ] memory-should-contain [ 2 <- 2 # first '/' of multiple @@ -858,8 +858,8 @@ scenario text-find-next-first [ scenario text-find-next-second [ run [ - 1:address:array:character <- new [ab/c/] - 2:number <- find-next 1:address:array:character, 47/slash, 3/start-index + 1:address:shared:array:character <- new [ab/c/] + 2:number <- find-next 1:address:shared:array:character, 47/slash, 3/start-index ] memory-should-contain [ 2 <- 4 # second '/' of multiple @@ -868,7 +868,7 @@ scenario text-find-next-second [ # search for a pattern of multiple characters # fairly dumb algorithm -recipe find-next text:address:array:character, pattern:address:array:character, idx:number -> next-index:number [ +recipe find-next text:address:shared:array:character, pattern:address:shared:array:character, idx:number -> next-index:number [ local-scope load-ingredients first:character <- index *pattern, 0 @@ -890,9 +890,9 @@ recipe find-next text:address:array:character, pattern:address:array:character, scenario find-next-text-1 [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [bc] - 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [bc] + 3:number <- find-next 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 1 @@ -901,9 +901,9 @@ scenario find-next-text-1 [ scenario find-next-text-2 [ run [ - 1:address:array:character <- new [abcd] - 2:address:array:character <- new [bc] - 3:number <- find-next 1:address:array:character, 2:address:array:character, 1 + 1:address:shared:array:character <- new [abcd] + 2:address:shared:array:character <- new [bc] + 3:number <- find-next 1:address:shared:array:character, 2:address:shared:array:character, 1 ] memory-should-contain [ 3 <- 1 @@ -912,9 +912,9 @@ scenario find-next-text-2 [ scenario find-next-no-match [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [bd] - 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [bd] + 3:number <- find-next 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 3 # not found @@ -923,9 +923,9 @@ scenario find-next-no-match [ scenario find-next-suffix-match [ run [ - 1:address:array:character <- new [abcd] - 2:address:array:character <- new [cd] - 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abcd] + 2:address:shared:array:character <- new [cd] + 3:number <- find-next 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 2 @@ -934,9 +934,9 @@ scenario find-next-suffix-match [ scenario find-next-suffix-match-2 [ run [ - 1:address:array:character <- new [abcd] - 2:address:array:character <- new [cde] - 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abcd] + 2:address:shared:array:character <- new [cde] + 3:number <- find-next 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 4 # not found @@ -944,7 +944,7 @@ scenario find-next-suffix-match-2 [ ] # checks if pattern matches at index 'idx' -recipe match-at text:address:array:character, pattern:address:array:character, idx:number -> result:boolean [ +recipe match-at text:address:shared:array:character, pattern:address:shared:array:character, idx:number -> result:boolean [ local-scope load-ingredients pattern-len:number <- length *pattern @@ -977,9 +977,9 @@ recipe match-at text:address:array:character, pattern:address:array:character, i scenario match-at-checks-pattern-at-index [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [ab] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [ab] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 1 # match found @@ -988,8 +988,8 @@ scenario match-at-checks-pattern-at-index [ scenario match-at-reflexive [ run [ - 1:address:array:character <- new [abc] - 3:boolean <- match-at 1:address:array:character, 1:address:array:character, 0 + 1:address:shared:array:character <- new [abc] + 3:boolean <- match-at 1:address:shared:array:character, 1:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 1 # match found @@ -998,9 +998,9 @@ scenario match-at-reflexive [ scenario match-at-outside-bounds [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [a] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 4 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [a] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 4 ] memory-should-contain [ 3 <- 0 # never matches @@ -1009,9 +1009,9 @@ scenario match-at-outside-bounds [ scenario match-at-empty-pattern [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 1 # always matches empty pattern given a valid index @@ -1020,9 +1020,9 @@ scenario match-at-empty-pattern [ scenario match-at-empty-pattern-outside-bound [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 4 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 4 ] memory-should-contain [ 3 <- 0 # no match @@ -1031,9 +1031,9 @@ scenario match-at-empty-pattern-outside-bound [ scenario match-at-empty-text [ run [ - 1:address:array:character <- new [] - 2:address:array:character <- new [abc] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [] + 2:address:shared:array:character <- new [abc] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 0 # no match @@ -1042,8 +1042,8 @@ scenario match-at-empty-text [ scenario match-at-empty-against-empty [ run [ - 1:address:array:character <- new [] - 3:boolean <- match-at 1:address:array:character, 1:address:array:character, 0 + 1:address:shared:array:character <- new [] + 3:boolean <- match-at 1:address:shared:array:character, 1:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 1 # matches because pattern is also empty @@ -1052,9 +1052,9 @@ scenario match-at-empty-against-empty [ scenario match-at-inside-bounds [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [bc] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 1 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [bc] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 1 ] memory-should-contain [ 3 <- 1 # match @@ -1063,16 +1063,16 @@ scenario match-at-inside-bounds [ scenario match-at-inside-bounds-2 [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [bc] - 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 0 + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [bc] + 3:boolean <- match-at 1:address:shared:array:character, 2:address:shared:array:character, 0 ] memory-should-contain [ 3 <- 0 # no match ] ] -recipe split s:address:array:character, delim:character -> result:address:array:address:array:character [ +recipe split s:address:shared:array:character, delim:character -> result:address:shared:array:address:shared:array:character [ local-scope load-ingredients # empty text? return empty array @@ -1080,7 +1080,7 @@ recipe split s:address:array:character, delim:character -> result:address:array: { empty?:boolean <- equal len, 0 break-unless empty? - result <- new {(address array character): type}, 0 + result <- new {(address shared array character): type}, 0 reply } # count #pieces we need room for @@ -1095,7 +1095,7 @@ recipe split s:address:array:character, delim:character -> result:address:array: loop } # allocate space - result <- new {(address array character): type}, count + result <- new {(address shared array character): type}, count # repeatedly copy slices start..end until delimiter into result[curr-result] curr-result:number <- copy 0 start:number <- copy 0 @@ -1105,7 +1105,7 @@ recipe split s:address:array:character, delim:character -> result:address:array: break-if done? end:number <- find-next s, delim, start # copy start..end into result[curr-result] - dest:address:address:array:character <- index-address *result, curr-result + dest:address:address:shared:array:character <- index-address *result, curr-result *dest <- copy-range s, start, end # slide over to next slice start <- add end, 1 @@ -1116,13 +1116,13 @@ recipe split s:address:array:character, delim:character -> result:address:array: scenario text-split-1 [ run [ - 1:address:array:character <- new [a/b] - 2:address:array:address:array:character <- split 1:address:array:character, 47/slash - 3:number <- length *2:address:array:address:array:character - 4:address:array:character <- index *2:address:array:address:array:character, 0 - 5:address:array:character <- index *2:address:array:address:array:character, 1 - 10:array:character <- copy *4:address:array:character - 20:array:character <- copy *5:address:array:character + 1:address:shared:array:character <- new [a/b] + 2:address:shared:array:address:shared:array:character <- split 1:address:shared:array:character, 47/slash + 3:number <- length *2:address:shared:array:address:shared:array:character + 4:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 0 + 5:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 1 + 10:array:character <- copy *4:address:shared:array:character + 20:array:character <- copy *5:address:shared:array:character ] memory-should-contain [ 3 <- 2 # length of result @@ -1133,15 +1133,15 @@ scenario text-split-1 [ scenario text-split-2 [ run [ - 1:address:array:character <- new [a/b/c] - 2:address:array:address:array:character <- split 1:address:array:character, 47/slash - 3:number <- length *2:address:array:address:array:character - 4:address:array:character <- index *2:address:array:address:array:character, 0 - 5:address:array:character <- index *2:address:array:address:array:character, 1 - 6:address:array:character <- index *2:address:array:address:array:character, 2 - 10:array:character <- copy *4:address:array:character - 20:array:character <- copy *5:address:array:character - 30:array:character <- copy *6:address:array:character + 1:address:shared:array:character <- new [a/b/c] + 2:address:shared:array:address:shared:array:character <- split 1:address:shared:array:character, 47/slash + 3:number <- length *2:address:shared:array:address:shared:array:character + 4:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 0 + 5:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 1 + 6:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 2 + 10:array:character <- copy *4:address:shared:array:character + 20:array:character <- copy *5:address:shared:array:character + 30:array:character <- copy *6:address:shared:array:character ] memory-should-contain [ 3 <- 3 # length of result @@ -1153,11 +1153,11 @@ scenario text-split-2 [ scenario text-split-missing [ run [ - 1:address:array:character <- new [abc] - 2:address:array:address:array:character <- split 1:address:array:character, 47/slash - 3:number <- length *2:address:array:address:array:character - 4:address:array:character <- index *2:address:array:address:array:character, 0 - 10:array:character <- copy *4:address:array:character + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:address:shared:array:character <- split 1:address:shared:array:character, 47/slash + 3:number <- length *2:address:shared:array:address:shared:array:character + 4:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 0 + 10:array:character <- copy *4:address:shared:array:character ] memory-should-contain [ 3 <- 1 # length of result @@ -1167,9 +1167,9 @@ scenario text-split-missing [ scenario text-split-empty [ run [ - 1:address:array:character <- new [] - 2:address:array:address:array:character <- split 1:address:array:character, 47/slash - 3:number <- length *2:address:array:address:array:character + 1:address:shared:array:character <- new [] + 2:address:shared:array:address:shared:array:character <- split 1:address:shared:array:character, 47/slash + 3:number <- length *2:address:shared:array:address:shared:array:character ] memory-should-contain [ 3 <- 0 # empty result @@ -1178,17 +1178,17 @@ scenario text-split-empty [ scenario text-split-empty-piece [ run [ - 1:address:array:character <- new [a/b//c] - 2:address:array:address:array:character <- split 1:address:array:character, 47/slash - 3:number <- length *2:address:array:address:array:character - 4:address:array:character <- index *2:address:array:address:array:character, 0 - 5:address:array:character <- index *2:address:array:address:array:character, 1 - 6:address:array:character <- index *2:address:array:address:array:character, 2 - 7:address:array:character <- index *2:address:array:address:array:character, 3 - 10:array:character <- copy *4:address:array:character - 20:array:character <- copy *5:address:array:character - 30:array:character <- copy *6:address:array:character - 40:array:character <- copy *7:address:array:character + 1:address:shared:array:character <- new [a/b//c] + 2:address:shared:array:address:shared:array:character <- split 1:address:shared:array:character, 47/slash + 3:number <- length *2:address:shared:array:address:shared:array:character + 4:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 0 + 5:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 1 + 6:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 2 + 7:address:shared:array:character <- index *2:address:shared:array:address:shared:array:character, 3 + 10:array:character <- copy *4:address:shared:array:character + 20:array:character <- copy *5:address:shared:array:character + 30:array:character <- copy *6:address:shared:array:character + 40:array:character <- copy *7:address:shared:array:character ] memory-should-contain [ 3 <- 4 # length of result @@ -1199,7 +1199,7 @@ scenario text-split-empty-piece [ ] ] -recipe split-first text:address:array:character, delim:character -> x:address:array:character, y:address:array:character [ +recipe split-first text:address:shared:array:character, delim:character -> x:address:shared:array:character, y:address:shared:array:character [ local-scope load-ingredients # empty text? return empty texts @@ -1207,22 +1207,22 @@ recipe split-first text:address:array:character, delim:character -> x:address:ar { empty?:boolean <- equal len, 0 break-unless empty? - x:address:array:character <- new [] - y:address:array:character <- new [] + x:address:shared:array:character <- new [] + y:address:shared:array:character <- new [] reply } idx:number <- find-next text, delim, 0 - x:address:array:character <- copy-range text, 0, idx + x:address:shared:array:character <- copy-range text, 0, idx idx <- add idx, 1 - y:address:array:character <- copy-range text, idx, len + y:address:shared:array:character <- copy-range text, idx, len ] scenario text-split-first [ run [ - 1:address:array:character <- new [a/b] - 2:address:array:character, 3:address:array:character <- split-first 1:address:array:character, 47/slash - 10:array:character <- copy *2:address:array:character - 20:array:character <- copy *3:address:array:character + 1:address:shared:array:character <- new [a/b] + 2:address:shared:array:character, 3:address:shared:array:character <- split-first 1:address:shared:array:character, 47/slash + 10:array:character <- copy *2:address:shared:array:character + 20:array:character <- copy *3:address:shared:array:character ] memory-should-contain [ 10:array:character <- [a] @@ -1230,7 +1230,7 @@ scenario text-split-first [ ] ] -recipe copy-range buf:address:array:character, start:number, end:number -> result:address:array:character [ +recipe copy-range buf:address:shared:array:character, start:number, end:number -> result:address:shared:array:character [ local-scope load-ingredients # if end is out of bounds, trim it @@ -1238,7 +1238,7 @@ recipe copy-range buf:address:array:character, start:number, end:number -> resul end:number <- min len, end # allocate space for result len <- subtract end, start - result:address:array:character <- new character:type, len + result:address:shared:array:character <- new character:type, len # copy start..end into result[curr-result] src-idx:number <- copy start dest-idx:number <- copy 0 @@ -1256,9 +1256,9 @@ recipe copy-range buf:address:array:character, start:number, end:number -> resul scenario text-copy-copies-partial-text [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- copy-range 1:address:array:character, 1, 3 - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- copy-range 1:address:shared:array:character, 1, 3 + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [bc] @@ -1267,9 +1267,9 @@ scenario text-copy-copies-partial-text [ scenario text-copy-out-of-bounds [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- copy-range 1:address:array:character, 2, 4 - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- copy-range 1:address:shared:array:character, 2, 4 + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [c] @@ -1278,9 +1278,9 @@ scenario text-copy-out-of-bounds [ scenario text-copy-out-of-bounds-2 [ run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- copy-range 1:address:array:character, 3, 3 - 3:array:character <- copy *2:address:array:character + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- copy-range 1:address:shared:array:character, 3, 3 + 3:array:character <- copy *2:address:shared:array:character ] memory-should-contain [ 3:array:character <- [] diff --git a/071channel.mu b/071channel.mu index f331904c..3cff3b7c 100644 --- a/071channel.mu +++ b/071channel.mu @@ -10,9 +10,9 @@ scenario channel [ run [ - 1:address:channel <- new-channel 3/capacity - 1:address:channel <- write 1:address:channel, 34 - 2:character, 1:address:channel <- read 1:address:channel + 1:address:shared:channel <- new-channel 3/capacity + 1:address:shared:channel <- write 1:address:shared:channel, 34 + 2:character, 1:address:shared:channel <- read 1:address:shared:channel ] memory-should-contain [ 2 <- 34 @@ -28,11 +28,10 @@ container channel [ # A circular buffer contains values from index first-full up to (but not # including) index first-empty. The reader always modifies it at first-full, # while the writer always modifies it at first-empty. - data:address:array:character + data:address:shared:array:character ] -# result:address:channel <- new-channel capacity:number -recipe new-channel capacity:number -> result:address:channel [ +recipe new-channel capacity:number -> result:address:shared:channel [ local-scope load-ingredients result <- new channel:type @@ -44,11 +43,11 @@ recipe new-channel capacity:number -> result:address:channel [ *free <- copy 0 # result.data = new location[ingredient+1] capacity <- add capacity, 1 # unused slot for 'full?' below - dest:address:address:array:character <- get-address *result, data:offset + dest:address:address:shared:array:character <- get-address *result, data:offset *dest <- new character:type, capacity ] -recipe write chan:address:channel, val:character -> chan:address:channel [ +recipe write chan:address:shared:channel, val:character -> chan:address:shared:channel [ local-scope load-ingredients { @@ -59,7 +58,7 @@ recipe write chan:address:channel, val:character -> chan:address:channel [ wait-for-location *full-address } # store val - circular-buffer:address:array:character <- get *chan, data:offset + circular-buffer:address:shared:array:character <- get *chan, data:offset free:address:number <- get-address *chan, first-free:offset dest:address:character <- index-address *circular-buffer, *free *dest <- copy val @@ -74,7 +73,7 @@ recipe write chan:address:channel, val:character -> chan:address:channel [ } ] -recipe read chan:address:channel -> result:character, chan:address:channel [ +recipe read chan:address:shared:channel -> result:character, chan:address:shared:channel [ local-scope load-ingredients { @@ -86,7 +85,7 @@ recipe read chan:address:channel -> result:character, chan:address:channel [ } # read result full:address:number <- get-address *chan, first-full:offset - circular-buffer:address:array:character <- get *chan, data:offset + circular-buffer:address:shared:array:character <- get *chan, data:offset result <- index *circular-buffer, *full # mark its slot as empty *full <- add *full, 1 @@ -99,7 +98,7 @@ recipe read chan:address:channel -> result:character, chan:address:channel [ } ] -recipe clear-channel chan:address:channel -> chan:address:channel [ +recipe clear-channel chan:address:shared:channel -> chan:address:shared:channel [ local-scope load-ingredients { @@ -111,9 +110,9 @@ recipe clear-channel chan:address:channel -> chan:address:channel [ scenario channel-initialization [ run [ - 1:address:channel <- new-channel 3/capacity - 2:number <- get *1:address:channel, first-full:offset - 3:number <- get *1:address:channel, first-free:offset + 1:address:shared:channel <- new-channel 3/capacity + 2:number <- get *1:address:shared:channel, first-full:offset + 3:number <- get *1:address:shared:channel, first-free:offset ] memory-should-contain [ 2 <- 0 # first-full @@ -123,10 +122,10 @@ scenario channel-initialization [ scenario channel-write-increments-free [ run [ - 1:address:channel <- new-channel 3/capacity - 1:address:channel <- write 1:address:channel, 34 - 2:number <- get *1:address:channel, first-full:offset - 3:number <- get *1:address:channel, first-free:offset + 1:address:shared:channel <- new-channel 3/capacity + 1:address:shared:channel <- write 1:address:shared:channel, 34 + 2:number <- get *1:address:shared:channel, first-full:offset + 3:number <- get *1:address:shared:channel, first-free:offset ] memory-should-contain [ 2 <- 0 # first-full @@ -136,11 +135,11 @@ scenario channel-write-increments-free [ scenario channel-read-increments-full [ run [ - 1:address:channel <- new-channel 3/capacity - 1:address:channel <- write 1:address:channel, 34 - _, 1:address:channel <- read 1:address:channel - 2:number <- get *1:address:channel, first-full:offset - 3:number <- get *1:address:channel, first-free:offset + 1:address:shared:channel <- new-channel 3/capacity + 1:address:shared:channel <- write 1:address:shared:channel, 34 + _, 1:address:shared:channel <- read 1:address:shared:channel + 2:number <- get *1:address:shared:channel, first-full:offset + 3:number <- get *1:address:shared:channel, first-free:offset ] memory-should-contain [ 2 <- 1 # first-full @@ -151,19 +150,19 @@ scenario channel-read-increments-full [ scenario channel-wrap [ run [ # channel with just 1 slot - 1:address:channel <- new-channel 1/capacity + 1:address:shared:channel <- new-channel 1/capacity # write and read a value - 1:address:channel <- write 1:address:channel, 34 - _, 1:address:channel <- read 1:address:channel + 1:address:shared:channel <- write 1:address:shared:channel, 34 + _, 1:address:shared:channel <- read 1:address:shared:channel # first-free will now be 1 - 2:number <- get *1:address:channel, first-free:offset - 3:number <- get *1:address:channel, first-free:offset + 2:number <- get *1:address:shared:channel, first-free:offset + 3:number <- get *1:address:shared:channel, first-free:offset # write second value, verify that first-free wraps - 1:address:channel <- write 1:address:channel, 34 - 4:number <- get *1:address:channel, first-free:offset + 1:address:shared:channel <- write 1:address:shared:channel, 34 + 4:number <- get *1:address:shared:channel, first-free:offset # read second value, verify that first-full wraps - _, 1:address:channel <- read 1:address:channel - 5:number <- get *1:address:channel, first-full:offset + _, 1:address:shared:channel <- read 1:address:shared:channel + 5:number <- get *1:address:shared:channel, first-full:offset ] memory-should-contain [ 2 <- 1 # first-free after first write @@ -176,7 +175,7 @@ scenario channel-wrap [ ## helpers # An empty channel has first-empty and first-full both at the same value. -recipe channel-empty? chan:address:channel -> result:boolean [ +recipe channel-empty? chan:address:shared:channel -> result:boolean [ local-scope load-ingredients # return chan.first-full == chan.first-free @@ -187,7 +186,7 @@ recipe channel-empty? chan:address:channel -> result:boolean [ # A full channel has first-empty just before first-full, wasting one slot. # (Other alternatives: https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction) -recipe channel-full? chan:address:channel -> result:boolean [ +recipe channel-full? chan:address:shared:channel -> result:boolean [ local-scope load-ingredients # tmp = chan.first-free + 1 @@ -205,19 +204,18 @@ recipe channel-full? chan:address:channel -> result:boolean [ result <- equal full, tmp ] -# result:number <- channel-capacity chan:address:channel -recipe channel-capacity chan:address:channel -> result:number [ +recipe channel-capacity chan:address:shared:channel -> result:number [ local-scope load-ingredients - q:address:array:character <- get *chan, data:offset + q:address:shared:array:character <- get *chan, data:offset result <- length *q ] scenario channel-new-empty-not-full [ run [ - 1:address:channel <- new-channel 3/capacity - 2:boolean <- channel-empty? 1:address:channel - 3:boolean <- channel-full? 1:address:channel + 1:address:shared:channel <- new-channel 3/capacity + 2:boolean <- channel-empty? 1:address:shared:channel + 3:boolean <- channel-full? 1:address:shared:channel ] memory-should-contain [ 2 <- 1 # empty? @@ -227,10 +225,10 @@ scenario channel-new-empty-not-full [ scenario channel-write-not-empty [ run [ - 1:address:channel <- new-channel 3/capacity - 1:address:channel <- write 1:address:channel, 34 - 2:boolean <- channel-empty? 1:address:channel - 3:boolean <- channel-full? 1:address:channel + 1:address:shared:channel <- new-channel 3/capacity + 1:address:shared:channel <- write 1:address:shared:channel, 34 + 2:boolean <- channel-empty? 1:address:shared:channel + 3:boolean <- channel-full? 1:address:shared:channel ] memory-should-contain [ 2 <- 0 # empty? @@ -240,10 +238,10 @@ scenario channel-write-not-empty [ scenario channel-write-full [ run [ - 1:address:channel <- new-channel 1/capacity - 1:address:channel <- write 1:address:channel, 34 - 2:boolean <- channel-empty? 1:address:channel - 3:boolean <- channel-full? 1:address:channel + 1:address:shared:channel <- new-channel 1/capacity + 1:address:shared:channel <- write 1:address:shared:channel, 34 + 2:boolean <- channel-empty? 1:address:shared:channel + 3:boolean <- channel-full? 1:address:shared:channel ] memory-should-contain [ 2 <- 0 # empty? @@ -253,11 +251,11 @@ scenario channel-write-full [ scenario channel-read-not-full [ run [ - 1:address:channel <- new-channel 1/capacity - 1:address:channel <- write 1:address:channel, 34 - _, 1:address:channel <- read 1:address:channel - 2:boolean <- channel-empty? 1:address:channel - 3:boolean <- channel-full? 1:address:channel + 1:address:shared:channel <- new-channel 1/capacity + 1:address:shared:channel <- write 1:address:shared:channel, 34 + _, 1:address:shared:channel <- read 1:address:shared:channel + 2:boolean <- channel-empty? 1:address:shared:channel + 3:boolean <- channel-full? 1:address:shared:channel ] memory-should-contain [ 2 <- 1 # empty? @@ -266,12 +264,12 @@ scenario channel-read-not-full [ ] # helper for channels of characters in particular -recipe buffer-lines in:address:channel, out:address:channel -> out:address:channel, in:address:channel [ +recipe buffer-lines in:address:shared:channel, out:address:shared:channel -> out:address:shared:channel, in:address:shared:channel [ local-scope load-ingredients # repeat forever { - line:address:buffer <- new-buffer, 30 + line:address:shared:buffer <- new-buffer 30 # read characters from 'in' until newline, copy into line { +next-character @@ -302,7 +300,7 @@ recipe buffer-lines in:address:channel, out:address:channel -> out:address:chann } # copy line into 'out' i:number <- copy 0 - line-contents:address:array:character <- get *line, data:offset + line-contents:address:shared:array:character <- get *line, data:offset max:number <- get *line, length:offset { done?:boolean <- greater-or-equal i, max @@ -318,36 +316,36 @@ recipe buffer-lines in:address:channel, out:address:channel -> out:address:chann scenario buffer-lines-blocks-until-newline [ run [ - 1:address:channel/stdin <- new-channel 10/capacity - 2:address:channel/buffered-stdin <- new-channel 10/capacity - 3:boolean <- channel-empty? 2:address:channel/buffered-stdin + 1:address:shared:channel/stdin <- new-channel 10/capacity + 2:address:shared:channel/buffered-stdin <- new-channel 10/capacity + 3:boolean <- channel-empty? 2:address:shared:channel/buffered-stdin assert 3:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after init] # buffer stdin into buffered-stdin, try to read from buffered-stdin - 4:number/buffer-routine <- start-running buffer-lines, 1:address:channel/stdin, 2:address:channel/buffered-stdin + 4:number/buffer-routine <- start-running buffer-lines, 1:address:shared:channel/stdin, 2:address:shared:channel/buffered-stdin wait-for-routine 4:number/buffer-routine - 5:boolean <- channel-empty? 2:address:channel/buffered-stdin + 5:boolean <- channel-empty? 2:address:shared:channel/buffered-stdin assert 5:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up] # write 'a' - 1:address:channel <- write 1:address:channel, 97/a + 1:address:shared:channel <- write 1:address:shared:channel, 97/a restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine - 6:boolean <- channel-empty? 2:address:channel/buffered-stdin + 6:boolean <- channel-empty? 2:address:shared:channel/buffered-stdin assert 6:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after writing 'a'] # write 'b' - 1:address:channel <- write 1:address:channel, 98/b + 1:address:shared:channel <- write 1:address:shared:channel, 98/b restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine - 7:boolean <- channel-empty? 2:address:channel/buffered-stdin + 7:boolean <- channel-empty? 2:address:shared:channel/buffered-stdin assert 7:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after writing 'b'] # write newline - 1:address:channel <- write 1:address:channel, 10/newline + 1:address:shared:channel <- write 1:address:shared:channel, 10/newline restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine - 8:boolean <- channel-empty? 2:address:channel/buffered-stdin + 8:boolean <- channel-empty? 2:address:shared:channel/buffered-stdin 9:boolean/completed? <- not 8:boolean assert 9:boolean/completed?, [ F buffer-lines-blocks-until-newline: channel should contain data after writing newline] diff --git a/072array.mu b/072array.mu index 03348c3a..147ec0bf 100644 --- a/072array.mu +++ b/072array.mu @@ -1,7 +1,7 @@ scenario array-from-args [ run [ - 1:address:array:character <- new-array 0, 1, 2 - 2:array:character <- copy *1:address:array:character + 1:address:shared:array:character <- new-array 0, 1, 2 + 2:array:character <- copy *1:address:shared:array:character ] memory-should-contain [ 2 <- 3 # array length @@ -12,7 +12,7 @@ scenario array-from-args [ ] # create an array out of a list of scalar args -recipe new-array [ +recipe new-array -> result:address:shared:array:character [ local-scope capacity:number <- copy 0 { @@ -22,7 +22,7 @@ recipe new-array [ capacity <- add capacity, 1 loop } - result:address:array:character <- new character:type, capacity + result <- new character:type, capacity rewind-ingredients i:number <- copy 0 { diff --git a/073list.mu b/073list.mu index 9881d85b..1971b98e 100644 --- a/073list.mu +++ b/073list.mu @@ -5,27 +5,27 @@ container list:_elem [ value:_elem - next:address:list:_elem + next:address:shared:list:_elem ] -recipe push x:_elem, in:address:list:_elem -> in:address:list:_elem [ +recipe push x:_elem, in:address:shared:list:_elem -> in:address:shared:list:_elem [ local-scope load-ingredients - result:address:list:_elem <- new {(list _elem): type} + result:address:shared:list:_elem <- new {(list _elem): type} val:address:_elem <- get-address *result, value:offset *val <- copy x - next:address:address:list:_elem <- get-address *result, next:offset + next:address:address:shared:list:_elem <- get-address *result, next:offset *next <- copy in reply result # needed explicitly because we need to replace 'in' with 'result' ] -recipe first in:address:list:_elem -> result:_elem [ +recipe first in:address:shared:list:_elem -> result:_elem [ local-scope load-ingredients result <- get *in, value:offset ] -recipe rest in:address:list:_elem -> result:address:list:_elem/contained-in:in [ +recipe rest in:address:shared:list:_elem -> result:address:shared:list:_elem/contained-in:in [ local-scope load-ingredients result <- get *in, next:offset @@ -33,15 +33,15 @@ recipe rest in:address:list:_elem -> result:address:list:_elem/contained-in:in [ scenario list-handling [ run [ - 1:address:list:number <- push 3, 0 - 1:address:list:number <- push 4, 1:address:list:number - 1:address:list:number <- push 5, 1:address:list:number - 2:number <- first 1:address:list:number - 1:address:list:number <- rest 1:address:list:number - 3:number <- first 1:address:list:number - 1:address:list:number <- rest 1:address:list:number - 4:number <- first 1:address:list:number - 1:address:list:number <- rest 1:address:list:number + 1:address:shared:list:number <- push 3, 0 + 1:address:shared:list:number <- push 4, 1:address:shared:list:number + 1:address:shared:list:number <- push 5, 1:address:shared:list:number + 2:number <- first 1:address:shared:list:number + 1:address:shared:list:number <- rest 1:address:shared:list:number + 3:number <- first 1:address:shared:list:number + 1:address:shared:list:number <- rest 1:address:shared:list:number + 4:number <- first 1:address:shared:list:number + 1:address:shared:list:number <- rest 1:address:shared:list:number ] memory-should-contain [ 1 <- 0 # empty to empty, dust to dust.. @@ -51,26 +51,26 @@ scenario list-handling [ ] ] -recipe to-text in:address:list:_elem -> result:address:array:character [ +recipe to-text in:address:shared:list:_elem -> result:address:shared:array:character [ local-scope #? $print [to text: list], 10/newline load-ingredients - buf:address:buffer <- new-buffer 80 + buf:address:shared:buffer <- new-buffer 80 buf <- to-buffer in, buf result <- buffer-to-array buf ] # variant of 'to-text' which stops printing after a few elements (and so is robust to cycles) -recipe to-text-line in:address:list:_elem -> result:address:array:character [ +recipe to-text-line in:address:shared:list:_elem -> result:address:shared:array:character [ local-scope #? $print [to text line: list], 10/newline load-ingredients - buf:address:buffer <- new-buffer 80 + buf:address:shared:buffer <- new-buffer 80 buf <- to-buffer in, buf, 6 # max elements to display result <- buffer-to-array buf ] -recipe to-buffer in:address:list:_elem, buf:address:buffer -> buf:address:buffer [ +recipe to-buffer in:address:shared:list:_elem, buf:address:shared:buffer -> buf:address:shared:buffer [ local-scope #? $print [to buffer: list], 10/newline load-ingredients @@ -83,13 +83,13 @@ recipe to-buffer in:address:list:_elem, buf:address:buffer -> buf:address:buffer val:_elem <- get *in, value:offset buf <- append buf, val # now prepare next - next:address:list:_elem <- rest in + next:address:shared:list:_elem <- rest in nextn:number <- copy next #? buf <- append buf, nextn reply-unless next space:character <- copy 32/space buf <- append buf, space:character - s:address:array:character <- new [-> ] + s:address:shared:array:character <- new [-> ] n:number <- length *s buf <- append buf, s # and recurse @@ -108,13 +108,13 @@ recipe to-buffer in:address:list:_elem, buf:address:buffer -> buf:address:buffer reply } # past recursion depth; insert ellipses and stop - s:address:array:character <- new [...] + s:address:shared:array:character <- new [...] append buf, s ] scenario stash-on-list-converts-to-text [ run [ - x:address:list:number <- push 4, 0 + x:address:shared:list:number <- push 4, 0 x <- push 5, x x <- push 6, x stash [foo foo], x @@ -126,8 +126,8 @@ scenario stash-on-list-converts-to-text [ scenario stash-handles-list-with-cycle [ run [ - x:address:list:number <- push 4, 0 - y:address:address:list:number <- get-address *x, next:offset + x:address:shared:list:number <- push 4, 0 + y:address:address:shared:list:number <- get-address *x, next:offset *y <- copy x stash [foo foo], x ] diff --git a/075duplex_list.mu b/075duplex_list.mu index 317fa1ac..c2f4d8ba 100644 --- a/075duplex_list.mu +++ b/075duplex_list.mu @@ -2,42 +2,42 @@ container duplex-list:_elem [ value:_elem - next:address:duplex-list:_elem - prev:address:duplex-list:_elem + next:address:shared:duplex-list:_elem + prev:address:shared:duplex-list:_elem ] # should I say in/contained-in:result, allow ingredients to refer to products? -recipe push x:_elem, in:address:duplex-list:_elem -> in:address:duplex-list:_elem [ +recipe push x:_elem, in:address:shared:duplex-list:_elem -> in:address:shared:duplex-list:_elem [ local-scope load-ingredients - result:address:duplex-list:_elem <- new {(duplex-list _elem): type} + result:address:shared:duplex-list:_elem <- new {(duplex-list _elem): type} val:address:_elem <- get-address *result, value:offset *val <- copy x - next:address:address:duplex-list:_elem <- get-address *result, next:offset + next:address:address:shared:duplex-list:_elem <- get-address *result, next:offset *next <- copy in { break-unless in - prev:address:address:duplex-list:_elem <- get-address *in, prev:offset + prev:address:address:shared:duplex-list:_elem <- get-address *in, prev:offset *prev <- copy result } reply result # needed explicitly because we need to replace 'in' with 'result' ] -recipe first in:address:duplex-list:_elem -> result:_elem [ +recipe first in:address:shared:duplex-list:_elem -> result:_elem [ local-scope load-ingredients reply-unless in, 0 result <- get *in, value:offset ] -recipe next in:address:duplex-list:_elem -> result:address:duplex-list:_elem/contained-in:in [ +recipe next in:address:shared:duplex-list:_elem -> result:address:shared:duplex-list:_elem/contained-in:in [ local-scope load-ingredients reply-unless in, 0 result <- get *in, next:offset ] -recipe prev in:address:duplex-list:_elem -> result:address:duplex-list:_elem/contained-in:in [ +recipe prev in:address:shared:duplex-list:_elem -> result:address:shared:duplex-list:_elem/contained-in:in [ local-scope load-ingredients reply-unless in, 0 @@ -50,24 +50,24 @@ scenario duplex-list-handling [ # reserve locations 0, 1 and 2 to check for missing null check 1:number <- copy 34 2:number <- copy 35 - 3:address:duplex-list:character <- push 3, 0 - 3:address:duplex-list:character <- push 4, 3:address:duplex-list:character - 3:address:duplex-list:character <- push 5, 3:address:duplex-list:character - 4:address:duplex-list:character <- copy 3:address:duplex-list:character - 5:character <- first 4:address:duplex-list:character - 4:address:duplex-list:character <- next 4:address:duplex-list:character - 6:character <- first 4:address:duplex-list:character - 4:address:duplex-list:character <- next 4:address:duplex-list:character - 7:character <- first 4:address:duplex-list:character - 8:address:duplex-list:character <- next 4:address:duplex-list:character - 9:character <- first 8:address:duplex-list:character - 10:address:duplex-list:character <- next 8:address:duplex-list:character - 11:address:duplex-list:character <- prev 8:address:duplex-list:character - 4:address:duplex-list:character <- prev 4:address:duplex-list:character - 12:character <- first 4:address:duplex-list:character - 4:address:duplex-list:character <- prev 4:address:duplex-list:character - 13:character <- first 4:address:duplex-list:character - 14:boolean <- equal 3:address:duplex-list:character, 4:address:duplex-list:character + 3:address:shared:duplex-list:character <- push 3, 0 + 3:address:shared:duplex-list:character <- push 4, 3:address:shared:duplex-list:character + 3:address:shared:duplex-list:character <- push 5, 3:address:shared:duplex-list:character + 4:address:shared:duplex-list:character <- copy 3:address:shared:duplex-list:character + 5:character <- first 4:address:shared:duplex-list:character + 4:address:shared:duplex-list:character <- next 4:address:shared:duplex-list:character + 6:character <- first 4:address:shared:duplex-list:character + 4:address:shared:duplex-list:character <- next 4:address:shared:duplex-list:character + 7:character <- first 4:address:shared:duplex-list:character + 8:address:shared:duplex-list:character <- next 4:address:shared:duplex-list:character + 9:character <- first 8:address:shared:duplex-list:character + 10:address:shared:duplex-list:character <- next 8:address:shared:duplex-list:character + 11:address:shared:duplex-list:character <- prev 8:address:shared:duplex-list:character + 4:address:shared:duplex-list:character <- prev 4:address:shared:duplex-list:character + 12:character <- first 4:address:shared:duplex-list:character + 4:address:shared:duplex-list:character <- prev 4:address:shared:duplex-list:character + 13:character <- first 4:address:shared:duplex-list:character + 14:boolean <- equal 3:address:shared:duplex-list:character, 4:address:shared:duplex-list:character ] memory-should-contain [ 0 <- 0 # no modifications to null pointers @@ -87,15 +87,15 @@ scenario duplex-list-handling [ ] # insert 'x' after 'in' -recipe insert x:_elem, in:address:duplex-list:_elem -> in:address:duplex-list:_elem [ +recipe insert x:_elem, in:address:shared:duplex-list:_elem -> in:address:shared:duplex-list:_elem [ local-scope load-ingredients - new-node:address:duplex-list:_elem <- new {(duplex-list _elem): type} + new-node:address:shared:duplex-list:_elem <- new {(duplex-list _elem): type} val:address:_elem <- get-address *new-node, value:offset *val <- copy x - next-node:address:duplex-list:_elem <- get *in, next:offset + next-node:address:shared:duplex-list:_elem <- get *in, next:offset # in.next = new-node - y:address:address:duplex-list:_elem <- get-address *in, next:offset + y:address:address:shared:duplex-list:_elem <- get-address *in, next:offset *y <- copy new-node # new-node.prev = in y <- get-address *new-node, prev:offset @@ -112,27 +112,27 @@ recipe insert x:_elem, in:address:duplex-list:_elem -> in:address:duplex-list:_e scenario inserting-into-duplex-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - 2:address:duplex-list:character <- next 1:address:duplex-list:character # 2 points inside list - 2:address:duplex-list:character <- insert 6, 2:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- push 4, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 5, 1:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character # 2 points inside list + 2:address:shared:duplex-list:character <- insert 6, 2:address:shared:duplex-list:character # check structure like before - 2:address:duplex-list:character <- copy 1:address:duplex-list:character - 3:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 4:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 5:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 6:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 7:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 8:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 9:character <- first 2:address:duplex-list:character - 10:boolean <- equal 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- copy 1:address:shared:duplex-list:character + 3:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 4:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 5:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 6:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 7:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 8:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 9:character <- first 2:address:shared:duplex-list:character + 10:boolean <- equal 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character ] memory-should-contain [ 3 <- 5 # scanning next @@ -148,28 +148,28 @@ scenario inserting-into-duplex-list [ scenario inserting-at-end-of-duplex-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - 2:address:duplex-list:character <- next 1:address:duplex-list:character # 2 points inside list - 2:address:duplex-list:character <- next 2:address:duplex-list:character # now at end of list - 2:address:duplex-list:character <- insert 6, 2:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- push 4, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 5, 1:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character # 2 points inside list + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character # now at end of list + 2:address:shared:duplex-list:character <- insert 6, 2:address:shared:duplex-list:character # check structure like before - 2:address:duplex-list:character <- copy 1:address:duplex-list:character - 3:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 4:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 5:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 6:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 7:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 8:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 9:character <- first 2:address:duplex-list:character - 10:boolean <- equal 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- copy 1:address:shared:duplex-list:character + 3:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 4:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 5:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 6:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 7:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 8:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 9:character <- first 2:address:shared:duplex-list:character + 10:boolean <- equal 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character ] memory-should-contain [ 3 <- 5 # scanning next @@ -185,26 +185,26 @@ scenario inserting-at-end-of-duplex-list [ scenario inserting-after-start-of-duplex-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - 1:address:duplex-list:character <- insert 6, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- push 4, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 5, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- insert 6, 1:address:shared:duplex-list:character # check structure like before - 2:address:duplex-list:character <- copy 1:address:duplex-list:character - 3:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 4:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 5:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 6:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 7:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 8:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 9:character <- first 2:address:duplex-list:character - 10:boolean <- equal 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- copy 1:address:shared:duplex-list:character + 3:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 4:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 5:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 6:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 7:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 8:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 9:character <- first 2:address:shared:duplex-list:character + 10:boolean <- equal 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character ] memory-should-contain [ 3 <- 5 # scanning next @@ -222,15 +222,15 @@ scenario inserting-after-start-of-duplex-list [ # # Returns null if and only if list is empty. Beware: in that case any other # pointers to the head are now invalid. -recipe remove x:address:duplex-list:_elem/contained-in:in, in:address:duplex-list:_elem -> in:address:duplex-list:_elem [ +recipe remove x:address:shared:duplex-list:_elem/contained-in:in, in:address:shared:duplex-list:_elem -> in:address:shared:duplex-list:_elem [ local-scope load-ingredients # if 'x' is null, return reply-unless x - next-node:address:duplex-list:_elem <- get *x, next:offset - prev-node:address:duplex-list:_elem <- get *x, prev:offset + next-node:address:shared:duplex-list:_elem <- get *x, next:offset + prev-node:address:shared:duplex-list:_elem <- get *x, prev:offset # null x's pointers - tmp:address:address:duplex-list:_elem <- get-address *x, next:offset + tmp:address:address:shared:duplex-list:_elem <- get-address *x, next:offset *tmp <- copy 0 tmp <- get-address *x, prev:offset *tmp <- copy 0 @@ -254,21 +254,21 @@ recipe remove x:address:duplex-list:_elem/contained-in:in, in:address:duplex-lis scenario removing-from-duplex-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - 2:address:duplex-list:character <- next 1:address:duplex-list:character # 2 points at second element - 1:address:duplex-list:character <- remove 2:address:duplex-list:character, 1:address:duplex-list:character - 3:boolean <- equal 2:address:duplex-list:character, 0 + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- push 4, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 5, 1:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character # 2 points at second element + 1:address:shared:duplex-list:character <- remove 2:address:shared:duplex-list:character, 1:address:shared:duplex-list:character + 3:boolean <- equal 2:address:shared:duplex-list:character, 0 # check structure like before - 2:address:duplex-list:character <- copy 1:address:duplex-list:character - 4:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 5:character <- first 2:address:duplex-list:character - 6:address:duplex-list:character <- next 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 7:character <- first 2:address:duplex-list:character - 8:boolean <- equal 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- copy 1:address:shared:duplex-list:character + 4:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 5:character <- first 2:address:shared:duplex-list:character + 6:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 7:character <- first 2:address:shared:duplex-list:character + 8:boolean <- equal 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character ] memory-should-contain [ 3 <- 0 # remove returned non-null @@ -282,19 +282,19 @@ scenario removing-from-duplex-list [ scenario removing-from-start-of-duplex-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character - 1:address:duplex-list:character <- remove 1:address:duplex-list:character, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- push 4, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 5, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- remove 1:address:shared:duplex-list:character, 1:address:shared:duplex-list:character # check structure like before - 2:address:duplex-list:character <- copy 1:address:duplex-list:character - 3:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 4:character <- first 2:address:duplex-list:character - 5:address:duplex-list:character <- next 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 6:character <- first 2:address:duplex-list:character - 7:boolean <- equal 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- copy 1:address:shared:duplex-list:character + 3:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 4:character <- first 2:address:shared:duplex-list:character + 5:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 6:character <- first 2:address:shared:duplex-list:character + 7:boolean <- equal 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character ] memory-should-contain [ 3 <- 4 # scanning next, skipping deleted element @@ -307,23 +307,23 @@ scenario removing-from-start-of-duplex-list [ scenario removing-from-end-of-duplex-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- push 4, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 5, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- push 4, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 5, 1:address:shared:duplex-list:character # delete last element - 2:address:duplex-list:character <- next 1:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 1:address:duplex-list:character <- remove 2:address:duplex-list:character, 1:address:duplex-list:character - 3:boolean <- equal 2:address:duplex-list:character, 0 + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- remove 2:address:shared:duplex-list:character, 1:address:shared:duplex-list:character + 3:boolean <- equal 2:address:shared:duplex-list:character, 0 # check structure like before - 2:address:duplex-list:character <- copy 1:address:duplex-list:character - 4:character <- first 2:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 5:character <- first 2:address:duplex-list:character - 6:address:duplex-list:character <- next 2:address:duplex-list:character - 2:address:duplex-list:character <- prev 2:address:duplex-list:character - 7:character <- first 2:address:duplex-list:character - 8:boolean <- equal 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- copy 1:address:shared:duplex-list:character + 4:character <- first 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 5:character <- first 2:address:shared:duplex-list:character + 6:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- prev 2:address:shared:duplex-list:character + 7:character <- first 2:address:shared:duplex-list:character + 8:boolean <- equal 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character ] memory-should-contain [ 3 <- 0 # remove returned non-null @@ -337,8 +337,8 @@ scenario removing-from-end-of-duplex-list [ scenario removing-from-singleton-list [ run [ - 1:address:duplex-list:character <- push 3, 0 - 1:address:duplex-list:character <- remove 1:address:duplex-list:character, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 3, 0 + 1:address:shared:duplex-list:character <- remove 1:address:shared:duplex-list:character, 1:address:shared:duplex-list:character ] memory-should-contain [ 1 <- 0 # back to an empty list @@ -347,16 +347,16 @@ scenario removing-from-singleton-list [ # remove values between 'start' and 'end' (both exclusive) # also clear pointers back out from start/end for hygiene -recipe remove-between start:address:duplex-list:_elem, end:address:duplex-list:_elem/contained-in:start -> start:address:duplex-list:_elem [ +recipe remove-between start:address:shared:duplex-list:_elem, end:address:shared:duplex-list:_elem/contained-in:start -> start:address:shared:duplex-list:_elem [ local-scope load-ingredients reply-unless start # start->next->prev = 0 # start->next = end - next:address:address:duplex-list:_elem <- get-address *start, next:offset + next:address:address:shared:duplex-list:_elem <- get-address *start, next:offset nothing-to-delete?:boolean <- equal *next, end reply-if nothing-to-delete? - prev:address:address:duplex-list:_elem <- get-address **next, prev:offset + prev:address:address:shared:duplex-list:_elem <- get-address **next, prev:offset *prev <- copy 0 *next <- copy end reply-unless end @@ -370,25 +370,25 @@ recipe remove-between start:address:duplex-list:_elem, end:address:duplex-list:_ scenario remove-range [ # construct a duplex list with six elements [13, 14, 15, 16, 17, 18] - 1:address:duplex-list:character <- push 18, 0 - 1:address:duplex-list:character <- push 17, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 16, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 15, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 14, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 13, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 18, 0 + 1:address:shared:duplex-list:character <- push 17, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 16, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 15, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 14, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 13, 1:address:shared:duplex-list:character run [ # delete 16 onwards # first pointer: to the third element - 2:address:duplex-list:character <- next 1:address:duplex-list:character - 2:address:duplex-list:character <- next 2:address:duplex-list:character - 2:address:duplex-list:character <- remove-between 2:address:duplex-list:character, 0 + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 2:address:shared:duplex-list:character <- remove-between 2:address:shared:duplex-list:character, 0 # now check the list - 4:character <- get *1:address:duplex-list:character, value:offset - 5:address:duplex-list:character <- next 1:address:duplex-list:character - 6:character <- get *5:address:duplex-list:character, value:offset - 7:address:duplex-list:character <- next 5:address:duplex-list:character - 8:character <- get *7:address:duplex-list:character, value:offset - 9:address:duplex-list:character <- next 7:address:duplex-list:character + 4:character <- get *1:address:shared:duplex-list:character, value:offset + 5:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character + 6:character <- get *5:address:shared:duplex-list:character, value:offset + 7:address:shared:duplex-list:character <- next 5:address:shared:duplex-list:character + 8:character <- get *7:address:shared:duplex-list:character, value:offset + 9:address:shared:duplex-list:character <- next 7:address:shared:duplex-list:character ] memory-should-contain [ 4 <- 13 @@ -400,29 +400,29 @@ scenario remove-range [ scenario remove-range-to-end [ # construct a duplex list with six elements [13, 14, 15, 16, 17, 18] - 1:address:duplex-list:character <- push 18, 0 - 1:address:duplex-list:character <- push 17, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 16, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 15, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 14, 1:address:duplex-list:character - 1:address:duplex-list:character <- push 13, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 18, 0 + 1:address:shared:duplex-list:character <- push 17, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 16, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 15, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 14, 1:address:shared:duplex-list:character + 1:address:shared:duplex-list:character <- push 13, 1:address:shared:duplex-list:character run [ # delete 15, 16 and 17 # first pointer: to the third element - 2:address:duplex-list:character <- next 1:address:duplex-list:character + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character # second pointer: to the fifth element - 3:address:duplex-list:character <- next 2:address:duplex-list:character - 3:address:duplex-list:character <- next 3:address:duplex-list:character - 3:address:duplex-list:character <- next 3:address:duplex-list:character - 3:address:duplex-list:character <- next 3:address:duplex-list:character - remove-between 2:address:duplex-list:character, 3:address:duplex-list:character + 3:address:shared:duplex-list:character <- next 2:address:shared:duplex-list:character + 3:address:shared:duplex-list:character <- next 3:address:shared:duplex-list:character + 3:address:shared:duplex-list:character <- next 3:address:shared:duplex-list:character + 3:address:shared:duplex-list:character <- next 3:address:shared:duplex-list:character + remove-between 2:address:shared:duplex-list:character, 3:address:shared:duplex-list:character # now check the list - 4:character <- get *1:address:duplex-list:character, value:offset - 5:address:duplex-list:character <- next 1:address:duplex-list:character - 6:character <- get *5:address:duplex-list:character, value:offset - 7:address:duplex-list:character <- next 5:address:duplex-list:character - 8:character <- get *7:address:duplex-list:character, value:offset - 9:address:duplex-list:character <- next 7:address:duplex-list:character + 4:character <- get *1:address:shared:duplex-list:character, value:offset + 5:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character + 6:character <- get *5:address:shared:duplex-list:character, value:offset + 7:address:shared:duplex-list:character <- next 5:address:shared:duplex-list:character + 8:character <- get *7:address:shared:duplex-list:character, value:offset + 9:address:shared:duplex-list:character <- next 7:address:shared:duplex-list:character ] memory-should-contain [ 4 <- 13 @@ -434,18 +434,18 @@ scenario remove-range-to-end [ scenario remove-range-empty [ # construct a duplex list with six elements [13, 14, 15, 16, 17, 18] - 1:address:duplex-list:character <- push 14, 0 - 1:address:duplex-list:character <- push 13, 1:address:duplex-list:character + 1:address:shared:duplex-list:character <- push 14, 0 + 1:address:shared:duplex-list:character <- push 13, 1:address:shared:duplex-list:character run [ # delete 16 onwards # first pointer: to the third element - 2:address:duplex-list:character <- next 1:address:duplex-list:character - remove-between 1:address:duplex-list:character, 2:address:duplex-list:character + 2:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character + remove-between 1:address:shared:duplex-list:character, 2:address:shared:duplex-list:character # now check the list - 4:character <- get *1:address:duplex-list:character, value:offset - 5:address:duplex-list:character <- next 1:address:duplex-list:character - 6:character <- get *5:address:duplex-list:character, value:offset - 7:address:duplex-list:character <- next 5:address:duplex-list:character + 4:character <- get *1:address:shared:duplex-list:character, value:offset + 5:address:shared:duplex-list:character <- next 1:address:shared:duplex-list:character + 6:character <- get *5:address:shared:duplex-list:character, value:offset + 7:address:shared:duplex-list:character <- next 5:address:shared:duplex-list:character ] memory-should-contain [ 4 <- 13 @@ -455,20 +455,20 @@ scenario remove-range-empty [ ] # insert list beginning at 'new' after 'in' -recipe insert-range in:address:duplex-list:_elem, start:address:duplex-list:_elem/contained-in:in -> in:address:duplex-list:_elem [ +recipe insert-range in:address:shared:duplex-list:_elem, start:address:shared:duplex-list:_elem/contained-in:in -> in:address:shared:duplex-list:_elem [ local-scope load-ingredients reply-unless in reply-unless start - end:address:duplex-list:_elem <- copy start + end:address:shared:duplex-list:_elem <- copy start { - next:address:duplex-list:_elem <- next end/insert-range + next:address:shared:duplex-list:_elem <- next end/insert-range break-unless next end <- copy next loop } - next:address:duplex-list:_elem <- next in - dest:address:address:duplex-list:_elem <- get-address *end, next:offset + next:address:shared:duplex-list:_elem <- next in + dest:address:address:shared:duplex-list:_elem <- get-address *end, next:offset *dest <- copy next { break-unless next @@ -481,23 +481,23 @@ recipe insert-range in:address:duplex-list:_elem, start:address:duplex-list:_ele *dest <- copy in ] -recipe append in:address:duplex-list:_elem, new:address:duplex-list:_elem/contained-in:in -> in:address:duplex-list:_elem [ +recipe append in:address:shared:duplex-list:_elem, new:address:shared:duplex-list:_elem/contained-in:in -> in:address:shared:duplex-list:_elem [ local-scope load-ingredients - last:address:duplex-list:_elem <- last in - dest:address:address:duplex-list:_elem <- get-address *last, next:offset + last:address:shared:duplex-list:_elem <- last in + dest:address:address:shared:duplex-list:_elem <- get-address *last, next:offset *dest <- copy new reply-unless new dest <- get-address *new, prev:offset *dest <- copy last ] -recipe last in:address:duplex-list:_elem -> result:address:duplex-list:_elem [ +recipe last in:address:shared:duplex-list:_elem -> result:address:shared:duplex-list:_elem [ local-scope load-ingredients result <- copy in { - next:address:duplex-list:_elem <- next result + next:address:shared:duplex-list:_elem <- next result break-unless next result <- copy next loop @@ -505,7 +505,7 @@ recipe last in:address:duplex-list:_elem -> result:address:duplex-list:_elem [ ] # helper for debugging -recipe dump-from x:address:duplex-list:_elem [ +recipe dump-from x:address:shared:duplex-list:_elem [ local-scope load-ingredients $print x, [: ] diff --git a/076stream.mu b/076stream.mu index be60d855..aa11b773 100644 --- a/076stream.mu +++ b/076stream.mu @@ -1,41 +1,41 @@ # new type to help incrementally read texts (arrays of characters) container stream [ index:number - data:address:array:character + data:address:shared:array:character ] -recipe new-stream s:address:array:character -> result:address:stream [ +recipe new-stream s:address:shared:array:character -> result:address:shared:stream [ local-scope load-ingredients result <- new stream:type i:address:number <- get-address *result, index:offset *i <- copy 0 - d:address:address:array:character <- get-address *result, data:offset + d:address:address:shared:array:character <- get-address *result, data:offset *d <- copy s ] -recipe rewind-stream in:address:stream -> in:address:stream [ +recipe rewind-stream in:address:shared:stream -> in:address:shared:stream [ local-scope load-ingredients x:address:number <- get-address *in, index:offset *x <- copy 0 ] -recipe read-line in:address:stream -> result:address:array:character, in:address:stream [ +recipe read-line in:address:shared:stream -> result:address:shared:array:character, in:address:shared:stream [ local-scope load-ingredients idx:address:number <- get-address *in, index:offset - s:address:array:character <- get *in, data:offset + s:address:shared:array:character <- get *in, data:offset next-idx:number <- find-next s, 10/newline, *idx result <- copy-range s, *idx, next-idx *idx <- add next-idx, 1 # skip newline ] -recipe end-of-stream? in:address:stream -> result:boolean [ +recipe end-of-stream? in:address:shared:stream -> result:boolean [ local-scope load-ingredients idx:number <- get *in, index:offset - s:address:array:character <- get *in, data:offset + s:address:shared:array:character <- get *in, data:offset len:number <- length *s result <- greater-or-equal idx, len ] diff --git a/081print.mu b/081print.mu index c0bc37ab..bb2f1636 100644 --- a/081print.mu +++ b/081print.mu @@ -6,7 +6,7 @@ container screen [ num-columns:number cursor-row:number cursor-column:number - data:address:array:screen-cell + data:address:shared:array:screen-cell ] container screen-cell [ @@ -14,7 +14,7 @@ container screen-cell [ color:number ] -recipe new-fake-screen w:number, h:number -> result:address:screen [ +recipe new-fake-screen w:number, h:number -> result:address:shared:screen [ local-scope load-ingredients result <- new screen:type @@ -27,19 +27,19 @@ recipe new-fake-screen w:number, h:number -> result:address:screen [ column:address:number <- get-address *result, cursor-column:offset *column <- copy 0 bufsize:number <- multiply *width, *height - buf:address:address:array:screen-cell <- get-address *result, data:offset + buf:address:address:shared:array:screen-cell <- get-address *result, data:offset *buf <- new screen-cell:type, bufsize result <- clear-screen result ] -recipe clear-screen screen:address:screen -> screen:address:screen [ +recipe clear-screen screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists { break-unless screen # clear fake screen - buf:address:array:screen-cell <- get *screen, data:offset + buf:address:shared:array:screen-cell <- get *screen, data:offset max:number <- length *buf i:number <- copy 0 { @@ -64,7 +64,7 @@ recipe clear-screen screen:address:screen -> screen:address:screen [ clear-display ] -recipe sync-screen screen:address:screen -> screen:address:screen [ +recipe sync-screen screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients { @@ -74,11 +74,11 @@ recipe sync-screen screen:address:screen -> screen:address:screen [ # do nothing for fake screens ] -recipe fake-screen-is-empty? screen:address:screen -> result:boolean [ +recipe fake-screen-is-empty? screen:address:shared:screen -> result:boolean [ local-scope load-ingredients reply-unless screen, 1/true - buf:address:array:screen-cell <- get *screen, data:offset + buf:address:shared:array:screen-cell <- get *screen, data:offset i:number <- copy 0 len:number <- length *buf { @@ -94,7 +94,7 @@ recipe fake-screen-is-empty? screen:address:screen -> result:boolean [ reply 1/true ] -recipe print screen:address:screen, c:character -> screen:address:screen [ +recipe print screen:address:shared:screen, c:character -> screen:address:shared:screen [ local-scope load-ingredients color:number, color-found?:boolean <- next-ingredient @@ -145,7 +145,7 @@ recipe print screen:address:screen, c:character -> screen:address:screen [ # save character in fake screen index:number <- multiply *row, width index <- add index, *column - buf:address:array:screen-cell <- get *screen, data:offset + buf:address:shared:array:screen-cell <- get *screen, data:offset len:number <- length *buf # special-case: backspace { @@ -186,11 +186,11 @@ recipe print screen:address:screen, c:character -> screen:address:screen [ scenario print-character-at-top-left [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a - 2:address:array:screen-cell <- get *1:address:screen, data:offset - 3:array:screen-cell <- copy *2:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a + 2:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 3:array:screen-cell <- copy *2:address:shared:array:screen-cell ] memory-should-contain [ 3 <- 6 # width*height @@ -202,11 +202,11 @@ scenario print-character-at-top-left [ scenario print-character-in-color [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a, 1/red - 2:address:array:screen-cell <- get *1:address:screen, data:offset - 3:array:screen-cell <- copy *2:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a, 1/red + 2:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 3:array:screen-cell <- copy *2:address:shared:array:screen-cell ] memory-should-contain [ 3 <- 6 # width*height @@ -218,14 +218,14 @@ scenario print-character-in-color [ scenario print-backspace-character [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a 12:character <- copy 8/backspace - 1:address:screen <- print 1:address:screen, 12:character/backspace - 2:number <- get *1:address:screen, cursor-column:offset - 3:address:array:screen-cell <- get *1:address:screen, data:offset - 4:array:screen-cell <- copy *3:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 12:character/backspace + 2:number <- get *1:address:shared:screen, cursor-column:offset + 3:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 4:array:screen-cell <- copy *3:address:shared:array:screen-cell ] memory-should-contain [ 2 <- 0 # cursor column @@ -238,16 +238,16 @@ scenario print-backspace-character [ scenario print-extra-backspace-character [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a 12:character <- copy 8/backspace - 1:address:screen <- print 1:address:screen, 12:character/backspace + 1:address:shared:screen <- print 1:address:shared:screen, 12:character/backspace 12:character <- copy 8/backspace - 1:address:screen <- print 1:address:screen, 12:character/backspace - 2:number <- get *1:address:screen, cursor-column:offset - 3:address:array:screen-cell <- get *1:address:screen, data:offset - 4:array:screen-cell <- copy *3:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 12:character/backspace + 2:number <- get *1:address:shared:screen, cursor-column:offset + 3:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 4:array:screen-cell <- copy *3:address:shared:array:screen-cell ] memory-should-contain [ 2 <- 0 # cursor column @@ -260,16 +260,16 @@ scenario print-extra-backspace-character [ scenario print-character-at-right-margin [ run [ - 1:address:screen <- new-fake-screen 2/width, 2/height + 1:address:shared:screen <- new-fake-screen 2/width, 2/height 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a 12:character <- copy 98/b - 1:address:screen <- print 1:address:screen, 12:character/b + 1:address:shared:screen <- print 1:address:shared:screen, 12:character/b 13:character <- copy 99/b - 1:address:screen <- print 1:address:screen, 13:character/c - 2:number <- get *1:address:screen, cursor-column:offset - 3:address:array:screen-cell <- get *1:address:screen, data:offset - 4:array:screen-cell <- copy *3:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 13:character/c + 2:number <- get *1:address:shared:screen, cursor-column:offset + 3:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 4:array:screen-cell <- copy *3:address:shared:array:screen-cell ] memory-should-contain [ 2 <- 1 # cursor column @@ -284,15 +284,15 @@ scenario print-character-at-right-margin [ scenario print-newline-character [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height 10:character <- copy 10/newline 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a - 1:address:screen <- print 1:address:screen, 10:character/newline - 2:number <- get *1:address:screen, cursor-row:offset - 3:number <- get *1:address:screen, cursor-column:offset - 4:address:array:screen-cell <- get *1:address:screen, data:offset - 5:array:screen-cell <- copy *4:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/newline + 2:number <- get *1:address:shared:screen, cursor-row:offset + 3:number <- get *1:address:shared:screen, cursor-column:offset + 4:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 5:array:screen-cell <- copy *4:address:shared:array:screen-cell ] memory-should-contain [ 2 <- 1 # cursor row @@ -306,13 +306,13 @@ scenario print-newline-character [ scenario print-newline-at-bottom-line [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height 10:character <- copy 10/newline - 1:address:screen <- print 1:address:screen, 10:character/newline - 1:address:screen <- print 1:address:screen, 10:character/newline - 1:address:screen <- print 1:address:screen, 10:character/newline - 2:number <- get *1:address:screen, cursor-row:offset - 3:number <- get *1:address:screen, cursor-column:offset + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/newline + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/newline + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/newline + 2:number <- get *1:address:shared:screen, cursor-row:offset + 3:number <- get *1:address:shared:screen, cursor-column:offset ] memory-should-contain [ 2 <- 1 # cursor row @@ -322,22 +322,22 @@ scenario print-newline-at-bottom-line [ scenario print-character-at-bottom-right [ run [ - 1:address:screen <- new-fake-screen 2/width, 2/height + 1:address:shared:screen <- new-fake-screen 2/width, 2/height 10:character <- copy 10/newline - 1:address:screen <- print 1:address:screen, 10:character/newline + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/newline 11:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 11:character/a + 1:address:shared:screen <- print 1:address:shared:screen, 11:character/a 12:character <- copy 98/b - 1:address:screen <- print 1:address:screen, 12:character/b + 1:address:shared:screen <- print 1:address:shared:screen, 12:character/b 13:character <- copy 99/c - 1:address:screen <- print 1:address:screen, 13:character/c - 1:address:screen <- print 1:address:screen, 10:character/newline + 1:address:shared:screen <- print 1:address:shared:screen, 13:character/c + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/newline 14:character <- copy 100/d - 1:address:screen <- print 1:address:screen, 14:character/d - 2:number <- get *1:address:screen, cursor-row:offset - 3:number <- get *1:address:screen, cursor-column:offset - 4:address:array:screen-cell <- get *1:address:screen, data:offset - 20:array:screen-cell <- copy *4:address:array:screen-cell + 1:address:shared:screen <- print 1:address:shared:screen, 14:character/d + 2:number <- get *1:address:shared:screen, cursor-row:offset + 3:number <- get *1:address:shared:screen, cursor-column:offset + 4:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 20:array:screen-cell <- copy *4:address:shared:array:screen-cell ] memory-should-contain [ 2 <- 1 # cursor row @@ -355,7 +355,7 @@ scenario print-character-at-bottom-right [ ] ] -recipe clear-line screen:address:screen -> screen:address:screen [ +recipe clear-line screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients space:character <- copy 0/nul @@ -381,7 +381,7 @@ recipe clear-line screen:address:screen -> screen:address:screen [ clear-line-on-display ] -recipe cursor-position screen:address:screen -> row:number, column:number [ +recipe cursor-position screen:address:shared:screen -> row:number, column:number [ local-scope load-ingredients # if x exists, lookup cursor in fake screen @@ -394,7 +394,7 @@ recipe cursor-position screen:address:screen -> row:number, column:number [ row, column <- cursor-position-on-display ] -recipe move-cursor screen:address:screen, new-row:number, new-column:number -> screen:address:screen [ +recipe move-cursor screen:address:shared:screen, new-row:number, new-column:number -> screen:address:shared:screen [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -412,16 +412,16 @@ recipe move-cursor screen:address:screen, new-row:number, new-column:number -> s scenario clear-line-erases-printed-characters [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height + 1:address:shared:screen <- new-fake-screen 3/width, 2/height # print a character 10:character <- copy 97/a - 1:address:screen <- print 1:address:screen, 10:character/a + 1:address:shared:screen <- print 1:address:shared:screen, 10:character/a # move cursor to start of line - 1:address:screen <- move-cursor 1:address:screen, 0/row, 0/column + 1:address:shared:screen <- move-cursor 1:address:shared:screen, 0/row, 0/column # clear line - 1:address:screen <- clear-line 1:address:screen - 2:address:array:screen-cell <- get *1:address:screen, data:offset - 20:array:screen-cell <- copy *2:address:array:screen-cell + 1:address:shared:screen <- clear-line 1:address:shared:screen + 2:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 20:array:screen-cell <- copy *2:address:shared:array:screen-cell ] # screen should be blank memory-should-contain [ @@ -441,7 +441,7 @@ scenario clear-line-erases-printed-characters [ ] ] -recipe cursor-down screen:address:screen -> screen:address:screen [ +recipe cursor-down screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -462,7 +462,7 @@ recipe cursor-down screen:address:screen -> screen:address:screen [ move-cursor-down-on-display ] -recipe cursor-up screen:address:screen -> screen:address:screen [ +recipe cursor-up screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -481,7 +481,7 @@ recipe cursor-up screen:address:screen -> screen:address:screen [ move-cursor-up-on-display ] -recipe cursor-right screen:address:screen -> screen:address:screen [ +recipe cursor-right screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -502,7 +502,7 @@ recipe cursor-right screen:address:screen -> screen:address:screen [ move-cursor-right-on-display ] -recipe cursor-left screen:address:screen -> screen:address:screen [ +recipe cursor-left screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -521,7 +521,7 @@ recipe cursor-left screen:address:screen -> screen:address:screen [ move-cursor-left-on-display ] -recipe cursor-to-start-of-line screen:address:screen -> screen:address:screen [ +recipe cursor-to-start-of-line screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients row:number <- cursor-position screen @@ -529,14 +529,14 @@ recipe cursor-to-start-of-line screen:address:screen -> screen:address:screen [ screen <- move-cursor screen, row, column ] -recipe cursor-to-next-line screen:address:screen -> screen:address:screen [ +recipe cursor-to-next-line screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients screen <- cursor-down screen screen <- cursor-to-start-of-line screen ] -recipe screen-width screen:address:screen -> width:number [ +recipe screen-width screen:address:shared:screen -> width:number [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -549,7 +549,7 @@ recipe screen-width screen:address:screen -> width:number [ width <- display-width ] -recipe screen-height screen:address:screen -> height:number [ +recipe screen-height screen:address:shared:screen -> height:number [ local-scope load-ingredients # if x exists, move cursor in fake screen @@ -562,7 +562,7 @@ recipe screen-height screen:address:screen -> height:number [ height <- display-height ] -recipe hide-cursor screen:address:screen -> screen:address:screen [ +recipe hide-cursor screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists (not real display), do nothing @@ -574,7 +574,7 @@ recipe hide-cursor screen:address:screen -> screen:address:screen [ hide-cursor-on-display ] -recipe show-cursor screen:address:screen -> screen:address:screen [ +recipe show-cursor screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists (not real display), do nothing @@ -586,7 +586,7 @@ recipe show-cursor screen:address:screen -> screen:address:screen [ show-cursor-on-display ] -recipe hide-screen screen:address:screen -> screen:address:screen [ +recipe hide-screen screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists (not real display), do nothing @@ -599,7 +599,7 @@ recipe hide-screen screen:address:screen -> screen:address:screen [ hide-display ] -recipe show-screen screen:address:screen -> screen:address:screen [ +recipe show-screen screen:address:shared:screen -> screen:address:shared:screen [ local-scope load-ingredients # if x exists (not real display), do nothing @@ -612,7 +612,7 @@ recipe show-screen screen:address:screen -> screen:address:screen [ show-display ] -recipe print screen:address:screen, s:address:array:character -> screen:address:screen [ +recipe print screen:address:shared:screen, s:address:shared:array:character -> screen:address:shared:screen [ local-scope load-ingredients color:number, color-found?:boolean <- next-ingredient @@ -641,11 +641,11 @@ recipe print screen:address:screen, s:address:array:character -> screen:address: scenario print-text-stops-at-right-margin [ run [ - 1:address:screen <- new-fake-screen 3/width, 2/height - 2:address:array:character <- new [abcd] - 1:address:screen <- print 1:address:screen, 2:address:array:character - 3:address:array:screen-cell <- get *1:address:screen, data:offset - 4:array:screen-cell <- copy *3:address:array:screen-cell + 1:address:shared:screen <- new-fake-screen 3/width, 2/height + 2:address:shared:array:character <- new [abcd] + 1:address:shared:screen <- print 1:address:shared:screen, 2:address:shared:array:character + 3:address:shared:array:screen-cell <- get *1:address:shared:screen, data:offset + 4:array:screen-cell <- copy *3:address:shared:array:screen-cell ] memory-should-contain [ 4 <- 6 # width*height @@ -659,7 +659,7 @@ scenario print-text-stops-at-right-margin [ ] ] -recipe print-integer screen:address:screen, n:number -> screen:address:screen [ +recipe print-integer screen:address:shared:screen, n:number -> screen:address:shared:screen [ local-scope load-ingredients color:number, color-found?:boolean <- next-ingredient @@ -675,12 +675,12 @@ recipe print-integer screen:address:screen, n:number -> screen:address:screen [ bg-color <- copy 0/black } # todo: other bases besides decimal - s:address:array:character <- to-text n + s:address:shared:array:character <- to-text n screen <- print screen, s, color, bg-color ] # for now, we can only print integers -recipe print screen:address:screen, n:number -> screen:address:screen [ +recipe print screen:address:shared:screen, n:number -> screen:address:shared:screen [ local-scope load-ingredients screen <- print-integer screen, n diff --git a/082scenario_screen.cc b/082scenario_screen.cc index fc667311..362c73f1 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -10,7 +10,7 @@ scenario screen-in-scenario [ assume-screen 5/width, 3/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a ] screen-should-contain [ # 01234 @@ -25,9 +25,9 @@ scenario screen-in-scenario-unicode-color [ assume-screen 5/width, 3/height run [ 1:character <- copy 955/greek-small-lambda - screen:address:screen <- print screen:address:screen, 1:character/lambda, 1/red + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/lambda, 1/red 2:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 2:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 2:character/a ] screen-should-contain [ # 01234 @@ -43,9 +43,9 @@ scenario screen-in-scenario-color [ assume-screen 5/width, 3/height run [ 1:character <- copy 955/greek-small-lambda - screen:address:screen <- print screen:address:screen, 1:character/lambda, 1/red + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/lambda, 1/red 2:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 2:character/a, 7/white + screen:address:shared:screen <- print screen:address:shared:screen, 2:character/a, 7/white ] # screen-should-contain shows everything screen-should-contain [ @@ -78,7 +78,7 @@ scenario screen-in-scenario-error [ assume-screen 5/width, 3/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a ] screen-should-contain [ # 01234 @@ -97,7 +97,7 @@ scenario screen-in-scenario-color [ assume-screen 5/width, 3/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a, 1/red + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a, 1/red ] screen-should-contain-in-color 2/green, [ # 01234 @@ -146,11 +146,11 @@ Name[r]["screen"] = SCREEN; :(before "End Rewrite Instruction(curr, recipe result)") // rewrite `assume-screen width, height` to -// `screen:address:screen <- new-fake-screen width, height` +// `screen:address:shared:screen <- new-fake-screen width, height` if (curr.name == "assume-screen") { curr.name = "new-fake-screen"; assert(curr.products.empty()); - curr.products.push_back(reagent("screen:address:screen")); + curr.products.push_back(reagent("screen:address:shared:screen")); curr.products.at(0).set_value(SCREEN); } @@ -210,7 +210,7 @@ void check_screen(const string& expected_contents, const int color) { long long int screen_location = get_or_insert(Memory, SCREEN); int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - long long int screen_data_location = screen_location+data_offset; // type: address:array:character + long long int screen_data_location = screen_location+data_offset; // type: address:shared:array:character long long int screen_data_start = get_or_insert(Memory, screen_data_location); // type: array:character int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); long long int screen_width = get_or_insert(Memory, screen_location+width_offset); @@ -349,7 +349,7 @@ void dump_screen() { long long int screen_height = get_or_insert(Memory, screen_location+height_offset); int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - long long int screen_data_location = screen_location+data_offset; // type: address:array:character + long long int screen_data_location = screen_location+data_offset; // type: address:shared:array:character long long int screen_data_start = get_or_insert(Memory, screen_data_location); // type: array:character assert(get_or_insert(Memory, screen_data_start) == screen_width*screen_height); long long int curr = screen_data_start+1; // skip length diff --git a/083scenario_screen_test.mu b/083scenario_screen_test.mu index 9679e9cf..a135984a 100644 --- a/083scenario_screen_test.mu +++ b/083scenario_screen_test.mu @@ -4,7 +4,7 @@ scenario print-character-at-top-left-2 [ assume-screen 3/width, 2/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a ] screen-should-contain [ .a . @@ -17,11 +17,11 @@ scenario clear-line-erases-printed-characters-2 [ run [ # print a character 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a # move cursor to start of line - screen:address:screen <- move-cursor screen:address:screen, 0/row, 0/column + screen:address:shared:screen <- move-cursor screen:address:shared:screen, 0/row, 0/column # clear line - screen:address:screen <- clear-line screen:address:screen + screen:address:shared:screen <- clear-line screen:address:shared:screen ] screen-should-contain [ . . diff --git a/084console.mu b/084console.mu index 6bc7a590..5adb5a36 100644 --- a/084console.mu +++ b/084console.mu @@ -22,31 +22,31 @@ container resize-event [ container console [ current-event-index:number - events:address:array:event + events:address:shared:array:event ] -recipe new-fake-console events:address:array:event -> result:address:console [ +recipe new-fake-console events:address:shared:array:event -> result:address:shared:console [ local-scope load-ingredients - result:address:console <- new console:type - buf:address:address:array:event <- get-address *result, events:offset + result:address:shared:console <- new console:type + buf:address:address:shared:array:event <- get-address *result, events:offset *buf <- copy events idx:address:number <- get-address *result, current-event-index:offset *idx <- copy 0 ] -recipe read-event console:address:console -> result:event, console:address:console, found?:boolean, quit?:boolean [ +recipe read-event console:address:shared:console -> result:event, console:address:shared:console, found?:boolean, quit?:boolean [ local-scope load-ingredients { break-unless console current-event-index:address:number <- get-address *console, current-event-index:offset - buf:address:array:event <- get *console, events:offset + buf:address:shared:array:event <- get *console, events:offset { max:number <- length *buf done?:boolean <- greater-or-equal *current-event-index, max break-unless done? - dummy:address:event <- new event:type + dummy:address:shared:event <- new event:type reply *dummy, console/same-as-ingredient:0, 1/found, 1/quit } result <- index *buf, *current-event-index @@ -61,7 +61,7 @@ recipe read-event console:address:console -> result:event, console:address:conso # variant of read-event for just keyboard events. Discards everything that # isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get # newlines, tabs, ctrl-d.. -recipe read-key console:address:console -> result:character, console:address:console, found?:boolean, quit?:boolean [ +recipe read-key console:address:shared:console -> result:character, console:address:shared:console, found?:boolean, quit?:boolean [ local-scope load-ingredients x:event, console, found?:boolean, quit?:boolean <- read-event console @@ -72,7 +72,7 @@ recipe read-key console:address:console -> result:character, console:address:con reply *c, console/same-as-ingredient:0, 1/found, 0/quit ] -recipe send-keys-to-channel console:address:console, chan:address:channel, screen:address:screen -> console:address:console, chan:address:channel, screen:address:screen [ +recipe send-keys-to-channel console:address:shared:console, chan:address:shared:channel, screen:address:shared:screen -> console:address:shared:console, chan:address:shared:channel, screen:address:shared:screen [ local-scope load-ingredients { @@ -86,7 +86,7 @@ recipe send-keys-to-channel console:address:console, chan:address:channel, scree } ] -recipe wait-for-event console:address:console -> console:address:console [ +recipe wait-for-event console:address:shared:console -> console:address:shared:console [ local-scope load-ingredients { @@ -96,7 +96,7 @@ recipe wait-for-event console:address:console -> console:address:console [ ] # use this helper to skip rendering if there's lots of other events queued up -recipe has-more-events? console:address:console -> result:boolean [ +recipe has-more-events? console:address:shared:console -> result:boolean [ local-scope load-ingredients { diff --git a/085scenario_console.cc b/085scenario_console.cc index ab07ad76..25737c85 100644 --- a/085scenario_console.cc +++ b/085scenario_console.cc @@ -11,10 +11,10 @@ scenario keyboard-in-scenario [ type [abc] ] run [ - 1:character, console:address:console, 2:boolean <- read-key console:address:console - 3:character, console:address:console, 4:boolean <- read-key console:address:console - 5:character, console:address:console, 6:boolean <- read-key console:address:console - 7:character, console:address:console, 8:boolean, 9:boolean <- read-key console:address:console + 1:character, console:address:shared:console, 2:boolean <- read-key console:address:shared:console + 3:character, console:address:shared:console, 4:boolean <- read-key console:address:shared:console + 5:character, console:address:shared:console, 6:boolean <- read-key console:address:shared:console + 7:character, console:address:shared:console, 8:boolean, 9:boolean <- read-key console:address:shared:console ] memory-should-contain [ 1 <- 97 # 'a' @@ -184,15 +184,15 @@ scenario events-in-scenario [ ] run [ # 3 keyboard events; each event occupies 4 locations - 1:event <- read-event console:address:console - 5:event <- read-event console:address:console - 9:event <- read-event console:address:console + 1:event <- read-event console:address:shared:console + 5:event <- read-event console:address:shared:console + 9:event <- read-event console:address:shared:console # mouse click - 13:event <- read-event console:address:console + 13:event <- read-event console:address:shared:console # non-character keycode - 17:event <- read-event console:address:console + 17:event <- read-event console:address:shared:console # final keyboard event - 21:event <- read-event console:address:console + 21:event <- read-event console:address:shared:console ] memory-should-contain [ 1 <- 0 # 'text' diff --git a/086scenario_console_test.mu b/086scenario_console_test.mu index 754f1166..a11b0091 100644 --- a/086scenario_console_test.mu +++ b/086scenario_console_test.mu @@ -7,10 +7,10 @@ scenario read-key-in-mu [ type [abc] ] run [ - 1:character, console:address:console, 2:boolean <- read-key console:address:console - 3:character, console:address:console, 4:boolean <- read-key console:address:console - 5:character, console:address:console, 6:boolean <- read-key console:address:console - 7:character, console:address:console, 8:boolean <- read-key console:address:console + 1:character, console:address:shared:console, 2:boolean <- read-key console:address:shared:console + 3:character, console:address:shared:console, 4:boolean <- read-key console:address:shared:console + 5:character, console:address:shared:console, 6:boolean <- read-key console:address:shared:console + 7:character, console:address:shared:console, 8:boolean <- read-key console:address:shared:console ] memory-should-contain [ 1 <- 97 # 'a' diff --git a/091run_interactive.cc b/091run_interactive.cc index 0fe335ed..cb01b2a5 100644 --- a/091run_interactive.cc +++ b/091run_interactive.cc @@ -4,16 +4,16 @@ :(scenario run_interactive_code) recipe main [ 1:number/raw <- copy 0 - 2:address:array:character <- new [1:number/raw <- copy 34] - run-interactive 2:address:array:character + 2:address:shared:array:character <- new [1:number/raw <- copy 34] + run-interactive 2:address:shared:array:character 3:number/raw <- copy 1:number/raw ] +mem: storing 34 in location 3 :(scenario run_interactive_empty) recipe main [ - 1:address:array:character <- copy 0/unsafe - 2:address:array:character <- run-interactive 1:address:array:character + 1:address:shared:array:character <- copy 0/unsafe + 2:address:shared:array:character <- run-interactive 1:address:shared:array:character ] # result is null +mem: storing 0 in location 2 @@ -88,7 +88,7 @@ bool run_interactive(long long int address) { // call run(string) but without the scheduling load(string("recipe! interactive [\n") + "local-scope\n" + - "screen:address:screen <- next-ingredient\n" + + "screen:address:shared:screen <- next-ingredient\n" + "$start-tracking-products\n" + command + "\n" + "$stop-tracking-products\n" + @@ -153,15 +153,15 @@ load(string( "]\n" + "recipe sandbox [\n" + "local-scope\n" + - "screen:address:screen/shared <- new-fake-screen 30, 5\n" + + "screen:address:shared:screen <- new-fake-screen 30, 5\n" + "r:number/routine_id <- start-running interactive, screen\n" + "limit-time r, 100000/instructions\n" + "wait-for-routine r\n" + "sandbox-state:number <- routine-state r/routine_id\n" + "completed?:boolean <- equal sandbox-state, 1/completed\n" + - "output:address:array:character <- $most-recent-products\n" + - "warnings:address:array:character <- save-errors-warnings\n" + - "stashes:address:array:character <- save-app-trace\n" + + "output:address:shared:array:character <- $most-recent-products\n" + + "warnings:address:shared:array:character <- save-errors-warnings\n" + + "stashes:address:shared:array:character <- save-app-trace\n" + "$cleanup-run-interactive\n" + "reply output, warnings, screen, stashes, completed?\n" + "]\n"); @@ -174,10 +174,10 @@ Recently_added_recipes.clear(); :(scenario run_interactive_comments) recipe main [ - 1:address:array:character <- new [# ab + 1:address:shared:array:character <- new [# ab add 2, 2] - 2:address:array:character <- run-interactive 1:address:array:character - 3:array:character <- copy *2:address:array:character + 2:address:shared:array:character <- run-interactive 1:address:shared:array:character + 3:array:character <- copy *2:address:shared:array:character ] +mem: storing 52 in location 4 @@ -271,9 +271,9 @@ case _CLEANUP_RUN_INTERACTIVE: { :(scenario "run_interactive_converts_result_to_text") recipe main [ # try to interactively add 2 and 2 - 1:address:array:character <- new [add 2, 2] - 2:address:array:character <- run-interactive 1:address:array:character - 10:array:character <- copy 2:address:array:character/lookup + 1:address:shared:array:character <- new [add 2, 2] + 2:address:shared:array:character <- run-interactive 1:address:shared:array:character + 10:array:character <- copy 2:address:shared:array:character/lookup ] # first letter in the output should be '4' in unicode +mem: storing 52 in location 11 @@ -281,13 +281,13 @@ recipe main [ :(scenario "run_interactive_returns_text") recipe main [ # try to interactively add 2 and 2 - 1:address:array:character <- new [ - x:address:array:character <- new [a] - y:address:array:character <- new [b] - z:address:array:character <- append x:address:array:character, y:address:array:character + 1:address:shared:array:character <- new [ + x:address:shared:array:character <- new [a] + y:address:shared:array:character <- new [b] + z:address:shared:array:character <- append x:address:shared:array:character, y:address:shared:array:character ] - 2:address:array:character <- run-interactive 1:address:array:character - 10:array:character <- copy 2:address:array:character/lookup + 2:address:shared:array:character <- run-interactive 1:address:shared:array:character + 10:array:character <- copy 2:address:shared:array:character/lookup ] # output contains "ab" +mem: storing 97 in location 11 @@ -296,10 +296,10 @@ recipe main [ :(scenario "run_interactive_returns_errors") recipe main [ # run a command that generates an error - 1:address:array:character <- new [x:number <- copy 34 + 1:address:shared:array:character <- new [x:number <- copy 34 get x:number, foo:offset] - 2:address:array:character, 3:address:array:character <- run-interactive 1:address:array:character - 10:array:character <- copy 3:address:array:character/lookup + 2:address:shared:array:character, 3:address:shared:array:character <- run-interactive 1:address:shared:array:character + 10:array:character <- copy 3:address:shared:array:character/lookup ] # error should be "unknown element foo in container number" +mem: storing 117 in location 11 @@ -311,10 +311,10 @@ get x:number, foo:offset] :(scenario run_interactive_with_comment) recipe main [ # 2 instructions, with a comment after the first - 1:address:array:number <- new [a:number <- copy 0 # abc + 1:address:shared:array:number <- new [a:number <- copy 0 # abc b:number <- copy 0 ] - 2:address:array:character, 3:address:array:character <- run-interactive 1:address:array:character + 2:address:shared:array:character, 3:address:shared:array:character <- run-interactive 1:address:shared:array:character ] # no errors +mem: storing 0 in location 3 @@ -331,8 +331,8 @@ void test_run_interactive_cleans_up_any_created_specializations() { // run-interactive a call that specializes this recipe run("recipe main [\n" " 1:number/raw <- copy 0\n" - " 2:address:array:character <- new [foo 1:number/raw]\n" - " run-interactive 2:address:array:character\n" + " 2:address:shared:array:character <- new [foo 1:number/raw]\n" + " run-interactive 2:address:shared:array:character\n" "]\n"); assert(SIZE(Recently_added_recipes) == 2); // foo, main // check that number of variants doesn't change @@ -504,7 +504,7 @@ case RELOAD: { :(scenario reload_continues_past_error) recipe main [ local-scope - x:address:array:character <- new [recipe foo [ + x:address:shared:array:character <- new [recipe foo [ get 1234:number, foo:offset ]] reload x @@ -520,7 +520,7 @@ void test_reload_cleans_up_any_created_specializations() { // a call that specializes this recipe run("recipe main [\n" " local-scope\n" - " x:address:array:character <- new [recipe foo x:_elem -> n:number [\n" + " x:address:shared:array:character <- new [recipe foo x:_elem -> n:number [\n" "local-scope\n" "load-ingredients\n" "reply 34\n" diff --git a/channel.mu b/channel.mu index def7c08b..54486957 100644 --- a/channel.mu +++ b/channel.mu @@ -1,6 +1,6 @@ # example program: communicating between routines using channels -recipe producer chan:address:channel -> chan:address:channel [ +recipe producer chan:address:shared:channel -> chan:address:shared:channel [ # produce characters 1 to 5 on a channel local-scope load-ingredients @@ -12,19 +12,19 @@ recipe producer chan:address:channel -> chan:address:channel [ # other threads might get between these prints $print [produce: ], n, [ ] - chan:address:channel <- write chan, n + chan:address:shared:channel <- write chan, n n <- add n, 1 loop } ] -recipe consumer chan:address:channel -> chan:address:channel [ +recipe consumer chan:address:shared:channel -> chan:address:shared:channel [ # consume and print integers from a channel local-scope load-ingredients { # read an integer from the channel - n:character, chan:address:channel <- read chan + n:character, chan:address:shared:channel <- read chan # other threads might get between these prints $print [consume: ], n:character, [ ] @@ -34,7 +34,7 @@ recipe consumer chan:address:channel -> chan:address:channel [ recipe main [ local-scope - chan:address:channel <- new-channel 3 + chan:address:shared:channel <- new-channel 3 # create two background 'routines' that communicate by a channel routine1:number <- start-running producer, chan routine2:number <- start-running consumer, chan diff --git a/chessboard.mu b/chessboard.mu index f1bd8853..d7cce788 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -34,7 +34,7 @@ scenario print-board-and-read-move [ ] ] run [ - screen:address:screen, console:address:console <- chessboard screen:address:screen, console:address:console + screen:address:shared:screen, console:address:shared:console <- chessboard screen:address:shared:screen, console:address:shared:console # icon for the cursor screen <- print screen, 9251/␣ ] @@ -66,18 +66,18 @@ scenario print-board-and-read-move [ ## Here's how 'chessboard' is implemented. -recipe chessboard screen:address:screen, console:address:console -> screen:address:screen, console:address:console [ +recipe chessboard screen:address:shared:screen, console:address:shared:console -> screen:address:shared:screen, console:address:shared:console [ local-scope load-ingredients - board:address:array:address:array:character <- initial-position + board:address:shared:array:address:shared:array:character <- initial-position # hook up stdin - stdin:address:channel <- new-channel 10/capacity + stdin:address:shared:channel <- new-channel 10/capacity start-running send-keys-to-channel, console, stdin, screen # buffer lines in stdin - buffered-stdin:address:channel <- new-channel 10/capacity + buffered-stdin:address:shared:channel <- new-channel 10/capacity start-running buffer-lines, stdin, buffered-stdin { - msg:address:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves. + msg:address:shared:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves. ] print screen, msg cursor-to-next-line screen @@ -94,7 +94,7 @@ recipe chessboard screen:address:screen, console:address:console -> screen:addre cursor-to-next-line screen msg <- new [move: ] screen <- print screen, msg - m:address:move, quit:boolean, error:boolean <- read-move buffered-stdin, screen + m:address:shared:move, quit:boolean, error:boolean <- read-move buffered-stdin, screen break-if quit, +quit:label buffered-stdin <- clear-channel buffered-stdin # cleanup after error. todo: test this? loop-if error @@ -103,12 +103,13 @@ recipe chessboard screen:address:screen, console:address:console -> screen:addre screen <- clear-screen screen loop } + msg <- copy 0 +quit ] ## a board is an array of files, a file is an array of characters (squares) -recipe new-board initial-position:address:array:character -> board:address:array:address:array:character [ +recipe new-board initial-position:address:shared:array:character -> board:address:shared:array:address:shared:array:character [ local-scope load-ingredients # assert(length(initial-position) == 64) @@ -116,19 +117,19 @@ recipe new-board initial-position:address:array:character -> board:address:array correct-length?:boolean <- equal len, 64 assert correct-length?, [chessboard had incorrect size] # board is an array of pointers to files; file is an array of characters - board <- new {(address array character): type}, 8 + board <- new {(address shared array character): type}, 8 col:number <- copy 0 { done?:boolean <- equal col, 8 break-if done? - file:address:address:array:character <- index-address *board, col + file:address:address:shared:array:character <- index-address *board, col *file <- new-file initial-position, col col <- add col, 1 loop } ] -recipe new-file position:address:array:character, index:number -> result:address:array:character [ +recipe new-file position:address:shared:array:character, index:number -> result:address:shared:array:character [ local-scope load-ingredients index <- multiply index, 8 @@ -145,7 +146,7 @@ recipe new-file position:address:array:character, index:number -> result:address } ] -recipe print-board screen:address:screen, board:address:array:address:array:character -> screen:address:screen [ +recipe print-board screen:address:shared:screen, board:address:shared:array:address:shared:array:character -> screen:address:shared:screen [ local-scope load-ingredients row:number <- copy 7 # start printing from the top of the board @@ -157,14 +158,14 @@ recipe print-board screen:address:screen, board:address:array:address:array:char # print rank number as a legend rank:number <- add row, 1 print-integer screen, rank - s:address:array:character <- new [ | ] + s:address:shared:array:character <- new [ | ] print screen, s # print each square in the row col:number <- copy 0 { done?:boolean <- equal col:number, 8 break-if done?:boolean - f:address:array:character <- index *board, col + f:address:shared:array:character <- index *board, col c:character <- index *f, row print screen, c print screen, space @@ -184,7 +185,7 @@ recipe print-board screen:address:screen, board:address:array:address:array:char screen <- cursor-to-next-line screen ] -recipe initial-position -> board:address:array:address:array:character [ +recipe initial-position -> board:address:shared:array:address:shared:array:character [ local-scope # layout in memory (in raster order): # R P _ _ _ _ p r @@ -195,7 +196,7 @@ recipe initial-position -> board:address:array:address:array:character [ # B P _ _ _ _ p B # N P _ _ _ _ p n # R P _ _ _ _ p r - initial-position:address:array:character <- new-array 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r + initial-position:address:shared:array:character <- new-array 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r #? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, #? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, #? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, @@ -210,8 +211,8 @@ recipe initial-position -> board:address:array:address:array:character [ scenario printing-the-board [ assume-screen 30/width, 12/height run [ - 1:address:array:address:array:character/board <- initial-position - screen:address:screen <- print-board screen:address:screen, 1:address:array:address:array:character/board + 1:address:shared:array:address:shared:array:character/board <- initial-position + screen:address:shared:screen <- print-board screen:address:shared:screen, 1:address:shared:array:address:shared:array:character/board ] screen-should-contain [ # 012345678901234567890123456789 @@ -241,14 +242,14 @@ container move [ ] # prints only error messages to screen -recipe read-move stdin:address:channel, screen:address:screen -> result:address:move, quit?:boolean, error?:boolean, stdin:address:channel, screen:address:screen [ +recipe read-move stdin:address:shared:channel, screen:address:shared:screen -> result:address:shared:move, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [ local-scope load-ingredients from-file:number, quit?:boolean, error?:boolean <- read-file stdin, screen reply-if quit?, 0/dummy, quit?, error? reply-if error?, 0/dummy, quit?, error? # construct the move object - result:address:move <- new move:type + result:address:shared:move <- new move:type x:address:number <- get-address *result, from-file:offset *x <- copy from-file x <- get-address *result, from-rank:offset @@ -271,7 +272,7 @@ recipe read-move stdin:address:channel, screen:address:screen -> result:address: ] # valid values for file: 0-7 -recipe read-file stdin:address:channel, screen:address:screen -> file:number, quit:boolean, error:boolean, stdin:address:channel, screen:address:screen [ +recipe read-file stdin:address:shared:channel, screen:address:shared:screen -> file:number, quit:boolean, error:boolean, stdin:address:shared:channel, screen:address:shared:screen [ local-scope load-ingredients c:character, stdin <- read stdin @@ -293,7 +294,7 @@ recipe read-file stdin:address:channel, screen:address:screen -> file:number, qu { newline?:boolean <- equal c, 10/newline break-unless newline? - error-message:address:array:character <- new [that's not enough] + error-message:address:shared:array:character <- new [that's not enough] print screen, error-message reply 0/dummy, 0/quit, 1/error } @@ -302,7 +303,7 @@ recipe read-file stdin:address:channel, screen:address:screen -> file:number, qu { above-min:boolean <- greater-or-equal file, 0 break-if above-min - error-message:address:array:character <- new [file too low: ] + error-message:address:shared:array:character <- new [file too low: ] print screen, error-message print screen, c cursor-to-next-line screen @@ -320,7 +321,7 @@ recipe read-file stdin:address:channel, screen:address:screen -> file:number, qu ] # valid values: 0-7, -1 (quit), -2 (error) -recipe read-rank stdin:address:channel, screen:address:screen -> rank:number, quit?:boolean, error?:boolean, stdin:address:channel, screen:address:screen [ +recipe read-rank stdin:address:shared:channel, screen:address:shared:screen -> rank:number, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [ local-scope load-ingredients c:character, stdin <- read stdin @@ -337,7 +338,7 @@ recipe read-rank stdin:address:channel, screen:address:screen -> rank:number, qu { newline?:boolean <- equal c, 10 # newline break-unless newline? - error-message:address:array:character <- new [that's not enough] + error-message:address:shared:array:character <- new [that's not enough] print screen, error-message reply 0/dummy, 0/quit, 1/error } @@ -364,14 +365,14 @@ recipe read-rank stdin:address:channel, screen:address:screen -> rank:number, qu # read a character from the given channel and check that it's what we expect # return true on error -recipe expect-from-channel stdin:address:channel, expected:character, screen:address:screen -> result:boolean, stdin:address:channel, screen:address:screen [ +recipe expect-from-channel stdin:address:shared:channel, expected:character, screen:address:shared:screen -> result:boolean, stdin:address:shared:channel, screen:address:shared:screen [ local-scope load-ingredients c:character, stdin <- read stdin { match?:boolean <- equal c, expected break-if match? - s:address:array:character <- new [expected character not found] + s:address:shared:array:character <- new [expected character not found] print screen, s } result <- not match? @@ -380,8 +381,8 @@ recipe expect-from-channel stdin:address:channel, expected:character, screen:add scenario read-move-blocking [ assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2 - 2:number/routine <- start-running read-move, 1:address:channel, screen:address:screen + 1:address:shared:channel <- new-channel 2 + 2:number/routine <- start-running read-move, 1:address:shared:channel, screen:address:shared:screen # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id @@ -389,7 +390,7 @@ scenario read-move-blocking [ assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)] # press 'a' - 1:address:channel <- write 1:address:channel, 97/a + 1:address:shared:channel <- write 1:address:shared:channel, 97/a restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number @@ -398,7 +399,7 @@ F read-move-blocking: routine failed to pause after coming up (before any keys w assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after rank 'a'] # press '2' - 1:address:channel <- write 1:address:channel, 50/'2' + 1:address:shared:channel <- write 1:address:shared:channel, 50/'2' restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number @@ -407,7 +408,7 @@ F read-move-blocking: routine failed to pause after rank 'a'] assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after file 'a2'] # press '-' - 1:address:channel <- write 1:address:channel, 45/'-' + 1:address:shared:channel <- write 1:address:shared:channel, 45/'-' restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number @@ -416,7 +417,7 @@ F read-move-blocking: routine failed to pause after file 'a2'] assert 4:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause after hyphen 'a2-'] # press 'a' - 1:address:channel <- write 1:address:channel, 97/a + 1:address:shared:channel <- write 1:address:shared:channel, 97/a restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number @@ -425,7 +426,7 @@ F read-move-blocking: routine failed to pause after hyphen 'a2-'] assert 4:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause after rank 'a2-a'] # press '4' - 1:address:channel <- write 1:address:channel, 52/'4' + 1:address:shared:channel <- write 1:address:shared:channel, 52/'4' restart 2:number/routine # 'read-move' still waiting for input wait-for-routine 2:number @@ -434,7 +435,7 @@ F read-move-blocking: routine failed to pause after rank 'a2-a'] assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after file 'a2-a4'] # press 'newline' - 1:address:channel <- write 1:address:channel, 10 # newline + 1:address:shared:channel <- write 1:address:shared:channel, 10 # newline restart 2:number/routine # 'read-move' now completes wait-for-routine 2:number @@ -452,8 +453,8 @@ F read-move-blocking: routine failed to terminate on newline] scenario read-move-quit [ assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2 - 2:number/routine <- start-running read-move, 1:address:channel, screen:address:screen + 1:address:shared:channel <- new-channel 2 + 2:number/routine <- start-running read-move, 1:address:shared:channel, screen:address:shared:screen # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id @@ -461,7 +462,7 @@ scenario read-move-quit [ assert 4:boolean/waiting?, [ F read-move-quit: routine failed to pause after coming up (before any keys were pressed)] # press 'q' - 1:address:channel <- write 1:address:channel, 113/q + 1:address:shared:channel <- write 1:address:shared:channel, 113/q restart 2:number/routine # 'read-move' completes wait-for-routine 2:number @@ -479,15 +480,15 @@ F read-move-quit: routine failed to terminate on 'q'] scenario read-move-illegal-file [ assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2 - 2:number/routine <- start-running read-move, 1:address:channel, screen:address:screen + 1:address:shared:channel <- new-channel 2 + 2:number/routine <- start-running read-move, 1:address:shared:channel, screen:address:shared:screen # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id 4:boolean/waiting? <- equal 3:number/routine-state, 3/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] - 1:address:channel <- write 1:address:channel, 50/'2' + 1:address:shared:channel <- write 1:address:shared:channel, 50/'2' restart 2:number/routine wait-for-routine 2:number ] @@ -500,16 +501,16 @@ F read-move-file: routine failed to pause after coming up (before any keys were scenario read-move-illegal-rank [ assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2 - 2:number/routine <- start-running read-move, 1:address:channel, screen:address:screen + 1:address:shared:channel <- new-channel 2 + 2:number/routine <- start-running read-move, 1:address:shared:channel, screen:address:shared:screen # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id 4:boolean/waiting? <- equal 3:number/routine-state, 3/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] - 1:address:channel <- write 1:address:channel, 97/a - 1:address:channel <- write 1:address:channel, 97/a + 1:address:shared:channel <- write 1:address:shared:channel, 97/a + 1:address:shared:channel <- write 1:address:shared:channel, 97/a restart 2:number/routine wait-for-routine 2:number ] @@ -522,16 +523,16 @@ F read-move-file: routine failed to pause after coming up (before any keys were scenario read-move-empty [ assume-screen 20/width, 2/height run [ - 1:address:channel <- new-channel 2 - 2:number/routine <- start-running read-move, 1:address:channel, screen:address:screen + 1:address:shared:channel <- new-channel 2 + 2:number/routine <- start-running read-move, 1:address:shared:channel, screen:address:shared:screen # 'read-move' is waiting for input wait-for-routine 2:number 3:number <- routine-state 2:number/id 4:boolean/waiting? <- equal 3:number/routine-state, 3/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] - 1:address:channel <- write 1:address:channel, 10/newline - 1:address:channel <- write 1:address:channel, 97/a + 1:address:shared:channel <- write 1:address:shared:channel, 10/newline + 1:address:shared:channel <- write 1:address:shared:channel, 97/a restart 2:number/routine wait-for-routine 2:number ] @@ -541,14 +542,14 @@ F read-move-file: routine failed to pause after coming up (before any keys were ] ] -recipe make-move board:address:array:address:array:character, m:address:move -> board:address:array:address:array:character [ +recipe make-move board:address:shared:array:address:shared:array:character, m:address:shared:move -> board:address:shared:array:address:shared:array:character [ local-scope load-ingredients from-file:number <- get *m, from-file:offset from-rank:number <- get *m, from-rank:offset to-file:number <- get *m, to-file:offset to-rank:number <- get *m, to-rank:offset - f:address:array:character <- index *board, from-file + f:address:shared:array:character <- index *board, from-file src:address:character/square <- index-address *f, from-rank f <- index *board, to-file dest:address:character/square <- index-address *f, to-rank @@ -559,18 +560,18 @@ recipe make-move board:address:array:address:array:character, m:address:move -> scenario making-a-move [ assume-screen 30/width, 12/height run [ - 2:address:array:address:array:character/board <- initial-position - 3:address:move <- new move:type - 4:address:number <- get-address *3:address:move, from-file:offset + 2:address:shared:array:address:shared:array:character/board <- initial-position + 3:address:shared:move <- new move:type + 4:address:number <- get-address *3:address:shared:move, from-file:offset *4:address:number <- copy 6/g - 5:address:number <- get-address *3:address:move, from-rank:offset + 5:address:number <- get-address *3:address:shared:move, from-rank:offset *5:address:number <- copy 1/'2' - 6:address:number <- get-address *3:address:move, to-file:offset + 6:address:number <- get-address *3:address:shared:move, to-file:offset *6:address:number <- copy 6/g - 7:address:number <- get-address *3:address:move, to-rank:offset + 7:address:number <- get-address *3:address:shared:move, to-rank:offset *7:address:number <- copy 3/'4' - 2:address:array:address:array:character/board <- make-move 2:address:array:address:array:character/board, 3:address:move - screen:address:screen <- print-board screen:address:screen, 2:address:array:address:array:character/board + 2:address:shared:array:address:shared:array:character/board <- make-move 2:address:shared:array:address:shared:array:character/board, 3:address:shared:move + screen:address:shared:screen <- print-board screen:address:shared:screen, 2:address:shared:array:address:shared:array:character/board ] screen-should-contain [ # 012345678901234567890123456789 diff --git a/counters.mu b/counters.mu index 22f5554f..b69b2eee 100644 --- a/counters.mu +++ b/counters.mu @@ -1,24 +1,24 @@ # example program: maintain multiple counters with isolated lexical scopes # (spaces) -recipe new-counter n:number -> default-space:address:array:location [ +recipe new-counter n:number -> default-space:address:shared:array:location [ default-space <- new location:type, 30 load-ingredients ] -recipe increment-counter outer:address:array:location/names:new-counter, x:number -> n:number/space:1 [ +recipe increment-counter outer:address:shared:array:location/names:new-counter, x:number -> n:number/space:1 [ local-scope load-ingredients - 0:address:array:location/names:new-counter <- copy outer # setup outer space; it *must* come from 'new-counter' + 0:address:shared:array:location/names:new-counter <- copy outer # setup outer space; it *must* come from 'new-counter' n/space:1 <- add n/space:1, x ] recipe main [ local-scope # counter A - a:address:array:location <- new-counter 34 + a:address:shared:array:location <- new-counter 34 # counter B - b:address:array:location <- new-counter 23 + b:address:shared:array:location <- new-counter 23 # increment both by 2 but in different ways increment-counter a, 1 b-value:number <- increment-counter b, 2 diff --git a/edit/001-editor.mu b/edit/001-editor.mu index fd44d493..773b7d77 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -2,7 +2,7 @@ # temporary main for this layer: just render the given text at the given # screen dimensions, then stop -recipe! main text:address:array:character [ +recipe! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -16,8 +16,8 @@ recipe! main text:address:array:character [ scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ - 1:address:array:character <- new [abc] - new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -29,11 +29,11 @@ scenario editor-initially-prints-text-to-screen [ container editor-data [ # editable text: doubly linked list of characters (head contains a special sentinel) - data:address:duplex-list:character - top-of-screen:address:duplex-list:character - bottom-of-screen:address:duplex-list:character + data:address:shared:duplex-list:character + top-of-screen:address:shared:duplex-list:character + bottom-of-screen:address:shared:duplex-list:character # location before cursor inside data - before-cursor:address:duplex-list:character + before-cursor:address:shared:duplex-list:character # raw bounds of display area on screen # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen @@ -47,7 +47,7 @@ container editor-data [ # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -recipe new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data, screen:address:screen [ +recipe new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ local-scope load-ingredients # no clipping of bounds @@ -63,11 +63,11 @@ recipe new-editor s:address:array:character, screen:address:screen, left:number, *x <- copy 1/top x <- get-address *result, cursor-column:offset *x <- copy left - init:address:address:duplex-list:character <- get-address *result, data:offset + init:address:address:shared:duplex-list:character <- get-address *result, data:offset *init <- push 167/§, 0/tail - top-of-screen:address:address:duplex-list:character <- get-address *result, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *result, top-of-screen:offset *top-of-screen <- copy *init - y:address:address:duplex-list:character <- get-address *result, before-cursor:offset + y:address:address:shared:duplex-list:character <- get-address *result, before-cursor:offset *y <- copy *init result <- insert-text result, s # initialize cursor to top of screen @@ -78,7 +78,7 @@ recipe new-editor s:address:array:character, screen:address:screen, left:number, <editor-initialization> ] -recipe insert-text editor:address:editor-data, text:address:array:character -> editor:address:editor-data [ +recipe insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ local-scope load-ingredients # early exit if text is empty @@ -87,7 +87,7 @@ recipe insert-text editor:address:editor-data, text:address:array:character -> e reply-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character - curr:address:duplex-list:character <- get *editor, data:offset + curr:address:shared:duplex-list:character <- get *editor, data:offset { done?:boolean <- greater-or-equal idx, len break-if done? @@ -104,8 +104,8 @@ recipe insert-text editor:address:editor-data, text:address:array:character -> e scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ - 1:address:editor-data <- new-editor 0/data, screen:address:screen, 2/left, 5/right - 2:editor-data <- copy *1:address:editor-data + 1:address:shared:editor-data <- new-editor 0/data, screen:address:shared:screen, 2/left, 5/right + 2:editor-data <- copy *1:address:shared:editor-data ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -127,7 +127,7 @@ scenario editor-initializes-without-data [ # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -recipe render screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +recipe render screen:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 @@ -135,8 +135,8 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb screen-height:number <- screen-height screen right:number <- get *editor, right:offset # traversing editor - curr:address:duplex-list:character <- get *editor, top-of-screen:offset - prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:shared:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr # traversing screen +render-loop-initialization @@ -145,7 +145,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb column:number <- copy left cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset screen <- move-cursor screen, row, column { +next-character @@ -208,7 +208,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb loop } # save first character off-screen - bottom-of-screen:address:address:duplex-list:character <- get-address *editor, bottom-of-screen:offset + bottom-of-screen:address:address:shared:duplex-list:character <- get-address *editor, bottom-of-screen:offset *bottom-of-screen <- copy curr # is cursor to the right of the last line? move to end { @@ -225,7 +225,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited screen:address:screen, column:number, right:number -> screen:address:screen [ +recipe clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients space:character <- copy 32/space @@ -238,7 +238,7 @@ recipe clear-line-delimited screen:address:screen, column:number, right:number - } ] -recipe clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number -> screen:address:screen [ +recipe clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive @@ -254,7 +254,7 @@ recipe clear-screen-from screen:address:screen, row:number, column:number, left: reply screen/same-as-ingredient:0 ] -recipe clear-rest-of-screen screen:address:screen, row:number, left:number, right:number -> screen:address:screen [ +recipe clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients row <- add row, 1 @@ -273,9 +273,9 @@ recipe clear-rest-of-screen screen:address:screen, row:number, left:number, righ scenario editor-initially-prints-multiple-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -288,8 +288,8 @@ def] scenario editor-initially-handles-offsets [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc] - new-editor s:address:array:character, screen:address:screen, 1/left, 5/right + s:address:shared:array:character <- new [abc] + new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -301,9 +301,9 @@ scenario editor-initially-handles-offsets [ scenario editor-initially-prints-multiple-lines-at-offset [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 1/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -316,8 +316,8 @@ def] scenario editor-initially-wraps-long-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + s:address:shared:array:character <- new [abc def] + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -336,8 +336,8 @@ scenario editor-initially-wraps-long-lines [ scenario editor-initially-wraps-barely-long-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abcde] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + s:address:shared:array:character <- new [abcde] + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -358,10 +358,10 @@ scenario editor-initially-wraps-barely-long-lines [ scenario editor-initializes-empty-text [ assume-screen 5/width, 5/height run [ - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -379,10 +379,10 @@ scenario editor-initializes-empty-text [ scenario render-colors-comments [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc # de f] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -460,10 +460,10 @@ recipe get-color color:number, c:character -> color:number [ scenario render-colors-assignment [ assume-screen 8/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc d <- e f] - new-editor s:address:array:character, screen:address:screen, 0/left, 8/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/edit/002-typing.mu b/edit/002-typing.mu index 037c222b..f3f6b321 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -2,16 +2,16 @@ # temporary main: interactive editor # hit ctrl-c to exit -recipe! main text:address:array:character [ +recipe! main text:address:shared:array:character [ local-scope load-ingredients open-console - editor:address:editor-data <- new-editor text, 0/screen, 5/left, 45/right + editor:address:shared:editor-data <- new-editor text, 0/screen, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] -recipe editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data -> screen:address:screen, console:address:console, editor:address:editor-data [ +recipe editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ local-scope load-ingredients { @@ -20,7 +20,7 @@ recipe editor-event-loop screen:address:screen, console:address:console, editor: cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column - e:event, console:address:console, found?:boolean, quit?:boolean <- read-event console + e:event, console:address:shared:console, found?:boolean, quit?:boolean <- read-event console loop-unless found? break-if quit? # only in tests trace 10, [app], [next-event] @@ -45,7 +45,7 @@ recipe editor-event-loop screen:address:screen, console:address:console, editor: ] # process click, return if it was on current editor -recipe move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event -> in-focus?:boolean, editor:address:editor-data [ +recipe move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor, 0/false @@ -70,7 +70,7 @@ recipe move-cursor-in-editor screen:address:screen, editor:address:editor-data, # Variant of 'render' that only moves the cursor (coordinates and # before-cursor). If it's past the end of a line, it 'slides' it left. If it's # past the last line it positions at end of last line. -recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number -> editor:address:editor-data [ +recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor @@ -78,8 +78,8 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row right:number <- get *editor, right:offset screen-height:number <- screen-height screen # count newlines until screen row - curr:address:duplex-list:character <- get *editor, top-of-screen:offset - prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:shared:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr row:number <- copy 1/top column:number <- copy left @@ -87,7 +87,7 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row *cursor-row <- copy target-row cursor-column:address:number <- get-address *editor, cursor-column:offset *cursor-column <- copy target-column - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset { +next-character break-unless curr @@ -155,7 +155,7 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row # Process an event 'e' and try to minimally update the screen. # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. -recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event -> screen:address:screen, editor:address:editor-data, go-render?:boolean [ +recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients go-render? <- copy 0/false @@ -164,7 +164,7 @@ recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, screen-height:number <- screen-height screen left:number <- get *editor, left:offset right:number <- get *editor, right:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset save-row:number <- copy *cursor-row @@ -195,10 +195,10 @@ recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, reply ] -recipe insert-at-cursor editor:address:editor-data, c:character, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset insert c, *before-cursor *before-cursor <- next *before-cursor cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -213,7 +213,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: <insert-character-special-case> # but mostly we'll just move the cursor right *cursor-column <- add *cursor-column, 1 - next:address:duplex-list:character <- next *before-cursor + next:address:shared:duplex-list:character <- next *before-cursor { # at end of all text? no need to scroll? just print the character and leave at-end?:boolean <- equal next, 0/null @@ -233,7 +233,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: break-unless next at-right?:boolean <- greater-or-equal *cursor-column, screen-width break-if at-right? - curr:address:duplex-list:character <- copy *before-cursor + curr:address:shared:duplex-list:character <- copy *before-cursor move-cursor screen, save-row, save-column curr-column:number <- copy save-column { @@ -259,7 +259,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: ] # helper for tests -recipe editor-render screen:address:screen, editor:address:editor-data -> screen:address:screen, editor:address:editor-data [ +recipe editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients left:number <- get *editor, left:offset @@ -274,12 +274,12 @@ recipe editor-render screen:address:screen, editor:address:editor-data -> screen scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -291,17 +291,17 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -318,16 +318,16 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -338,17 +338,17 @@ scenario editor-handles-mouse-clicks-outside-text [ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -359,17 +359,17 @@ def] scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -380,19 +380,19 @@ def] scenario editor-handles-mouse-clicks-outside-column [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] + 1:address:shared:array:character <- new [abc] # editor occupies only left half of screen - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -409,18 +409,18 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -431,15 +431,15 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -452,9 +452,9 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # type two letters at different places assume-console [ @@ -463,7 +463,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -476,16 +476,16 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -498,17 +498,17 @@ scenario editor-inserts-characters-at-cursor-2 [ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -522,16 +522,16 @@ d] scenario editor-inserts-characters-at-cursor-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -544,17 +544,17 @@ scenario editor-inserts-characters-at-cursor-3 [ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -568,17 +568,17 @@ d] scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -592,14 +592,14 @@ d] scenario editor-moves-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ab] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [ab] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [01] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -613,15 +613,15 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ assume-screen 5/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # no wrap yet screen-should-contain [ @@ -636,7 +636,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # now wrap screen-should-contain [ @@ -651,19 +651,19 @@ scenario editor-wraps-line-on-insert [ scenario editor-wraps-line-on-insert-2 [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abcdefg + 1:address:shared:array:character <- new [abcdefg defg] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -703,16 +703,16 @@ after <insert-character-special-case> [ scenario editor-wraps-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 1, 4 # line is full; no wrap icon yet type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -729,16 +729,16 @@ scenario editor-wraps-cursor-after-inserting-characters [ scenario editor-wraps-cursor-after-inserting-characters-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -755,16 +755,16 @@ scenario editor-wraps-cursor-after-inserting-characters-2 [ scenario editor-wraps-cursor-to-left-margin [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 2/left, 7/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -792,14 +792,14 @@ after <editor-initialization> [ scenario editor-moves-cursor-down-after-inserting-newline [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -822,12 +822,12 @@ after <handle-special-character> [ } ] -recipe insert-new-line-and-indent editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset screen-height:number <- screen-height screen @@ -847,8 +847,8 @@ recipe insert-new-line-and-indent editor:address:editor-data, screen:address:scr # indent if necessary indent?:boolean <- get *editor, indent?:offset reply-unless indent? - d:address:duplex-list:character <- get *editor, data:offset - end-of-previous-line:address:duplex-list:character <- prev *before-cursor + d:address:shared:duplex-list:character <- get *editor, data:offset + end-of-previous-line:address:shared:duplex-list:character <- prev *before-cursor indent:number <- line-indent end-of-previous-line, d i:number <- copy 0 { @@ -862,7 +862,7 @@ recipe insert-new-line-and-indent editor:address:editor-data, screen:address:scr # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the number of spaces at the start of the line containing 'curr'. -recipe line-indent curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +recipe line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -894,14 +894,14 @@ recipe line-indent curr:address:duplex-list:character, start:address:duplex-list scenario editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -914,8 +914,8 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ scenario editor-clears-previous-line-completely-after-inserting-newline [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ press enter ] @@ -927,7 +927,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # line should be fully cleared screen-should-contain [ @@ -941,10 +941,10 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ scenario editor-inserts-indent-after-newline [ assume-screen 10/width, 10/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -952,9 +952,9 @@ ef] ] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -965,10 +965,10 @@ ef] scenario editor-skips-indent-around-paste [ assume-screen 10/width, 10/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -977,9 +977,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1012,7 +1012,7 @@ after <handle-special-key> [ ## helpers -recipe draw-horizontal screen:address:screen, row:number, x:number, right:number -> screen:address:screen [ +recipe draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index feab04ea..b69bf2bd 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -7,14 +7,14 @@ scenario editor-inserts-two-spaces-on-tab [ assume-screen 10/width, 5/height # just one character in final line - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -40,18 +40,18 @@ after <handle-special-character> [ scenario editor-handles-backspace-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -71,7 +71,7 @@ after <handle-special-character> [ delete-previous-character?:boolean <- equal *c, 8/backspace break-unless delete-previous-character? <backspace-character-begin> - editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character <- delete-before-cursor editor, screen + editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen <backspace-character-end> reply } @@ -80,19 +80,19 @@ after <handle-special-character> [ # return values: # go-render? - whether caller needs to update the screen # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. -recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, backspaced-cell:address:duplex-list:character [ +recipe delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + data:address:shared:duplex-list:character <- get *editor, data:offset # if at start of text (before-cursor at § sentinel), return - prev:address:duplex-list:character <- prev *before-cursor + prev:address:shared:duplex-list:character <- prev *before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted reply-unless prev trace 10, [app], [delete-before-cursor] original-row:number <- get *editor, cursor-row:offset editor, scroll?:boolean <- move-cursor-coordinates-left editor - backspaced-cell:address:duplex-list:character <- copy *before-cursor + backspaced-cell:address:shared:duplex-list:character <- copy *before-cursor data <- remove *before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/*before-cursor *before-cursor <- copy prev go-render? <- copy 1/true @@ -106,7 +106,7 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> reply-unless same-row? left:number <- get *editor, left:offset right:number <- get *editor, right:offset - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor screen <- move-cursor screen, cursor-row, cursor-column curr-column:number <- copy cursor-column { @@ -130,10 +130,10 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> go-render? <- copy 0/false ] -recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -165,7 +165,7 @@ recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address break-unless previous-character-is-newline? # compute length of previous line trace 10, [app], [switching to previous line] - d:address:duplex-list:character <- get *editor, data:offset + d:address:shared:duplex-list:character <- get *editor, data:offset end-of-line:number <- previous-line-length before-cursor, d *cursor-column <- add left, end-of-line reply @@ -178,7 +178,7 @@ recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -recipe previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +recipe previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -201,17 +201,17 @@ recipe previous-line-length curr:address:duplex-list:character, start:address:du scenario editor-clears-last-line-on-backspace [ assume-screen 10/width, 5/height # just one character in final line - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -228,10 +228,10 @@ cd] scenario editor-joins-and-wraps-lines-on-backspace [ assume-screen 10/width, 5/height # initialize editor with two long-ish but non-wrapping lines - 1:address:array:character <- new [abc def + 1:address:shared:array:character <- new [abc def ghi jkl] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -239,7 +239,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # resulting single line should wrap correctly screen-should-contain [ @@ -254,9 +254,9 @@ ghi jkl] scenario editor-wraps-long-lines-on-backspace [ assume-screen 10/width, 5/height # initialize editor in part of the screen with a long line - 1:address:array:character <- new [abc def ghij] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 8/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc def ghij] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right + editor-render screen, 2:address:shared:editor-data # confirm that it wraps screen-should-contain [ . . @@ -271,7 +271,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -287,15 +287,15 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -309,7 +309,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -325,18 +325,18 @@ after <handle-special-key> [ delete-next-character?:boolean <- equal *k, 65522/delete break-unless delete-next-character? <delete-character-begin> - editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character <- delete-at-cursor editor, screen + editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen <delete-character-end> reply } ] -recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, deleted-cell:address:duplex-list:character [ +recipe delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset - deleted-cell:address:duplex-list:character <- next *before-cursor + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + data:address:shared:duplex-list:character <- get *editor, data:offset + deleted-cell:address:shared:duplex-list:character <- next *before-cursor go-render? <- copy 0/false reply-unless deleted-cell currc:character <- get *deleted-cell, value:offset @@ -345,7 +345,7 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi go-render? <- copy 1/true reply-if deleted-newline? # wasn't a newline? render rest of line - curr:address:duplex-list:character <- next *before-cursor # refresh after remove above + curr:address:shared:duplex-list:character <- next *before-cursor # refresh after remove above cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset screen <- move-cursor screen, *cursor-row, *cursor-column @@ -376,16 +376,16 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi scenario editor-moves-cursor-right-with-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -401,7 +401,7 @@ after <handle-special-key> [ move-to-next-character?:boolean <- equal *k, 65514/right-arrow break-unless move-to-next-character? # if not at end of text - next-cursor:address:duplex-list:character <- next *before-cursor + next-cursor:address:shared:duplex-list:character <- next *before-cursor break-unless next-cursor # scan to next character <move-cursor-begin> @@ -414,10 +414,10 @@ after <handle-special-key> [ } ] -recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor before-cursor:offset + before-cursor:address:shared:duplex-list:character <- get *editor before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -444,7 +444,7 @@ recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:n at-wrap?:boolean <- equal *cursor-column, wrap-column break-unless at-wrap? # and if next character isn't newline - next:address:duplex-list:character <- next before-cursor + next:address:shared:duplex-list:character <- next before-cursor break-unless next next-character:character <- get *next, value:offset newline?:boolean <- equal next-character, 10/newline @@ -465,10 +465,10 @@ recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:n scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -478,7 +478,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -486,7 +486,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -500,10 +500,10 @@ d] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ press right-arrow press right-arrow @@ -512,7 +512,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -525,18 +525,18 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcdef] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -555,9 +555,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen 10/width, 5/height # line just barely wrapping - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -565,9 +565,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -578,9 +578,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -591,18 +591,18 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 6/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcdef] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 6/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -620,10 +620,10 @@ 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 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -632,7 +632,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # new character should be in next line screen-should-contain [ @@ -651,9 +651,9 @@ d] scenario editor-moves-cursor-left-with-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 2 @@ -661,7 +661,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -678,7 +678,7 @@ after <handle-special-key> [ break-unless move-to-previous-character? trace 10, [app], [left arrow] # if not at start of text (before-cursor at § sentinel) - prev:address:duplex-list:character <- prev *before-cursor + prev:address:shared:duplex-list:character <- prev *before-cursor go-render? <- copy 0/false reply-unless prev <move-cursor-begin> @@ -693,10 +693,10 @@ after <handle-special-key> [ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ assume-screen 10/width, 5/height # initialize editor with two lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -704,9 +704,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -718,11 +718,11 @@ d] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ assume-screen 10/width, 5/height # initialize editor with three lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -732,7 +732,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -746,11 +746,11 @@ g] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -759,7 +759,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # left-arrow should have had no effect screen-should-contain [ @@ -775,11 +775,11 @@ g] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor right after empty line assume-console [ @@ -788,7 +788,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -803,9 +803,9 @@ d] scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcdef] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace screen-should-contain [ . . @@ -820,9 +820,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -837,19 +837,19 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -860,7 +860,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -883,12 +883,12 @@ after <handle-special-key> [ } ] -recipe move-to-previous-line editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +recipe move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset already-at-top?:boolean <- lesser-or-equal *cursor-row, 1/top @@ -898,13 +898,13 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor # if not at newline, move to start of line (previous newline) # then scan back another line # if either step fails, give up without modifying cursor or coordinates - curr:address:duplex-list:character <- copy *before-cursor + curr:address:shared:duplex-list:character <- copy *before-cursor { - old:address:duplex-list:character <- copy curr + old:address:shared:duplex-list:character <- copy curr c2:character <- get *curr, value:offset at-newline?:boolean <- equal c2, 10/newline break-if at-newline? - curr:address:duplex-list:character <- before-previous-line curr, editor + curr:address:shared:duplex-list:character <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false reply-if no-motion? @@ -924,7 +924,7 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor { done?:boolean <- greater-or-equal *cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -948,19 +948,19 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -971,7 +971,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -984,19 +984,19 @@ def] scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1007,7 +1007,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1021,11 +1021,11 @@ def] scenario editor-moves-to-previous-line-from-left-margin [ assume-screen 10/width, 5/height # start out with three lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1033,9 +1033,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1046,7 +1046,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1061,19 +1061,19 @@ ghi] scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1085,7 +1085,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1108,12 +1108,12 @@ after <handle-special-key> [ } ] -recipe move-to-next-line editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +recipe move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset last-line:number <- subtract screen-height, 1 @@ -1123,7 +1123,7 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi break-if already-at-bottom? # scan to start of next line, then to right column or until end of line max:number <- subtract right, left - next-line:address:duplex-list:character <- before-start-of-next-line *before-cursor, max + next-line:address:shared:duplex-list:character <- before-start-of-next-line *before-cursor, max { # already at end of buffer? try to scroll up (so we can see more # warnings or sandboxes below) @@ -1141,7 +1141,7 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi { done?:boolean <- greater-or-equal *cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -1161,19 +1161,19 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1184,7 +1184,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1199,10 +1199,10 @@ de] scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1210,9 +1210,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1248,7 +1248,7 @@ after <handle-special-key> [ } ] -recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor-data [ +recipe move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # update cursor column @@ -1256,8 +1256,8 @@ recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor cursor-column:address:number <- get-address *editor, cursor-column:offset *cursor-column <- copy left # update before-cursor - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - init:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + init:address:shared:duplex-list:character <- get *editor, data:offset # while not at start of line, move { at-start-of-text?:boolean <- equal *before-cursor, init @@ -1273,10 +1273,10 @@ recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1284,9 +1284,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1298,9 +1298,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ scenario editor-moves-to-start-of-line-with-home [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1308,9 +1308,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1322,10 +1322,10 @@ scenario editor-moves-to-start-of-line-with-home [ scenario editor-moves-to-start-of-line-with-home-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1333,9 +1333,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1349,10 +1349,10 @@ scenario editor-moves-to-start-of-line-with-home-2 [ scenario editor-moves-to-end-of-line-with-ctrl-e [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1360,9 +1360,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1375,9 +1375,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1419,14 +1419,14 @@ after <handle-special-key> [ } ] -recipe move-to-end-of-line editor:address:editor-data -> editor:address:editor-data [ +recipe move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset cursor-column:address:number <- get-address *editor, cursor-column:offset # while not at start of line, move { - next:address:duplex-list:character <- next *before-cursor + next:address:shared:duplex-list:character <- next *before-cursor break-unless next # end of text nextc:character <- get *next, value:offset at-end-of-line?:boolean <- equal nextc, 10/newline @@ -1439,10 +1439,10 @@ recipe move-to-end-of-line editor:address:editor-data -> editor:address:editor-d scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1450,9 +1450,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1464,10 +1464,10 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ scenario editor-moves-to-end-of-line-with-end [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line, press 'end' assume-console [ @@ -1475,9 +1475,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1489,10 +1489,10 @@ scenario editor-moves-to-end-of-line-with-end [ scenario editor-moves-to-end-of-line-with-end-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1500,9 +1500,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1516,16 +1516,16 @@ scenario editor-moves-to-end-of-line-with-end-2 [ scenario editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1542,21 +1542,21 @@ after <handle-special-character> [ delete-to-start-of-line?:boolean <- equal *c, 21/ctrl-u break-unless delete-to-start-of-line? <delete-to-start-of-line-begin> - deleted-cells:address:duplex-list:character <- delete-to-start-of-line editor + deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor <delete-to-start-of-line-end> go-render? <- copy 1/true reply } ] -recipe delete-to-start-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +recipe delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete - init:address:duplex-list:character <- get *editor, data:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - start:address:duplex-list:character <- copy *before-cursor - end:address:duplex-list:character <- next *before-cursor + init:address:shared:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + start:address:shared:duplex-list:character <- copy *before-cursor + end:address:shared:duplex-list:character <- next *before-cursor { at-start-of-text?:boolean <- equal start, init break-if at-start-of-text? @@ -1568,7 +1568,7 @@ recipe delete-to-start-of-line editor:address:editor-data -> result:address:dupl loop } # snip it out - result:address:duplex-list:character <- next start + result:address:shared:duplex-list:character <- next start remove-between start, end # adjust cursor *before-cursor <- copy start @@ -1579,16 +1579,16 @@ recipe delete-to-start-of-line editor:address:editor-data -> result:address:dupl scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1602,16 +1602,16 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1625,16 +1625,16 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1650,16 +1650,16 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ scenario editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1676,19 +1676,19 @@ after <handle-special-character> [ delete-to-end-of-line?:boolean <- equal *c, 11/ctrl-k break-unless delete-to-end-of-line? <delete-to-end-of-line-begin> - deleted-cells:address:duplex-list:character <- delete-to-end-of-line editor + deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor <delete-to-end-of-line-end> go-render? <- copy 1/true reply } ] -recipe delete-to-end-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +recipe delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete - start:address:duplex-list:character <- get *editor, before-cursor:offset - end:address:duplex-list:character <- next start + start:address:shared:duplex-list:character <- get *editor, before-cursor:offset + end:address:shared:duplex-list:character <- next start { at-end-of-text?:boolean <- equal end, 0/null break-if at-end-of-text? @@ -1705,16 +1705,16 @@ recipe delete-to-end-of-line editor:address:editor-data -> result:address:duplex scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1728,16 +1728,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes just last character screen-should-contain [ @@ -1751,16 +1751,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1774,16 +1774,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes just the final character screen-should-contain [ @@ -1797,16 +1797,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1824,11 +1824,11 @@ scenario editor-can-scroll-down-using-arrow-keys [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -1841,7 +1841,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -1854,11 +1854,11 @@ d] after <scroll-down> [ trace 10, [app], [scroll down] - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset max:number <- subtract right, left - old-top:address:duplex-list:character <- copy *top-of-screen + old-top:address:shared:duplex-list:character <- copy *top-of-screen *top-of-screen <- before-start-of-next-line *top-of-screen, max no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false @@ -1868,11 +1868,11 @@ after <scroll-down> [ # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline # beware: never return null pointer. -recipe before-start-of-next-line original:address:duplex-list:character, max:number -> curr:address:duplex-list:character [ +recipe before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ local-scope load-ingredients count:number <- copy 0 - curr:address:duplex-list:character <- copy original + curr:address:shared:duplex-list:character <- copy original # skip the initial newline if it exists { c:character <- get *curr, value:offset @@ -1901,11 +1901,11 @@ scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -1918,7 +1918,7 @@ i] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -1933,18 +1933,18 @@ scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # editor starts with a long line wrapping twice - 1:address:array:character <- new [abcdefghij + 1:address:shared:array:character <- new [abcdefghij k l m] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line containing a wrap icon screen-should-contain [ @@ -1958,7 +1958,7 @@ m] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -1973,19 +1973,19 @@ scenario editor-scrolls-down-when-line-wraps [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a long line in the third line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2003,19 +2003,19 @@ cdef] scenario editor-scrolls-down-on-newline [ assume-screen 5/width, 4/height # position cursor after last line and type newline - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 3, 4 type [ ] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2034,19 +2034,19 @@ scenario editor-scrolls-down-on-right-arrow [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2065,20 +2065,20 @@ scenario editor-scrolls-down-on-right-arrow-2 [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains more lines than can fit on screen - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2095,10 +2095,10 @@ d] scenario editor-scrolls-at-end-on-down-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # try to move down past end of text assume-console [ @@ -2106,9 +2106,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should scroll, moving cursor to end of text memory-should-contain [ @@ -2119,7 +2119,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2134,9 +2134,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen stops scrolling because cursor is already at top memory-should-contain [ @@ -2148,7 +2148,7 @@ de] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2162,14 +2162,14 @@ scenario editor-combines-page-and-line-scroll [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a few pages of lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # scroll down one page and one line assume-console [ press page-down @@ -2177,7 +2177,7 @@ g] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen scrolls down 3 lines screen-should-contain [ @@ -2194,11 +2194,11 @@ scenario editor-can-scroll-up-using-arrow-keys [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2211,7 +2211,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -2224,8 +2224,8 @@ d] after <scroll-up> [ trace 10, [app], [scroll up] - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen *top-of-screen <- before-previous-line *top-of-screen, editor no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false @@ -2235,7 +2235,7 @@ after <scroll-up> [ # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line # beware: never return null pointer -recipe before-previous-line curr:address:duplex-list:character, editor:address:editor-data -> curr:address:duplex-list:character [ +recipe before-previous-line curr:address:shared:duplex-list:character, editor:address:shared:editor-data -> curr:address:shared:duplex-list:character [ local-scope load-ingredients c:character <- get *curr, value:offset @@ -2245,12 +2245,12 @@ recipe before-previous-line curr:address:duplex-list:character, editor:address:e left:number <- get *editor, left:offset right:number <- get *editor, right:offset max-line-length:number <- subtract right, left, -1/exclusive-right, 1/wrap-icon - sentinel:address:duplex-list:character <- get *editor, data:offset + sentinel:address:shared:duplex-list:character <- get *editor, data:offset len:number <- previous-line-length curr, sentinel { break-if len # empty line; just skip this newline - prev:address:duplex-list:character <- prev curr + prev:address:shared:duplex-list:character <- prev curr reply-unless prev, curr reply prev } @@ -2266,7 +2266,7 @@ recipe before-previous-line curr:address:duplex-list:character, editor:address:e { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- prev curr + prev:address:shared:duplex-list:character <- prev curr break-unless prev curr <- copy prev count <- add count, 1 @@ -2280,11 +2280,11 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2296,7 +2296,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2309,7 +2309,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2324,17 +2324,17 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [ # 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:address:array:character <- new [abcdefghij + 1:address:shared:array:character <- new [abcdefghij k l m] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2348,7 +2348,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2363,7 +2363,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2378,7 +2378,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2397,11 +2397,11 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-3 [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right screen-should-contain [ . . .abcde↩ . @@ -2413,7 +2413,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2426,7 +2426,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2441,18 +2441,18 @@ i] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ assume-screen 10/width, 4/height # initialize editor with some lines around an empty line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2464,7 +2464,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2476,7 +2476,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2490,18 +2490,18 @@ scenario editor-scrolls-up-on-left-arrow [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2514,9 +2514,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2535,11 +2535,11 @@ scenario editor-can-scroll-up-to-start-of-file [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2554,7 +2554,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -2568,7 +2568,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen remains unchanged screen-should-contain [ @@ -2583,11 +2583,11 @@ d] scenario editor-can-scroll [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2599,7 +2599,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows next page screen-should-contain [ @@ -2614,8 +2614,8 @@ after <handle-special-character> [ { page-down?:boolean <- equal *c, 6/ctrl-f break-unless page-down? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never @@ -2630,8 +2630,8 @@ after <handle-special-key> [ { page-down?:boolean <- equal *k, 65518/page-down break-unless page-down? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never @@ -2644,14 +2644,14 @@ after <handle-special-key> [ # page-down skips entire wrapped lines, so it can't scroll past lines # taking up the entire screen -recipe page-down editor:address:editor-data -> editor:address:editor-data [ +recipe page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # if editor contents don't overflow screen, do nothing - bottom-of-screen:address:duplex-list:character <- get *editor, bottom-of-screen:offset + bottom-of-screen:address:shared:duplex-list:character <- get *editor, bottom-of-screen:offset reply-unless bottom-of-screen # if not, position cursor at final character - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset *before-cursor <- prev bottom-of-screen # keep one line in common with previous page { @@ -2662,16 +2662,16 @@ recipe page-down editor:address:editor-data -> editor:address:editor-data [ } # move cursor and top-of-screen to start of that line move-to-start-of-line editor - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top-of-screen <- copy *before-cursor ] scenario editor-does-not-scroll-past-end [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -2683,7 +2683,7 @@ b] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen remains unmodified screen-should-contain [ @@ -2698,11 +2698,11 @@ scenario editor-starts-next-page-at-start-of-wrapped-line [ # screen has 1 line for menu + 3 lines for text assume-screen 10/width, 4/height # editor contains a long last line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] # editor screen triggers wrap of last line - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2715,7 +2715,7 @@ cdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2731,9 +2731,9 @@ scenario editor-starts-next-page-at-start-of-wrapped-line-2 [ 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:address:array:character <- new [a + 1:address:shared:array:character <- new [a bcdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2746,7 +2746,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2761,11 +2761,11 @@ bcdefgh] scenario editor-can-scroll-up [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2777,7 +2777,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows next page screen-should-contain [ @@ -2791,7 +2791,7 @@ d] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows original page again screen-should-contain [ @@ -2806,8 +2806,8 @@ after <handle-special-character> [ { page-up?:boolean <- equal *c, 2/ctrl-b break-unless page-up? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never @@ -2822,8 +2822,8 @@ after <handle-special-key> [ { page-up?:boolean <- equal *k, 65519/page-up break-unless page-up? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never @@ -2835,16 +2835,16 @@ after <handle-special-key> [ } ] -recipe page-up editor:address:editor-data, screen-height:number -> editor:address:editor-data [ +recipe page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ local-scope load-ingredients max:number <- subtract screen-height, 1/menu-bar, 1/overlapping-line count:number <- copy 0 - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- before-previous-line *top-of-screen, editor + prev:address:shared:duplex-list:character <- before-previous-line *top-of-screen, editor break-unless prev *top-of-screen <- copy prev count <- add count, 1 @@ -2856,7 +2856,7 @@ scenario editor-can-scroll-up-multiple-pages [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with 8 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d @@ -2864,7 +2864,7 @@ e f g h] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2877,7 +2877,7 @@ h] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows third page screen-should-contain [ @@ -2891,7 +2891,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows second page screen-should-contain [ @@ -2905,7 +2905,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows original page again screen-should-contain [ @@ -2920,7 +2920,7 @@ scenario editor-can-scroll-up-wrapped-lines [ # 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:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh i @@ -2931,7 +2931,7 @@ m n o] # editor screen triggers wrap of last line - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2948,7 +2948,7 @@ o] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2964,7 +2964,7 @@ o] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen resets screen-should-contain [ @@ -2982,9 +2982,9 @@ scenario editor-can-scroll-up-wrapped-lines-2 [ 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:address:array:character <- new [a + 1:address:shared:array:character <- new [a bcdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2997,7 +2997,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -3011,7 +3011,7 @@ bcdefgh] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen resets screen-should-contain [ @@ -3025,7 +3025,7 @@ bcdefgh] scenario editor-can-scroll-up-past-nonempty-lines [ assume-screen 10/width, 4/height # text with empty line in second screen - 1:address:array:character <- new [axx + 1:address:shared:array:character <- new [axx bxx cxx dxx @@ -3034,7 +3034,7 @@ fxx gxx hxx ] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right screen-should-contain [ . . .axx . @@ -3045,7 +3045,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3057,7 +3057,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3070,7 +3070,7 @@ hxx press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3083,7 +3083,7 @@ hxx scenario editor-can-scroll-up-past-empty-lines [ assume-screen 10/width, 4/height # text with empty line in second screen - 1:address:array:character <- new [axy + 1:address:shared:array:character <- new [axy bxy cxy @@ -3092,7 +3092,7 @@ exy fxy gxy ] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right screen-should-contain [ . . .axy . @@ -3103,7 +3103,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3115,7 +3115,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3128,7 +3128,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 7ed6376e..99cefbb4 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -6,22 +6,22 @@ recipe! main [ local-scope open-console - initial-recipe:address:array:character <- restore [recipes.mu] - initial-sandbox:address:array:character <- new [] + initial-recipe:address:shared:array:character <- restore [recipes.mu] + initial-sandbox:address:shared:array:character <- new [] hide-screen 0/screen - env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox + env:address:shared:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox render-all 0/screen, env event-loop 0/screen, 0/console, env # never gets here ] container programming-environment-data [ - recipes:address:editor-data - current-sandbox:address:editor-data + recipes:address:shared:editor-data + current-sandbox:address:shared:editor-data sandbox-in-focus?:boolean # false => cursor in recipes; true => cursor in current-sandbox ] -recipe new-programming-environment screen:address:screen, initial-recipe-contents:address:array:character, initial-sandbox-contents:address:array:character -> result:address:programming-environment-data, screen:address:screen [ +recipe new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients width:number <- screen-width screen @@ -33,25 +33,25 @@ recipe new-programming-environment screen:address:screen, initial-recipe-content button-on-screen?:boolean <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start - run-button:address:array:character <- new [ run (F4) ] + run-button:address:shared:array:character <- new [ run (F4) ] print screen, run-button, 255/white, 161/reddish # dotted line down the middle divider:number, _ <- divide-with-remainder width, 2 draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted # recipe editor on the left - recipes:address:address:editor-data <- get-address *result, recipes:offset + recipes:address:address:shared:editor-data <- get-address *result, recipes:offset *recipes <- new-editor initial-recipe-contents, screen, 0/left, divider/right # sandbox editor on the right new-left:number <- add divider, 1 - current-sandbox:address:address:editor-data <- get-address *result, current-sandbox:offset + current-sandbox:address:address:shared:editor-data <- get-address *result, current-sandbox:offset *current-sandbox <- new-editor initial-sandbox-contents, screen, new-left, width/right ] -recipe event-loop screen:address:screen, console:address:console, env:address:programming-environment-data -> screen:address:screen, console:address:console, env:address:programming-environment-data [ +recipe event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ local-scope load-ingredients - recipes:address:editor-data <- get *env, recipes:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + recipes:address:shared:editor-data <- get *env, recipes:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset sandbox-in-focus?:address:boolean <- get-address *env, sandbox-in-focus?:offset # if we fall behind we'll stop updating the screen, but then we have to # render the entire screen when we catch up. @@ -179,14 +179,14 @@ recipe event-loop screen:address:screen, console:address:console, env:address:pr } ] -recipe resize screen:address:screen, env:address:programming-environment-data -> env:address:programming-environment-data, screen:address:screen [ +recipe resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions width:number <- screen-width screen divider:number, _ <- divide-with-remainder width, 2 # update recipe editor - recipes:address:editor-data <- get *env, recipes:offset + recipes:address:shared:editor-data <- get *env, recipes:offset right:address:number <- get-address *recipes, right:offset *right <- subtract divider, 1 # reset cursor (later we'll try to preserve its position) @@ -195,7 +195,7 @@ recipe resize screen:address:screen, env:address:programming-environment-data -> cursor-column:address:number <- get-address *recipes, cursor-column:offset *cursor-column <- copy 0 # update sandbox editor - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset left:address:number <- get-address *current-sandbox, left:offset right:address:number <- get-address *current-sandbox, right:offset *left <- add divider, 1 @@ -211,9 +211,9 @@ scenario point-at-multiple-editors [ trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize both halves of screen - 1:address:array:character <- new [abc] - 2:address:array:character <- new [def] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [def] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # focus on both sides assume-console [ left-click 1, 1 @@ -221,11 +221,11 @@ scenario point-at-multiple-editors [ ] # check cursor column in each run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data - 4:address:editor-data <- get *3:address:programming-environment-data, recipes:offset - 5:number <- get *4:address:editor-data, cursor-column:offset - 6:address:editor-data <- get *3:address:programming-environment-data, current-sandbox:offset - 7:number <- get *6:address:editor-data, cursor-column:offset + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 4:address:shared:editor-data <- get *3:address:shared:programming-environment-data, recipes:offset + 5:number <- get *4:address:shared:editor-data, cursor-column:offset + 6:address:shared:editor-data <- get *3:address:shared:programming-environment-data, current-sandbox:offset + 7:number <- get *6:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 5 <- 1 @@ -237,10 +237,10 @@ scenario edit-multiple-editors [ trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize both halves of screen - 1:address:array:character <- new [abc] - 2:address:array:character <- new [def] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [def] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + render-all screen, 3:address:shared:programming-environment-data # type one letter in each of them assume-console [ left-click 1, 1 @@ -249,11 +249,11 @@ scenario edit-multiple-editors [ type [1] ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data - 4:address:editor-data <- get *3:address:programming-environment-data, recipes:offset - 5:number <- get *4:address:editor-data, cursor-column:offset - 6:address:editor-data <- get *3:address:programming-environment-data, current-sandbox:offset - 7:number <- get *6:address:editor-data, cursor-column:offset + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + 4:address:shared:editor-data <- get *3:address:shared:programming-environment-data, recipes:offset + 5:number <- get *4:address:shared:editor-data, cursor-column:offset + 6:address:shared:editor-data <- get *3:address:shared:programming-environment-data, current-sandbox:offset + 7:number <- get *6:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . run (F4) . # this line has a different background, but we don't test that yet @@ -268,7 +268,7 @@ scenario edit-multiple-editors [ # show the cursor at the right window run [ 8:character/cursor <- copy 9251/␣ - print screen:address:screen, 8:character/cursor + print screen:address:shared:screen, 8:character/cursor ] screen-should-contain [ . run (F4) . @@ -282,10 +282,10 @@ scenario multiple-editors-cover-only-their-own-areas [ trace-until 100/app # trace too long assume-screen 60/width, 10/height run [ - 1:address:array:character <- new [abc] - 2:address:array:character <- new [def] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [def] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + render-all screen, 3:address:shared:programming-environment-data ] # divider isn't messed up screen-should-contain [ @@ -300,16 +300,16 @@ scenario multiple-editors-cover-only-their-own-areas [ scenario editor-in-focus-keeps-cursor [ trace-until 100/app # trace too long assume-screen 30/width, 5/height - 1:address:array:character <- new [abc] - 2:address:array:character <- new [def] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:array:character <- new [def] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + render-all screen, 3:address:shared:programming-environment-data # initialize programming environment and highlight cursor assume-console [] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] # is cursor at the right place? screen-should-contain [ @@ -323,9 +323,9 @@ scenario editor-in-focus-keeps-cursor [ type [z] ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] # cursor should still be right screen-should-contain [ @@ -340,11 +340,11 @@ scenario backspace-in-sandbox-editor-joins-lines [ trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize sandbox side with two lines - 1:address:array:character <- new [] - 2:address:array:character <- new [abc + 1:address:shared:array:character <- new [] + 2:address:shared:array:character <- new [abc def] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + render-all screen, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊abc . @@ -358,9 +358,9 @@ def] press backspace ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] # cursor moves to end of old line screen-should-contain [ @@ -371,7 +371,7 @@ def] ] ] -recipe render-all screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients trace 10, [app], [render all] @@ -384,7 +384,7 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat button-on-screen?:boolean <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start - run-button:address:array:character <- new [ run (F4) ] + run-button:address:shared:array:character <- new [ run (F4) ] print screen, run-button, 255/white, 161/reddish # dotted line down the middle trace 11, [app], [render divider] @@ -396,19 +396,19 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat screen <- render-sandbox-side screen, env <render-components-end> # - recipes:address:editor-data <- get *env, recipes:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + recipes:address:shared:editor-data <- get *env, recipes:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset sandbox-in-focus?:boolean <- get *env, sandbox-in-focus?:offset screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus? # show-screen screen ] -recipe render-recipes screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients trace 11, [app], [render recipes] - recipes:address:editor-data <- get *env, recipes:offset + recipes:address:shared:editor-data <- get *env, recipes:offset # render recipes left:number <- get *recipes, left:offset right:number <- get *recipes, right:offset @@ -423,10 +423,10 @@ recipe render-recipes screen:address:screen, env:address:programming-environment ] # replaced in a later layer -recipe render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset row:number, column:number, screen, current-sandbox <- render screen, current-sandbox @@ -438,7 +438,7 @@ recipe render-sandbox-side screen:address:screen, env:address:programming-enviro clear-screen-from screen, row, left, left, right ] -recipe update-cursor screen:address:screen, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:boolean -> screen:address:screen [ +recipe update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean -> screen:address:shared:screen [ local-scope load-ingredients { @@ -456,7 +456,7 @@ recipe update-cursor screen:address:screen, recipes:address:editor-data, current # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ +recipe render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless s @@ -517,7 +517,7 @@ recipe render screen:address:screen, s:address:array:character, left:number, rig ] # like 'render' for texts, but with colorization for comments like in the editor -recipe render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ +recipe render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless s @@ -585,7 +585,7 @@ after <global-type> [ { redraw-screen?:boolean <- equal *c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:address:programming-environment-data + screen <- render-all screen, env:address:shared:programming-environment-data sync-screen screen loop +next-event:label } @@ -606,7 +606,7 @@ after <global-type> [ ## helpers -recipe draw-vertical screen:address:screen, col:number, y:number, bottom:number -> screen:address:screen [ +recipe draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number -> screen:address:shared:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 3929fb76..3095e865 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -7,10 +7,10 @@ recipe! main [ local-scope open-console - initial-recipe:address:array:character <- restore [recipes.mu] - initial-sandbox:address:array:character <- new [] + initial-recipe:address:shared:array:character <- restore [recipes.mu] + initial-sandbox:address:shared:array:character <- new [] hide-screen 0/screen - env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox + env:address:shared:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox env <- restore-sandboxes env render-all 0/screen, env event-loop 0/screen, 0/console, env @@ -18,35 +18,35 @@ recipe! main [ ] container programming-environment-data [ - sandbox:address:sandbox-data # list of sandboxes, from top to bottom + sandbox:address:shared:sandbox-data # list of sandboxes, from top to bottom ] container sandbox-data [ - data:address:array:character - response:address:array:character - expected-response:address:array:character + data:address:shared:array:character + response:address:shared:array:character + expected-response:address:shared:array:character # coordinates to track clicks starting-row-on-screen:number code-ending-row-on-screen:number # past end of code response-starting-row-on-screen:number - screen:address:screen # prints in the sandbox go here - next-sandbox:address:sandbox-data + screen:address:shared:screen # prints in the sandbox go here + next-sandbox:address:shared:sandbox-data ] scenario run-and-show-results [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # sandbox editor contains an instruction without storing outputs - 2:address:array:character <- new [divide-with-remainder 11, 3] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [divide-with-remainder 11, 3] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -89,7 +89,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -115,14 +115,14 @@ after <global-keypress> [ do-run?:boolean <- equal *k, 65532/F4 break-unless do-run? #? $log [F4 pressed] - status:address:array:character <- new [running... ] + status:address:shared:array:character <- new [running... ] screen <- update-status screen, status, 245/grey error?:boolean, env, screen <- run-sandboxes env, screen # F4 might update warnings and results on both sides screen <- render-all screen, env { break-if error? - status:address:array:character <- new [ ] + status:address:shared:array:character <- new [ ] screen <- update-status screen, status, 245/grey } screen <- update-cursor screen, recipes, current-sandbox, *sandbox-in-focus? @@ -130,36 +130,36 @@ after <global-keypress> [ } ] -recipe run-sandboxes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients errors-found?:boolean, env, screen <- update-recipes env, screen reply-if errors-found? # check contents of right editor (sandbox) - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset { - sandbox-contents:address:array:character <- editor-contents current-sandbox + sandbox-contents:address:shared:array:character <- editor-contents current-sandbox break-unless sandbox-contents # if contents exist, first save them # run them and turn them into a new sandbox-data - new-sandbox:address:sandbox-data <- new sandbox-data:type - data:address:address:array:character <- get-address *new-sandbox, data:offset + new-sandbox:address:shared:sandbox-data <- new sandbox-data:type + data:address:address:shared:array:character <- get-address *new-sandbox, data:offset *data <- copy sandbox-contents # push to head of sandbox list - dest:address:address:sandbox-data <- get-address *env, sandbox:offset - next:address:address:sandbox-data <- get-address *new-sandbox, next-sandbox:offset + dest:address:address:shared:sandbox-data <- get-address *env, sandbox:offset + next:address:address:shared:sandbox-data <- get-address *new-sandbox, next-sandbox:offset *next <- copy *dest *dest <- copy new-sandbox # clear sandbox editor - init:address:address:duplex-list:character <- get-address *current-sandbox, data:offset + init:address:address:shared:duplex-list:character <- get-address *current-sandbox, data:offset *init <- push 167/§, 0/tail - top-of-screen:address:address:duplex-list:character <- get-address *current-sandbox, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *current-sandbox, top-of-screen:offset *top-of-screen <- copy *init } # save all sandboxes before running, just in case we die when running save-sandboxes env # run all sandboxes - curr:address:sandbox-data <- get *env, sandbox:offset + curr:address:shared:sandbox-data <- get *env, sandbox:offset { break-unless curr curr <- update-sandbox curr @@ -171,49 +171,49 @@ recipe run-sandboxes env:address:programming-environment-data, screen:address:sc # copy code from recipe editor, persist, load into mu # replaced in a later layer (whereupon errors-found? will actually be set) -recipe update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients - recipes:address:editor-data <- get *env, recipes:offset - in:address:array:character <- editor-contents recipes + recipes:address:shared:editor-data <- get *env, recipes:offset + in:address:shared:array:character <- editor-contents recipes save [recipes.mu], in # newlayer: persistence reload in errors-found? <- copy 0/false ] # replaced in a later layer -recipe update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset *response, _, *fake-screen <- run-interactive data ] -recipe update-status screen:address:screen, msg:address:array:character, color:number -> screen:address:screen [ +recipe update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -recipe save-sandboxes env:address:programming-environment-data [ +recipe save-sandboxes env:address:shared:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset # first clear previous versions, in case we deleted some sandbox $system [rm lesson/[0-9]* >/dev/null 2>/dev/null] # some shells can't handle '>&' - curr:address:sandbox-data <- get *env, sandbox:offset - suffix:address:array:character <- new [.out] + curr:address:shared:sandbox-data <- get *env, sandbox:offset + suffix:address:shared:array:character <- new [.out] idx:number <- copy 0 { break-unless curr - data:address:array:character <- get *curr, data:offset - filename:address:array:character <- to-text idx + data:address:shared:array:character <- get *curr, data:offset + filename:address:shared:array:character <- to-text idx save filename, data { - expected-response:address:array:character <- get *curr, expected-response:offset + expected-response:address:shared:array:character <- get *curr, expected-response:offset break-unless expected-response filename <- append filename, suffix save filename, expected-response @@ -224,24 +224,24 @@ recipe save-sandboxes env:address:programming-environment-data [ } ] -recipe! render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients #? $log [render sandbox side] trace 11, [app], [render sandbox side] - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset row:number, column:number, screen, current-sandbox <- render screen, current-sandbox clear-screen-from screen, row, column, left, right row <- add row, 1 draw-horizontal screen, row, left, right, 9473/horizontal-double - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:address:shared:sandbox-data <- get *env, sandbox:offset row, screen <- render-sandboxes screen, sandbox, left, right, row clear-rest-of-screen screen, row, left, left, right ] -recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number -> row:number, screen:address:screen, sandbox:address:sandbox-data [ +recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ local-scope load-ingredients #? $log [render sandbox] @@ -261,16 +261,16 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef # render sandbox contents row <- add row, 1 screen <- move-cursor screen, row, left - sandbox-data:address:array:character <- get *sandbox, data:offset + sandbox-data:address:shared:array:character <- get *sandbox, data:offset row, screen <- render-code screen, sandbox-data, left, right, row code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - sandbox-response:address:array:character <- get *sandbox, response:offset + sandbox-response:address:shared:array:character <- get *sandbox, response:offset <render-sandbox-results> { - sandbox-screen:address:screen <- get *sandbox, screen:offset + sandbox-screen:address:shared:screen <- get *sandbox, screen:offset empty-screen?:boolean <- fake-screen-is-empty? sandbox-screen break-if empty-screen? row, screen <- render-screen screen, sandbox-screen, left, right, row @@ -287,32 +287,32 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double # draw next sandbox - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset row, screen <- render-sandboxes screen, next-sandbox, left, right, row ] # assumes programming environment has no sandboxes; restores them from previous session -recipe restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ +recipe restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios - suffix:address:array:character <- new [.out] + suffix:address:shared:array:character <- new [.out] idx:number <- copy 0 - curr:address:address:sandbox-data <- get-address *env, sandbox:offset + curr:address:address:shared:sandbox-data <- get-address *env, sandbox:offset { - filename:address:array:character <- to-text idx - contents:address:array:character <- restore filename + filename:address:shared:array:character <- to-text idx + contents:address:shared:array:character <- restore filename break-unless contents # stop at first error; assuming file didn't exist # create new sandbox for file *curr <- new sandbox-data:type - data:address:address:array:character <- get-address **curr, data:offset + data:address:address:shared:array:character <- get-address **curr, data:offset *data <- copy contents # restore expected output for sandbox if it exists { filename <- append filename, suffix contents <- restore filename break-unless contents - expected-response:address:address:array:character <- get-address **curr, expected-response:offset + expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset *expected-response <- copy contents } +continue @@ -324,19 +324,19 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -recipe render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number -> row:number, screen:address:screen [ +recipe render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless sandbox-screen # print 'screen:' - header:address:array:character <- new [screen:] + header:address:shared:array:character <- new [screen:] row <- render screen, header, left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left s-width:number <- screen-width sandbox-screen s-height:number <- screen-height sandbox-screen - buf:address:array:screen-cell <- get *sandbox-screen, data:offset + buf:address:shared:array:screen-cell <- get *sandbox-screen, data:offset stop-printing:number <- add left, s-width, 3 max-column:number <- min stop-printing, right i:number <- copy 0 @@ -394,19 +394,19 @@ scenario run-updates-results [ 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:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ z:number <- add 2, 2 reply z ]] # sandbox editor contains an instruction without storing outputs - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the code in the editors assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -425,7 +425,7 @@ reply z press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen updates the result on the right screen-should-contain [ @@ -444,16 +444,16 @@ scenario run-instruction-manages-screen-per-sandbox [ trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an instruction - 2:address:array:character <- new [print-integer screen, 4] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [print-integer screen, 4] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that it prints a little toy screen screen-should-contain [ @@ -473,11 +473,11 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -recipe editor-contents editor:address:editor-data -> result:address:array:character [ +recipe editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ local-scope load-ingredients - buf:address:buffer <- new-buffer 80 - curr:address:duplex-list:character <- get *editor, data:offset + buf:address:shared:buffer <- new-buffer 80 + curr:address:shared:duplex-list:character <- get *editor, data:offset # skip § sentinel assert curr, [editor without data is illegal; must have at least a sentinel] curr <- next curr @@ -494,16 +494,16 @@ recipe editor-contents editor:address:editor-data -> result:address:array:charac scenario editor-provides-edited-contents [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:address:array:character <- editor-contents 2:address:editor-data - 4:array:character <- copy *3:address:array:character + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:address:shared:array:character <- editor-contents 2:address:shared:editor-data + 4:array:character <- copy *3:address:shared:array:character ] memory-should-contain [ 4:array:character <- [abdefc] diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu index 0e294be3..80ceb2b9 100644 --- a/edit/006-sandbox-edit.mu +++ b/edit/006-sandbox-edit.mu @@ -4,17 +4,17 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 3, 30 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # it pops back into editor screen-should-contain [ @@ -48,7 +48,7 @@ recipe foo [ type [0] ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -69,7 +69,7 @@ after <global-touch> [ click-column:number <- get *t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset @@ -78,8 +78,8 @@ after <global-touch> [ empty-sandbox-editor?:boolean <- empty-editor? current-sandbox break-unless empty-sandbox-editor? # don't clobber existing contents # identify the sandbox to edit and remove it from the sandbox list - sandbox:address:sandbox-data <- extract-sandbox env, click-row - text:address:array:character <- get *sandbox, data:offset + sandbox:address:shared:sandbox-data <- extract-sandbox env, click-row + text:address:shared:array:character <- get *sandbox, data:offset current-sandbox <- insert-text current-sandbox, text hide-screen screen screen <- render-sandbox-side screen, env @@ -89,24 +89,24 @@ after <global-touch> [ } ] -recipe empty-editor? editor:address:editor-data -> result:boolean [ +recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ local-scope load-ingredients - head:address:duplex-list:character <- get *editor, data:offset - first:address:duplex-list:character <- next head + head:address:shared:duplex-list:character <- get *editor, data:offset + first:address:shared:duplex-list:character <- next head result <- not first ] -recipe extract-sandbox env:address:programming-environment-data, click-row:number -> result:address:sandbox-data, env:address:programming-environment-data [ +recipe extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:address:sandbox-data <- get-address *env, sandbox:offset + sandbox:address:address:shared:sandbox-data <- get-address *env, sandbox:offset start:number <- get **sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] { - next-sandbox:address:sandbox-data <- get **sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get **sandbox, next-sandbox:offset break-unless next-sandbox # if click-row < sandbox.next-sandbox.starting-row-on-screen, break next-start:number <- get *next-sandbox, starting-row-on-screen:offset @@ -127,15 +127,15 @@ scenario sandbox-with-print-can-be-edited [ trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an instruction - 2:address:array:character <- new [print-integer screen, 4] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [print-integer screen, 4] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the sandbox assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -156,7 +156,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 70 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu index e9d28ffa..95b6042f 100644 --- a/edit/007-sandbox-delete.mu +++ b/edit/007-sandbox-delete.mu @@ -3,9 +3,9 @@ scenario deleting-sandboxes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [] - 2:address:array:character <- new [] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 1:address:shared:array:character <- new [] + 2:address:shared:array:character <- new [] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run a few commands assume-console [ left-click 1, 80 @@ -14,7 +14,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -35,7 +35,7 @@ scenario deleting-sandboxes [ left-click 7, 99 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -53,7 +53,7 @@ scenario deleting-sandboxes [ left-click 3, 99 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -77,17 +77,17 @@ after <global-touch> [ } ] -recipe delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean, env:address:programming-environment-data [ +recipe delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ local-scope load-ingredients click-column:number <- get t, column:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset right:number <- get *current-sandbox, right:offset at-right?:boolean <- equal click-column, right reply-unless at-right?, 0/false click-row:number <- get t, row:offset - prev:address:address:sandbox-data <- get-address *env, sandbox:offset - curr:address:sandbox-data <- get *env, sandbox:offset + prev:address:address:shared:sandbox-data <- get-address *env, sandbox:offset + curr:address:shared:sandbox-data <- get *env, sandbox:offset { break-unless curr # more sandboxes to check diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu index 77cac2ce..b15eb37e 100644 --- a/edit/008-sandbox-test.mu +++ b/edit/008-sandbox-test.mu @@ -4,17 +4,17 @@ scenario sandbox-click-on-result-toggles-color-to-green [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ reply 4 ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -30,7 +30,7 @@ recipe foo [ left-click 5, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # color toggles to green screen-should-contain-in-color 2/green, [ @@ -46,7 +46,7 @@ recipe foo [ # cursor should remain unmoved run [ 4:character/cursor <- copy 9251/␣ - print screen:address:screen, 4:character/cursor + print screen:address:shared:screen, 4:character/cursor ] screen-should-contain [ . run (F4) . @@ -67,7 +67,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # result turns red screen-should-contain-in-color 1/red, [ @@ -90,14 +90,14 @@ after <global-touch> [ click-column:number <- get *t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on - sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:address:shared:sandbox-data <- find-click-in-sandbox-output env, click-row break-unless sandbox # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox @@ -111,17 +111,17 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:address:shared:sandbox-data <- get *env, sandbox:offset start:number <- get *sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -137,10 +137,10 @@ recipe find-click-in-sandbox-output env:address:programming-environment-data, cl reply sandbox ] -recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - expected-response:address:address:array:character <- get-address *sandbox, expected-response:offset + expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset { # if expected-response is set, reset break-unless *expected-response @@ -148,7 +148,7 @@ recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address: reply sandbox/same-as-ingredient:0 } # if not, current response is the expected response - response:address:array:character <- get *sandbox, response:offset + response:address:shared:array:character <- get *sandbox, response:offset *expected-response <- copy response ] @@ -156,7 +156,7 @@ recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address: after <render-sandbox-response> [ { break-unless sandbox-response - expected-response:address:array:character <- get *sandbox, expected-response:offset + expected-response:address:shared:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- equal expected-response, sandbox-response { diff --git a/edit/009-sandbox-trace.mu b/edit/009-sandbox-trace.mu index 03bde749..92d46bc0 100644 --- a/edit/009-sandbox-trace.mu +++ b/edit/009-sandbox-trace.mu @@ -4,17 +4,17 @@ scenario sandbox-click-on-code-toggles-app-trace [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ stash [abc] ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -29,9 +29,9 @@ recipe foo [ left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data 4:character/cursor-icon <- copy 9251/␣ - print screen:address:screen, 4:character/cursor-icon + print screen:address:shared:screen, 4:character/cursor-icon ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -59,8 +59,8 @@ recipe foo [ left-click 4, 25 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data - print screen:address:screen, 4:character/cursor-icon + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data + print screen:address:shared:screen, 4:character/cursor-icon ] # trace hidden again screen-should-contain [ @@ -78,18 +78,18 @@ scenario sandbox-shows-app-trace-and-result [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # basic recipe - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ stash [abc] reply 4 ]] # run it - 2:address:array:character <- new [foo] + 2:address:shared:array:character <- new [foo] assume-console [ press F4 ] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . ┊ . @@ -105,7 +105,7 @@ recipe foo [ left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # trace now printed above result screen-should-contain [ @@ -122,18 +122,18 @@ recipe foo [ ] container sandbox-data [ - trace:address:array:character + trace:address:shared:array:character display-trace?:boolean ] # replaced in a later layer -recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe! update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - trace:address:address:array:character <- get-address *sandbox, trace:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + trace:address:address:shared:array:character <- get-address *sandbox, trace:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset *response, _, *fake-screen, *trace <- run-interactive data ] @@ -145,14 +145,14 @@ after <global-touch> [ click-column:number <- get *t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose code is being clicked on - sandbox:address:sandbox-data <- find-click-in-sandbox-code env, click-row + sandbox:address:shared:sandbox-data <- find-click-in-sandbox-code env, click-row break-unless sandbox # toggle its display-trace? property x:address:boolean <- get-address *sandbox, display-trace?:offset @@ -166,7 +166,7 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-code env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +recipe find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -176,7 +176,7 @@ recipe find-click-in-sandbox-code env:address:programming-environment-data, clic assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -202,7 +202,7 @@ after <render-sandbox-results> [ { display-trace?:boolean <- get *sandbox, display-trace?:offset break-unless display-trace? - sandbox-trace:address:array:character <- get *sandbox, trace:offset + sandbox-trace:address:shared:array:character <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on row, screen <- render screen, sandbox-trace, left, right, 245/grey, row } diff --git a/edit/010-warnings.mu b/edit/010-warnings.mu index 6bfa3e3e..61cac2d2 100644 --- a/edit/010-warnings.mu +++ b/edit/010-warnings.mu @@ -1,23 +1,23 @@ ## handling malformed programs container programming-environment-data [ - recipe-warnings:address:array:character + recipe-warnings:address:shared:array:character ] # copy code from recipe editor, persist, load into mu, save any warnings -recipe! update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients #? $log [update recipes] - recipes:address:editor-data <- get *env, recipes:offset - in:address:array:character <- editor-contents recipes + recipes:address:shared:editor-data <- get *env, recipes:offset + in:address:shared:array:character <- editor-contents recipes save [recipes.mu], in - recipe-warnings:address:address:array:character <- get-address *env, recipe-warnings:offset + recipe-warnings:address:address:shared:array:character <- get-address *env, recipe-warnings:offset *recipe-warnings <- reload in # if recipe editor has errors, stop { break-unless *recipe-warnings - status:address:array:character <- new [errors found] + status:address:shared:array:character <- new [errors found] update-status screen, status, 1/red errors-found? <- copy 1/true reply @@ -27,35 +27,35 @@ recipe! update-recipes env:address:programming-environment-data, screen:address: before <render-components-end> [ trace 11, [app], [render status] - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset { break-unless recipe-warnings - status:address:array:character <- new [errors found] + status:address:shared:array:character <- new [errors found] update-status screen, status, 1/red } ] before <render-recipe-components-end> [ { - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset break-unless recipe-warnings row, screen <- render screen, recipe-warnings, left, right, 1/red, row } ] container sandbox-data [ - warnings:address:array:character + warnings:address:shared:array:character ] -recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe! update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients #? $log [update sandbox] - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - warnings:address:address:array:character <- get-address *sandbox, warnings:offset - trace:address:address:array:character <- get-address *sandbox, trace:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + warnings:address:address:shared:array:character <- get-address *sandbox, warnings:offset + trace:address:address:shared:array:character <- get-address *sandbox, trace:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset #? $print [run-interactive], 10/newline *response, *warnings, *fake-screen, *trace, completed?:boolean <- run-interactive data { @@ -70,7 +70,7 @@ recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-d # make sure we render any trace after <render-sandbox-trace-done> [ { - sandbox-warnings:address:array:character <- get *sandbox, warnings:offset + sandbox-warnings:address:shared:array:character <- get *sandbox, warnings:offset break-unless sandbox-warnings *response-starting-row <- copy 0 # no response row, screen <- render screen, sandbox-warnings, left, right, 1/red, row @@ -82,17 +82,17 @@ after <render-sandbox-trace-done> [ scenario run-shows-warnings-in-get [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ get 123:number, foo:offset ]] - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -122,14 +122,14 @@ recipe foo [ scenario run-hides-warnings-from-past-sandboxes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [] - 2:address:array:character <- new [get foo, x:offset] # invalid - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 1:address:shared:array:character <- new [] + 2:address:shared:array:character <- new [get foo, x:offset] # invalid + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 # generate error ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] assume-console [ left-click 3, 80 @@ -138,7 +138,7 @@ scenario run-hides-warnings-from-past-sandboxes [ press F4 # error should disappear ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -156,18 +156,18 @@ scenario run-updates-warnings-for-shape-shifting-recipes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # define a shape-shifting recipe with an error - 1:address:array:character <- new [recipe foo x:_elem -> z:_elem [ + 1:address:shared:array:character <- new [recipe foo x:_elem -> z:_elem [ local-scope load-ingredients z <- add x, [a] ]] - 2:address:array:character <- new [foo 2] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo 2] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -185,7 +185,7 @@ z <- add x, [a] press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # error should remain unchanged screen-should-contain [ @@ -205,24 +205,24 @@ scenario run-avoids-spurious-warnings-on-reloading-shape-shifting-recipes [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # overload a well-known shape-shifting recipe - 1:address:array:character <- new [recipe length l:address:list:_elem -> n:number [ + 1:address:shared:array:character <- new [recipe length l:address:shared:list:_elem -> n:number [ ]] # call code that uses other variants of it, but not it itself - 2:address:array:character <- new [x:address:list:number <- copy 0 + 2:address:shared:array:character <- new [x:address:shared:list:number <- copy 0 to-text x] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run it once assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data # no errors anywhere on screen (can't check anything else, since to-text will return an address) screen-should-contain-in-color 1/red, [ . . . . . . . . - . <- . + . <- . . . . . . . @@ -239,7 +239,7 @@ to-text x] press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # still no errors screen-should-contain-in-color 1/red, [ @@ -247,7 +247,7 @@ to-text x] . . . . . . - . <- . + . <- . . . . . . . @@ -264,17 +264,17 @@ to-text x] scenario run-shows-missing-type-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ x <- copy 0 ]] - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -290,18 +290,18 @@ scenario run-shows-unbalanced-bracket-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height # recipe is incomplete (unbalanced '[') - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo « x <- copy 0 ] - replace 1:address:array:character, 171/«, 91 # '[' - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + replace 1:address:shared:array:character, 171/«, 91 # '[' + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -318,28 +318,28 @@ recipe foo « scenario run-shows-get-on-non-container-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ - x:address:point <- new point:type - get x:address:point, 1:offset + x:address:shared:point <- new point:type + get x:address:shared:point, 1:offset ]] - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . . ┊foo . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - . x:address:point <- new point:type ┊ . - . get x:address:point, 1:offset ┊ . + . x:address:shared:point <- new point:type ┊ . + . get x:address:shared:point, 1:offset ┊ . .] ┊ . .foo: first ingredient of 'get' should be a contai↩┊ . - .ner, but got x:address:point ┊ . + .ner, but got x:address:shared:point ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . . ┊ . ] @@ -348,27 +348,27 @@ recipe foo [ scenario run-shows-non-literal-get-argument-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ x:number <- copy 0 - y:address:point <- new point:type - get *y:address:point, x:number + y:address:shared:point <- new point:type + get *y:address:shared:point, x:number ]] - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . . ┊foo . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . x:number <- copy 0 ┊ . - . y:address:point <- new point:type ┊ . - . get *y:address:point, x:number ┊ . + . y:address:shared:point <- new point:type ┊ . + . get *y:address:shared:point, x:number ┊ . .] ┊ . .foo: expected ingredient 1 of 'get' to have type ↩┊ . .'offset'; got x:number ┊ . @@ -383,17 +383,17 @@ scenario run-shows-warnings-everytime [ trace-until 100/app # trace too long # try to run a file with an error assume-screen 100/width, 15/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ recipe foo [ x:number <- copy y:number ]] - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -410,7 +410,7 @@ recipe foo [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . errors found run (F4) . @@ -428,16 +428,16 @@ scenario run-instruction-and-print-warnings [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # left editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an illegal instruction - 2:address:array:character <- new [get 1234:number, foo:offset] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [get 1234:number, foo:offset] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints error message in red screen-should-contain [ @@ -491,17 +491,17 @@ scenario run-instruction-and-print-warnings-only-once [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # left editor is empty - 1:address:array:character <- new [] + 1:address:shared:array:character <- new [] # right editor contains an illegal instruction - 2:address:array:character <- new [get 1234:number, foo:offset] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [get 1234:number, foo:offset] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # check that screen prints error message just once screen-should-contain [ @@ -522,20 +522,20 @@ scenario sandbox-can-handle-infinite-loop [ trace-until 100/app # trace too long assume-screen 100/width, 20/height # left editor is empty - 1:address:array:character <- new [recipe foo [ + 1:address:shared:array:character <- new [recipe foo [ { loop } ]] # right editor contains an instruction - 2:address:array:character <- new [foo] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -553,7 +553,7 @@ scenario sandbox-with-warnings-shows-trace [ trace-until 100/app # trace too long assume-screen 100/width, 10/height # generate a stash and a warning - 1:address:array:character <- new [recipe foo [ + 1:address:shared:array:character <- new [recipe foo [ local-scope a:number <- next-ingredient b:number <- next-ingredient @@ -561,13 +561,13 @@ stash [dividing by], b _, c:number <- divide-with-remainder a, b reply b ]] - 2:address:array:character <- new [foo 4, 0] - 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + 2:address:shared:array:character <- new [foo 4, 0] + 3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character # run assume-console [ press F4 ] - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data # screen prints error message screen-should-contain [ . run (F4) . @@ -585,7 +585,7 @@ reply b left-click 4, 55 ] run [ - event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data ] # screen should expand trace screen-should-contain [ diff --git a/edit/011-editor-undo.mu b/edit/011-editor-undo.mu index 4939013e..82362dd9 100644 --- a/edit/011-editor-undo.mu +++ b/edit/011-editor-undo.mu @@ -11,13 +11,13 @@ exclusive-container operation [ container insert-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate - insert-from:address:duplex-list:character - insert-until:address:duplex-list:character + insert-from:address:shared:duplex-list:character + insert-until:address:shared:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (enter+indent) # 1: regular alphanumeric characters @@ -26,10 +26,10 @@ container insert-operation [ container move-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (touch events, etc) # 1: left arrow @@ -41,13 +41,13 @@ container move-operation [ container delete-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character - deleted-text:address:duplex-list:character - delete-from:address:duplex-list:character - delete-until:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character + deleted-text:address:shared:duplex-list:character + delete-from:address:shared:duplex-list:character + delete-until:address:shared:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (ctrl-k, ctrl-u) # 1: backspace @@ -56,8 +56,8 @@ container delete-operation [ # every editor accumulates a list of operations to undo/redo container editor-data [ - undo:address:list:address:operation - redo:address:list:address:operation + undo:address:shared:list:address:shared:operation + redo:address:shared:list:address:shared:operation ] # ctrl-z - undo operation @@ -65,11 +65,11 @@ after <handle-special-character> [ { undo?:boolean <- equal *c, 26/ctrl-z break-unless undo? - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset break-unless *undo - op:address:operation <- first *undo + op:address:shared:operation <- first *undo *undo <- rest *undo - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- push op, *redo <handle-undo> reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render @@ -81,11 +81,11 @@ after <handle-special-character> [ { redo?:boolean <- equal *c, 25/ctrl-y break-unless redo? - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset break-unless *redo - op:address:operation <- first *redo + op:address:shared:operation <- first *redo *redo <- rest *redo - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op, *undo <handle-redo> reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render @@ -97,19 +97,19 @@ after <handle-special-character> [ scenario editor-can-undo-typing [ # create an editor and type a character assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # character should be gone screen-should-contain [ @@ -123,7 +123,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -135,34 +135,34 @@ scenario editor-can-undo-typing [ # save operation to undo after <insert-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- copy *before-cursor + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:shared:duplex-list:character <- copy *before-cursor ] before <insert-character-end> [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - typing:address:insert-operation <- maybe-convert *op, typing:variant + op:address:shared:operation <- first *undo + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing previous-coalesce-tag:number <- get *typing, tag:offset break-unless previous-coalesce-tag - insert-until:address:address:duplex-list:character <- get-address *typing, insert-until:offset + insert-until:address:address:shared:duplex-list:character <- get-address *typing, insert-until:offset *insert-until <- next *before-cursor after-row:address:number <- get-address *typing, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *typing, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *typing, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *typing, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-insert-operation:label } # if not, create a new operation - insert-from:address:duplex-list:character <- next cursor-before - insert-to:address:duplex-list:character <- next insert-from - op:address:operation <- new operation:type + insert-from:address:shared:duplex-list:character <- next cursor-before + insert-to:address:shared:duplex-list:character <- next insert-from + op:address:shared:operation <- new operation:type *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, insert-from, insert-to, 1/coalesce editor <- add-operation editor, op +done-adding-insert-operation @@ -172,15 +172,15 @@ before <insert-character-end> [ after <insert-enter-begin> [ cursor-row-before:number <- copy *cursor-row cursor-column-before:number <- copy *cursor-column - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- copy *before-cursor + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:shared:duplex-list:character <- copy *before-cursor ] before <insert-enter-end> [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset # never coalesce - insert-from:address:duplex-list:character <- next cursor-before - insert-to:address:duplex-list:character <- next *before-cursor - op:address:operation <- new operation:type + insert-from:address:shared:duplex-list:character <- next cursor-before + insert-to:address:shared:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, *cursor-row/after, *cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce editor <- add-operation editor, op ] @@ -189,28 +189,28 @@ before <insert-enter-end> [ # redo stack, because it's now obsolete. # Beware: since we're counting cursor moves as operations, this means just # moving the cursor can lose work on the undo stack. -recipe add-operation editor:address:editor-data, op:address:operation -> editor:address:editor-data [ +recipe add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ local-scope load-ingredients - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op *undo - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- copy 0 reply editor/same-as-ingredient:0 ] after <handle-undo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing - start:address:duplex-list:character <- get *typing, insert-from:offset - end:address:duplex-list:character <- get *typing, insert-until:offset + start:address:shared:duplex-list:character <- get *typing, insert-from:offset + end:address:shared:duplex-list:character <- get *typing, insert-until:offset # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *before-cursor <- prev start remove-between *before-cursor, end *cursor-row <- get *typing, before-row:offset *cursor-column <- get *typing, before-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *typing, before-top-of-screen:offset } ] @@ -218,19 +218,19 @@ after <handle-undo> [ scenario editor-can-undo-typing-multiple [ # create an editor and type multiple characters assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be gone screen-should-contain [ @@ -244,14 +244,14 @@ scenario editor-can-undo-typing-multiple [ scenario editor-can-undo-typing-multiple-2 [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [a] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [a] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # type some characters assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .012a . @@ -263,7 +263,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # back to original text screen-should-contain [ @@ -277,7 +277,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -290,15 +290,15 @@ scenario editor-can-undo-typing-multiple-2 [ scenario editor-can-undo-typing-enter [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [ abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [ abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . abc . @@ -307,8 +307,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -318,10 +318,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -338,7 +338,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -353,14 +353,14 @@ scenario editor-can-undo-typing-enter [ scenario editor-redo-typing [ # create an editor, type something, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [a] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [a] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -372,7 +372,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be back screen-should-contain [ @@ -386,7 +386,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -398,15 +398,15 @@ scenario editor-redo-typing [ after <handle-redo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing - insert-from:address:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away + insert-from:address:shared:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away # assert insert-to matches next(*before-cursor) insert-range *before-cursor, insert-from # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *typing, after-row:offset *cursor-column <- get *typing, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *typing, after-top-of-screen:offset } ] @@ -414,14 +414,14 @@ after <handle-redo> [ scenario editor-redo-typing-empty [ # create an editor, type something, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . . @@ -433,7 +433,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be back screen-should-contain [ @@ -447,7 +447,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -460,21 +460,21 @@ scenario editor-redo-typing-empty [ scenario editor-work-clears-redo-stack [ # create an editor with some text, do some work, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # do some more work assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .0abc . @@ -487,7 +487,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # nothing should happen screen-should-contain [ @@ -502,9 +502,9 @@ ghi] scenario editor-can-redo-typing-and-enter-and-tab [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -515,7 +515,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . ab cd . @@ -523,8 +523,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -534,11 +534,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # typing in second line deleted, but not indent - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -555,11 +555,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # indent and newline deleted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -575,11 +575,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # empty screen - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -595,11 +595,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -615,11 +615,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # newline and indent inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -636,11 +636,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # indent and newline deleted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -659,24 +659,24 @@ scenario editor-can-redo-typing-and-enter-and-tab [ scenario editor-can-undo-touch [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # click undone memory-should-contain [ @@ -688,7 +688,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -702,20 +702,20 @@ ghi] after <move-cursor-begin> [ before-cursor-row:number <- get *editor, cursor-row:offset before-cursor-column:number <- get *editor, cursor-column:offset - before-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + before-top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <move-cursor-end> [ after-cursor-row:number <- get *editor, cursor-row:offset after-cursor-column:number <- get *editor, cursor-column:offset - after-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + after-top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset { break-unless undo-coalesce-tag # if previous operation was also a move, and also had the same coalesce # tag, coalesce with it - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset break-unless *undo - op:address:operation <- first *undo - move:address:move-operation <- maybe-convert *op, move:variant + op:address:shared:operation <- first *undo + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move previous-coalesce-tag:number <- get *move, tag:offset coalesce?:boolean <- equal undo-coalesce-tag, previous-coalesce-tag @@ -724,11 +724,11 @@ before <move-cursor-end> [ *after-row <- copy after-cursor-row after-column:address:number <- get-address *move, after-column:offset *after-column <- copy after-cursor-column - after-top:address:address:duplex-list:character <- get-address *move, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *move, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-move-operation:label } - op:address:operation <- new operation:type + op:address:shared:operation <- new operation:type *op <- merge 1/move-operation, before-cursor-row, before-cursor-column, before-top-of-screen, after-cursor-row, after-cursor-column, after-top-of-screen, undo-coalesce-tag editor <- add-operation editor, op +done-adding-move-operation @@ -736,10 +736,10 @@ before <move-cursor-end> [ after <handle-undo> [ { - move:address:move-operation <- maybe-convert *op, move:variant + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *cursor-row <- get *move, before-row:offset *cursor-column <- get *move, before-column:offset *top <- get *move, before-top-of-screen:offset @@ -750,18 +750,18 @@ scenario editor-can-undo-scroll [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset # screen scrolls screen-should-contain [ . . @@ -778,9 +778,9 @@ cdefgh] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moved back memory-should-contain [ @@ -799,7 +799,7 @@ cdefgh] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -812,25 +812,25 @@ cdefgh] scenario editor-can-undo-left-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -842,7 +842,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -856,19 +856,19 @@ ghi] scenario editor-can-undo-up-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -878,9 +878,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -892,7 +892,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -906,25 +906,25 @@ ghi] scenario editor-can-undo-down-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -936,7 +936,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -950,27 +950,27 @@ ghi] scenario editor-can-undo-ctrl-f [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page assume-console [ press ctrl-f ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 1 screen-should-contain [ @@ -985,27 +985,27 @@ f] scenario editor-can-undo-page-down [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page assume-console [ press page-down ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 1 screen-should-contain [ @@ -1020,28 +1020,28 @@ f] scenario editor-can-undo-ctrl-b [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page down and up assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 2 screen-should-contain [ @@ -1056,28 +1056,28 @@ f] scenario editor-can-undo-page-up [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page down and up assume-console [ press page-down press page-up ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 2 screen-should-contain [ @@ -1092,25 +1092,25 @@ f] scenario editor-can-undo-ctrl-a [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1122,7 +1122,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1136,25 +1136,25 @@ ghi] scenario editor-can-undo-home [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1166,7 +1166,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1180,25 +1180,25 @@ ghi] scenario editor-can-undo-ctrl-e [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1210,7 +1210,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1224,25 +1224,25 @@ ghi] scenario editor-can-undo-end [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1254,7 +1254,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1268,17 +1268,17 @@ ghi] scenario editor-separates-undo-insert-from-undo-cursor-move [ # create an editor, type some text, move the cursor, type some more text assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1294,9 +1294,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1314,9 +1314,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1334,9 +1334,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1354,9 +1354,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # first insert screen-should-contain [ @@ -1374,9 +1374,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1394,9 +1394,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # second insert screen-should-contain [ @@ -1414,11 +1414,11 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ scenario editor-can-undo-multiple-arrows-in-the-same-direction [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 2, 1 @@ -1426,9 +1426,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1438,9 +1438,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # up-arrow is undone memory-should-contain [ @@ -1452,9 +1452,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # both right-arrows are undone memory-should-contain [ @@ -1468,24 +1468,24 @@ ghi] scenario editor-redo-touch [ # create an editor with some text, click on a character, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to left-click memory-should-contain [ @@ -1497,7 +1497,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1510,12 +1510,12 @@ ghi] after <handle-redo> [ { - move:address:move-operation <- maybe-convert *op, move:variant + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *move, after-row:offset *cursor-column <- get *move, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *move, after-top-of-screen:offset } ] @@ -1525,24 +1525,24 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-backspace [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1552,10 +1552,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1571,10 +1571,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1589,38 +1589,38 @@ scenario editor-can-undo-and-redo-backspace [ # save operation to undo after <backspace-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <backspace-character-end> [ { break-unless backspaced-cell # backspace failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant + op:address:shared:operation <- first *undo + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion previous-coalesce-tag:number <- get *deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace break-unless coalesce? - delete-from:address:address:duplex-list:character <- get-address *deletion, delete-from:offset + delete-from:address:address:shared:duplex-list:character <- get-address *deletion, delete-from:offset *delete-from <- copy *before-cursor - backspaced-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset + backspaced-so-far:address:address:shared:duplex-list:character <- get-address *deletion, deleted-text:offset insert-range backspaced-cell, *backspaced-so-far *backspaced-so-far <- copy backspaced-cell after-row:address:number <- get-address *deletion, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *deletion, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *deletion, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-backspace-operation:label } # if not, create a new operation - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, backspaced-cell/deleted, *before-cursor/delete-from, deleted-until, 1/coalesce-backspace editor <- add-operation editor, op +done-adding-backspace-operation @@ -1629,34 +1629,34 @@ before <backspace-character-end> [ after <handle-undo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion - start2:address:address:duplex-list:character <- get-address *editor, data:offset - anchor:address:duplex-list:character <- get *deletion, delete-from:offset + start2:address:address:shared:duplex-list:character <- get-address *editor, data:offset + anchor:address:shared:duplex-list:character <- get *deletion, delete-from:offset break-unless anchor - deleted:address:duplex-list:character <- get *deletion, deleted-text:offset - old-cursor:address:duplex-list:character <- last deleted + deleted:address:shared:duplex-list:character <- get *deletion, deleted-text:offset + old-cursor:address:shared:duplex-list:character <- last deleted insert-range anchor, deleted # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *before-cursor <- copy old-cursor *cursor-row <- get *deletion, before-row:offset *cursor-column <- get *deletion, before-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *deletion, before-top-of-screen:offset } ] after <handle-redo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion - start:address:duplex-list:character <- get *deletion, delete-from:offset - end:address:duplex-list:character <- get *deletion, delete-until:offset + start:address:shared:duplex-list:character <- get *deletion, delete-from:offset + end:address:shared:duplex-list:character <- get *deletion, delete-until:offset remove-between start, end # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *deletion, after-row:offset *cursor-column <- get *deletion, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *deletion, after-top-of-screen:offset } ] @@ -1666,9 +1666,9 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-delete [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1678,15 +1678,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1696,10 +1696,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1715,10 +1715,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1734,10 +1734,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1753,11 +1753,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1773,11 +1773,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1793,11 +1793,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1811,37 +1811,37 @@ scenario editor-can-undo-and-redo-delete [ ] after <delete-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-character-end> [ { break-unless deleted-cell # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant + op:address:shared:operation <- first *undo + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion previous-coalesce-tag:number <- get *deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete break-unless coalesce? - delete-until:address:address:duplex-list:character <- get-address *deletion, delete-until:offset + delete-until:address:address:shared:duplex-list:character <- get-address *deletion, delete-until:offset *delete-until <- next *before-cursor - deleted-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset + deleted-so-far:address:address:shared:duplex-list:character <- get-address *deletion, deleted-text:offset *deleted-so-far <- append *deleted-so-far, deleted-cell after-row:address:number <- get-address *deletion, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *deletion, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *deletion, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-delete-operation:label } # if not, create a new operation - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cell/deleted, *before-cursor/delete-from, deleted-until, 2/coalesce-delete editor <- add-operation editor, op +done-adding-delete-operation @@ -1853,16 +1853,16 @@ before <delete-character-end> [ scenario editor-can-undo-and-redo-ctrl-k [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 1 press ctrl-k ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -1870,8 +1870,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1881,7 +1881,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1890,8 +1890,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1901,7 +1901,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted screen-should-contain [ @@ -1911,8 +1911,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1922,7 +1922,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1934,15 +1934,15 @@ def] ] after <delete-to-end-of-line-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-to-end-of-line-end> [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -1954,16 +1954,16 @@ before <delete-to-end-of-line-end> [ scenario editor-can-undo-and-redo-ctrl-u [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 2 press ctrl-u ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .c . @@ -1971,8 +1971,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1982,7 +1982,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1991,8 +1991,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -2002,7 +2002,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted screen-should-contain [ @@ -2012,8 +2012,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2023,7 +2023,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2035,15 +2035,15 @@ def] ] after <delete-to-start-of-line-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-to-start-of-line-end> [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -2053,16 +2053,16 @@ before <delete-to-start-of-line-end> [ scenario editor-can-undo-and-redo-ctrl-u-2 [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # 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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .abc . diff --git a/global.mu b/global.mu index 756469c1..b78ba47b 100644 --- a/global.mu +++ b/global.mu @@ -2,7 +2,7 @@ recipe main [ # allocate 5 locations for globals - global-space:address:array:location <- new location:type, 5 + global-space:address:shared:array:location <- new location:type, 5 # read to globals by using /space:global 1:number/space:global <- copy 3 foo @@ -10,5 +10,5 @@ recipe main [ recipe foo [ # ditto for writing to globals - $print 1:number/space:global + $print 1:number/space:global, 10/newline ] diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index fd44d493..773b7d77 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -2,7 +2,7 @@ # temporary main for this layer: just render the given text at the given # screen dimensions, then stop -recipe! main text:address:array:character [ +recipe! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -16,8 +16,8 @@ recipe! main text:address:array:character [ scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ - 1:address:array:character <- new [abc] - new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -29,11 +29,11 @@ scenario editor-initially-prints-text-to-screen [ container editor-data [ # editable text: doubly linked list of characters (head contains a special sentinel) - data:address:duplex-list:character - top-of-screen:address:duplex-list:character - bottom-of-screen:address:duplex-list:character + data:address:shared:duplex-list:character + top-of-screen:address:shared:duplex-list:character + bottom-of-screen:address:shared:duplex-list:character # location before cursor inside data - before-cursor:address:duplex-list:character + before-cursor:address:shared:duplex-list:character # raw bounds of display area on screen # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen @@ -47,7 +47,7 @@ container editor-data [ # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -recipe new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data, screen:address:screen [ +recipe new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ local-scope load-ingredients # no clipping of bounds @@ -63,11 +63,11 @@ recipe new-editor s:address:array:character, screen:address:screen, left:number, *x <- copy 1/top x <- get-address *result, cursor-column:offset *x <- copy left - init:address:address:duplex-list:character <- get-address *result, data:offset + init:address:address:shared:duplex-list:character <- get-address *result, data:offset *init <- push 167/§, 0/tail - top-of-screen:address:address:duplex-list:character <- get-address *result, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *result, top-of-screen:offset *top-of-screen <- copy *init - y:address:address:duplex-list:character <- get-address *result, before-cursor:offset + y:address:address:shared:duplex-list:character <- get-address *result, before-cursor:offset *y <- copy *init result <- insert-text result, s # initialize cursor to top of screen @@ -78,7 +78,7 @@ recipe new-editor s:address:array:character, screen:address:screen, left:number, <editor-initialization> ] -recipe insert-text editor:address:editor-data, text:address:array:character -> editor:address:editor-data [ +recipe insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ local-scope load-ingredients # early exit if text is empty @@ -87,7 +87,7 @@ recipe insert-text editor:address:editor-data, text:address:array:character -> e reply-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character - curr:address:duplex-list:character <- get *editor, data:offset + curr:address:shared:duplex-list:character <- get *editor, data:offset { done?:boolean <- greater-or-equal idx, len break-if done? @@ -104,8 +104,8 @@ recipe insert-text editor:address:editor-data, text:address:array:character -> e scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ - 1:address:editor-data <- new-editor 0/data, screen:address:screen, 2/left, 5/right - 2:editor-data <- copy *1:address:editor-data + 1:address:shared:editor-data <- new-editor 0/data, screen:address:shared:screen, 2/left, 5/right + 2:editor-data <- copy *1:address:shared:editor-data ] memory-should-contain [ # 2 (data) <- just the § sentinel @@ -127,7 +127,7 @@ scenario editor-initializes-without-data [ # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -recipe render screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ +recipe render screen:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 @@ -135,8 +135,8 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb screen-height:number <- screen-height screen right:number <- get *editor, right:offset # traversing editor - curr:address:duplex-list:character <- get *editor, top-of-screen:offset - prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:shared:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr # traversing screen +render-loop-initialization @@ -145,7 +145,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb column:number <- copy left cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset screen <- move-cursor screen, row, column { +next-character @@ -208,7 +208,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb loop } # save first character off-screen - bottom-of-screen:address:address:duplex-list:character <- get-address *editor, bottom-of-screen:offset + bottom-of-screen:address:address:shared:duplex-list:character <- get-address *editor, bottom-of-screen:offset *bottom-of-screen <- copy curr # is cursor to the right of the last line? move to end { @@ -225,7 +225,7 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited screen:address:screen, column:number, right:number -> screen:address:screen [ +recipe clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients space:character <- copy 32/space @@ -238,7 +238,7 @@ recipe clear-line-delimited screen:address:screen, column:number, right:number - } ] -recipe clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number -> screen:address:screen [ +recipe clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive @@ -254,7 +254,7 @@ recipe clear-screen-from screen:address:screen, row:number, column:number, left: reply screen/same-as-ingredient:0 ] -recipe clear-rest-of-screen screen:address:screen, row:number, left:number, right:number -> screen:address:screen [ +recipe clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients row <- add row, 1 @@ -273,9 +273,9 @@ recipe clear-rest-of-screen screen:address:screen, row:number, left:number, righ scenario editor-initially-prints-multiple-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -288,8 +288,8 @@ def] scenario editor-initially-handles-offsets [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc] - new-editor s:address:array:character, screen:address:screen, 1/left, 5/right + s:address:shared:array:character <- new [abc] + new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -301,9 +301,9 @@ scenario editor-initially-handles-offsets [ scenario editor-initially-prints-multiple-lines-at-offset [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 1/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -316,8 +316,8 @@ def] scenario editor-initially-wraps-long-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + s:address:shared:array:character <- new [abc def] + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -336,8 +336,8 @@ scenario editor-initially-wraps-long-lines [ scenario editor-initially-wraps-barely-long-lines [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abcde] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + s:address:shared:array:character <- new [abcde] + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -358,10 +358,10 @@ scenario editor-initially-wraps-barely-long-lines [ scenario editor-initializes-empty-text [ assume-screen 5/width, 5/height run [ - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -379,10 +379,10 @@ scenario editor-initializes-empty-text [ scenario render-colors-comments [ assume-screen 5/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc # de f] - new-editor s:address:array:character, screen:address:screen, 0/left, 5/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -460,10 +460,10 @@ recipe get-color color:number, c:character -> color:number [ scenario render-colors-assignment [ assume-screen 8/width, 5/height run [ - s:address:array:character <- new [abc + s:address:shared:array:character <- new [abc d <- e f] - new-editor s:address:array:character, screen:address:screen, 0/left, 8/right + new-editor s:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right ] screen-should-contain [ . . diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu index 037c222b..f3f6b321 100644 --- a/sandbox/002-typing.mu +++ b/sandbox/002-typing.mu @@ -2,16 +2,16 @@ # temporary main: interactive editor # hit ctrl-c to exit -recipe! main text:address:array:character [ +recipe! main text:address:shared:array:character [ local-scope load-ingredients open-console - editor:address:editor-data <- new-editor text, 0/screen, 5/left, 45/right + editor:address:shared:editor-data <- new-editor text, 0/screen, 5/left, 45/right editor-event-loop 0/screen, 0/console, editor close-console ] -recipe editor-event-loop screen:address:screen, console:address:console, editor:address:editor-data -> screen:address:screen, console:address:console, editor:address:editor-data [ +recipe editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ local-scope load-ingredients { @@ -20,7 +20,7 @@ recipe editor-event-loop screen:address:screen, console:address:console, editor: cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column - e:event, console:address:console, found?:boolean, quit?:boolean <- read-event console + e:event, console:address:shared:console, found?:boolean, quit?:boolean <- read-event console loop-unless found? break-if quit? # only in tests trace 10, [app], [next-event] @@ -45,7 +45,7 @@ recipe editor-event-loop screen:address:screen, console:address:console, editor: ] # process click, return if it was on current editor -recipe move-cursor-in-editor screen:address:screen, editor:address:editor-data, t:touch-event -> in-focus?:boolean, editor:address:editor-data [ +recipe move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor, 0/false @@ -70,7 +70,7 @@ recipe move-cursor-in-editor screen:address:screen, editor:address:editor-data, # Variant of 'render' that only moves the cursor (coordinates and # before-cursor). If it's past the end of a line, it 'slides' it left. If it's # past the last line it positions at end of last line. -recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row:number, target-column:number -> editor:address:editor-data [ +recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ local-scope load-ingredients reply-unless editor @@ -78,8 +78,8 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row right:number <- get *editor, right:offset screen-height:number <- screen-height screen # count newlines until screen row - curr:address:duplex-list:character <- get *editor, top-of-screen:offset - prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:shared:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev curr <- next curr row:number <- copy 1/top column:number <- copy left @@ -87,7 +87,7 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row *cursor-row <- copy target-row cursor-column:address:number <- get-address *editor, cursor-column:offset *cursor-column <- copy target-column - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset { +next-character break-unless curr @@ -155,7 +155,7 @@ recipe snap-cursor screen:address:screen, editor:address:editor-data, target-row # Process an event 'e' and try to minimally update the screen. # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. -recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, e:event -> screen:address:screen, editor:address:editor-data, go-render?:boolean [ +recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients go-render? <- copy 0/false @@ -164,7 +164,7 @@ recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, screen-height:number <- screen-height screen left:number <- get *editor, left:offset right:number <- get *editor, right:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset save-row:number <- copy *cursor-row @@ -195,10 +195,10 @@ recipe handle-keyboard-event screen:address:screen, editor:address:editor-data, reply ] -recipe insert-at-cursor editor:address:editor-data, c:character, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset insert c, *before-cursor *before-cursor <- next *before-cursor cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -213,7 +213,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: <insert-character-special-case> # but mostly we'll just move the cursor right *cursor-column <- add *cursor-column, 1 - next:address:duplex-list:character <- next *before-cursor + next:address:shared:duplex-list:character <- next *before-cursor { # at end of all text? no need to scroll? just print the character and leave at-end?:boolean <- equal next, 0/null @@ -233,7 +233,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: break-unless next at-right?:boolean <- greater-or-equal *cursor-column, screen-width break-if at-right? - curr:address:duplex-list:character <- copy *before-cursor + curr:address:shared:duplex-list:character <- copy *before-cursor move-cursor screen, save-row, save-column curr-column:number <- copy save-column { @@ -259,7 +259,7 @@ recipe insert-at-cursor editor:address:editor-data, c:character, screen:address: ] # helper for tests -recipe editor-render screen:address:screen, editor:address:editor-data -> screen:address:screen, editor:address:editor-data [ +recipe editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients left:number <- get *editor, left:offset @@ -274,12 +274,12 @@ recipe editor-render screen:address:screen, editor:address:editor-data -> screen scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -291,17 +291,17 @@ scenario editor-handles-empty-event-queue [ scenario editor-handles-mouse-clicks [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 1 # on the 'b' ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -318,16 +318,16 @@ scenario editor-handles-mouse-clicks [ scenario editor-handles-mouse-clicks-outside-text [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -338,17 +338,17 @@ scenario editor-handles-mouse-clicks-outside-text [ scenario editor-handles-mouse-clicks-outside-text-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # cursor row @@ -359,17 +359,17 @@ def] scenario editor-handles-mouse-clicks-outside-text-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right $clear-trace assume-console [ left-click 3, 7 # below text ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 # cursor row @@ -380,19 +380,19 @@ def] scenario editor-handles-mouse-clicks-outside-column [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] + 1:address:shared:array:character <- new [abc] # editor occupies only left half of screen - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ # click on right half of screen left-click 3, 8 ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -409,18 +409,18 @@ scenario editor-handles-mouse-clicks-outside-column [ scenario editor-handles-mouse-clicks-in-menu-area [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ # click on first, 'menu' row left-click 0, 3 ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # no change to cursor memory-should-contain [ @@ -431,15 +431,15 @@ scenario editor-handles-mouse-clicks-in-menu-area [ scenario editor-inserts-characters-into-empty-editor [ assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ type [abc] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -452,9 +452,9 @@ scenario editor-inserts-characters-into-empty-editor [ scenario editor-inserts-characters-at-cursor [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # type two letters at different places assume-console [ @@ -463,7 +463,7 @@ scenario editor-inserts-characters-at-cursor [ type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -476,16 +476,16 @@ scenario editor-inserts-characters-at-cursor [ scenario editor-inserts-characters-at-cursor-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 5 # right of last line type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -498,17 +498,17 @@ scenario editor-inserts-characters-at-cursor-2 [ scenario editor-inserts-characters-at-cursor-5 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 5 # right of non-last line type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -522,16 +522,16 @@ d] scenario editor-inserts-characters-at-cursor-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [d] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -544,17 +544,17 @@ scenario editor-inserts-characters-at-cursor-3 [ scenario editor-inserts-characters-at-cursor-4 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -568,17 +568,17 @@ d] scenario editor-inserts-characters-at-cursor-6 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 3, 5 # below all text type [ef] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -592,14 +592,14 @@ d] scenario editor-moves-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ab] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [ab] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [01] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -613,15 +613,15 @@ scenario editor-moves-cursor-after-inserting-characters [ scenario editor-wraps-line-on-insert [ assume-screen 5/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data # type a letter assume-console [ type [e] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # no wrap yet screen-should-contain [ @@ -636,7 +636,7 @@ scenario editor-wraps-line-on-insert [ type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # now wrap screen-should-contain [ @@ -651,19 +651,19 @@ scenario editor-wraps-line-on-insert [ scenario editor-wraps-line-on-insert-2 [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abcdefg + 1:address:shared:array:character <- new [abcdefg defg] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data # type more text at the start assume-console [ left-click 3, 0 type [abc] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor is not wrapped memory-should-contain [ @@ -703,16 +703,16 @@ after <insert-character-special-case> [ scenario editor-wraps-cursor-after-inserting-characters [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 1, 4 # line is full; no wrap icon yet type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -729,16 +729,16 @@ scenario editor-wraps-cursor-after-inserting-characters [ scenario editor-wraps-cursor-after-inserting-characters-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 1, 3 # right before the wrap icon type [f] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -755,16 +755,16 @@ scenario editor-wraps-cursor-after-inserting-characters-2 [ scenario editor-wraps-cursor-to-left-margin [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 2/left, 7/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -792,14 +792,14 @@ after <editor-initialization> [ scenario editor-moves-cursor-down-after-inserting-newline [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -822,12 +822,12 @@ after <handle-special-character> [ } ] -recipe insert-new-line-and-indent editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean [ +recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset screen-height:number <- screen-height screen @@ -847,8 +847,8 @@ recipe insert-new-line-and-indent editor:address:editor-data, screen:address:scr # indent if necessary indent?:boolean <- get *editor, indent?:offset reply-unless indent? - d:address:duplex-list:character <- get *editor, data:offset - end-of-previous-line:address:duplex-list:character <- prev *before-cursor + d:address:shared:duplex-list:character <- get *editor, data:offset + end-of-previous-line:address:shared:duplex-list:character <- prev *before-cursor indent:number <- line-indent end-of-previous-line, d i:number <- copy 0 { @@ -862,7 +862,7 @@ recipe insert-new-line-and-indent editor:address:editor-data, screen:address:scr # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the number of spaces at the start of the line containing 'curr'. -recipe line-indent curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +recipe line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -894,14 +894,14 @@ recipe line-indent curr:address:duplex-list:character, start:address:duplex-list scenario editor-moves-cursor-down-after-inserting-newline-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 10/right assume-console [ type [0 1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -914,8 +914,8 @@ scenario editor-moves-cursor-down-after-inserting-newline-2 [ scenario editor-clears-previous-line-completely-after-inserting-newline [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ press enter ] @@ -927,7 +927,7 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ . . ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # line should be fully cleared screen-should-contain [ @@ -941,10 +941,10 @@ scenario editor-clears-previous-line-completely-after-inserting-newline [ scenario editor-inserts-indent-after-newline [ assume-screen 10/width, 10/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' assume-console [ left-click 2, 8 @@ -952,9 +952,9 @@ ef] ] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -965,10 +965,10 @@ ef] scenario editor-skips-indent-around-paste [ assume-screen 10/width, 10/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd ef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # position cursor after 'cd' and hit 'newline' surrounded by paste markers assume-console [ left-click 2, 8 @@ -977,9 +977,9 @@ ef] press 65506 # end paste ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor should be below start of previous line memory-should-contain [ @@ -1012,7 +1012,7 @@ after <handle-special-key> [ ## helpers -recipe draw-horizontal screen:address:screen, row:number, x:number, right:number -> screen:address:screen [ +recipe draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu index feab04ea..b69bf2bd 100644 --- a/sandbox/003-shortcuts.mu +++ b/sandbox/003-shortcuts.mu @@ -7,14 +7,14 @@ scenario editor-inserts-two-spaces-on-tab [ assume-screen 10/width, 5/height # just one character in final line - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ press tab ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -40,18 +40,18 @@ after <handle-special-character> [ scenario editor-handles-backspace-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 1 press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -71,7 +71,7 @@ after <handle-special-character> [ delete-previous-character?:boolean <- equal *c, 8/backspace break-unless delete-previous-character? <backspace-character-begin> - editor, screen, go-render?:boolean, backspaced-cell:address:duplex-list:character <- delete-before-cursor editor, screen + editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen <backspace-character-end> reply } @@ -80,19 +80,19 @@ after <handle-special-character> [ # return values: # go-render? - whether caller needs to update the screen # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. -recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, backspaced-cell:address:duplex-list:character [ +recipe delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + data:address:shared:duplex-list:character <- get *editor, data:offset # if at start of text (before-cursor at § sentinel), return - prev:address:duplex-list:character <- prev *before-cursor + prev:address:shared:duplex-list:character <- prev *before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted reply-unless prev trace 10, [app], [delete-before-cursor] original-row:number <- get *editor, cursor-row:offset editor, scroll?:boolean <- move-cursor-coordinates-left editor - backspaced-cell:address:duplex-list:character <- copy *before-cursor + backspaced-cell:address:shared:duplex-list:character <- copy *before-cursor data <- remove *before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/*before-cursor *before-cursor <- copy prev go-render? <- copy 1/true @@ -106,7 +106,7 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> reply-unless same-row? left:number <- get *editor, left:offset right:number <- get *editor, right:offset - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor screen <- move-cursor screen, cursor-row, cursor-column curr-column:number <- copy cursor-column { @@ -130,10 +130,10 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen -> go-render? <- copy 0/false ] -recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -165,7 +165,7 @@ recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address break-unless previous-character-is-newline? # compute length of previous line trace 10, [app], [switching to previous line] - d:address:duplex-list:character <- get *editor, data:offset + d:address:shared:duplex-list:character <- get *editor, data:offset end-of-line:number <- previous-line-length before-cursor, d *cursor-column <- add left, end-of-line reply @@ -178,7 +178,7 @@ recipe move-cursor-coordinates-left editor:address:editor-data -> editor:address # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -recipe previous-line-length curr:address:duplex-list:character, start:address:duplex-list:character -> result:number [ +recipe previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 @@ -201,17 +201,17 @@ recipe previous-line-length curr:address:duplex-list:character, start:address:du scenario editor-clears-last-line-on-backspace [ assume-screen 10/width, 5/height # just one character in final line - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab cd] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -228,10 +228,10 @@ cd] scenario editor-joins-and-wraps-lines-on-backspace [ assume-screen 10/width, 5/height # initialize editor with two long-ish but non-wrapping lines - 1:address:array:character <- new [abc def + 1:address:shared:array:character <- new [abc def ghi jkl] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position the cursor at the start of the second and hit backspace assume-console [ @@ -239,7 +239,7 @@ ghi jkl] press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # resulting single line should wrap correctly screen-should-contain [ @@ -254,9 +254,9 @@ ghi jkl] scenario editor-wraps-long-lines-on-backspace [ assume-screen 10/width, 5/height # initialize editor in part of the screen with a long line - 1:address:array:character <- new [abc def ghij] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 8/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc def ghij] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 8/right + editor-render screen, 2:address:shared:editor-data # confirm that it wraps screen-should-contain [ . . @@ -271,7 +271,7 @@ scenario editor-wraps-long-lines-on-backspace [ press backspace ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # resulting single line should wrap correctly and not overflow its bounds screen-should-contain [ @@ -287,15 +287,15 @@ scenario editor-wraps-long-lines-on-backspace [ scenario editor-handles-delete-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -309,7 +309,7 @@ scenario editor-handles-delete-key [ press delete ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -325,18 +325,18 @@ after <handle-special-key> [ delete-next-character?:boolean <- equal *k, 65522/delete break-unless delete-next-character? <delete-character-begin> - editor, screen, go-render?:boolean, deleted-cell:address:duplex-list:character <- delete-at-cursor editor, screen + editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen <delete-character-end> reply } ] -recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> editor:address:editor-data, screen:address:screen, go-render?:boolean, deleted-cell:address:duplex-list:character [ +recipe delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - data:address:duplex-list:character <- get *editor, data:offset - deleted-cell:address:duplex-list:character <- next *before-cursor + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + data:address:shared:duplex-list:character <- get *editor, data:offset + deleted-cell:address:shared:duplex-list:character <- next *before-cursor go-render? <- copy 0/false reply-unless deleted-cell currc:character <- get *deleted-cell, value:offset @@ -345,7 +345,7 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi go-render? <- copy 1/true reply-if deleted-newline? # wasn't a newline? render rest of line - curr:address:duplex-list:character <- next *before-cursor # refresh after remove above + curr:address:shared:duplex-list:character <- next *before-cursor # refresh after remove above cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset screen <- move-cursor screen, *cursor-row, *cursor-column @@ -376,16 +376,16 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi scenario editor-moves-cursor-right-with-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ press right-arrow type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -401,7 +401,7 @@ after <handle-special-key> [ move-to-next-character?:boolean <- equal *k, 65514/right-arrow break-unless move-to-next-character? # if not at end of text - next-cursor:address:duplex-list:character <- next *before-cursor + next-cursor:address:shared:duplex-list:character <- next *before-cursor break-unless next-cursor # scan to next character <move-cursor-begin> @@ -414,10 +414,10 @@ after <handle-special-key> [ } ] -recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients - before-cursor:address:duplex-list:character <- get *editor before-cursor:offset + before-cursor:address:shared:duplex-list:character <- get *editor before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset left:number <- get *editor, left:offset @@ -444,7 +444,7 @@ recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:n at-wrap?:boolean <- equal *cursor-column, wrap-column break-unless at-wrap? # and if next character isn't newline - next:address:duplex-list:character <- next before-cursor + next:address:shared:duplex-list:character <- next before-cursor break-unless next next-character:character <- get *next, value:offset newline?:boolean <- equal next-character, 10/newline @@ -465,10 +465,10 @@ recipe move-cursor-coordinates-right editor:address:editor-data, screen-height:n scenario editor-moves-cursor-to-next-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # type right-arrow a few times to get to start of second line assume-console [ @@ -478,7 +478,7 @@ d] press right-arrow # next line ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] check-trace-count-for-label 0, [print-character] # type something and ensure it goes where it should @@ -486,7 +486,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -500,10 +500,10 @@ d] scenario editor-moves-cursor-to-next-line-with-right-arrow-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ press right-arrow press right-arrow @@ -512,7 +512,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -525,18 +525,18 @@ d] scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcdef] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 3 press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -555,9 +555,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ assume-screen 10/width, 5/height # line just barely wrapping - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcde] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor at last character before wrap and hit right-arrow assume-console [ @@ -565,9 +565,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -578,9 +578,9 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -591,18 +591,18 @@ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 1/left, 6/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcdef] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 1/left, 6/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 4 press right-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] screen-should-contain [ . . @@ -620,10 +620,10 @@ 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 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # move to end of line, press right-arrow, type a character assume-console [ @@ -632,7 +632,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # new character should be in next line screen-should-contain [ @@ -651,9 +651,9 @@ d] scenario editor-moves-cursor-left-with-key [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 2 @@ -661,7 +661,7 @@ scenario editor-moves-cursor-left-with-key [ type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -678,7 +678,7 @@ after <handle-special-key> [ break-unless move-to-previous-character? trace 10, [app], [left arrow] # if not at start of text (before-cursor at § sentinel) - prev:address:duplex-list:character <- prev *before-cursor + prev:address:shared:duplex-list:character <- prev *before-cursor go-render? <- copy 0/false reply-unless prev <move-cursor-begin> @@ -693,10 +693,10 @@ after <handle-special-key> [ scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ assume-screen 10/width, 5/height # initialize editor with two lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor at start of second line (so there's no previous newline) assume-console [ @@ -704,9 +704,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -718,11 +718,11 @@ d] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ assume-screen 10/width, 5/height # initialize editor with three lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor further down (so there's a newline before the character at # the cursor) @@ -732,7 +732,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -746,11 +746,11 @@ g] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor at start of text, press left-arrow, then type a character assume-console [ @@ -759,7 +759,7 @@ g] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # left-arrow should have had no effect screen-should-contain [ @@ -775,11 +775,11 @@ g] scenario editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # position cursor right after empty line assume-console [ @@ -788,7 +788,7 @@ d] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -803,9 +803,9 @@ d] scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ assume-screen 10/width, 5/height # initialize editor with text containing an empty line - 1:address:array:character <- new [abcdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [abcdef] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right + editor-render screen, 2:address:shared:editor-data $clear-trace screen-should-contain [ . . @@ -820,9 +820,9 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 # previous row @@ -837,19 +837,19 @@ scenario editor-moves-across-screen-lines-across-wrap-with-left-arrow [ scenario editor-moves-to-previous-line-with-up-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 2, 1 press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -860,7 +860,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -883,12 +883,12 @@ after <handle-special-key> [ } ] -recipe move-to-previous-line editor:address:editor-data -> editor:address:editor-data, go-render?:boolean [ +recipe move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset already-at-top?:boolean <- lesser-or-equal *cursor-row, 1/top @@ -898,13 +898,13 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor # if not at newline, move to start of line (previous newline) # then scan back another line # if either step fails, give up without modifying cursor or coordinates - curr:address:duplex-list:character <- copy *before-cursor + curr:address:shared:duplex-list:character <- copy *before-cursor { - old:address:duplex-list:character <- copy curr + old:address:shared:duplex-list:character <- copy curr c2:character <- get *curr, value:offset at-newline?:boolean <- equal c2, 10/newline break-if at-newline? - curr:address:duplex-list:character <- before-previous-line curr, editor + curr:address:shared:duplex-list:character <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false reply-if no-motion? @@ -924,7 +924,7 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor { done?:boolean <- greater-or-equal *cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -948,19 +948,19 @@ recipe move-to-previous-line editor:address:editor-data -> editor:address:editor scenario editor-adjusts-column-at-previous-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ab + 1:address:shared:array:character <- new [ab def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -971,7 +971,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -984,19 +984,19 @@ def] scenario editor-adjusts-column-at-empty-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [ + 1:address:shared:array:character <- new [ def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 2, 3 press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 1 @@ -1007,7 +1007,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1021,11 +1021,11 @@ def] scenario editor-moves-to-previous-line-from-left-margin [ assume-screen 10/width, 5/height # start out with three lines - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # click on the third line and hit up-arrow, so you end up just after a newline assume-console [ @@ -1033,9 +1033,9 @@ ghi] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1046,7 +1046,7 @@ ghi] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1061,19 +1061,19 @@ ghi] scenario editor-moves-to-next-line-with-down-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # cursor starts out at (1, 0) assume-console [ press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # ..and ends at (2, 0) memory-should-contain [ @@ -1085,7 +1085,7 @@ def] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1108,12 +1108,12 @@ after <handle-special-key> [ } ] -recipe move-to-next-line editor:address:editor-data, screen-height:number -> editor:address:editor-data, go-render?:boolean [ +recipe move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset last-line:number <- subtract screen-height, 1 @@ -1123,7 +1123,7 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi break-if already-at-bottom? # scan to start of next line, then to right column or until end of line max:number <- subtract right, left - next-line:address:duplex-list:character <- before-start-of-next-line *before-cursor, max + next-line:address:shared:duplex-list:character <- before-start-of-next-line *before-cursor, max { # already at end of buffer? try to scroll up (so we can see more # warnings or sandboxes below) @@ -1141,7 +1141,7 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi { done?:boolean <- greater-or-equal *cursor-column, target-column break-if done? - curr:address:duplex-list:character <- next *before-cursor + curr:address:shared:duplex-list:character <- next *before-cursor break-unless curr currc:character <- get *curr, value:offset at-newline?:boolean <- equal currc, 10/newline @@ -1161,19 +1161,19 @@ recipe move-to-next-line editor:address:editor-data, screen-height:number -> edi scenario editor-adjusts-column-at-next-line [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace assume-console [ left-click 1, 3 press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 3 <- 2 @@ -1184,7 +1184,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1199,10 +1199,10 @@ de] scenario editor-moves-to-start-of-line-with-ctrl-a [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on second line, press ctrl-a assume-console [ @@ -1210,9 +1210,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a [ press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1248,7 +1248,7 @@ after <handle-special-key> [ } ] -recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor-data [ +recipe move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # update cursor column @@ -1256,8 +1256,8 @@ recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor cursor-column:address:number <- get-address *editor, cursor-column:offset *cursor-column <- copy left # update before-cursor - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - init:address:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + init:address:shared:duplex-list:character <- get *editor, data:offset # while not at start of line, move { at-start-of-text?:boolean <- equal *before-cursor, init @@ -1273,10 +1273,10 @@ recipe move-to-start-of-line editor:address:editor-data -> editor:address:editor scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line (no newline before), press ctrl-a assume-console [ @@ -1284,9 +1284,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ press ctrl-a ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1298,9 +1298,9 @@ scenario editor-moves-to-start-of-line-with-ctrl-a-2 [ scenario editor-moves-to-start-of-line-with-home [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right $clear-trace # start on second line, press 'home' assume-console [ @@ -1308,9 +1308,9 @@ scenario editor-moves-to-start-of-line-with-home [ press home ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1322,10 +1322,10 @@ scenario editor-moves-to-start-of-line-with-home [ scenario editor-moves-to-start-of-line-with-home-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line (no newline before), press 'home' assume-console [ @@ -1333,9 +1333,9 @@ scenario editor-moves-to-start-of-line-with-home-2 [ press home ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to start of line memory-should-contain [ @@ -1349,10 +1349,10 @@ scenario editor-moves-to-start-of-line-with-home-2 [ scenario editor-moves-to-end-of-line-with-ctrl-e [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line, press ctrl-e assume-console [ @@ -1360,9 +1360,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1375,9 +1375,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e [ type [z] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] memory-should-contain [ 4 <- 1 @@ -1419,14 +1419,14 @@ after <handle-special-key> [ } ] -recipe move-to-end-of-line editor:address:editor-data -> editor:address:editor-data [ +recipe move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset cursor-column:address:number <- get-address *editor, cursor-column:offset # while not at start of line, move { - next:address:duplex-list:character <- next *before-cursor + next:address:shared:duplex-list:character <- next *before-cursor break-unless next # end of text nextc:character <- get *next, value:offset at-end-of-line?:boolean <- equal nextc, 10/newline @@ -1439,10 +1439,10 @@ recipe move-to-end-of-line editor:address:editor-data -> editor:address:editor-d scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on second line (no newline after), press ctrl-e assume-console [ @@ -1450,9 +1450,9 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ press ctrl-e ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 4:number <- get *2:address:editor-data, cursor-row:offset - 5:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 4:number <- get *2:address:shared:editor-data, cursor-row:offset + 5:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1464,10 +1464,10 @@ scenario editor-moves-to-end-of-line-with-ctrl-e-2 [ scenario editor-moves-to-end-of-line-with-end [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on first line, press 'end' assume-console [ @@ -1475,9 +1475,9 @@ scenario editor-moves-to-end-of-line-with-end [ press end ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1489,10 +1489,10 @@ scenario editor-moves-to-end-of-line-with-end [ scenario editor-moves-to-end-of-line-with-end-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # start on second line (no newline after), press 'end' assume-console [ @@ -1500,9 +1500,9 @@ scenario editor-moves-to-end-of-line-with-end-2 [ press end ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to end of line memory-should-contain [ @@ -1516,16 +1516,16 @@ scenario editor-moves-to-end-of-line-with-end-2 [ scenario editor-deletes-to-start-of-line-with-ctrl-u [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1542,21 +1542,21 @@ after <handle-special-character> [ delete-to-start-of-line?:boolean <- equal *c, 21/ctrl-u break-unless delete-to-start-of-line? <delete-to-start-of-line-begin> - deleted-cells:address:duplex-list:character <- delete-to-start-of-line editor + deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor <delete-to-start-of-line-end> go-render? <- copy 1/true reply } ] -recipe delete-to-start-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +recipe delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete - init:address:duplex-list:character <- get *editor, data:offset - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset - start:address:duplex-list:character <- copy *before-cursor - end:address:duplex-list:character <- next *before-cursor + init:address:shared:duplex-list:character <- get *editor, data:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset + start:address:shared:duplex-list:character <- copy *before-cursor + end:address:shared:duplex-list:character <- next *before-cursor { at-start-of-text?:boolean <- equal start, init break-if at-start-of-text? @@ -1568,7 +1568,7 @@ recipe delete-to-start-of-line editor:address:editor-data -> result:address:dupl loop } # snip it out - result:address:duplex-list:character <- next start + result:address:shared:duplex-list:character <- next start remove-between start, end # adjust cursor *before-cursor <- copy start @@ -1579,16 +1579,16 @@ recipe delete-to-start-of-line editor:address:editor-data -> result:address:dupl scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1602,16 +1602,16 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-2 [ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1625,16 +1625,16 @@ scenario editor-deletes-to-start-of-line-with-ctrl-u-3 [ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to start of line screen-should-contain [ @@ -1650,16 +1650,16 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [ scenario editor-deletes-to-end-of-line-with-ctrl-k [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1676,19 +1676,19 @@ after <handle-special-character> [ delete-to-end-of-line?:boolean <- equal *c, 11/ctrl-k break-unless delete-to-end-of-line? <delete-to-end-of-line-begin> - deleted-cells:address:duplex-list:character <- delete-to-end-of-line editor + deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor <delete-to-end-of-line-end> go-render? <- copy 1/true reply } ] -recipe delete-to-end-of-line editor:address:editor-data -> result:address:duplex-list:character, editor:address:editor-data [ +recipe delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete - start:address:duplex-list:character <- get *editor, before-cursor:offset - end:address:duplex-list:character <- next start + start:address:shared:duplex-list:character <- get *editor, before-cursor:offset + end:address:shared:duplex-list:character <- next start { at-end-of-text?:boolean <- equal end, 0/null break-if at-end-of-text? @@ -1705,16 +1705,16 @@ recipe delete-to-end-of-line editor:address:editor-data -> result:address:duplex scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes to end of line screen-should-contain [ @@ -1728,16 +1728,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start at end of line assume-console [ left-click 1, 2 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes just last character screen-should-contain [ @@ -1751,16 +1751,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-3 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start past end of line assume-console [ left-click 1, 3 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1774,16 +1774,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-4 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start at end of text assume-console [ left-click 2, 2 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes just the final character screen-should-contain [ @@ -1797,16 +1797,16 @@ scenario editor-deletes-to-end-of-line-with-ctrl-k-5 [ scenario editor-deletes-to-end-of-line-with-ctrl-k-6 [ assume-screen 10/width, 5/height - 1:address:array:character <- new [123 + 1:address:shared:array:character <- new [123 456] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right # start past end of text assume-console [ left-click 2, 3 press ctrl-k ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # cursor deletes nothing screen-should-contain [ @@ -1824,11 +1824,11 @@ scenario editor-can-scroll-down-using-arrow-keys [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -1841,7 +1841,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -1854,11 +1854,11 @@ d] after <scroll-down> [ trace 10, [app], [scroll down] - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset left:number <- get *editor, left:offset right:number <- get *editor, right:offset max:number <- subtract right, left - old-top:address:duplex-list:character <- copy *top-of-screen + old-top:address:shared:duplex-list:character <- copy *top-of-screen *top-of-screen <- before-start-of-next-line *top-of-screen, max no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false @@ -1868,11 +1868,11 @@ after <scroll-down> [ # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline # beware: never return null pointer. -recipe before-start-of-next-line original:address:duplex-list:character, max:number -> curr:address:duplex-list:character [ +recipe before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ local-scope load-ingredients count:number <- copy 0 - curr:address:duplex-list:character <- copy original + curr:address:shared:duplex-list:character <- copy original # skip the initial newline if it exists { c:character <- get *curr, value:offset @@ -1901,11 +1901,11 @@ scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -1918,7 +1918,7 @@ i] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -1933,18 +1933,18 @@ scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # editor starts with a long line wrapping twice - 1:address:array:character <- new [abcdefghij + 1:address:shared:array:character <- new [abcdefghij k l m] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line containing a wrap icon screen-should-contain [ @@ -1958,7 +1958,7 @@ m] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -1973,19 +1973,19 @@ scenario editor-scrolls-down-when-line-wraps [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a long line in the third line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdef] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2003,19 +2003,19 @@ cdef] scenario editor-scrolls-down-on-newline [ assume-screen 5/width, 4/height # position cursor after last line and type newline - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right assume-console [ left-click 3, 4 type [ ] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2034,19 +2034,19 @@ scenario editor-scrolls-down-on-right-arrow [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2065,20 +2065,20 @@ scenario editor-scrolls-down-on-right-arrow-2 [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains more lines than can fit on screen - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2095,10 +2095,10 @@ d] scenario editor-scrolls-at-end-on-down-arrow [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc de] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data $clear-trace # try to move down past end of text assume-console [ @@ -2106,9 +2106,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should scroll, moving cursor to end of text memory-should-contain [ @@ -2119,7 +2119,7 @@ de] type [0] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2134,9 +2134,9 @@ de] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen stops scrolling because cursor is already at top memory-should-contain [ @@ -2148,7 +2148,7 @@ de] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2162,14 +2162,14 @@ scenario editor-combines-page-and-line-scroll [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with a few pages of lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f g] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # scroll down one page and one line assume-console [ press page-down @@ -2177,7 +2177,7 @@ g] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen scrolls down 3 lines screen-should-contain [ @@ -2194,11 +2194,11 @@ scenario editor-can-scroll-up-using-arrow-keys [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2211,7 +2211,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -2224,8 +2224,8 @@ d] after <scroll-up> [ trace 10, [app], [scroll up] - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen *top-of-screen <- before-previous-line *top-of-screen, editor no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false @@ -2235,7 +2235,7 @@ after <scroll-up> [ # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line # beware: never return null pointer -recipe before-previous-line curr:address:duplex-list:character, editor:address:editor-data -> curr:address:duplex-list:character [ +recipe before-previous-line curr:address:shared:duplex-list:character, editor:address:shared:editor-data -> curr:address:shared:duplex-list:character [ local-scope load-ingredients c:character <- get *curr, value:offset @@ -2245,12 +2245,12 @@ recipe before-previous-line curr:address:duplex-list:character, editor:address:e left:number <- get *editor, left:offset right:number <- get *editor, right:offset max-line-length:number <- subtract right, left, -1/exclusive-right, 1/wrap-icon - sentinel:address:duplex-list:character <- get *editor, data:offset + sentinel:address:shared:duplex-list:character <- get *editor, data:offset len:number <- previous-line-length curr, sentinel { break-if len # empty line; just skip this newline - prev:address:duplex-list:character <- prev curr + prev:address:shared:duplex-list:character <- prev curr reply-unless prev, curr reply prev } @@ -2266,7 +2266,7 @@ recipe before-previous-line curr:address:duplex-list:character, editor:address:e { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- prev curr + prev:address:shared:duplex-list:character <- prev curr break-unless prev curr <- copy prev count <- add count, 1 @@ -2280,11 +2280,11 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right screen-should-contain [ . . .abcd↩ . @@ -2296,7 +2296,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2309,7 +2309,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2324,17 +2324,17 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [ # 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:address:array:character <- new [abcdefghij + 1:address:shared:array:character <- new [abcdefghij k l m] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2348,7 +2348,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2363,7 +2363,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2378,7 +2378,7 @@ m] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2397,11 +2397,11 @@ scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-3 [ assume-screen 10/width, 4/height # initialize editor with a long, wrapped line and more than a screen of # other lines - 1:address:array:character <- new [abcdef + 1:address:shared:array:character <- new [abcdef g h i] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right screen-should-contain [ . . .abcde↩ . @@ -2413,7 +2413,7 @@ i] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2426,7 +2426,7 @@ i] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows partial wrapped line screen-should-contain [ @@ -2441,18 +2441,18 @@ i] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ assume-screen 10/width, 4/height # initialize editor with some lines around an empty line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 6/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 6/right assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2464,7 +2464,7 @@ e] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2476,7 +2476,7 @@ e] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2490,18 +2490,18 @@ scenario editor-scrolls-up-on-left-arrow [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 5/right # position cursor at top of second page assume-console [ press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2514,9 +2514,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen scrolls screen-should-contain [ @@ -2535,11 +2535,11 @@ scenario editor-can-scroll-up-to-start-of-file [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with >3 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2554,7 +2554,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen slides by one line screen-should-contain [ @@ -2568,7 +2568,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen remains unchanged screen-should-contain [ @@ -2583,11 +2583,11 @@ d] scenario editor-can-scroll [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2599,7 +2599,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows next page screen-should-contain [ @@ -2614,8 +2614,8 @@ after <handle-special-character> [ { page-down?:boolean <- equal *c, 6/ctrl-f break-unless page-down? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never @@ -2630,8 +2630,8 @@ after <handle-special-key> [ { page-down?:boolean <- equal *k, 65518/page-down break-unless page-down? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> page-down editor undo-coalesce-tag:number <- copy 0/never @@ -2644,14 +2644,14 @@ after <handle-special-key> [ # page-down skips entire wrapped lines, so it can't scroll past lines # taking up the entire screen -recipe page-down editor:address:editor-data -> editor:address:editor-data [ +recipe page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # if editor contents don't overflow screen, do nothing - bottom-of-screen:address:duplex-list:character <- get *editor, bottom-of-screen:offset + bottom-of-screen:address:shared:duplex-list:character <- get *editor, bottom-of-screen:offset reply-unless bottom-of-screen # if not, position cursor at final character - before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset + before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset *before-cursor <- prev bottom-of-screen # keep one line in common with previous page { @@ -2662,16 +2662,16 @@ recipe page-down editor:address:editor-data -> editor:address:editor-data [ } # move cursor and top-of-screen to start of that line move-to-start-of-line editor - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top-of-screen <- copy *before-cursor ] scenario editor-does-not-scroll-past-end [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -2683,7 +2683,7 @@ b] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen remains unmodified screen-should-contain [ @@ -2698,11 +2698,11 @@ scenario editor-starts-next-page-at-start-of-wrapped-line [ # screen has 1 line for menu + 3 lines for text assume-screen 10/width, 4/height # editor contains a long last line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] # editor screen triggers wrap of last line - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2715,7 +2715,7 @@ cdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2731,9 +2731,9 @@ scenario editor-starts-next-page-at-start-of-wrapped-line-2 [ 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:address:array:character <- new [a + 1:address:shared:array:character <- new [a bcdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2746,7 +2746,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2761,11 +2761,11 @@ bcdefgh] scenario editor-can-scroll-up [ assume-screen 10/width, 4/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2777,7 +2777,7 @@ d] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows next page screen-should-contain [ @@ -2791,7 +2791,7 @@ d] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows original page again screen-should-contain [ @@ -2806,8 +2806,8 @@ after <handle-special-character> [ { page-up?:boolean <- equal *c, 2/ctrl-b break-unless page-up? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never @@ -2822,8 +2822,8 @@ after <handle-special-key> [ { page-up?:boolean <- equal *k, 65519/page-up break-unless page-up? - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset - old-top:address:duplex-list:character <- copy *top-of-screen + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset + old-top:address:shared:duplex-list:character <- copy *top-of-screen <move-cursor-begin> editor <- page-up editor, screen-height undo-coalesce-tag:number <- copy 0/never @@ -2835,16 +2835,16 @@ after <handle-special-key> [ } ] -recipe page-up editor:address:editor-data, screen-height:number -> editor:address:editor-data [ +recipe page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ local-scope load-ingredients max:number <- subtract screen-height, 1/menu-bar, 1/overlapping-line count:number <- copy 0 - top-of-screen:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset { done?:boolean <- greater-or-equal count, max break-if done? - prev:address:duplex-list:character <- before-previous-line *top-of-screen, editor + prev:address:shared:duplex-list:character <- before-previous-line *top-of-screen, editor break-unless prev *top-of-screen <- copy prev count <- add count, 1 @@ -2856,7 +2856,7 @@ scenario editor-can-scroll-up-multiple-pages [ # screen has 1 line for menu + 3 lines assume-screen 10/width, 4/height # initialize editor with 8 lines - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d @@ -2864,7 +2864,7 @@ e f g h] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right screen-should-contain [ . . .a . @@ -2877,7 +2877,7 @@ h] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows third page screen-should-contain [ @@ -2891,7 +2891,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows second page screen-should-contain [ @@ -2905,7 +2905,7 @@ h] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows original page again screen-should-contain [ @@ -2920,7 +2920,7 @@ scenario editor-can-scroll-up-wrapped-lines [ # 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:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh i @@ -2931,7 +2931,7 @@ m n o] # editor screen triggers wrap of last line - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2948,7 +2948,7 @@ o] press down-arrow ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -2964,7 +2964,7 @@ o] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen resets screen-should-contain [ @@ -2982,9 +2982,9 @@ scenario editor-can-scroll-up-wrapped-lines-2 [ 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:address:array:character <- new [a + 1:address:shared:array:character <- new [a bcdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right # some part of last line is not displayed screen-should-contain [ . . @@ -2997,7 +2997,7 @@ bcdefgh] press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen shows entire wrapped line screen-should-contain [ @@ -3011,7 +3011,7 @@ bcdefgh] press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # screen resets screen-should-contain [ @@ -3025,7 +3025,7 @@ bcdefgh] scenario editor-can-scroll-up-past-nonempty-lines [ assume-screen 10/width, 4/height # text with empty line in second screen - 1:address:array:character <- new [axx + 1:address:shared:array:character <- new [axx bxx cxx dxx @@ -3034,7 +3034,7 @@ fxx gxx hxx ] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right screen-should-contain [ . . .axx . @@ -3045,7 +3045,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3057,7 +3057,7 @@ hxx press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3070,7 +3070,7 @@ hxx press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3083,7 +3083,7 @@ hxx scenario editor-can-scroll-up-past-empty-lines [ assume-screen 10/width, 4/height # text with empty line in second screen - 1:address:array:character <- new [axy + 1:address:shared:array:character <- new [axy bxy cxy @@ -3092,7 +3092,7 @@ exy fxy gxy ] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 4/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 4/right screen-should-contain [ . . .axy . @@ -3103,7 +3103,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3115,7 +3115,7 @@ gxy press page-down ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -3128,7 +3128,7 @@ gxy press page-up ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 4a16d2fa..3e8922e5 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -3,12 +3,12 @@ recipe! main [ local-scope open-console - initial-sandbox:address:array:character <- new [] + initial-sandbox:address:shared:array:character <- new [] hide-screen 0/screen - env:address:programming-environment-data <- new-programming-environment 0/screen, initial-sandbox + env:address:shared:programming-environment-data <- new-programming-environment 0/screen, initial-sandbox env <- restore-sandboxes env render-sandbox-side 0/screen, env - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset update-cursor 0/screen, current-sandbox show-screen 0/screen event-loop 0/screen, 0/console, env @@ -16,10 +16,10 @@ recipe! main [ ] container programming-environment-data [ - current-sandbox:address:editor-data + current-sandbox:address:shared:editor-data ] -recipe new-programming-environment screen:address:screen, initial-sandbox-contents:address:array:character -> result:address:programming-environment-data, screen:address:screen [ +recipe new-programming-environment screen:address:shared:screen, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients width:number <- screen-width screen @@ -31,17 +31,17 @@ recipe new-programming-environment screen:address:screen, initial-sandbox-conten button-on-screen?:boolean <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start - run-button:address:array:character <- new [ run (F4) ] + run-button:address:shared:array:character <- new [ run (F4) ] print screen, run-button, 255/white, 161/reddish # sandbox editor - current-sandbox:address:address:editor-data <- get-address *result, current-sandbox:offset + current-sandbox:address:address:shared:editor-data <- get-address *result, current-sandbox:offset *current-sandbox <- new-editor initial-sandbox-contents, screen, 0, width/right ] -recipe event-loop screen:address:screen, console:address:console, env:address:programming-environment-data -> screen:address:screen, console:address:console, env:address:programming-environment-data [ +recipe event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset # if we fall behind we'll stop updating the screen, but then we have to # render the entire screen when we catch up. # todo: test this @@ -56,18 +56,18 @@ recipe event-loop screen:address:screen, console:address:console, env:address:pr <handle-event> # check for global events that will trigger regardless of which editor has focus { - k:address:number <- maybe-convert e:event, keycode:variant + k:address:shared:number <- maybe-convert e:event, keycode:variant break-unless k <global-keypress> } { - c:address:character <- maybe-convert e:event, text:variant + c:address:shared:character <- maybe-convert e:event, text:variant break-unless c <global-type> } # 'touch' event { - t:address:touch-event <- maybe-convert e:event, touch:variant + t:address:shared:touch-event <- maybe-convert e:event, touch:variant break-unless t # ignore all but 'left-click' events for now # todo: test this @@ -83,7 +83,7 @@ recipe event-loop screen:address:screen, console:address:console, env:address:pr # 'resize' event - redraw editor # todo: test this after supporting resize in assume-console { - r:address:resize-event <- maybe-convert e:event, resize:variant + r:address:shared:resize-event <- maybe-convert e:event, resize:variant break-unless r # if more events, we're still resizing; wait until we stop more-events?:boolean <- has-more-events? console @@ -135,13 +135,13 @@ recipe event-loop screen:address:screen, console:address:console, env:address:pr } ] -recipe resize screen:address:screen, env:address:programming-environment-data -> env:address:programming-environment-data, screen:address:screen [ +recipe resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions width:number <- screen-width screen # update sandbox editor - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset right:address:number <- get-address *current-sandbox, right:offset *right <- subtract width, 1 # reset cursor @@ -151,7 +151,7 @@ recipe resize screen:address:screen, env:address:programming-environment-data -> *cursor-column <- copy 0 ] -recipe render-all screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients trace 10, [app], [render all] @@ -164,23 +164,23 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat button-on-screen?:boolean <- greater-or-equal button-start, 0 assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start - run-button:address:array:character <- new [ run (F4) ] + run-button:address:shared:array:character <- new [ run (F4) ] print screen, run-button, 255/white, 161/reddish # screen <- render-sandbox-side screen, env <render-components-end> # - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset screen <- update-cursor screen, current-sandbox # show-screen screen ] # replaced in a later layer -recipe render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset row:number, column:number, screen, current-sandbox <- render screen, current-sandbox @@ -192,7 +192,7 @@ recipe render-sandbox-side screen:address:screen, env:address:programming-enviro clear-screen-from screen, row, left, left, right ] -recipe update-cursor screen:address:screen, current-sandbox:address:editor-data -> screen:address:screen [ +recipe update-cursor screen:address:shared:screen, current-sandbox:address:shared:editor-data -> screen:address:shared:screen [ local-scope load-ingredients cursor-row:number <- get *current-sandbox, cursor-row:offset @@ -202,7 +202,7 @@ recipe update-cursor screen:address:screen, current-sandbox:address:editor-data # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ +recipe render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless s @@ -263,7 +263,7 @@ recipe render screen:address:screen, s:address:array:character, left:number, rig ] # like 'render' for texts, but with colorization for comments like in the editor -recipe render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ +recipe render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless s @@ -331,8 +331,13 @@ after <global-type> [ { redraw-screen?:boolean <- equal *c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:address:programming-environment-data + screen <- render-all screen, env:address:shared:programming-environment-data sync-screen screen loop +next-event:label } ] + +# dummy +recipe restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ + # do nothing; redefined later +] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index a424209a..405dee01 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -5,33 +5,33 @@ # few other things. container programming-environment-data [ - sandbox:address:sandbox-data # list of sandboxes, from top to bottom + sandbox:address:shared:sandbox-data # list of sandboxes, from top to bottom ] container sandbox-data [ - data:address:array:character - response:address:array:character - expected-response:address:array:character + data:address:shared:array:character + response:address:shared:array:character + expected-response:address:shared:array:character # coordinates to track clicks starting-row-on-screen:number code-ending-row-on-screen:number # past end of code response-starting-row-on-screen:number - screen:address:screen # prints in the sandbox go here - next-sandbox:address:sandbox-data + screen:address:shared:screen # prints in the sandbox go here + next-sandbox:address:shared:sandbox-data ] scenario run-and-show-results [ trace-until 100/app # trace too long assume-screen 50/width, 15/height # sandbox editor contains an instruction without storing outputs - 1:address:array:character <- new [divide-with-remainder 11, 3] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 1:address:shared:array:character <- new [divide-with-remainder 11, 3] + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character # run the code in the editors assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] # check that screen prints the results screen-should-contain [ @@ -74,7 +74,7 @@ scenario run-and-show-results [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] # check that screen prints both sandboxes screen-should-contain [ @@ -99,14 +99,14 @@ after <global-keypress> [ { do-run?:boolean <- equal *k, 65532/F4 break-unless do-run? - status:address:array:character <- new [running... ] + status:address:shared:array:character <- new [running... ] screen <- update-status screen, status, 245/grey error?:boolean, env, screen <- run-sandboxes env, screen # F4 might update warnings and results on both sides screen <- render-all screen, env { break-if error? - status:address:array:character <- new [ ] + status:address:shared:array:character <- new [ ] screen <- update-status screen, status, 245/grey } screen <- update-cursor screen, current-sandbox @@ -114,36 +114,36 @@ after <global-keypress> [ } ] -recipe run-sandboxes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients errors-found?:boolean, env, screen <- update-recipes env, screen reply-if errors-found? # check contents of editor - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset { - sandbox-contents:address:array:character <- editor-contents current-sandbox + sandbox-contents:address:shared:array:character <- editor-contents current-sandbox break-unless sandbox-contents # if contents exist, first save them # run them and turn them into a new sandbox-data - new-sandbox:address:sandbox-data <- new sandbox-data:type - data:address:address:array:character <- get-address *new-sandbox, data:offset + new-sandbox:address:shared:sandbox-data <- new sandbox-data:type + data:address:address:shared:array:character <- get-address *new-sandbox, data:offset *data <- copy sandbox-contents # push to head of sandbox list - dest:address:address:sandbox-data <- get-address *env, sandbox:offset - next:address:address:sandbox-data <- get-address *new-sandbox, next-sandbox:offset + dest:address:address:shared:sandbox-data <- get-address *env, sandbox:offset + next:address:address:shared:sandbox-data <- get-address *new-sandbox, next-sandbox:offset *next <- copy *dest *dest <- copy new-sandbox # clear sandbox editor - init:address:address:duplex-list:character <- get-address *current-sandbox, data:offset + init:address:address:shared:duplex-list:character <- get-address *current-sandbox, data:offset *init <- push 167/§, 0/tail - top-of-screen:address:address:duplex-list:character <- get-address *current-sandbox, top-of-screen:offset + top-of-screen:address:address:shared:duplex-list:character <- get-address *current-sandbox, top-of-screen:offset *top-of-screen <- copy *init } # save all sandboxes before running, just in case we die when running save-sandboxes env # run all sandboxes - curr:address:sandbox-data <- get *env, sandbox:offset + curr:address:shared:sandbox-data <- get *env, sandbox:offset { break-unless curr curr <- update-sandbox curr, env @@ -155,47 +155,47 @@ recipe run-sandboxes env:address:programming-environment-data, screen:address:sc # load code from recipes.mu # replaced in a later layer (whereupon errors-found? will actually be set) -recipe update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients - in:address:array:character <- restore [recipes.mu] # newlayer: persistence + in:address:shared:array:character <- restore [recipes.mu] # newlayer: persistence reload in errors-found? <- copy 0/false ] # replaced in a later layer -recipe update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset *response, _, *fake-screen <- run-interactive data ] -recipe update-status screen:address:screen, msg:address:array:character, color:number -> screen:address:screen [ +recipe update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -recipe save-sandboxes env:address:programming-environment-data [ +recipe save-sandboxes env:address:shared:programming-environment-data [ local-scope load-ingredients - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset # first clear previous versions, in case we deleted some sandbox $system [rm lesson/[0-9]* >/dev/null 2>/dev/null] # some shells can't handle '>&' - curr:address:sandbox-data <- get *env, sandbox:offset - suffix:address:array:character <- new [.out] + curr:address:shared:sandbox-data <- get *env, sandbox:offset + suffix:address:shared:array:character <- new [.out] idx:number <- copy 0 { break-unless curr - data:address:array:character <- get *curr, data:offset - filename:address:array:character <- to-text idx + data:address:shared:array:character <- get *curr, data:offset + filename:address:shared:array:character <- to-text idx save filename, data { - expected-response:address:array:character <- get *curr, expected-response:offset + expected-response:address:shared:array:character <- get *curr, expected-response:offset break-unless expected-response filename <- append filename, suffix save filename, expected-response @@ -206,26 +206,26 @@ recipe save-sandboxes env:address:programming-environment-data [ } ] -recipe! render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen [ +recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients trace 11, [app], [render sandbox side] - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset row:number, column:number, screen, current-sandbox <- render screen, current-sandbox clear-screen-from screen, row, column, left, right row <- add row, 1 draw-horizontal screen, row, left, right, 9473/horizontal-double - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:address:shared:sandbox-data <- get *env, sandbox:offset row, screen <- render-sandboxes screen, sandbox, left, right, row, env clear-rest-of-screen screen, row, left, left, right ] -recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:number, right:number, row:number -> row:number, screen:address:screen, sandbox:address:sandbox-data [ +recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ local-scope load-ingredients - env:address:programming-environment-data, _/optional <- next-ingredient + env:address:shared:programming-environment-data, _/optional <- next-ingredient reply-unless sandbox screen-height:number <- screen-height screen at-bottom?:boolean <- greater-or-equal row, screen-height @@ -242,16 +242,16 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef # render sandbox contents row <- add row, 1 screen <- move-cursor screen, row, left - sandbox-data:address:array:character <- get *sandbox, data:offset + sandbox-data:address:shared:array:character <- get *sandbox, data:offset row, screen <- render-code screen, sandbox-data, left, right, row code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order response-starting-row:address:number <- get-address *sandbox, response-starting-row-on-screen:offset - sandbox-response:address:array:character <- get *sandbox, response:offset + sandbox-response:address:shared:array:character <- get *sandbox, response:offset <render-sandbox-results> { - sandbox-screen:address:screen <- get *sandbox, screen:offset + sandbox-screen:address:shared:screen <- get *sandbox, screen:offset empty-screen?:boolean <- fake-screen-is-empty? sandbox-screen break-if empty-screen? row, screen <- render-screen screen, sandbox-screen, left, right, row @@ -268,32 +268,32 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double # draw next sandbox - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset row, screen <- render-sandboxes screen, next-sandbox, left, right, row ] # assumes programming environment has no sandboxes; restores them from previous session -recipe restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ +recipe! restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios - suffix:address:array:character <- new [.out] + suffix:address:shared:array:character <- new [.out] idx:number <- copy 0 - curr:address:address:sandbox-data <- get-address *env, sandbox:offset + curr:address:address:shared:sandbox-data <- get-address *env, sandbox:offset { - filename:address:array:character <- to-text idx - contents:address:array:character <- restore filename + filename:address:shared:array:character <- to-text idx + contents:address:shared:array:character <- restore filename break-unless contents # stop at first error; assuming file didn't exist # create new sandbox for file *curr <- new sandbox-data:type - data:address:address:array:character <- get-address **curr, data:offset + data:address:address:shared:array:character <- get-address **curr, data:offset *data <- copy contents # restore expected output for sandbox if it exists { filename <- append filename, suffix contents <- restore filename break-unless contents - expected-response:address:address:array:character <- get-address **curr, expected-response:offset + expected-response:address:address:shared:array:character <- get-address **curr, expected-response:offset *expected-response <- copy contents } +continue @@ -305,19 +305,19 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -recipe render-screen screen:address:screen, sandbox-screen:address:screen, left:number, right:number, row:number -> row:number, screen:address:screen [ +recipe render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients reply-unless sandbox-screen # print 'screen:' - header:address:array:character <- new [screen:] + header:address:shared:array:character <- new [screen:] row <- render screen, header, left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left s-width:number <- screen-width sandbox-screen s-height:number <- screen-height sandbox-screen - buf:address:array:screen-cell <- get *sandbox-screen, data:offset + buf:address:shared:array:screen-cell <- get *sandbox-screen, data:offset stop-printing:number <- add left, s-width, 3 max-column:number <- min stop-printing, right i:number <- copy 0 @@ -375,14 +375,14 @@ scenario run-instruction-manages-screen-per-sandbox [ trace-until 100/app # trace too long assume-screen 50/width, 20/height # editor contains an instruction - 1:address:array:character <- new [print-integer screen, 4] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 1:address:shared:array:character <- new [print-integer screen, 4] + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character # run the code in the editor assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] # check that it prints a little toy screen screen-should-contain [ @@ -402,11 +402,11 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -recipe editor-contents editor:address:editor-data -> result:address:array:character [ +recipe editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ local-scope load-ingredients - buf:address:buffer <- new-buffer 80 - curr:address:duplex-list:character <- get *editor, data:offset + buf:address:shared:buffer <- new-buffer 80 + curr:address:shared:duplex-list:character <- get *editor, data:offset # skip § sentinel assert curr, [editor without data is illegal; must have at least a sentinel] curr <- next curr @@ -423,16 +423,16 @@ recipe editor-contents editor:address:editor-data -> result:address:array:charac scenario editor-provides-edited-contents [ assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right + 1:address:shared:array:character <- new [abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right assume-console [ left-click 1, 2 type [def] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:address:array:character <- editor-contents 2:address:editor-data - 4:array:character <- copy *3:address:array:character + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:address:shared:array:character <- editor-contents 2:address:shared:editor-data + 4:array:character <- copy *3:address:shared:array:character ] memory-should-contain [ 4:array:character <- [abdefc] diff --git a/sandbox/006-sandbox-edit.mu b/sandbox/006-sandbox-edit.mu index 83257df0..4b4c5175 100644 --- a/sandbox/006-sandbox-edit.mu +++ b/sandbox/006-sandbox-edit.mu @@ -4,12 +4,12 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # run something - 1:address:array:character <- new [add 2, 2] + 1:address:shared:array:character <- new [add 2, 2] assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -27,7 +27,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ left-click 3, 0 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] # it pops back into editor screen-should-contain [ @@ -47,7 +47,7 @@ scenario clicking-on-a-sandbox-moves-it-to-editor [ type [0] ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -70,7 +70,7 @@ after <global-touch> [ click-column:number <- get *t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset @@ -79,8 +79,8 @@ after <global-touch> [ empty-sandbox-editor?:boolean <- empty-editor? current-sandbox break-unless empty-sandbox-editor? # make the user hit F4 before editing a new sandbox # identify the sandbox to edit and remove it from the sandbox list - sandbox:address:sandbox-data <- extract-sandbox env, click-row - text:address:array:character <- get *sandbox, data:offset + sandbox:address:shared:sandbox-data <- extract-sandbox env, click-row + text:address:shared:array:character <- get *sandbox, data:offset current-sandbox <- insert-text current-sandbox, text hide-screen screen screen <- render-sandbox-side screen, env @@ -90,24 +90,24 @@ after <global-touch> [ } ] -recipe empty-editor? editor:address:editor-data -> result:boolean [ +recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ local-scope load-ingredients - head:address:duplex-list:character <- get *editor, data:offset - first:address:duplex-list:character <- next head + head:address:shared:duplex-list:character <- get *editor, data:offset + first:address:shared:duplex-list:character <- next head result <- not first ] -recipe extract-sandbox env:address:programming-environment-data, click-row:number -> result:address:sandbox-data, env:address:programming-environment-data [ +recipe extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:address:sandbox-data <- get-address *env, sandbox:offset + sandbox:address:address:shared:sandbox-data <- get-address *env, sandbox:offset start:number <- get **sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] { - next-sandbox:address:sandbox-data <- get **sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get **sandbox, next-sandbox:offset break-unless next-sandbox # if click-row < sandbox.next-sandbox.starting-row-on-screen, break next-start:number <- get *next-sandbox, starting-row-on-screen:offset @@ -125,14 +125,14 @@ scenario sandbox-with-print-can-be-edited [ trace-until 100/app # trace too long assume-screen 50/width, 20/height # run a print instruction - 1:address:array:character <- new [print-integer screen, 4] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 1:address:shared:array:character <- new [print-integer screen, 4] + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -161,7 +161,7 @@ scenario sandbox-with-print-can-be-edited [ left-click 3, 70 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index b0b6f4ee..64843d2d 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -3,8 +3,8 @@ scenario deleting-sandboxes [ trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:address:array:character <- new [] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 1:address:shared:array:character <- new [] + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character # run a few commands assume-console [ left-click 1, 0 @@ -13,7 +13,7 @@ scenario deleting-sandboxes [ type [add 2, 2] press F4 ] - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -34,7 +34,7 @@ scenario deleting-sandboxes [ left-click 7, 49 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -52,7 +52,7 @@ scenario deleting-sandboxes [ left-click 3, 49 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . @@ -76,17 +76,17 @@ after <global-touch> [ } ] -recipe delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean, env:address:programming-environment-data [ +recipe delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ local-scope load-ingredients click-column:number <- get t, column:offset - current-sandbox:address:editor-data <- get *env, current-sandbox:offset + current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset right:number <- get *current-sandbox, right:offset at-right?:boolean <- equal click-column, right reply-unless at-right?, 0/false click-row:number <- get t, row:offset - prev:address:address:sandbox-data <- get-address *env, sandbox:offset - curr:address:sandbox-data <- get *env, sandbox:offset + prev:address:address:shared:sandbox-data <- get-address *env, sandbox:offset + curr:address:shared:sandbox-data <- get *env, sandbox:offset { break-unless curr # more sandboxes to check diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu index e1a27a69..faf76441 100644 --- a/sandbox/008-sandbox-test.mu +++ b/sandbox/008-sandbox-test.mu @@ -10,14 +10,14 @@ after <global-touch> [ click-column:number <- get *t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose output is being clicked on - sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row + sandbox:address:shared:sandbox-data <- find-click-in-sandbox-output env, click-row break-unless sandbox # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox @@ -31,17 +31,17 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen - sandbox:address:sandbox-data <- get *env, sandbox:offset + sandbox:address:shared:sandbox-data <- get *env, sandbox:offset start:number <- get *sandbox, starting-row-on-screen:offset clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -57,10 +57,10 @@ recipe find-click-in-sandbox-output env:address:programming-environment-data, cl reply sandbox ] -recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - expected-response:address:address:array:character <- get-address *sandbox, expected-response:offset + expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset { # if expected-response is set, reset break-unless *expected-response @@ -68,7 +68,7 @@ recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address: reply sandbox/same-as-ingredient:0 } # if not, current response is the expected response - response:address:array:character <- get *sandbox, response:offset + response:address:shared:array:character <- get *sandbox, response:offset *expected-response <- copy response ] @@ -76,7 +76,7 @@ recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address: after <render-sandbox-response> [ { break-unless sandbox-response - expected-response:address:array:character <- get *sandbox, expected-response:offset + expected-response:address:shared:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey response-is-expected?:boolean <- equal expected-response, sandbox-response { diff --git a/sandbox/009-sandbox-trace.mu b/sandbox/009-sandbox-trace.mu index 45759b75..5c9c6714 100644 --- a/sandbox/009-sandbox-trace.mu +++ b/sandbox/009-sandbox-trace.mu @@ -4,12 +4,12 @@ scenario sandbox-click-on-code-toggles-app-trace [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # run a stash instruction - 1:address:array:character <- new [stash [abc]] + 1:address:shared:array:character <- new [stash [abc]] assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data 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:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data 4:character/cursor-icon <- copy 9251/␣ - print screen:address:screen, 4:character/cursor-icon + print screen:address:shared:screen, 4:character/cursor-icon ] # trace now printed and cursor shouldn't have budged screen-should-contain [ @@ -54,8 +54,8 @@ scenario sandbox-click-on-code-toggles-app-trace [ left-click 4, 25 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data - print screen:address:screen, 4:character/cursor-icon + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data + print screen:address:shared:screen, 4:character/cursor-icon ] # trace hidden again screen-should-contain [ @@ -73,13 +73,13 @@ scenario sandbox-shows-app-trace-and-result [ trace-until 100/app # trace too long assume-screen 40/width, 10/height # run a stash instruction and some code - 1:address:array:character <- new [stash [abc] + 1:address:shared:array:character <- new [stash [abc] add 2, 2] assume-console [ press F4 ] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data screen-should-contain [ . run (F4) . . . @@ -96,7 +96,7 @@ add 2, 2] left-click 4, 21 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] # trace now printed above result screen-should-contain [ @@ -114,18 +114,18 @@ add 2, 2] ] container sandbox-data [ - trace:address:array:character + trace:address:shared:array:character display-trace?:boolean ] # replaced in a later layer -recipe! update-sandbox sandbox:address:sandbox-data -> sandbox:address:sandbox-data [ +recipe! update-sandbox sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - trace:address:address:array:character <- get-address *sandbox, trace:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + trace:address:address:shared:array:character <- get-address *sandbox, trace:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset *response, _, *fake-screen, *trace <- run-interactive data ] @@ -137,14 +137,14 @@ after <global-touch> [ click-column:number <- get *t, column:offset on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin break-unless on-sandbox-side? - first-sandbox:address:sandbox-data <- get *env, sandbox:offset + first-sandbox:address:shared:sandbox-data <- get *env, sandbox:offset break-unless first-sandbox first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset click-row:number <- get *t, row:offset below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins break-unless below-sandbox-editor? # identify the sandbox whose code is being clicked on - sandbox:address:sandbox-data <- find-click-in-sandbox-code env, click-row + sandbox:address:shared:sandbox-data <- find-click-in-sandbox-code env, click-row break-unless sandbox # toggle its display-trace? property x:address:boolean <- get-address *sandbox, display-trace?:offset @@ -158,7 +158,7 @@ after <global-touch> [ } ] -recipe find-click-in-sandbox-code env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [ +recipe find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -168,7 +168,7 @@ recipe find-click-in-sandbox-code env:address:programming-environment-data, clic assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor] # while click-row < sandbox.next-sandbox.starting-row-on-screen { - next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset + next-sandbox:address:shared:sandbox-data <- get *sandbox, next-sandbox:offset break-unless next-sandbox next-start:number <- get *next-sandbox, starting-row-on-screen:offset found?:boolean <- lesser-than click-row, next-start @@ -194,7 +194,7 @@ after <render-sandbox-results> [ { display-trace?:boolean <- get *sandbox, display-trace?:offset break-unless display-trace? - sandbox-trace:address:array:character <- get *sandbox, trace:offset + sandbox-trace:address:shared:array:character <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on row, screen <- render screen, sandbox-trace, left, right, 245/grey, row } diff --git a/sandbox/010-warnings.mu b/sandbox/010-warnings.mu index 5bfb9d7d..ff3a1598 100644 --- a/sandbox/010-warnings.mu +++ b/sandbox/010-warnings.mu @@ -1,20 +1,20 @@ ## handling malformed programs container programming-environment-data [ - recipe-warnings:address:array:character + recipe-warnings:address:shared:array:character ] # copy code from recipe editor, persist, load into mu, save any warnings -recipe! update-recipes env:address:programming-environment-data, screen:address:screen -> errors-found?:boolean, env:address:programming-environment-data, screen:address:screen [ +recipe! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients - in:address:array:character <- restore [recipes.mu] - recipe-warnings:address:address:array:character <- get-address *env, recipe-warnings:offset + in:address:shared:array:character <- restore [recipes.mu] + recipe-warnings:address:address:shared:array:character <- get-address *env, recipe-warnings:offset *recipe-warnings <- reload in # if recipe editor has errors, stop { break-unless *recipe-warnings - status:address:array:character <- new [errors found] + status:address:shared:array:character <- new [errors found] update-status screen, status, 1/red } errors-found? <- copy 0/false @@ -22,27 +22,27 @@ recipe! update-recipes env:address:programming-environment-data, screen:address: before <render-components-end> [ trace 11, [app], [render status] - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset { break-unless recipe-warnings - status:address:array:character <- new [errors found] + status:address:shared:array:character <- new [errors found] update-status screen, status, 1/red } ] container sandbox-data [ - warnings:address:array:character + warnings:address:shared:array:character ] -recipe! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data -> sandbox:address:sandbox-data [ +recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients - data:address:array:character <- get *sandbox, data:offset - response:address:address:array:character <- get-address *sandbox, response:offset - warnings:address:address:array:character <- get-address *sandbox, warnings:offset - trace:address:address:array:character <- get-address *sandbox, trace:offset - fake-screen:address:address:screen <- get-address *sandbox, screen:offset - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + data:address:shared:array:character <- get *sandbox, data:offset + response:address:address:shared:array:character <- get-address *sandbox, response:offset + warnings:address:address:shared:array:character <- get-address *sandbox, warnings:offset + trace:address:address:shared:array:character <- get-address *sandbox, trace:offset + fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset { break-unless recipe-warnings *warnings <- copy recipe-warnings @@ -60,12 +60,12 @@ recipe! update-sandbox sandbox:address:sandbox-data, env:address:programming-env # make sure we render any trace after <render-sandbox-trace-done> [ { - sandbox-warnings:address:array:character <- get *sandbox, warnings:offset + sandbox-warnings:address:shared:array:character <- get *sandbox, warnings:offset break-unless sandbox-warnings *response-starting-row <- copy 0 # no response { break-unless env - recipe-warnings:address:array:character <- get *env, recipe-warnings:offset + recipe-warnings:address:shared:array:character <- get *env, recipe-warnings:offset row, screen <- render screen, recipe-warnings, left, right, 1/red, row } row, screen <- render screen, sandbox-warnings, left, right, 1/red, row @@ -77,22 +77,22 @@ after <render-sandbox-trace-done> [ scenario run-instruction-and-print-warnings [ trace-until 100/app # trace too long assume-screen 50/width, 15/height - 1:address:array:character <- new [get 1:address:point, 1:offset] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 1:address:shared:array:character <- new [get 1:address:shared:point, 1:offset] + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . . . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . x. - .get 1:address:point, 1:offset . + .get 1:address:shared:point, 1:offset . .first ingredient of 'get' should be a container, ↩. - .but got 1:address:point . + .but got 1:address:shared:point . .━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . . ] @@ -103,7 +103,7 @@ scenario run-instruction-and-print-warnings [ . . . . .first ingredient of 'get' should be a container, . - .but got 1:address:point . + .but got 1:address:shared:point . . . . . ] @@ -115,15 +115,15 @@ scenario run-instruction-and-print-warnings-only-once [ trace-until 100/app # trace too long assume-screen 50/width, 10/height # editor contains an illegal instruction - 1:address:array:character <- new [get 1234:number, foo:offset] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 1:address:shared:array:character <- new [get 1234:number, foo:offset] + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character # run the code in the editors multiple times assume-console [ press F4 press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] # check that screen prints error message just once screen-should-contain [ @@ -144,16 +144,16 @@ scenario sandbox-can-handle-infinite-loop [ trace-until 100/app # trace too long assume-screen 50/width, 20/height # editor contains an infinite loop - 1:address:array:character <- new [{ + 1:address:shared:array:character <- new [{ loop }] - 2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character + 2:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character # run the sandbox assume-console [ press F4 ] run [ - event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data + event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:programming-environment-data ] screen-should-contain [ . run (F4) . diff --git a/sandbox/011-editor-undo.mu b/sandbox/011-editor-undo.mu index 4939013e..82362dd9 100644 --- a/sandbox/011-editor-undo.mu +++ b/sandbox/011-editor-undo.mu @@ -11,13 +11,13 @@ exclusive-container operation [ container insert-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate - insert-from:address:duplex-list:character - insert-until:address:duplex-list:character + insert-from:address:shared:duplex-list:character + insert-until:address:shared:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (enter+indent) # 1: regular alphanumeric characters @@ -26,10 +26,10 @@ container insert-operation [ container move-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (touch events, etc) # 1: left arrow @@ -41,13 +41,13 @@ container move-operation [ container delete-operation [ before-row:number before-column:number - before-top-of-screen:address:duplex-list:character + before-top-of-screen:address:shared:duplex-list:character after-row:number after-column:number - after-top-of-screen:address:duplex-list:character - deleted-text:address:duplex-list:character - delete-from:address:duplex-list:character - delete-until:address:duplex-list:character + after-top-of-screen:address:shared:duplex-list:character + deleted-text:address:shared:duplex-list:character + delete-from:address:shared:duplex-list:character + delete-until:address:shared:duplex-list:character tag:number # event causing this operation; might be used to coalesce runs of similar events # 0: no coalesce (ctrl-k, ctrl-u) # 1: backspace @@ -56,8 +56,8 @@ container delete-operation [ # every editor accumulates a list of operations to undo/redo container editor-data [ - undo:address:list:address:operation - redo:address:list:address:operation + undo:address:shared:list:address:shared:operation + redo:address:shared:list:address:shared:operation ] # ctrl-z - undo operation @@ -65,11 +65,11 @@ after <handle-special-character> [ { undo?:boolean <- equal *c, 26/ctrl-z break-unless undo? - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset break-unless *undo - op:address:operation <- first *undo + op:address:shared:operation <- first *undo *undo <- rest *undo - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- push op, *redo <handle-undo> reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render @@ -81,11 +81,11 @@ after <handle-special-character> [ { redo?:boolean <- equal *c, 25/ctrl-y break-unless redo? - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset break-unless *redo - op:address:operation <- first *redo + op:address:shared:operation <- first *redo *redo <- rest *redo - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op, *undo <handle-redo> reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render @@ -97,19 +97,19 @@ after <handle-special-character> [ scenario editor-can-undo-typing [ # create an editor and type a character assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # character should be gone screen-should-contain [ @@ -123,7 +123,7 @@ scenario editor-can-undo-typing [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -135,34 +135,34 @@ scenario editor-can-undo-typing [ # save operation to undo after <insert-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- copy *before-cursor + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:shared:duplex-list:character <- copy *before-cursor ] before <insert-character-end> [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - typing:address:insert-operation <- maybe-convert *op, typing:variant + op:address:shared:operation <- first *undo + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing previous-coalesce-tag:number <- get *typing, tag:offset break-unless previous-coalesce-tag - insert-until:address:address:duplex-list:character <- get-address *typing, insert-until:offset + insert-until:address:address:shared:duplex-list:character <- get-address *typing, insert-until:offset *insert-until <- next *before-cursor after-row:address:number <- get-address *typing, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *typing, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *typing, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *typing, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-insert-operation:label } # if not, create a new operation - insert-from:address:duplex-list:character <- next cursor-before - insert-to:address:duplex-list:character <- next insert-from - op:address:operation <- new operation:type + insert-from:address:shared:duplex-list:character <- next cursor-before + insert-to:address:shared:duplex-list:character <- next insert-from + op:address:shared:operation <- new operation:type *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, insert-from, insert-to, 1/coalesce editor <- add-operation editor, op +done-adding-insert-operation @@ -172,15 +172,15 @@ before <insert-character-end> [ after <insert-enter-begin> [ cursor-row-before:number <- copy *cursor-row cursor-column-before:number <- copy *cursor-column - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset - cursor-before:address:duplex-list:character <- copy *before-cursor + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + cursor-before:address:shared:duplex-list:character <- copy *before-cursor ] before <insert-enter-end> [ - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset # never coalesce - insert-from:address:duplex-list:character <- next cursor-before - insert-to:address:duplex-list:character <- next *before-cursor - op:address:operation <- new operation:type + insert-from:address:shared:duplex-list:character <- next cursor-before + insert-to:address:shared:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, *cursor-row/after, *cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce editor <- add-operation editor, op ] @@ -189,28 +189,28 @@ before <insert-enter-end> [ # redo stack, because it's now obsolete. # Beware: since we're counting cursor moves as operations, this means just # moving the cursor can lose work on the undo stack. -recipe add-operation editor:address:editor-data, op:address:operation -> editor:address:editor-data [ +recipe add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ local-scope load-ingredients - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op *undo - redo:address:address:list:address:operation <- get-address *editor, redo:offset + redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- copy 0 reply editor/same-as-ingredient:0 ] after <handle-undo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing - start:address:duplex-list:character <- get *typing, insert-from:offset - end:address:duplex-list:character <- get *typing, insert-until:offset + start:address:shared:duplex-list:character <- get *typing, insert-from:offset + end:address:shared:duplex-list:character <- get *typing, insert-until:offset # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *before-cursor <- prev start remove-between *before-cursor, end *cursor-row <- get *typing, before-row:offset *cursor-column <- get *typing, before-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *typing, before-top-of-screen:offset } ] @@ -218,19 +218,19 @@ after <handle-undo> [ scenario editor-can-undo-typing-multiple [ # create an editor and type multiple characters assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be gone screen-should-contain [ @@ -244,14 +244,14 @@ scenario editor-can-undo-typing-multiple [ scenario editor-can-undo-typing-multiple-2 [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [a] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [a] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # type some characters assume-console [ type [012] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .012a . @@ -263,7 +263,7 @@ scenario editor-can-undo-typing-multiple-2 [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # back to original text screen-should-contain [ @@ -277,7 +277,7 @@ scenario editor-can-undo-typing-multiple-2 [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -290,15 +290,15 @@ scenario editor-can-undo-typing-multiple-2 [ scenario editor-can-undo-typing-enter [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [ abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [ abc] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # new line assume-console [ left-click 1, 8 press enter ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . abc . @@ -307,8 +307,8 @@ scenario editor-can-undo-typing-enter [ . . ] # line is indented - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -318,10 +318,10 @@ scenario editor-can-undo-typing-enter [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 5 @@ -338,7 +338,7 @@ scenario editor-can-undo-typing-enter [ type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -353,14 +353,14 @@ scenario editor-can-undo-typing-enter [ scenario editor-redo-typing [ # create an editor, type something, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [a] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [a] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -372,7 +372,7 @@ scenario editor-redo-typing [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be back screen-should-contain [ @@ -386,7 +386,7 @@ scenario editor-redo-typing [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -398,15 +398,15 @@ scenario editor-redo-typing [ after <handle-redo> [ { - typing:address:insert-operation <- maybe-convert *op, typing:variant + typing:address:shared:insert-operation <- maybe-convert *op, typing:variant break-unless typing - insert-from:address:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away + insert-from:address:shared:duplex-list:character <- get *typing, insert-from:offset # ignore insert-to because it's already been spliced away # assert insert-to matches next(*before-cursor) insert-range *before-cursor, insert-from # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *typing, after-row:offset *cursor-column <- get *typing, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *typing, after-top-of-screen:offset } ] @@ -414,14 +414,14 @@ after <handle-redo> [ scenario editor-redo-typing-empty [ # create an editor, type something, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [012] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . . @@ -433,7 +433,7 @@ scenario editor-redo-typing-empty [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # all characters must be back screen-should-contain [ @@ -447,7 +447,7 @@ scenario editor-redo-typing-empty [ type [3] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -460,21 +460,21 @@ scenario editor-redo-typing-empty [ scenario editor-work-clears-redo-stack [ # create an editor with some text, do some work, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [1] press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # do some more work assume-console [ type [0] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .0abc . @@ -487,7 +487,7 @@ ghi] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # nothing should happen screen-should-contain [ @@ -502,9 +502,9 @@ ghi] scenario editor-can-redo-typing-and-enter-and-tab [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and tabs, hit enter, some more text and tabs assume-console [ press tab @@ -515,7 +515,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press tab type [efg] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . . ab cd . @@ -523,8 +523,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [ .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -534,11 +534,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # typing in second line deleted, but not indent - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -555,11 +555,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # indent and newline deleted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -575,11 +575,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # empty screen - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -595,11 +595,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 8 @@ -615,11 +615,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # newline and indent inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 2 @@ -636,11 +636,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # indent and newline deleted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 7 @@ -659,24 +659,24 @@ scenario editor-can-redo-typing-and-enter-and-tab [ scenario editor-can-undo-touch [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 3, 1 ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # click undone memory-should-contain [ @@ -688,7 +688,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -702,20 +702,20 @@ ghi] after <move-cursor-begin> [ before-cursor-row:number <- get *editor, cursor-row:offset before-cursor-column:number <- get *editor, cursor-column:offset - before-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + before-top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <move-cursor-end> [ after-cursor-row:number <- get *editor, cursor-row:offset after-cursor-column:number <- get *editor, cursor-column:offset - after-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + after-top-of-screen:address:shared:duplex-list:character <- get *editor, top-of-screen:offset { break-unless undo-coalesce-tag # if previous operation was also a move, and also had the same coalesce # tag, coalesce with it - undo:address:address:list:address:operation <- get-address *editor, undo:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset break-unless *undo - op:address:operation <- first *undo - move:address:move-operation <- maybe-convert *op, move:variant + op:address:shared:operation <- first *undo + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move previous-coalesce-tag:number <- get *move, tag:offset coalesce?:boolean <- equal undo-coalesce-tag, previous-coalesce-tag @@ -724,11 +724,11 @@ before <move-cursor-end> [ *after-row <- copy after-cursor-row after-column:address:number <- get-address *move, after-column:offset *after-column <- copy after-cursor-column - after-top:address:address:duplex-list:character <- get-address *move, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *move, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-move-operation:label } - op:address:operation <- new operation:type + op:address:shared:operation <- new operation:type *op <- merge 1/move-operation, before-cursor-row, before-cursor-column, before-top-of-screen, after-cursor-row, after-cursor-column, after-top-of-screen, undo-coalesce-tag editor <- add-operation editor, op +done-adding-move-operation @@ -736,10 +736,10 @@ before <move-cursor-end> [ after <handle-undo> [ { - move:address:move-operation <- maybe-convert *op, move:variant + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *cursor-row <- get *move, before-row:offset *cursor-column <- get *move, before-column:offset *top <- get *move, before-top-of-screen:offset @@ -750,18 +750,18 @@ scenario editor-can-undo-scroll [ # screen has 1 line for menu + 3 lines assume-screen 5/width, 4/height # editor contains a wrapped line - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b cdefgh] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared: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:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset # screen scrolls screen-should-contain [ . . @@ -778,9 +778,9 @@ cdefgh] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moved back memory-should-contain [ @@ -799,7 +799,7 @@ cdefgh] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -812,25 +812,25 @@ cdefgh] scenario editor-can-undo-left-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 3, 1 press left-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -842,7 +842,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -856,19 +856,19 @@ ghi] scenario editor-can-undo-up-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 3, 1 press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 2 4 <- 1 @@ -878,9 +878,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -892,7 +892,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -906,25 +906,25 @@ ghi] scenario editor-can-undo-down-arrow [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 2, 1 press down-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -936,7 +936,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -950,27 +950,27 @@ ghi] scenario editor-can-undo-ctrl-f [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page assume-console [ press ctrl-f ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 1 screen-should-contain [ @@ -985,27 +985,27 @@ f] scenario editor-can-undo-page-down [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page assume-console [ press page-down ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 1 screen-should-contain [ @@ -1020,28 +1020,28 @@ f] scenario editor-can-undo-ctrl-b [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page down and up assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 2 screen-should-contain [ @@ -1056,28 +1056,28 @@ f] scenario editor-can-undo-page-up [ # create an editor with multiple pages of text assume-screen 10/width, 5/height - 1:address:array:character <- new [a + 1:address:shared:array:character <- new [a b c d e f] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # scroll the page down and up assume-console [ press page-down press page-up ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen should again show page 2 screen-should-contain [ @@ -1092,25 +1092,25 @@ f] scenario editor-can-undo-ctrl-a [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-a ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1122,7 +1122,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1136,25 +1136,25 @@ ghi] scenario editor-can-undo-home [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press home ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1166,7 +1166,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1180,25 +1180,25 @@ ghi] scenario editor-can-undo-ctrl-e [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press ctrl-e ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1210,7 +1210,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1224,25 +1224,25 @@ ghi] scenario editor-can-undo-end [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor, then to start of line assume-console [ left-click 2, 1 press end ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # undo assume-console [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves back memory-should-contain [ @@ -1254,7 +1254,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1268,17 +1268,17 @@ ghi] scenario editor-separates-undo-insert-from-undo-cursor-move [ # create an editor, type some text, move the cursor, type some more text assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ type [abc] left-click 1, 1 type [d] ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset screen-should-contain [ . . .adbc . @@ -1294,9 +1294,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # last letter typed is deleted screen-should-contain [ @@ -1314,9 +1314,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # no change to screen; cursor moves screen-should-contain [ @@ -1334,9 +1334,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # screen empty screen-should-contain [ @@ -1354,9 +1354,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # first insert screen-should-contain [ @@ -1374,9 +1374,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves screen-should-contain [ @@ -1394,9 +1394,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # second insert screen-should-contain [ @@ -1414,11 +1414,11 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [ scenario editor-can-undo-multiple-arrows-in-the-same-direction [ # create an editor with some text assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # move the cursor assume-console [ left-click 2, 1 @@ -1426,9 +1426,9 @@ ghi] press right-arrow press up-arrow ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1438,9 +1438,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # up-arrow is undone memory-should-contain [ @@ -1452,9 +1452,9 @@ ghi] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # both right-arrows are undone memory-should-contain [ @@ -1468,24 +1468,24 @@ ghi] scenario editor-redo-touch [ # create an editor with some text, click on a character, undo assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def ghi] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data assume-console [ left-click 3, 1 press ctrl-z ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data # redo assume-console [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset ] # cursor moves to left-click memory-should-contain [ @@ -1497,7 +1497,7 @@ ghi] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1510,12 +1510,12 @@ ghi] after <handle-redo> [ { - move:address:move-operation <- maybe-convert *op, move:variant + move:address:shared:move-operation <- maybe-convert *op, move:variant break-unless move # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *move, after-row:offset *cursor-column <- get *move, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *move, after-top-of-screen:offset } ] @@ -1525,24 +1525,24 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-backspace [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit backspace assume-console [ type [abc] press backspace press backspace ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1552,10 +1552,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 3 @@ -1571,10 +1571,10 @@ scenario editor-can-undo-and-redo-backspace [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1589,38 +1589,38 @@ scenario editor-can-undo-and-redo-backspace [ # save operation to undo after <backspace-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <backspace-character-end> [ { break-unless backspaced-cell # backspace failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant + op:address:shared:operation <- first *undo + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion previous-coalesce-tag:number <- get *deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace break-unless coalesce? - delete-from:address:address:duplex-list:character <- get-address *deletion, delete-from:offset + delete-from:address:address:shared:duplex-list:character <- get-address *deletion, delete-from:offset *delete-from <- copy *before-cursor - backspaced-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset + backspaced-so-far:address:address:shared:duplex-list:character <- get-address *deletion, deleted-text:offset insert-range backspaced-cell, *backspaced-so-far *backspaced-so-far <- copy backspaced-cell after-row:address:number <- get-address *deletion, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *deletion, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *deletion, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-backspace-operation:label } # if not, create a new operation - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, backspaced-cell/deleted, *before-cursor/delete-from, deleted-until, 1/coalesce-backspace editor <- add-operation editor, op +done-adding-backspace-operation @@ -1629,34 +1629,34 @@ before <backspace-character-end> [ after <handle-undo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion - start2:address:address:duplex-list:character <- get-address *editor, data:offset - anchor:address:duplex-list:character <- get *deletion, delete-from:offset + start2:address:address:shared:duplex-list:character <- get-address *editor, data:offset + anchor:address:shared:duplex-list:character <- get *deletion, delete-from:offset break-unless anchor - deleted:address:duplex-list:character <- get *deletion, deleted-text:offset - old-cursor:address:duplex-list:character <- last deleted + deleted:address:shared:duplex-list:character <- get *deletion, deleted-text:offset + old-cursor:address:shared:duplex-list:character <- last deleted insert-range anchor, deleted # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *before-cursor <- copy old-cursor *cursor-row <- get *deletion, before-row:offset *cursor-column <- get *deletion, before-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *deletion, before-top-of-screen:offset } ] after <handle-redo> [ { - deletion:address:delete-operation <- maybe-convert *op, delete:variant + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion - start:address:duplex-list:character <- get *deletion, delete-from:offset - end:address:duplex-list:character <- get *deletion, delete-until:offset + start:address:shared:duplex-list:character <- get *deletion, delete-from:offset + end:address:shared:duplex-list:character <- get *deletion, delete-until:offset remove-between start, end # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen *cursor-row <- get *deletion, after-row:offset *cursor-column <- get *deletion, after-column:offset - top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset + top:address:address:shared:duplex-list:character <- get-address *editor, top-of-screen:offset *top <- get *deletion, after-top-of-screen:offset } ] @@ -1666,9 +1666,9 @@ after <handle-redo> [ scenario editor-can-undo-and-redo-delete [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit delete and backspace a few times assume-console [ type [abcdef] @@ -1678,15 +1678,15 @@ scenario editor-can-undo-and-redo-delete [ press delete press delete ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .af . .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1696,10 +1696,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1715,10 +1715,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1734,10 +1734,10 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1753,11 +1753,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -1773,11 +1773,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1793,11 +1793,11 @@ scenario editor-can-undo-and-redo-delete [ press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1811,37 +1811,37 @@ scenario editor-can-undo-and-redo-delete [ ] after <delete-character-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-character-end> [ { break-unless deleted-cell # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset { # if previous operation was an insert, coalesce this operation with it break-unless *undo - op:address:operation <- first *undo - deletion:address:delete-operation <- maybe-convert *op, delete:variant + op:address:shared:operation <- first *undo + deletion:address:shared:delete-operation <- maybe-convert *op, delete:variant break-unless deletion previous-coalesce-tag:number <- get *deletion, tag:offset coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete break-unless coalesce? - delete-until:address:address:duplex-list:character <- get-address *deletion, delete-until:offset + delete-until:address:address:shared:duplex-list:character <- get-address *deletion, delete-until:offset *delete-until <- next *before-cursor - deleted-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset + deleted-so-far:address:address:shared:duplex-list:character <- get-address *deletion, deleted-text:offset *deleted-so-far <- append *deleted-so-far, deleted-cell after-row:address:number <- get-address *deletion, after-row:offset *after-row <- copy *cursor-row after-column:address:number <- get-address *deletion, after-column:offset *after-column <- copy *cursor-column - after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset + after-top:address:address:shared:duplex-list:character <- get-address *deletion, after-top-of-screen:offset *after-top <- get *editor, top-of-screen:offset break +done-adding-delete-operation:label } # if not, create a new operation - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cell/deleted, *before-cursor/delete-from, deleted-until, 2/coalesce-delete editor <- add-operation editor, op +done-adding-delete-operation @@ -1853,16 +1853,16 @@ before <delete-character-end> [ scenario editor-can-undo-and-redo-ctrl-k [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 1 press ctrl-k ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .a . @@ -1870,8 +1870,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1881,7 +1881,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1890,8 +1890,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1901,7 +1901,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted screen-should-contain [ @@ -1911,8 +1911,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 1 @@ -1922,7 +1922,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1934,15 +1934,15 @@ def] ] after <delete-to-end-of-line-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-to-end-of-line-end> [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -1954,16 +1954,16 @@ before <delete-to-end-of-line-end> [ scenario editor-can-undo-and-redo-ctrl-u [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [abc + 1:address:shared:array:character <- new [abc def] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # insert some text and hit delete and backspace a few times assume-console [ left-click 1, 2 press ctrl-u ] - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .c . @@ -1971,8 +1971,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -1982,7 +1982,7 @@ def] press ctrl-z ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -1991,8 +1991,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 2 @@ -2002,7 +2002,7 @@ def] press ctrl-y ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] # first line inserted screen-should-contain [ @@ -2012,8 +2012,8 @@ def] .┈┈┈┈┈┈┈┈┈┈. . . ] - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + 3:number <- get *2:address:shared:editor-data, cursor-row:offset + 4:number <- get *2:address:shared:editor-data, cursor-column:offset memory-should-contain [ 3 <- 1 4 <- 0 @@ -2023,7 +2023,7 @@ def] type [1] ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data ] screen-should-contain [ . . @@ -2035,15 +2035,15 @@ def] ] after <delete-to-start-of-line-begin> [ - top-before:address:duplex-list:character <- get *editor, top-of-screen:offset + top-before:address:shared:duplex-list:character <- get *editor, top-of-screen:offset ] before <delete-to-start-of-line-end> [ { break-unless deleted-cells # delete failed; don't add an undo operation - top-after:address:duplex-list:character <- get *editor, top-of-screen:offset - undo:address:address:list:address:operation <- get-address *editor, undo:offset - op:address:operation <- new operation:type - deleted-until:address:duplex-list:character <- next *before-cursor + top-after:address:shared:duplex-list:character <- get *editor, top-of-screen:offset + undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset + op:address:shared:operation <- new operation:type + deleted-until:address:shared:duplex-list:character <- next *before-cursor *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce editor <- add-operation editor, op +done-adding-delete-operation @@ -2053,16 +2053,16 @@ before <delete-to-start-of-line-end> [ scenario editor-can-undo-and-redo-ctrl-u-2 [ # create an editor assume-screen 10/width, 5/height - 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right - editor-render screen, 2:address:editor-data + 1:address:shared:array:character <- new [] + 2:address:shared:editor-data <- new-editor 1:address:shared:array:character, screen:address:shared:screen, 0/left, 10/right + editor-render screen, 2:address:shared:editor-data # 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:address:screen, console:address:console, 2:address:editor-data + editor-event-loop screen:address:shared:screen, console:address:shared:console, 2:address:shared:editor-data screen-should-contain [ . . .abc . diff --git a/screen.mu b/screen.mu index 1061d191..99efc9ce 100644 --- a/screen.mu +++ b/screen.mu @@ -11,7 +11,8 @@ recipe main [ wait-for-event 0/console clear-screen 0/screen move-cursor 0/screen, 0/row, 4/column - print 0/screen, 98/b + 10:character <- copy 98/b + print 0/screen, 10:character wait-for-event 0/console move-cursor 0/screen, 0/row, 0/column clear-line 0/screen |