From 717d6cddc1464df9744a37056016b9f4230ab650 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 11 Jan 2017 09:40:41 -0800 Subject: 3732 --- html/022arithmetic.cc.html | 4 +- html/101run_sandboxed.cc.html | 798 +++++++++++----------- html/edit/001-editor.mu.html | 913 +++++++++++++------------- html/edit/002-typing.mu.html | 58 +- html/edit/003-shortcuts.mu.html | 142 ++-- html/edit/004-programming-environment.mu.html | 26 +- html/edit/005-sandbox.mu.html | 30 +- html/edit/006-sandbox-copy.mu.html | 4 +- html/edit/007-sandbox-delete.mu.html | 10 +- html/edit/008-sandbox-edit.mu.html | 8 +- html/edit/009-sandbox-test.mu.html | 2 +- html/edit/010-sandbox-trace.mu.html | 2 +- html/edit/011-errors.mu.html | 2 +- html/edit/012-editor-undo.mu.html | 58 +- 14 files changed, 1033 insertions(+), 1024 deletions(-) (limited to 'html') diff --git a/html/022arithmetic.cc.html b/html/022arithmetic.cc.html index e1e953a7..98e44ac6 100644 --- a/html/022arithmetic.cc.html +++ b/html/022arithmetic.cc.html @@ -813,13 +813,13 @@ if ('onhashchange' in window) { 751 752 :(scenario truncate_to_nearest_integer) 753 def main [ -754 1:num <- truncate 12.2 +754 1:num <- truncate 12.2 755 ] 756 +mem: storing 12 in location 1 757 758 :(scenario truncate_negative) 759 def main [ -760 1:num <- truncate -12.2 +760 1:num <- truncate -12.2 761 ] 762 +mem: storing -12 in location 1 763 diff --git a/html/101run_sandboxed.cc.html b/html/101run_sandboxed.cc.html index 58c7aac2..384cb677 100644 --- a/html/101run_sandboxed.cc.html +++ b/html/101run_sandboxed.cc.html @@ -118,11 +118,11 @@ if ('onhashchange' in window) { 56 if (!new_code_pushed_to_stack) { 57 products.resize(5); 58 products.at(0).push_back(0); - 59 products.at(1).push_back(trace_error_contents()); + 59 products.at(1).push_back(trace_error_contents()); 60 products.at(2).push_back(0); - 61 products.at(3).push_back(trace_app_contents()); + 61 products.at(3).push_back(trace_app_contents()); 62 products.at(4).push_back(1); // completed - 63 run_code_end(); + 63 run_code_end(); 64 break; // done with this instruction 65 } 66 else { @@ -157,9 +157,9 @@ if ('onhashchange' in window) { 95 for (int i = 1; i < Reserved_for_tests; ++i) 96 Memory.erase(i); 97 } - 98 string command = trim(strip_comments(read_mu_text(address))); + 98 string command = trim(strip_comments(read_mu_text(address))); 99 Name[get(Recipe_ordinal, "interactive")].clear(); -100 run_code_begin(/*should_stash_snapshots*/true); +100 run_code_begin(/*should_stash_snapshots*/true); 101 if (command.empty()) return false; 102 // don't kill the current routine on parse errors 103 routine* save_current_routine = Current_routine; @@ -197,396 +197,404 @@ if ('onhashchange' in window) { 135 map<recipe_ordinal, map<string, int> > Name_snapshot_stash; 136 map<string, vector<recipe_ordinal> > Recipe_variants_snapshot_stash; 137 map<string, type_tree*> Type_abbreviations_snapshot_stash; -138 -139 :(code) -140 void run_code_begin(bool should_stash_snapshots) { -141 // stuff to undo later, in run_code_end() -142 Hide_errors = true; -143 Disable_redefine_checks = true; -144 if (should_stash_snapshots) -145 stash_snapshots(); -146 Save_trace_stream = Trace_stream; -147 Trace_stream = new trace_stream; -148 Trace_stream->collect_depth = App_depth; -149 } -150 -151 void run_code_end() { -152 Hide_errors = false; -153 Disable_redefine_checks = false; -154 //? ofstream fout("sandbox.log"); -155 //? fout << Trace_stream->readable_contents(""); -156 //? fout.close(); -157 delete Trace_stream; -158 Trace_stream = Save_trace_stream; -159 Save_trace_stream = NULL; -160 Save_trace_file.clear(); -161 Recipe.erase(get(Recipe_ordinal, "interactive")); // keep past sandboxes from inserting errors -162 if (!Recipe_snapshot_stash.empty()) -163 unstash_snapshots(); -164 } -165 -166 // keep sync'd with save_snapshots and restore_snapshots -167 void stash_snapshots() { -168 assert(Recipe_ordinal_snapshot_stash.empty()); -169 Recipe_ordinal_snapshot_stash = Recipe_ordinal_snapshot; -170 assert(Recipe_snapshot_stash.empty()); -171 Recipe_snapshot_stash = Recipe_snapshot; -172 assert(Type_ordinal_snapshot_stash.empty()); -173 Type_ordinal_snapshot_stash = Type_ordinal_snapshot; -174 assert(Type_snapshot_stash.empty()); -175 Type_snapshot_stash = Type_snapshot; -176 assert(Name_snapshot_stash.empty()); -177 Name_snapshot_stash = Name_snapshot; -178 assert(Recipe_variants_snapshot_stash.empty()); -179 Recipe_variants_snapshot_stash = Recipe_variants_snapshot; -180 assert(Type_abbreviations_snapshot_stash.empty()); -181 Type_abbreviations_snapshot_stash = Type_abbreviations_snapshot; -182 save_snapshots(); -183 } -184 void unstash_snapshots() { -185 restore_snapshots(); -186 Recipe_ordinal_snapshot = Recipe_ordinal_snapshot_stash; Recipe_ordinal_snapshot_stash.clear(); -187 Recipe_snapshot = Recipe_snapshot_stash; Recipe_snapshot_stash.clear(); -188 Type_ordinal_snapshot = Type_ordinal_snapshot_stash; Type_ordinal_snapshot_stash.clear(); -189 Type_snapshot = Type_snapshot_stash; Type_snapshot_stash.clear(); -190 Name_snapshot = Name_snapshot_stash; Name_snapshot_stash.clear(); -191 Recipe_variants_snapshot = Recipe_variants_snapshot_stash; Recipe_variants_snapshot_stash.clear(); -192 Type_abbreviations_snapshot = Type_abbreviations_snapshot_stash; Type_abbreviations_snapshot_stash.clear(); -193 } -194 -195 :(before "End Load Recipes") -196 load(string( -197 "recipe interactive [\n") + // just a dummy version to initialize the Recipe_ordinal and so on -198 "]\n" + -199 "recipe sandbox [\n" + -200 "local-scope\n" + -201 "screen:&:screen <- new-fake-screen 30, 5\n" + -202 "routine-id:num <- start-running interactive, screen\n" + -203 "limit-time routine-id, 100000/instructions\n" + -204 "wait-for-routine routine-id\n" + -205 "instructions-run:num <- number-of-instructions routine-id\n" + -206 "stash instructions-run [instructions run]\n" + -207 "sandbox-state:num <- routine-state routine-id\n" + -208 "completed?:bool <- equal sandbox-state, 1/completed\n" + -209 "output:text <- $most-recent-products\n" + -210 "errors:text <- save-errors\n" + -211 "stashes:text <- save-app-trace\n" + -212 "$cleanup-run-sandboxed\n" + -213 "return output, errors, screen, stashes, completed?\n" + -214 "]\n"); -215 -216 //: adjust errors in the sandbox -217 :(after "string maybe(string s)") -218 if (s == "interactive") return ""; -219 -220 :(scenario run_interactive_comments) -221 def main [ -222 1:text <- new [# ab -223 add 2, 2] -224 2:text <- run-sandboxed 1:text -225 3:@:char <- copy *2:text -226 ] -227 +mem: storing 52 in location 4 -228 -229 :(before "End Primitive Recipe Declarations") -230 _START_TRACKING_PRODUCTS, -231 :(before "End Primitive Recipe Numbers") -232 put(Recipe_ordinal, "$start-tracking-products", _START_TRACKING_PRODUCTS); -233 :(before "End Primitive Recipe Checks") -234 case _START_TRACKING_PRODUCTS: { -235 break; -236 } -237 :(before "End Primitive Recipe Implementations") -238 case _START_TRACKING_PRODUCTS: { -239 Track_most_recent_products = true; -240 break; -241 } -242 -243 :(before "End Primitive Recipe Declarations") -244 _STOP_TRACKING_PRODUCTS, -245 :(before "End Primitive Recipe Numbers") -246 put(Recipe_ordinal, "$stop-tracking-products", _STOP_TRACKING_PRODUCTS); -247 :(before "End Primitive Recipe Checks") -248 case _STOP_TRACKING_PRODUCTS: { -249 break; -250 } -251 :(before "End Primitive Recipe Implementations") -252 case _STOP_TRACKING_PRODUCTS: { -253 Track_most_recent_products = false; -254 break; -255 } -256 -257 :(before "End Primitive Recipe Declarations") -258 _MOST_RECENT_PRODUCTS, -259 :(before "End Primitive Recipe Numbers") -260 put(Recipe_ordinal, "$most-recent-products", _MOST_RECENT_PRODUCTS); -261 :(before "End Primitive Recipe Checks") -262 case _MOST_RECENT_PRODUCTS: { -263 break; -264 } -265 :(before "End Primitive Recipe Implementations") -266 case _MOST_RECENT_PRODUCTS: { -267 products.resize(1); -268 products.at(0).push_back(new_mu_text(Most_recent_products)); -269 break; -270 } -271 -272 :(before "End Primitive Recipe Declarations") -273 SAVE_ERRORS, -274 :(before "End Primitive Recipe Numbers") -275 put(Recipe_ordinal, "save-errors", SAVE_ERRORS); -276 :(before "End Primitive Recipe Checks") -277 case SAVE_ERRORS: { -278 break; -279 } -280 :(before "End Primitive Recipe Implementations") -281 case SAVE_ERRORS: { -282 products.resize(1); -283 products.at(0).push_back(trace_error_contents()); -284 break; -285 } -286 -287 :(before "End Primitive Recipe Declarations") -288 SAVE_APP_TRACE, -289 :(before "End Primitive Recipe Numbers") -290 put(Recipe_ordinal, "save-app-trace", SAVE_APP_TRACE); -291 :(before "End Primitive Recipe Checks") -292 case SAVE_APP_TRACE: { -293 break; -294 } -295 :(before "End Primitive Recipe Implementations") -296 case SAVE_APP_TRACE: { -297 products.resize(1); -298 products.at(0).push_back(trace_app_contents()); -299 break; -300 } -301 -302 :(before "End Primitive Recipe Declarations") -303 _CLEANUP_RUN_SANDBOXED, -304 :(before "End Primitive Recipe Numbers") -305 put(Recipe_ordinal, "$cleanup-run-sandboxed", _CLEANUP_RUN_SANDBOXED); -306 :(before "End Primitive Recipe Checks") -307 case _CLEANUP_RUN_SANDBOXED: { -308 break; -309 } -310 :(before "End Primitive Recipe Implementations") -311 case _CLEANUP_RUN_SANDBOXED: { -312 run_code_end(); -313 break; -314 } -315 -316 :(scenario "run_interactive_converts_result_to_text") -317 def main [ -318 # try to interactively add 2 and 2 -319 1:text <- new [add 2, 2] -320 2:text <- run-sandboxed 1:text -321 10:@:char <- copy 2:text/lookup -322 ] -323 # first letter in the output should be '4' in unicode -324 +mem: storing 52 in location 11 -325 -326 :(scenario "run_interactive_returns_text") -327 def main [ -328 # try to interactively add 2 and 2 -329 1:text <- new [ -330 x:text <- new [a] -331 y:text <- new [b] -332 z:text <- append x:text, y:text -333 ] -334 2:text <- run-sandboxed 1:text -335 10:@:char <- copy 2:text/lookup -336 ] -337 # output contains "ab" -338 +mem: storing 97 in location 11 -339 +mem: storing 98 in location 12 -340 -341 :(scenario "run_interactive_returns_errors") -342 def main [ -343 # run a command that generates an error -344 1:text <- new [x:num <- copy 34 -345 get x:num, foo:offset] -346 2:text, 3:text <- run-sandboxed 1:text -347 10:@:char <- copy 3:text/lookup -348 ] -349 # error should be "unknown element foo in container number" -350 +mem: storing 117 in location 11 -351 +mem: storing 110 in location 12 -352 +mem: storing 107 in location 13 -353 +mem: storing 110 in location 14 -354 # ... -355 -356 :(scenario run_interactive_with_comment) -357 def main [ -358 # 2 instructions, with a comment after the first -359 1:&:@:num <- new [a:num <- copy 0 # abc -360 b:num <- copy 0 -361 ] -362 2:text, 3:text <- run-sandboxed 1:text -363 ] -364 # no errors -365 +mem: storing 0 in location 3 -366 -367 :(before "End Running One Instruction") -368 if (Track_most_recent_products) { -369 track_most_recent_products(current_instruction(), products); -370 } -371 :(code) -372 void track_most_recent_products(const instruction& instruction, const vector<vector<double> >& products) { -373 ostringstream out; -374 for (int i = 0; i < SIZE(products); ++i) { -375 // A sandbox can print a string result, but only if it is actually saved -376 // to a variable in the sandbox, because otherwise the results are -377 // reclaimed before the sandbox sees them. So you get these interactions -378 // in the sandbox: -379 // -380 // new [abc] -381 // => <address> -382 // -383 // x:text <- new [abc] -384 // => abc -385 if (i < SIZE(instruction.products)) { -386 if (is_mu_text(instruction.products.at(i))) { -387 if (!scalar(products.at(i))) continue; // error handled elsewhere -388 out << read_mu_text(products.at(i).at(0)) << '\n'; -389 continue; -390 } -391 } -392 for (int j = 0; j < SIZE(products.at(i)); ++j) -393 out << no_scientific(products.at(i).at(j)) << ' '; -394 out << '\n'; -395 } -396 Most_recent_products = out.str(); -397 } -398 -399 :(code) -400 string strip_comments(string in) { -401 ostringstream result; -402 for (int i = 0; i < SIZE(in); ++i) { -403 if (in.at(i) != '#') { -404 result << in.at(i); -405 } -406 else { -407 while (i+1 < SIZE(in) && in.at(i+1) != '\n') -408 ++i; -409 } -410 } -411 return result.str(); -412 } -413 -414 int stringified_value_of_location(int address) { -415 // convert to string -416 ostringstream out; -417 out << no_scientific(get_or_insert(Memory, address)); -418 return new_mu_text(out.str()); -419 } -420 -421 int trace_error_contents() { -422 if (!Trace_stream) return 0; -423 ostringstream out; -424 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -425 if (p->label != "error") continue; -426 out << p->contents; -427 if (*--p->contents.end() != '\n') out << '\n'; -428 } -429 string result = out.str(); -430 truncate(result); -431 if (result.empty()) return 0; -432 return new_mu_text(result); -433 } -434 -435 int trace_app_contents() { -436 if (!Trace_stream) return 0; -437 ostringstream out; -438 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { -439 if (p->depth != App_depth) continue; -440 out << p->contents; -441 if (*--p->contents.end() != '\n') out << '\n'; -442 } -443 string result = out.str(); -444 if (result.empty()) return 0; -445 truncate(result); -446 return new_mu_text(result); -447 } -448 -449 void truncate(string& x) { -450 if (SIZE(x) > 1024) { -451 x.erase(1024); -452 *x.rbegin() = '\n'; -453 *++x.rbegin() = '.'; -454 *++++x.rbegin() = '.'; -455 } -456 } -457 -458 //: simpler version of run-sandboxed: doesn't do any running, just loads -459 //: recipes and reports errors. -460 -461 :(before "End Primitive Recipe Declarations") -462 RELOAD, -463 :(before "End Primitive Recipe Numbers") -464 put(Recipe_ordinal, "reload", RELOAD); -465 :(before "End Primitive Recipe Checks") -466 case RELOAD: { -467 if (SIZE(inst.ingredients) != 1) { -468 raise << maybe(get(Recipe, r).name) << "'reload' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); -469 break; -470 } -471 if (!is_mu_text(inst.ingredients.at(0))) { -472 raise << maybe(get(Recipe, r).name) << "first ingredient of 'reload' should be a string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); -473 break; -474 } -475 break; -476 } -477 :(before "End Primitive Recipe Implementations") -478 case RELOAD: { -479 restore_non_recipe_snapshots(); -480 string code = read_mu_text(ingredients.at(0).at(0)); -481 run_code_begin(/*should_stash_snapshots*/false); -482 routine* save_current_routine = Current_routine; -483 Current_routine = NULL; -484 Sandbox_mode = true; -485 vector<recipe_ordinal> recipes_reloaded = load(code); -486 transform_all(); -487 Trace_stream->newline(); // flush trace -488 Sandbox_mode = false; -489 Current_routine = save_current_routine; -490 products.resize(1); -491 products.at(0).push_back(trace_error_contents()); -492 run_code_end(); // wait until we're done with the trace contents -493 break; -494 } -495 -496 :(scenario reload_continues_past_error) -497 def main [ -498 local-scope -499 x:text <- new [recipe foo [ -500 get 1234:num, foo:offset -501 ]] -502 reload x -503 1:num/raw <- copy 34 -504 ] -505 +mem: storing 34 in location 1 -506 -507 :(scenario reload_can_repeatedly_load_container_definitions) -508 # define a container and try to create it (merge requires knowing container size) -509 def main [ -510 local-scope -511 x:text <- new [ -512 container foo [ -513 x:num -514 y:num -515 ] -516 recipe bar [ -517 local-scope -518 x:foo <- merge 34, 35 -519 ] -520 ] -521 # save warning addresses in locations of type 'number' to avoid spurious changes to them due to 'abandon' -522 1:num/raw <- reload x -523 2:num/raw <- reload x -524 ] -525 # no errors on either load -526 +mem: storing 0 in location 1 -527 +mem: storing 0 in location 2 +138 vector<scenario> Scenarios_snapshot_stash; +139 set<string> Scenario_names_snapshot_stash; +140 +141 :(code) +142 void run_code_begin(bool should_stash_snapshots) { +143 // stuff to undo later, in run_code_end() +144 Hide_errors = true; +145 Disable_redefine_checks = true; +146 if (should_stash_snapshots) +147 stash_snapshots(); +148 Save_trace_stream = Trace_stream; +149 Trace_stream = new trace_stream; +150 Trace_stream->collect_depth = App_depth; +151 } +152 +153 void run_code_end() { +154 Hide_errors = false; +155 Disable_redefine_checks = false; +156 //? ofstream fout("sandbox.log"); +157 //? fout << Trace_stream->readable_contents(""); +158 //? fout.close(); +159 delete Trace_stream; +160 Trace_stream = Save_trace_stream; +161 Save_trace_stream = NULL; +162 Save_trace_file.clear(); +163 Recipe.erase(get(Recipe_ordinal, "interactive")); // keep past sandboxes from inserting errors +164 if (!Recipe_snapshot_stash.empty()) +165 unstash_snapshots(); +166 } +167 +168 // keep sync'd with save_snapshots and restore_snapshots +169 void stash_snapshots() { +170 assert(Recipe_ordinal_snapshot_stash.empty()); +171 Recipe_ordinal_snapshot_stash = Recipe_ordinal_snapshot; +172 assert(Recipe_snapshot_stash.empty()); +173 Recipe_snapshot_stash = Recipe_snapshot; +174 assert(Type_ordinal_snapshot_stash.empty()); +175 Type_ordinal_snapshot_stash = Type_ordinal_snapshot; +176 assert(Type_snapshot_stash.empty()); +177 Type_snapshot_stash = Type_snapshot; +178 assert(Name_snapshot_stash.empty()); +179 Name_snapshot_stash = Name_snapshot; +180 assert(Recipe_variants_snapshot_stash.empty()); +181 Recipe_variants_snapshot_stash = Recipe_variants_snapshot; +182 assert(Type_abbreviations_snapshot_stash.empty()); +183 Type_abbreviations_snapshot_stash = Type_abbreviations_snapshot; +184 assert(Scenarios_snapshot_stash.empty()); +185 Scenarios_snapshot_stash = Scenarios_snapshot; +186 assert(Scenario_names_snapshot_stash.empty()); +187 Scenario_names_snapshot_stash = Scenario_names_snapshot; +188 save_snapshots(); +189 } +190 void unstash_snapshots() { +191 restore_snapshots(); +192 Recipe_ordinal_snapshot = Recipe_ordinal_snapshot_stash; Recipe_ordinal_snapshot_stash.clear(); +193 Recipe_snapshot = Recipe_snapshot_stash; Recipe_snapshot_stash.clear(); +194 Type_ordinal_snapshot = Type_ordinal_snapshot_stash; Type_ordinal_snapshot_stash.clear(); +195 Type_snapshot = Type_snapshot_stash; Type_snapshot_stash.clear(); +196 Name_snapshot = Name_snapshot_stash; Name_snapshot_stash.clear(); +197 Recipe_variants_snapshot = Recipe_variants_snapshot_stash; Recipe_variants_snapshot_stash.clear(); +198 Type_abbreviations_snapshot = Type_abbreviations_snapshot_stash; Type_abbreviations_snapshot_stash.clear(); +199 Scenarios_snapshot = Scenarios_snapshot_stash; Scenarios_snapshot_stash.clear(); +200 Scenario_names_snapshot = Scenario_names_snapshot_stash; Scenario_names_snapshot_stash.clear(); +201 } +202 +203 :(before "End Load Recipes") +204 load(string( +205 "recipe interactive [\n") + // just a dummy version to initialize the Recipe_ordinal and so on +206 "]\n" + +207 "recipe sandbox [\n" + +208 "local-scope\n" + +209 "screen:&:screen <- new-fake-screen 30, 5\n" + +210 "routine-id:num <- start-running interactive, screen\n" + +211 "limit-time routine-id, 100000/instructions\n" + +212 "wait-for-routine routine-id\n" + +213 "instructions-run:num <- number-of-instructions routine-id\n" + +214 "stash instructions-run [instructions run]\n" + +215 "sandbox-state:num <- routine-state routine-id\n" + +216 "completed?:bool <- equal sandbox-state, 1/completed\n" + +217 "output:text <- $most-recent-products\n" + +218 "errors:text <- save-errors\n" + +219 "stashes:text <- save-app-trace\n" + +220 "$cleanup-run-sandboxed\n" + +221 "return output, errors, screen, stashes, completed?\n" + +222 "]\n"); +223 +224 //: adjust errors in the sandbox +225 :(after "string maybe(string s)") +226 if (s == "interactive") return ""; +227 +228 :(scenario run_interactive_comments) +229 def main [ +230 1:text <- new [# ab +231 add 2, 2] +232 2:text <- run-sandboxed 1:text +233 3:@:char <- copy *2:text +234 ] +235 +mem: storing 52 in location 4 +236 +237 :(before "End Primitive Recipe Declarations") +238 _START_TRACKING_PRODUCTS, +239 :(before "End Primitive Recipe Numbers") +240 put(Recipe_ordinal, "$start-tracking-products", _START_TRACKING_PRODUCTS); +241 :(before "End Primitive Recipe Checks") +242 case _START_TRACKING_PRODUCTS: { +243 break; +244 } +245 :(before "End Primitive Recipe Implementations") +246 case _START_TRACKING_PRODUCTS: { +247 Track_most_recent_products = true; +248 break; +249 } +250 +251 :(before "End Primitive Recipe Declarations") +252 _STOP_TRACKING_PRODUCTS, +253 :(before "End Primitive Recipe Numbers") +254 put(Recipe_ordinal, "$stop-tracking-products", _STOP_TRACKING_PRODUCTS); +255 :(before "End Primitive Recipe Checks") +256 case _STOP_TRACKING_PRODUCTS: { +257 break; +258 } +259 :(before "End Primitive Recipe Implementations") +260 case _STOP_TRACKING_PRODUCTS: { +261 Track_most_recent_products = false; +262 break; +263 } +264 +265 :(before "End Primitive Recipe Declarations") +266 _MOST_RECENT_PRODUCTS, +267 :(before "End Primitive Recipe Numbers") +268 put(Recipe_ordinal, "$most-recent-products", _MOST_RECENT_PRODUCTS); +269 :(before "End Primitive Recipe Checks") +270 case _MOST_RECENT_PRODUCTS: { +271 break; +272 } +273 :(before "End Primitive Recipe Implementations") +274 case _MOST_RECENT_PRODUCTS: { +275 products.resize(1); +276 products.at(0).push_back(new_mu_text(Most_recent_products)); +277 break; +278 } +279 +280 :(before "End Primitive Recipe Declarations") +281 SAVE_ERRORS, +282 :(before "End Primitive Recipe Numbers") +283 put(Recipe_ordinal, "save-errors", SAVE_ERRORS); +284 :(before "End Primitive Recipe Checks") +285 case SAVE_ERRORS: { +286 break; +287 } +288 :(before "End Primitive Recipe Implementations") +289 case SAVE_ERRORS: { +290 products.resize(1); +291 products.at(0).push_back(trace_error_contents()); +292 break; +293 } +294 +295 :(before "End Primitive Recipe Declarations") +296 SAVE_APP_TRACE, +297 :(before "End Primitive Recipe Numbers") +298 put(Recipe_ordinal, "save-app-trace", SAVE_APP_TRACE); +299 :(before "End Primitive Recipe Checks") +300 case SAVE_APP_TRACE: { +301 break; +302 } +303 :(before "End Primitive Recipe Implementations") +304 case SAVE_APP_TRACE: { +305 products.resize(1); +306 products.at(0).push_back(trace_app_contents()); +307 break; +308 } +309 +310 :(before "End Primitive Recipe Declarations") +311 _CLEANUP_RUN_SANDBOXED, +312 :(before "End Primitive Recipe Numbers") +313 put(Recipe_ordinal, "$cleanup-run-sandboxed", _CLEANUP_RUN_SANDBOXED); +314 :(before "End Primitive Recipe Checks") +315 case _CLEANUP_RUN_SANDBOXED: { +316 break; +317 } +318 :(before "End Primitive Recipe Implementations") +319 case _CLEANUP_RUN_SANDBOXED: { +320 run_code_end(); +321 break; +322 } +323 +324 :(scenario "run_interactive_converts_result_to_text") +325 def main [ +326 # try to interactively add 2 and 2 +327 1:text <- new [add 2, 2] +328 2:text <- run-sandboxed 1:text +329 10:@:char <- copy 2:text/lookup +330 ] +331 # first letter in the output should be '4' in unicode +332 +mem: storing 52 in location 11 +333 +334 :(scenario "run_interactive_returns_text") +335 def main [ +336 # try to interactively add 2 and 2 +337 1:text <- new [ +338 x:text <- new [a] +339 y:text <- new [b] +340 z:text <- append x:text, y:text +341 ] +342 2:text <- run-sandboxed 1:text +343 10:@:char <- copy 2:text/lookup +344 ] +345 # output contains "ab" +346 +mem: storing 97 in location 11 +347 +mem: storing 98 in location 12 +348 +349 :(scenario "run_interactive_returns_errors") +350 def main [ +351 # run a command that generates an error +352 1:text <- new [x:num <- copy 34 +353 get x:num, foo:offset] +354 2:text, 3:text <- run-sandboxed 1:text +355 10:@:char <- copy 3:text/lookup +356 ] +357 # error should be "unknown element foo in container number" +358 +mem: storing 117 in location 11 +359 +mem: storing 110 in location 12 +360 +mem: storing 107 in location 13 +361 +mem: storing 110 in location 14 +362 # ... +363 +364 :(scenario run_interactive_with_comment) +365 def main [ +366 # 2 instructions, with a comment after the first +367 1:&:@:num <- new [a:num <- copy 0 # abc +368 b:num <- copy 0 +369 ] +370 2:text, 3:text <- run-sandboxed 1:text +371 ] +372 # no errors +373 +mem: storing 0 in location 3 +374 +375 :(before "End Running One Instruction") +376 if (Track_most_recent_products) { +377 track_most_recent_products(current_instruction(), products); +378 } +379 :(code) +380 void track_most_recent_products(const instruction& instruction, const vector<vector<double> >& products) { +381 ostringstream out; +382 for (int i = 0; i < SIZE(products); ++i) { +383 // A sandbox can print a string result, but only if it is actually saved +384 // to a variable in the sandbox, because otherwise the results are +385 // reclaimed before the sandbox sees them. So you get these interactions +386 // in the sandbox: +387 // +388 // new [abc] +389 // => <address> +390 // +391 // x:text <- new [abc] +392 // => abc +393 if (i < SIZE(instruction.products)) { +394 if (is_mu_text(instruction.products.at(i))) { +395 if (!scalar(products.at(i))) continue; // error handled elsewhere +396 out << read_mu_text(products.at(i).at(0)) << '\n'; +397 continue; +398 } +399 } +400 for (int j = 0; j < SIZE(products.at(i)); ++j) +401 out << no_scientific(products.at(i).at(j)) << ' '; +402 out << '\n'; +403 } +404 Most_recent_products = out.str(); +405 } +406 +407 :(code) +408 string strip_comments(string in) { +409 ostringstream result; +410 for (int i = 0; i < SIZE(in); ++i) { +411 if (in.at(i) != '#') { +412 result << in.at(i); +413 } +414 else { +415 while (i+1 < SIZE(in) && in.at(i+1) != '\n') +416 ++i; +417 } +418 } +419 return result.str(); +420 } +421 +422 int stringified_value_of_location(int address) { +423 // convert to string +424 ostringstream out; +425 out << no_scientific(get_or_insert(Memory, address)); +426 return new_mu_text(out.str()); +427 } +428 +429 int trace_error_contents() { +430 if (!Trace_stream) return 0; +431 ostringstream out; +432 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +433 if (p->label != "error") continue; +434 out << p->contents; +435 if (*--p->contents.end() != '\n') out << '\n'; +436 } +437 string result = out.str(); +438 truncate(result); +439 if (result.empty()) return 0; +440 return new_mu_text(result); +441 } +442 +443 int trace_app_contents() { +444 if (!Trace_stream) return 0; +445 ostringstream out; +446 for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { +447 if (p->depth != App_depth) continue; +448 out << p->contents; +449 if (*--p->contents.end() != '\n') out << '\n'; +450 } +451 string result = out.str(); +452 if (result.empty()) return 0; +453 truncate(result); +454 return new_mu_text(result); +455 } +456 +457 void truncate(string& x) { +458 if (SIZE(x) > 1024) { +459 x.erase(1024); +460 *x.rbegin() = '\n'; +461 *++x.rbegin() = '.'; +462 *++++x.rbegin() = '.'; +463 } +464 } +465 +466 //: simpler version of run-sandboxed: doesn't do any running, just loads +467 //: recipes and reports errors. +468 +469 :(before "End Primitive Recipe Declarations") +470 RELOAD, +471 :(before "End Primitive Recipe Numbers") +472 put(Recipe_ordinal, "reload", RELOAD); +473 :(before "End Primitive Recipe Checks") +474 case RELOAD: { +475 if (SIZE(inst.ingredients) != 1) { +476 raise << maybe(get(Recipe, r).name) << "'reload' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); +477 break; +478 } +479 if (!is_mu_text(inst.ingredients.at(0))) { +480 raise << maybe(get(Recipe, r).name) << "first ingredient of 'reload' should be a string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); +481 break; +482 } +483 break; +484 } +485 :(before "End Primitive Recipe Implementations") +486 case RELOAD: { +487 restore_non_recipe_snapshots(); +488 string code = read_mu_text(ingredients.at(0).at(0)); +489 run_code_begin(/*should_stash_snapshots*/false); +490 routine* save_current_routine = Current_routine; +491 Current_routine = NULL; +492 Sandbox_mode = true; +493 vector<recipe_ordinal> recipes_reloaded = load(code); +494 transform_all(); +495 Trace_stream->newline(); // flush trace +496 Sandbox_mode = false; +497 Current_routine = save_current_routine; +498 products.resize(1); +499 products.at(0).push_back(trace_error_contents()); +500 run_code_end(); // wait until we're done with the trace contents +501 break; +502 } +503 +504 :(scenario reload_continues_past_error) +505 def main [ +506 local-scope +507 x:text <- new [recipe foo [ +508 get 1234:num, foo:offset +509 ]] +510 reload x +511 1:num/raw <- copy 34 +512 ] +513 +mem: storing 34 in location 1 +514 +515 :(scenario reload_can_repeatedly_load_container_definitions) +516 # define a container and try to create it (merge requires knowing container size) +517 def main [ +518 local-scope +519 x:text <- new [ +520 container foo [ +521 x:num +522 y:num +523 ] +524 recipe bar [ +525 local-scope +526 x:foo <- merge 34, 35 +527 ] +528 ] +529 # save warning addresses in locations of type 'number' to avoid spurious changes to them due to 'abandon' +530 1:num/raw <- reload x +531 2:num/raw <- reload x +532 ] +533 # no errors on either load +534 +mem: storing 0 in location 1 +535 +mem: storing 0 in location 2 diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 525ab56f..55cb3a73 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -68,472 +68,473 @@ if ('onhashchange' in window) { 7 load-ingredients 8 open-console 9 hide-screen 0/screen - 10 new-editor text, 0/left, 5/right - 11 show-screen 0/screen - 12 wait-for-event 0/console - 13 close-console - 14 ] - 15 - 16 scenario editor-renders-text-to-screen [ - 17 local-scope - 18 assume-screen 10/width, 5/height - 19 e:&:editor <- new-editor [abc], 0/left, 10/right - 20 run [ - 21 render screen, e - 22 ] - 23 screen-should-contain [ - 24 # top line of screen reserved for menu - 25 . . - 26 .abc . - 27 . . - 28 ] - 29 ] - 30 - 31 container editor [ - 32 # editable text: doubly linked list of characters (head contains a special sentinel) - 33 data:&:duplex-list:char - 34 top-of-screen:&:duplex-list:char - 35 bottom-of-screen:&:duplex-list:char - 36 # location before cursor inside data - 37 before-cursor:&:duplex-list:char - 38 - 39 # raw bounds of display area on screen - 40 # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen - 41 left:num - 42 right:num - 43 bottom:num - 44 # raw screen coordinates of cursor - 45 cursor-row:num - 46 cursor-column:num - 47 ] - 48 - 49 # creates a new editor widget - 50 # right is exclusive - 51 def new-editor s:text, left:num, right:num -> result:&:editor [ - 52 local-scope - 53 load-ingredients - 54 # no clipping of bounds - 55 right <- subtract right, 1 - 56 result <- new editor:type - 57 # initialize screen-related fields - 58 *result <- put *result, left:offset, left - 59 *result <- put *result, right:offset, right - 60 # initialize cursor coordinates - 61 *result <- put *result, cursor-row:offset, 1/top - 62 *result <- put *result, cursor-column:offset, left - 63 # initialize empty contents - 64 init:&:duplex-list:char <- push 167/§, 0/tail - 65 *result <- put *result, data:offset, init - 66 *result <- put *result, top-of-screen:offset, init - 67 *result <- put *result, before-cursor:offset, init - 68 result <- insert-text result, s - 69 <editor-initialization> - 70 ] - 71 - 72 def insert-text editor:&:editor, text:text -> editor:&:editor [ - 73 local-scope - 74 load-ingredients - 75 # early exit if text is empty - 76 return-unless text - 77 len:num <- length *text - 78 return-unless len - 79 idx:num <- copy 0 - 80 # now we can start appending the rest, character by character - 81 curr:&:duplex-list:char <- get *editor, data:offset - 82 { - 83 done?:bool <- greater-or-equal idx, len - 84 break-if done? - 85 c:char <- index *text, idx - 86 insert c, curr - 87 # next iter - 88 curr <- next curr - 89 idx <- add idx, 1 - 90 loop - 91 } - 92 ] - 93 - 94 scenario editor-initializes-without-data [ - 95 local-scope - 96 assume-screen 5/width, 3/height - 97 run [ - 98 e:&:editor <- new-editor 0/data, 2/left, 5/right - 99 2:editor/raw <- copy *e -100 ] -101 memory-should-contain [ -102 # 2 (data) <- just the § sentinel -103 # 3 (top of screen) <- the § sentinel -104 4 <- 0 # bottom-of-screen; null since text fits on screen -105 # 5 (before cursor) <- the § sentinel -106 6 <- 2 # left -107 7 <- 4 # right (inclusive) -108 8 <- 0 # bottom (not set until render) -109 9 <- 1 # cursor row -110 10 <- 2 # cursor column -111 ] -112 screen-should-contain [ -113 . . + 10 e:&:editor <- new-editor text, 0/left, 5/right + 11 render 0/screen, e + 12 show-screen 0/screen + 13 wait-for-event 0/console + 14 close-console + 15 ] + 16 + 17 scenario editor-renders-text-to-screen [ + 18 local-scope + 19 assume-screen 10/width, 5/height + 20 e:&:editor <- new-editor [abc], 0/left, 10/right + 21 run [ + 22 render screen, e + 23 ] + 24 screen-should-contain [ + 25 # top line of screen reserved for menu + 26 . . + 27 .abc . + 28 . . + 29 ] + 30 ] + 31 + 32 container editor [ + 33 # editable text: doubly linked list of characters (head contains a special sentinel) + 34 data:&:duplex-list:char + 35 top-of-screen:&:duplex-list:char + 36 bottom-of-screen:&:duplex-list:char + 37 # location before cursor inside data + 38 before-cursor:&:duplex-list:char + 39 + 40 # raw bounds of display area on screen + 41 # always displays from row 1 (leaving row 0 for a menu) and at most until bottom of screen + 42 left:num + 43 right:num + 44 bottom:num + 45 # raw screen coordinates of cursor + 46 cursor-row:num + 47 cursor-column:num + 48 ] + 49 + 50 # creates a new editor widget + 51 # right is exclusive + 52 def new-editor s:text, left:num, right:num -> result:&:editor [ + 53 local-scope + 54 load-ingredients + 55 # no clipping of bounds + 56 right <- subtract right, 1 + 57 result <- new editor:type + 58 # initialize screen-related fields + 59 *result <- put *result, left:offset, left + 60 *result <- put *result, right:offset, right + 61 # initialize cursor coordinates + 62 *result <- put *result, cursor-row:offset, 1/top + 63 *result <- put *result, cursor-column:offset, left + 64 # initialize empty contents + 65 init:&:duplex-list:char <- push 167/§, 0/tail + 66 *result <- put *result, data:offset, init + 67 *result <- put *result, top-of-screen:offset, init + 68 *result <- put *result, before-cursor:offset, init + 69 result <- insert-text result, s + 70 <editor-initialization> + 71 ] + 72 + 73 def insert-text editor:&:editor, text:text -> editor:&:editor [ + 74 local-scope + 75 load-ingredients + 76 # early exit if text is empty + 77 return-unless text + 78 len:num <- length *text + 79 return-unless len + 80 idx:num <- copy 0 + 81 # now we can start appending the rest, character by character + 82 curr:&:duplex-list:char <- get *editor, data:offset + 83 { + 84 done?:bool <- greater-or-equal idx, len + 85 break-if done? + 86 c:char <- index *text, idx + 87 insert c, curr + 88 # next iter + 89 curr <- next curr + 90 idx <- add idx, 1 + 91 loop + 92 } + 93 ] + 94 + 95 scenario editor-initializes-without-data [ + 96 local-scope + 97 assume-screen 5/width, 3/height + 98 run [ + 99 e:&:editor <- new-editor 0/data, 2/left, 5/right +100 2:editor/raw <- copy *e +101 ] +102 memory-should-contain [ +103 # 2 (data) <- just the § sentinel +104 # 3 (top of screen) <- the § sentinel +105 4 <- 0 # bottom-of-screen; null since text fits on screen +106 # 5 (before cursor) <- the § sentinel +107 6 <- 2 # left +108 7 <- 4 # right (inclusive) +109 8 <- 0 # bottom (not set until render) +110 9 <- 1 # cursor row +111 10 <- 2 # cursor column +112 ] +113 screen-should-contain [ 114 . . 115 . . -116 ] -117 ] -118 -119 # Assumes cursor should be at coordinates (cursor-row, cursor-column) and -120 # updates before-cursor to match. Might also move coordinates if they're -121 # outside text. -122 def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ -123 local-scope -124 load-ingredients -125 return-unless editor, 1/top, 0/left -126 left:num <- get *editor, left:offset -127 screen-height:num <- screen-height screen -128 right:num <- get *editor, right:offset -129 # traversing editor -130 curr:&:duplex-list:char <- get *editor, top-of-screen:offset -131 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev -132 curr <- next curr -133 # traversing screen -134 +render-loop-initialization -135 color:num <- copy 7/white -136 row:num <- copy 1/top -137 column:num <- copy left -138 cursor-row:num <- get *editor, cursor-row:offset -139 cursor-column:num <- get *editor, cursor-column:offset -140 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -141 screen <- move-cursor screen, row, column -142 { -143 +next-character -144 break-unless curr -145 off-screen?:bool <- greater-or-equal row, screen-height -146 break-if off-screen? -147 # update editor.before-cursor -148 # Doing so at the start of each iteration ensures it stays one step behind -149 # the current character. -150 { -151 at-cursor-row?:bool <- equal row, cursor-row -152 break-unless at-cursor-row? -153 at-cursor?:bool <- equal column, cursor-column -154 break-unless at-cursor? -155 before-cursor <- copy prev -156 } -157 c:char <- get *curr, value:offset -158 <character-c-received> -159 { -160 # newline? move to left rather than 0 -161 newline?:bool <- equal c, 10/newline -162 break-unless newline? -163 # adjust cursor if necessary -164 { -165 at-cursor-row?:bool <- equal row, cursor-row -166 break-unless at-cursor-row? -167 left-of-cursor?:bool <- lesser-than column, cursor-column -168 break-unless left-of-cursor? -169 cursor-column <- copy column -170 before-cursor <- prev curr -171 } -172 # clear rest of line in this window -173 clear-line-until screen, right -174 # skip to next line -175 row <- add row, 1 -176 column <- copy left -177 screen <- move-cursor screen, row, column -178 curr <- next curr -179 prev <- next prev -180 loop +next-character -181 } -182 { -183 # at right? wrap. even if there's only one more letter left; we need -184 # room for clicking on the cursor after it. -185 at-right?:bool <- equal column, right -186 break-unless at-right? -187 # print wrap icon -188 wrap-icon:char <- copy 8617/loop-back-to-left -189 print screen, wrap-icon, 245/grey -190 column <- copy left -191 row <- add row, 1 -192 screen <- move-cursor screen, row, column -193 # don't increment curr -194 loop +next-character -195 } -196 print screen, c, color -197 curr <- next curr -198 prev <- next prev -199 column <- add column, 1 -200 loop -201 } -202 # save first character off-screen -203 *editor <- put *editor, bottom-of-screen:offset, curr -204 # is cursor to the right of the last line? move to end -205 { -206 at-cursor-row?:bool <- equal row, cursor-row -207 cursor-outside-line?:bool <- lesser-or-equal column, cursor-column -208 before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line? -209 above-cursor-row?:bool <- lesser-than row, cursor-row -210 before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row? -211 break-unless before-cursor? -212 cursor-row <- copy row -213 cursor-column <- copy column -214 before-cursor <- copy prev -215 } -216 *editor <- put *editor, bottom:offset, row -217 *editor <- put *editor, cursor-row:offset, cursor-row -218 *editor <- put *editor, cursor-column:offset, cursor-column -219 *editor <- put *editor, before-cursor:offset, before-cursor -220 return row, column -221 ] -222 -223 def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ -224 local-scope -225 load-ingredients -226 # if it's the real screen, use the optimized primitive -227 { -228 break-if screen -229 clear-display-from row, column, left, right -230 return -231 } -232 # if not, go the slower route -233 screen <- move-cursor screen, row, column -234 clear-line-until screen, right -235 clear-rest-of-screen screen, row, left, right -236 ] -237 -238 def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ -239 local-scope -240 load-ingredients -241 row <- add row, 1 -242 screen <- move-cursor screen, row, left -243 screen-height:num <- screen-height screen -244 { -245 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height -246 break-if at-bottom-of-screen? -247 screen <- move-cursor screen, row, left -248 clear-line-until screen, right -249 row <- add row, 1 -250 loop -251 } -252 ] -253 -254 scenario editor-prints-multiple-lines [ -255 local-scope -256 assume-screen 5/width, 5/height -257 s:text <- new [abc -258 def] -259 e:&:editor <- new-editor s, 0/left, 5/right -260 run [ -261 render screen, e -262 ] -263 screen-should-contain [ -264 . . -265 .abc . -266 .def . -267 . . -268 ] -269 ] -270 -271 scenario editor-handles-offsets [ -272 local-scope -273 assume-screen 5/width, 5/height -274 e:&:editor <- new-editor [abc], 1/left, 5/right -275 run [ -276 render screen, e -277 ] -278 screen-should-contain [ -279 . . -280 . abc . -281 . . -282 ] -283 ] -284 -285 scenario editor-prints-multiple-lines-at-offset [ -286 local-scope -287 assume-screen 5/width, 5/height -288 s:text <- new [abc -289 def] -290 e:&:editor <- new-editor s, 1/left, 5/right -291 run [ -292 render screen, e -293 ] -294 screen-should-contain [ -295 . . -296 . abc . -297 . def . -298 . . -299 ] -300 ] -301 -302 scenario editor-wraps-long-lines [ -303 local-scope -304 assume-screen 5/width, 5/height -305 e:&:editor <- new-editor [abc def], 0/left, 5/right -306 run [ -307 render screen, e -308 ] -309 screen-should-contain [ -310 . . -311 .abc ↩. -312 .def . -313 . . -314 ] -315 screen-should-contain-in-color 245/grey [ -316 . . -317 . ↩. -318 . . +116 . . +117 ] +118 ] +119 +120 # Assumes cursor should be at coordinates (cursor-row, cursor-column) and +121 # updates before-cursor to match. Might also move coordinates if they're +122 # outside text. +123 def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ +124 local-scope +125 load-ingredients +126 return-unless editor, 1/top, 0/left +127 left:num <- get *editor, left:offset +128 screen-height:num <- screen-height screen +129 right:num <- get *editor, right:offset +130 # traversing editor +131 curr:&:duplex-list:char <- get *editor, top-of-screen:offset +132 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev +133 curr <- next curr +134 # traversing screen +135 +render-loop-initialization +136 color:num <- copy 7/white +137 row:num <- copy 1/top +138 column:num <- copy left +139 cursor-row:num <- get *editor, cursor-row:offset +140 cursor-column:num <- get *editor, cursor-column:offset +141 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset +142 screen <- move-cursor screen, row, column +143 { +144 +next-character +145 break-unless curr +146 off-screen?:bool <- greater-or-equal row, screen-height +147 break-if off-screen? +148 # update editor.before-cursor +149 # Doing so at the start of each iteration ensures it stays one step behind +150 # the current character. +151 { +152 at-cursor-row?:bool <- equal row, cursor-row +153 break-unless at-cursor-row? +154 at-cursor?:bool <- equal column, cursor-column +155 break-unless at-cursor? +156 before-cursor <- copy prev +157 } +158 c:char <- get *curr, value:offset +159 <character-c-received> +160 { +161 # newline? move to left rather than 0 +162 newline?:bool <- equal c, 10/newline +163 break-unless newline? +164 # adjust cursor if necessary +165 { +166 at-cursor-row?:bool <- equal row, cursor-row +167 break-unless at-cursor-row? +168 left-of-cursor?:bool <- lesser-than column, cursor-column +169 break-unless left-of-cursor? +170 cursor-column <- copy column +171 before-cursor <- prev curr +172 } +173 # clear rest of line in this window +174 clear-line-until screen, right +175 # skip to next line +176 row <- add row, 1 +177 column <- copy left +178 screen <- move-cursor screen, row, column +179 curr <- next curr +180 prev <- next prev +181 loop +next-character +182 } +183 { +184 # at right? wrap. even if there's only one more letter left; we need +185 # room for clicking on the cursor after it. +186 at-right?:bool <- equal column, right +187 break-unless at-right? +188 # print wrap icon +189 wrap-icon:char <- copy 8617/loop-back-to-left +190 print screen, wrap-icon, 245/grey +191 column <- copy left +192 row <- add row, 1 +193 screen <- move-cursor screen, row, column +194 # don't increment curr +195 loop +next-character +196 } +197 print screen, c, color +198 curr <- next curr +199 prev <- next prev +200 column <- add column, 1 +201 loop +202 } +203 # save first character off-screen +204 *editor <- put *editor, bottom-of-screen:offset, curr +205 # is cursor to the right of the last line? move to end +206 { +207 at-cursor-row?:bool <- equal row, cursor-row +208 cursor-outside-line?:bool <- lesser-or-equal column, cursor-column +209 before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line? +210 above-cursor-row?:bool <- lesser-than row, cursor-row +211 before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row? +212 break-unless before-cursor? +213 cursor-row <- copy row +214 cursor-column <- copy column +215 before-cursor <- copy prev +216 } +217 *editor <- put *editor, bottom:offset, row +218 *editor <- put *editor, cursor-row:offset, cursor-row +219 *editor <- put *editor, cursor-column:offset, cursor-column +220 *editor <- put *editor, before-cursor:offset, before-cursor +221 return row, column +222 ] +223 +224 def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ +225 local-scope +226 load-ingredients +227 # if it's the real screen, use the optimized primitive +228 { +229 break-if screen +230 clear-display-from row, column, left, right +231 return +232 } +233 # if not, go the slower route +234 screen <- move-cursor screen, row, column +235 clear-line-until screen, right +236 clear-rest-of-screen screen, row, left, right +237 ] +238 +239 def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ +240 local-scope +241 load-ingredients +242 row <- add row, 1 +243 screen <- move-cursor screen, row, left +244 screen-height:num <- screen-height screen +245 { +246 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height +247 break-if at-bottom-of-screen? +248 screen <- move-cursor screen, row, left +249 clear-line-until screen, right +250 row <- add row, 1 +251 loop +252 } +253 ] +254 +255 scenario editor-prints-multiple-lines [ +256 local-scope +257 assume-screen 5/width, 5/height +258 s:text <- new [abc +259 def] +260 e:&:editor <- new-editor s, 0/left, 5/right +261 run [ +262 render screen, e +263 ] +264 screen-should-contain [ +265 . . +266 .abc . +267 .def . +268 . . +269 ] +270 ] +271 +272 scenario editor-handles-offsets [ +273 local-scope +274 assume-screen 5/width, 5/height +275 e:&:editor <- new-editor [abc], 1/left, 5/right +276 run [ +277 render screen, e +278 ] +279 screen-should-contain [ +280 . . +281 . abc . +282 . . +283 ] +284 ] +285 +286 scenario editor-prints-multiple-lines-at-offset [ +287 local-scope +288 assume-screen 5/width, 5/height +289 s:text <- new [abc +290 def] +291 e:&:editor <- new-editor s, 1/left, 5/right +292 run [ +293 render screen, e +294 ] +295 screen-should-contain [ +296 . . +297 . abc . +298 . def . +299 . . +300 ] +301 ] +302 +303 scenario editor-wraps-long-lines [ +304 local-scope +305 assume-screen 5/width, 5/height +306 e:&:editor <- new-editor [abc def], 0/left, 5/right +307 run [ +308 render screen, e +309 ] +310 screen-should-contain [ +311 . . +312 .abc ↩. +313 .def . +314 . . +315 ] +316 screen-should-contain-in-color 245/grey [ +317 . . +318 . ↩. 319 . . -320 ] -321 ] -322 -323 scenario editor-wraps-barely-long-lines [ -324 local-scope -325 assume-screen 5/width, 5/height -326 e:&:editor <- new-editor [abcde], 0/left, 5/right -327 run [ -328 render screen, e -329 ] -330 # still wrap, even though the line would fit. We need room to click on the -331 # end of the line -332 screen-should-contain [ -333 . . -334 .abcd↩. -335 .e . -336 . . -337 ] -338 screen-should-contain-in-color 245/grey [ -339 . . -340 . ↩. -341 . . +320 . . +321 ] +322 ] +323 +324 scenario editor-wraps-barely-long-lines [ +325 local-scope +326 assume-screen 5/width, 5/height +327 e:&:editor <- new-editor [abcde], 0/left, 5/right +328 run [ +329 render screen, e +330 ] +331 # still wrap, even though the line would fit. We need room to click on the +332 # end of the line +333 screen-should-contain [ +334 . . +335 .abcd↩. +336 .e . +337 . . +338 ] +339 screen-should-contain-in-color 245/grey [ +340 . . +341 . ↩. 342 . . -343 ] -344 ] -345 -346 scenario editor-with-empty-text [ -347 local-scope -348 assume-screen 5/width, 5/height -349 e:&:editor <- new-editor [], 0/left, 5/right -350 run [ -351 render screen, e -352 3:num/raw <- get *e, cursor-row:offset -353 4:num/raw <- get *e, cursor-column:offset -354 ] -355 screen-should-contain [ -356 . . +343 . . +344 ] +345 ] +346 +347 scenario editor-with-empty-text [ +348 local-scope +349 assume-screen 5/width, 5/height +350 e:&:editor <- new-editor [], 0/left, 5/right +351 run [ +352 render screen, e +353 3:num/raw <- get *e, cursor-row:offset +354 4:num/raw <- get *e, cursor-column:offset +355 ] +356 screen-should-contain [ 357 . . 358 . . -359 ] -360 memory-should-contain [ -361 3 <- 1 # cursor row -362 4 <- 0 # cursor column -363 ] -364 ] -365 -366 # just a little color for Mu code -367 -368 scenario render-colors-comments [ -369 local-scope -370 assume-screen 5/width, 5/height -371 s:text <- new [abc -372 # de -373 f] -374 e:&:editor <- new-editor s, 0/left, 5/right -375 run [ -376 render screen, e -377 ] -378 screen-should-contain [ -379 . . -380 .abc . -381 .# de . -382 .f . -383 . . -384 ] -385 screen-should-contain-in-color 12/lightblue, [ -386 . . +359 . . +360 ] +361 memory-should-contain [ +362 3 <- 1 # cursor row +363 4 <- 0 # cursor column +364 ] +365 ] +366 +367 # just a little color for Mu code +368 +369 scenario render-colors-comments [ +370 local-scope +371 assume-screen 5/width, 5/height +372 s:text <- new [abc +373 # de +374 f] +375 e:&:editor <- new-editor s, 0/left, 5/right +376 run [ +377 render screen, e +378 ] +379 screen-should-contain [ +380 . . +381 .abc . +382 .# de . +383 .f . +384 . . +385 ] +386 screen-should-contain-in-color 12/lightblue, [ 387 . . -388 .# de . -389 . . +388 . . +389 .# de . 390 . . -391 ] -392 screen-should-contain-in-color 7/white, [ -393 . . -394 .abc . -395 . . -396 .f . -397 . . -398 ] -399 ] -400 -401 after <character-c-received> [ -402 color <- get-color color, c -403 ] -404 -405 # so far the previous color is all the information we need; that may change -406 def get-color color:num, c:char -> color:num [ -407 local-scope -408 load-ingredients -409 color-is-white?:bool <- equal color, 7/white -410 # if color is white and next character is '#', switch color to blue -411 { -412 break-unless color-is-white? -413 starting-comment?:bool <- equal c, 35/# -414 break-unless starting-comment? -415 trace 90, [app], [switch color back to blue] -416 color <- copy 12/lightblue -417 jump +exit -418 } -419 # if color is blue and next character is newline, switch color to white -420 { -421 color-is-blue?:bool <- equal color, 12/lightblue -422 break-unless color-is-blue? -423 ending-comment?:bool <- equal c, 10/newline -424 break-unless ending-comment? -425 trace 90, [app], [switch color back to white] -426 color <- copy 7/white -427 jump +exit -428 } -429 # if color is white (no comments) and next character is '<', switch color to red -430 { -431 break-unless color-is-white? -432 starting-assignment?:bool <- equal c, 60/< -433 break-unless starting-assignment? -434 color <- copy 1/red -435 jump +exit -436 } -437 # if color is red and next character is space, switch color to white -438 { -439 color-is-red?:bool <- equal color, 1/red -440 break-unless color-is-red? -441 ending-assignment?:bool <- equal c, 32/space -442 break-unless ending-assignment? -443 color <- copy 7/white -444 jump +exit -445 } -446 # otherwise no change -447 +exit -448 return color -449 ] -450 -451 scenario render-colors-assignment [ -452 local-scope -453 assume-screen 8/width, 5/height -454 s:text <- new [abc -455 d <- e -456 f] -457 e:&:editor <- new-editor s, 0/left, 8/right -458 run [ -459 render screen, e -460 ] -461 screen-should-contain [ -462 . . -463 .abc . -464 .d <- e . -465 .f . -466 . . -467 ] -468 screen-should-contain-in-color 1/red, [ -469 . . +391 . . +392 ] +393 screen-should-contain-in-color 7/white, [ +394 . . +395 .abc . +396 . . +397 .f . +398 . . +399 ] +400 ] +401 +402 after <character-c-received> [ +403 color <- get-color color, c +404 ] +405 +406 # so far the previous color is all the information we need; that may change +407 def get-color color:num, c:char -> color:num [ +408 local-scope +409 load-ingredients +410 color-is-white?:bool <- equal color, 7/white +411 # if color is white and next character is '#', switch color to blue +412 { +413 break-unless color-is-white? +414 starting-comment?:bool <- equal c, 35/# +415 break-unless starting-comment? +416 trace 90, [app], [switch color back to blue] +417 color <- copy 12/lightblue +418 jump +exit +419 } +420 # if color is blue and next character is newline, switch color to white +421 { +422 color-is-blue?:bool <- equal color, 12/lightblue +423 break-unless color-is-blue? +424 ending-comment?:bool <- equal c, 10/newline +425 break-unless ending-comment? +426 trace 90, [app], [switch color back to white] +427 color <- copy 7/white +428 jump +exit +429 } +430 # if color is white (no comments) and next character is '<', switch color to red +431 { +432 break-unless color-is-white? +433 starting-assignment?:bool <- equal c, 60/< +434 break-unless starting-assignment? +435 color <- copy 1/red +436 jump +exit +437 } +438 # if color is red and next character is space, switch color to white +439 { +440 color-is-red?:bool <- equal color, 1/red +441 break-unless color-is-red? +442 ending-assignment?:bool <- equal c, 32/space +443 break-unless ending-assignment? +444 color <- copy 7/white +445 jump +exit +446 } +447 # otherwise no change +448 +exit +449 return color +450 ] +451 +452 scenario render-colors-assignment [ +453 local-scope +454 assume-screen 8/width, 5/height +455 s:text <- new [abc +456 d <- e +457 f] +458 e:&:editor <- new-editor s, 0/left, 8/right +459 run [ +460 render screen, e +461 ] +462 screen-should-contain [ +463 . . +464 .abc . +465 .d <- e . +466 .f . +467 . . +468 ] +469 screen-should-contain-in-color 1/red, [ 470 . . -471 . <- . -472 . . +471 . . +472 . <- . 473 . . -474 ] -475 ] +474 . . +475 ] +476 ] diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index d3f59451..71244ddb 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -67,7 +67,7 @@ if ('onhashchange' in window) { 6 local-scope 7 load-ingredients 8 open-console - 9 editor:&:editor <- new-editor text, 5/left, 45/right + 9 editor:&:editor <- new-editor text, 5/left, 45/right 10 editor-event-loop 0/screen, 0/console, editor 11 close-console 12 ] @@ -326,18 +326,18 @@ if ('onhashchange' in window) { 265 load-ingredients 266 left:num <- get *editor, left:offset 267 right:num <- get *editor, right:offset - 268 row:num, column:num <- render screen, editor + 268 row:num, column:num <- render screen, editor 269 clear-line-until screen, right 270 row <- add row, 1 271 draw-horizontal screen, row, left, right, 9480/horizontal-dotted 272 row <- add row, 1 - 273 clear-screen-from screen, row, left, left, right + 273 clear-screen-from screen, row, left, left, right 274 ] 275 276 scenario editor-handles-empty-event-queue [ 277 local-scope 278 assume-screen 10/width, 5/height - 279 e:&:editor <- new-editor [abc], 0/left, 10/right + 279 e:&:editor <- new-editor [abc], 0/left, 10/right 280 editor-render screen, e 281 assume-console [] 282 run [ @@ -354,7 +354,7 @@ if ('onhashchange' in window) { 293 scenario editor-handles-mouse-clicks [ 294 local-scope 295 assume-screen 10/width, 5/height - 296 e:&:editor <- new-editor [abc], 0/left, 10/right + 296 e:&:editor <- new-editor [abc], 0/left, 10/right 297 editor-render screen, e 298 $clear-trace 299 assume-console [ @@ -381,7 +381,7 @@ if ('onhashchange' in window) { 320 scenario editor-handles-mouse-clicks-outside-text [ 321 local-scope 322 assume-screen 10/width, 5/height - 323 e:&:editor <- new-editor [abc], 0/left, 10/right + 323 e:&:editor <- new-editor [abc], 0/left, 10/right 324 $clear-trace 325 assume-console [ 326 left-click 1, 7 # last line, to the right of text @@ -403,7 +403,7 @@ if ('onhashchange' in window) { 342 assume-screen 10/width, 5/height 343 s:text <- new [abc 344 def] - 345 e:&:editor <- new-editor s, 0/left, 10/right + 345 e:&:editor <- new-editor s, 0/left, 10/right 346 $clear-trace 347 assume-console [ 348 left-click 1, 7 # interior line, to the right of text @@ -425,7 +425,7 @@ if ('onhashchange' in window) { 364 assume-screen 10/width, 5/height 365 s:text <- new [abc 366 def] - 367 e:&:editor <- new-editor s, 0/left, 10/right + 367 e:&:editor <- new-editor s, 0/left, 10/right 368 $clear-trace 369 assume-console [ 370 left-click 3, 7 # below text @@ -446,7 +446,7 @@ if ('onhashchange' in window) { 385 local-scope 386 assume-screen 10/width, 5/height 387 # editor occupies only left half of screen - 388 e:&:editor <- new-editor [abc], 0/left, 5/right + 388 e:&:editor <- new-editor [abc], 0/left, 5/right 389 editor-render screen, e 390 $clear-trace 391 assume-console [ @@ -474,7 +474,7 @@ if ('onhashchange' in window) { 413 scenario editor-handles-mouse-clicks-in-menu-area [ 414 local-scope 415 assume-screen 10/width, 5/height - 416 e:&:editor <- new-editor [abc], 0/left, 5/right + 416 e:&:editor <- new-editor [abc], 0/left, 5/right 417 editor-render screen, e 418 $clear-trace 419 assume-console [ @@ -496,7 +496,7 @@ if ('onhashchange' in window) { 435 scenario editor-inserts-characters-into-empty-editor [ 436 local-scope 437 assume-screen 10/width, 5/height - 438 e:&:editor <- new-editor [], 0/left, 5/right + 438 e:&:editor <- new-editor [], 0/left, 5/right 439 editor-render screen, e 440 $clear-trace 441 assume-console [ @@ -517,7 +517,7 @@ if ('onhashchange' in window) { 456 scenario editor-inserts-characters-at-cursor [ 457 local-scope 458 assume-screen 10/width, 5/height - 459 e:&:editor <- new-editor [abc], 0/left, 10/right + 459 e:&:editor <- new-editor [abc], 0/left, 10/right 460 editor-render screen, e 461 $clear-trace 462 # type two letters at different places @@ -541,7 +541,7 @@ if ('onhashchange' in window) { 480 scenario editor-inserts-characters-at-cursor-2 [ 481 local-scope 482 assume-screen 10/width, 5/height - 483 e:&:editor <- new-editor [abc], 0/left, 10/right + 483 e:&:editor <- new-editor [abc], 0/left, 10/right 484 editor-render screen, e 485 $clear-trace 486 assume-console [ @@ -565,7 +565,7 @@ if ('onhashchange' in window) { 504 assume-screen 10/width, 5/height 505 s:text <- new [abc 506 d] - 507 e:&:editor <- new-editor s, 0/left, 10/right + 507 e:&:editor <- new-editor s, 0/left, 10/right 508 editor-render screen, e 509 $clear-trace 510 assume-console [ @@ -588,7 +588,7 @@ if ('onhashchange' in window) { 527 scenario editor-inserts-characters-at-cursor-3 [ 528 local-scope 529 assume-screen 10/width, 5/height - 530 e:&:editor <- new-editor [abc], 0/left, 10/right + 530 e:&:editor <- new-editor [abc], 0/left, 10/right 531 editor-render screen, e 532 $clear-trace 533 assume-console [ @@ -612,7 +612,7 @@ if ('onhashchange' in window) { 551 assume-screen 10/width, 5/height 552 s:text <- new [abc 553 d] - 554 e:&:editor <- new-editor s, 0/left, 10/right + 554 e:&:editor <- new-editor s, 0/left, 10/right 555 editor-render screen, e 556 $clear-trace 557 assume-console [ @@ -637,7 +637,7 @@ if ('onhashchange' in window) { 576 assume-screen 10/width, 5/height 577 s:text <- new [abc 578 d] - 579 e:&:editor <- new-editor s, 0/left, 10/right + 579 e:&:editor <- new-editor s, 0/left, 10/right 580 editor-render screen, e 581 $clear-trace 582 assume-console [ @@ -660,7 +660,7 @@ if ('onhashchange' in window) { 599 scenario editor-moves-cursor-after-inserting-characters [ 600 local-scope 601 assume-screen 10/width, 5/height - 602 e:&:editor <- new-editor [ab], 0/left, 5/right + 602 e:&:editor <- new-editor [ab], 0/left, 5/right 603 editor-render screen, e 604 assume-console [ 605 type [01] @@ -681,7 +681,7 @@ if ('onhashchange' in window) { 620 scenario editor-wraps-line-on-insert [ 621 local-scope 622 assume-screen 5/width, 5/height - 623 e:&:editor <- new-editor [abc], 0/left, 5/right + 623 e:&:editor <- new-editor [abc], 0/left, 5/right 624 editor-render screen, e 625 # type a letter 626 assume-console [ @@ -721,7 +721,7 @@ if ('onhashchange' in window) { 660 assume-screen 10/width, 5/height 661 s:text <- new [abcdefg 662 defg] - 663 e:&:editor <- new-editor s, 0/left, 5/right + 663 e:&:editor <- new-editor s, 0/left, 5/right 664 editor-render screen, e 665 # type more text at the start 666 assume-console [ @@ -801,7 +801,7 @@ if ('onhashchange' in window) { 740 scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ 741 local-scope 742 assume-screen 10/width, 5/height - 743 e:&:editor <- new-editor [abcde], 0/left, 5/right + 743 e:&:editor <- new-editor [abcde], 0/left, 5/right 744 assume-console [ 745 left-click 1, 3 # right before the wrap icon 746 type [f] @@ -830,7 +830,7 @@ if ('onhashchange' in window) { 769 # create an editor containing two lines 770 s:text <- new [abc 771 xyz] - 772 e:&:editor <- new-editor s, 0/left, 5/right + 772 e:&:editor <- new-editor s, 0/left, 5/right 773 editor-render screen, e 774 screen-should-contain [ 775 . . @@ -858,7 +858,7 @@ if ('onhashchange' in window) { 797 scenario editor-wraps-cursor-to-left-margin [ 798 local-scope 799 assume-screen 10/width, 5/height - 800 e:&:editor <- new-editor [abcde], 2/left, 7/right + 800 e:&:editor <- new-editor [abcde], 2/left, 7/right 801 assume-console [ 802 left-click 1, 5 # line is full; no wrap icon yet 803 type [01] @@ -887,14 +887,14 @@ if ('onhashchange' in window) { 826 indent?:bool 827 ] 828 - 829 after <editor-initialization> [ + 829 after <editor-initialization> [ 830 *result <- put *result, indent?:offset, 1/true 831 ] 832 833 scenario editor-moves-cursor-down-after-inserting-newline [ 834 local-scope 835 assume-screen 10/width, 5/height - 836 e:&:editor <- new-editor [abc], 0/left, 10/right + 836 e:&:editor <- new-editor [abc], 0/left, 10/right 837 assume-console [ 838 type [0 839 1] @@ -998,7 +998,7 @@ if ('onhashchange' in window) { 937 scenario editor-moves-cursor-down-after-inserting-newline-2 [ 938 local-scope 939 assume-screen 10/width, 5/height - 940 e:&:editor <- new-editor [abc], 1/left, 10/right + 940 e:&:editor <- new-editor [abc], 1/left, 10/right 941 assume-console [ 942 type [0 943 1] @@ -1018,7 +1018,7 @@ if ('onhashchange' in window) { 957 scenario editor-clears-previous-line-completely-after-inserting-newline [ 958 local-scope 959 assume-screen 10/width, 5/height - 960 e:&:editor <- new-editor [abcde], 0/left, 5/right + 960 e:&:editor <- new-editor [abcde], 0/left, 5/right 961 editor-render screen, e 962 screen-should-contain [ 963 . . @@ -1049,7 +1049,7 @@ if ('onhashchange' in window) { 988 s:text <- new [ab 989 cd 990 ef] - 991 e:&:editor <- new-editor s, 0/left, 10/right + 991 e:&:editor <- new-editor s, 0/left, 10/right 992 # position cursor after 'cd' and hit 'newline' 993 assume-console [ 994 left-click 2, 8 @@ -1074,7 +1074,7 @@ if ('onhashchange' in window) { 1013 s:text <- new [ab 1014 cd 1015 ef] -1016 e:&:editor <- new-editor s, 0/left, 10/right +1016 e:&:editor <- new-editor s, 0/left, 10/right 1017 # position cursor after 'cd' and hit 'newline' surrounded by paste markers 1018 assume-console [ 1019 left-click 2, 8 diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 078af9cb..0881417f 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -70,7 +70,7 @@ if ('onhashchange' in window) { 10 # just one character in final line 11 s:text <- new [ab 12 cd] - 13 e:&:editor <- new-editor s, 0/left, 5/right + 13 e:&:editor <- new-editor s, 0/left, 5/right 14 assume-console [ 15 press tab 16 ] @@ -101,7 +101,7 @@ if ('onhashchange' in window) { 41 scenario editor-handles-backspace-key [ 42 local-scope 43 assume-screen 10/width, 5/height - 44 e:&:editor <- new-editor [abc], 0/left, 10/right + 44 e:&:editor <- new-editor [abc], 0/left, 10/right 45 editor-render screen, e 46 $clear-trace 47 assume-console [ @@ -276,7 +276,7 @@ if ('onhashchange' in window) { 216 # just one character in final line 217 s:text <- new [ab 218 cd] - 219 e:&:editor <- new-editor s, 0/left, 10/right + 219 e:&:editor <- new-editor s, 0/left, 10/right 220 assume-console [ 221 left-click 2, 0 # cursor at only character in final line 222 press backspace @@ -304,7 +304,7 @@ if ('onhashchange' in window) { 244 # initialize editor with two long-ish but non-wrapping lines 245 s:text <- new [abc def 246 ghi jkl] - 247 e:&:editor <- new-editor s, 0/left, 10/right + 247 e:&:editor <- new-editor s, 0/left, 10/right 248 editor-render screen, e 249 $clear-trace 250 # position the cursor at the start of the second and hit backspace @@ -329,7 +329,7 @@ if ('onhashchange' in window) { 269 local-scope 270 assume-screen 10/width, 5/height 271 # initialize editor in part of the screen with a long line - 272 e:&:editor <- new-editor [abc def ghij], 0/left, 8/right + 272 e:&:editor <- new-editor [abc def ghij], 0/left, 8/right 273 editor-render screen, e 274 # confirm that it wraps 275 screen-should-contain [ @@ -362,7 +362,7 @@ if ('onhashchange' in window) { 302 scenario editor-handles-delete-key [ 303 local-scope 304 assume-screen 10/width, 5/height - 305 e:&:editor <- new-editor [abc], 0/left, 10/right + 305 e:&:editor <- new-editor [abc], 0/left, 10/right 306 editor-render screen, e 307 $clear-trace 308 assume-console [ @@ -448,7 +448,7 @@ if ('onhashchange' in window) { 388 scenario editor-moves-cursor-right-with-key [ 389 local-scope 390 assume-screen 10/width, 5/height - 391 e:&:editor <- new-editor [abc], 0/left, 10/right + 391 e:&:editor <- new-editor [abc], 0/left, 10/right 392 editor-render screen, e 393 $clear-trace 394 assume-console [ @@ -544,7 +544,7 @@ if ('onhashchange' in window) { 484 assume-screen 10/width, 5/height 485 s:text <- new [abc 486 d] - 487 e:&:editor <- new-editor s, 0/left, 10/right + 487 e:&:editor <- new-editor s, 0/left, 10/right 488 editor-render screen, e 489 $clear-trace 490 # type right-arrow a few times to get to start of second line @@ -580,7 +580,7 @@ if ('onhashchange' in window) { 520 assume-screen 10/width, 5/height 521 s:text <- new [abc 522 d] - 523 e:&:editor <- new-editor s, 1/left, 10/right + 523 e:&:editor <- new-editor s, 1/left, 10/right 524 editor-render screen, e 525 assume-console [ 526 press right-arrow @@ -604,7 +604,7 @@ if ('onhashchange' in window) { 544 scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ 545 local-scope 546 assume-screen 10/width, 5/height - 547 e:&:editor <- new-editor [abcdef], 0/left, 5/right + 547 e:&:editor <- new-editor [abcdef], 0/left, 5/right 548 editor-render screen, e 549 $clear-trace 550 assume-console [ @@ -634,7 +634,7 @@ if ('onhashchange' in window) { 574 local-scope 575 assume-screen 10/width, 5/height 576 # line just barely wrapping - 577 e:&:editor <- new-editor [abcde], 0/left, 5/right + 577 e:&:editor <- new-editor [abcde], 0/left, 5/right 578 editor-render screen, e 579 $clear-trace 580 # position cursor at last character before wrap and hit right-arrow @@ -670,7 +670,7 @@ if ('onhashchange' in window) { 610 scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ 611 local-scope 612 assume-screen 10/width, 5/height - 613 e:&:editor <- new-editor [abcdef], 1/left, 6/right + 613 e:&:editor <- new-editor [abcdef], 1/left, 6/right 614 editor-render screen, e 615 $clear-trace 616 assume-console [ @@ -701,7 +701,7 @@ if ('onhashchange' in window) { 641 assume-screen 10/width, 5/height 642 s:text <- new [abc 643 d] - 644 e:&:editor <- new-editor s, 0/left, 10/right + 644 e:&:editor <- new-editor s, 0/left, 10/right 645 editor-render screen, e 646 $clear-trace 647 # move to end of line, press right-arrow, type a character @@ -731,7 +731,7 @@ if ('onhashchange' in window) { 671 scenario editor-moves-cursor-left-with-key [ 672 local-scope 673 assume-screen 10/width, 5/height - 674 e:&:editor <- new-editor [abc], 0/left, 10/right + 674 e:&:editor <- new-editor [abc], 0/left, 10/right 675 editor-render screen, e 676 $clear-trace 677 assume-console [ @@ -775,7 +775,7 @@ if ('onhashchange' in window) { 715 # initialize editor with two lines 716 s:text <- new [abc 717 d] - 718 e:&:editor <- new-editor s, 0/left, 10/right + 718 e:&:editor <- new-editor s, 0/left, 10/right 719 editor-render screen, e 720 $clear-trace 721 # position cursor at start of second line (so there's no previous newline) @@ -802,7 +802,7 @@ if ('onhashchange' in window) { 742 s:text <- new [abc 743 def 744 g] - 745 e:&:editor <- new-editor s:text, 0/left, 10/right + 745 e:&:editor <- new-editor s:text, 0/left, 10/right 746 editor-render screen, e 747 $clear-trace 748 # position cursor further down (so there's a newline before the character at @@ -831,7 +831,7 @@ if ('onhashchange' in window) { 771 s:text <- new [abc 772 def 773 g] - 774 e:&:editor <- new-editor s, 0/left, 10/right + 774 e:&:editor <- new-editor s, 0/left, 10/right 775 editor-render screen, e 776 $clear-trace 777 # position cursor at start of text, press left-arrow, then type a character @@ -861,7 +861,7 @@ if ('onhashchange' in window) { 801 s:text <- new [abc 802 803 d] - 804 e:&:editor <- new-editor s, 0/left, 10/right + 804 e:&:editor <- new-editor s, 0/left, 10/right 805 editor-render screen, e:&:editor 806 $clear-trace 807 # position cursor right after empty line @@ -887,7 +887,7 @@ if ('onhashchange' in window) { 827 local-scope 828 assume-screen 10/width, 5/height 829 # initialize editor with a wrapping line - 830 e:&:editor <- new-editor [abcdef], 0/left, 5/right + 830 e:&:editor <- new-editor [abcdef], 0/left, 5/right 831 editor-render screen, e 832 $clear-trace 833 screen-should-contain [ @@ -920,7 +920,7 @@ if ('onhashchange' in window) { 860 # initialize editor with a wrapping line followed by a second line 861 s:text <- new [abcdef 862 g] - 863 e:&:editor <- new-editor s, 0/left, 5/right + 863 e:&:editor <- new-editor s, 0/left, 5/right 864 editor-render screen, e 865 $clear-trace 866 screen-should-contain [ @@ -953,7 +953,7 @@ if ('onhashchange' in window) { 893 # initialize editor with a line on the verge of wrapping, followed by a second line 894 s:text <- new [abcd 895 e] - 896 e:&:editor <- new-editor s, 0/left, 5/right + 896 e:&:editor <- new-editor s, 0/left, 5/right 897 editor-render screen, e 898 $clear-trace 899 screen-should-contain [ @@ -989,7 +989,7 @@ if ('onhashchange' in window) { 929 assume-screen 10/width, 5/height 930 s:text <- new [abc 931 def] - 932 e:&:editor <- new-editor s, 0/left, 10/right + 932 e:&:editor <- new-editor s, 0/left, 10/right 933 editor-render screen, e 934 $clear-trace 935 assume-console [ @@ -1103,7 +1103,7 @@ if ('onhashchange' in window) { 1043 assume-screen 10/width, 5/height 1044 s:text <- new [ab 1045 def] -1046 e:&:editor <- new-editor s, 0/left, 10/right +1046 e:&:editor <- new-editor s, 0/left, 10/right 1047 editor-render screen, e 1048 $clear-trace 1049 assume-console [ @@ -1140,7 +1140,7 @@ if ('onhashchange' in window) { 1080 assume-screen 10/width, 5/height 1081 s:text <- new [ 1082 def] -1083 e:&:editor <- new-editor s, 0/left, 10/right +1083 e:&:editor <- new-editor s, 0/left, 10/right 1084 editor-render screen, e 1085 $clear-trace 1086 assume-console [ @@ -1179,7 +1179,7 @@ if ('onhashchange' in window) { 1119 s:text <- new [abc 1120 def 1121 ghi] -1122 e:&:editor <- new-editor s, 0/left, 10/right +1122 e:&:editor <- new-editor s, 0/left, 10/right 1123 editor-render screen, e 1124 $clear-trace 1125 # click on the third line and hit up-arrow, so you end up just after a newline @@ -1219,7 +1219,7 @@ if ('onhashchange' in window) { 1159 assume-screen 10/width, 5/height 1160 s:text <- new [abc 1161 def] -1162 e:&:editor <- new-editor s, 0/left, 10/right +1162 e:&:editor <- new-editor s, 0/left, 10/right 1163 editor-render screen, e 1164 $clear-trace 1165 # cursor starts out at (1, 0) @@ -1323,7 +1323,7 @@ if ('onhashchange' in window) { 1263 assume-screen 10/width, 5/height 1264 s:text <- new [abc 1265 de] -1266 e:&:editor <- new-editor s, 0/left, 10/right +1266 e:&:editor <- new-editor s, 0/left, 10/right 1267 editor-render screen, e 1268 $clear-trace 1269 assume-console [ @@ -1362,7 +1362,7 @@ if ('onhashchange' in window) { 1302 assume-screen 10/width, 5/height 1303 s:text <- new [123 1304 456] -1305 e:&:editor <- new-editor s, 0/left, 10/right +1305 e:&:editor <- new-editor s, 0/left, 10/right 1306 editor-render screen, e 1307 $clear-trace 1308 # start on second line, press ctrl-a @@ -1436,7 +1436,7 @@ if ('onhashchange' in window) { 1376 assume-screen 10/width, 5/height 1377 s:text <- new [123 1378 456] -1379 e:&:editor <- new-editor s, 0/left, 10/right +1379 e:&:editor <- new-editor s, 0/left, 10/right 1380 editor-render screen, e 1381 $clear-trace 1382 # start on first line (no newline before), press ctrl-a @@ -1462,7 +1462,7 @@ if ('onhashchange' in window) { 1402 assume-screen 10/width, 5/height 1403 s:text <- new [123 1404 456] -1405 e:&:editor <- new-editor s, 0/left, 10/right +1405 e:&:editor <- new-editor s, 0/left, 10/right 1406 $clear-trace 1407 # start on second line, press 'home' 1408 assume-console [ @@ -1487,7 +1487,7 @@ if ('onhashchange' in window) { 1427 assume-screen 10/width, 5/height 1428 s:text <- new [123 1429 456] -1430 e:&:editor <- new-editor s, 0/left, 10/right +1430 e:&:editor <- new-editor s, 0/left, 10/right 1431 editor-render screen, e 1432 $clear-trace 1433 # start on first line (no newline before), press 'home' @@ -1515,7 +1515,7 @@ if ('onhashchange' in window) { 1455 assume-screen 10/width, 5/height 1456 s:text <- new [123 1457 456] -1458 e:&:editor <- new-editor s, 0/left, 10/right +1458 e:&:editor <- new-editor s, 0/left, 10/right 1459 editor-render screen, e 1460 $clear-trace 1461 # start on first line, press ctrl-e @@ -1606,7 +1606,7 @@ if ('onhashchange' in window) { 1546 assume-screen 10/width, 5/height 1547 s:text <- new [123 1548 456] -1549 e:&:editor <- new-editor s, 0/left, 10/right +1549 e:&:editor <- new-editor s, 0/left, 10/right 1550 editor-render screen, e 1551 $clear-trace 1552 # start on second line (no newline after), press ctrl-e @@ -1632,7 +1632,7 @@ if ('onhashchange' in window) { 1572 assume-screen 10/width, 5/height 1573 s:text <- new [123 1574 456] -1575 e:&:editor <- new-editor s, 0/left, 10/right +1575 e:&:editor <- new-editor s, 0/left, 10/right 1576 editor-render screen, e 1577 $clear-trace 1578 # start on first line, press 'end' @@ -1658,7 +1658,7 @@ if ('onhashchange' in window) { 1598 assume-screen 10/width, 5/height 1599 s:text <- new [123 1600 456] -1601 e:&:editor <- new-editor s, 0/left, 10/right +1601 e:&:editor <- new-editor s, 0/left, 10/right 1602 editor-render screen, e 1603 $clear-trace 1604 # start on second line (no newline after), press 'end' @@ -1686,7 +1686,7 @@ if ('onhashchange' in window) { 1626 assume-screen 10/width, 5/height 1627 s:text <- new [123 1628 456] -1629 e:&:editor <- new-editor s, 0/left, 10/right +1629 e:&:editor <- new-editor s, 0/left, 10/right 1630 # start on second line, press ctrl-u 1631 assume-console [ 1632 left-click 2, 2 @@ -1749,7 +1749,7 @@ if ('onhashchange' in window) { 1689 assume-screen 10/width, 5/height 1690 s:text <- new [123 1691 456] -1692 e:&:editor <- new-editor s, 0/left, 10/right +1692 e:&:editor <- new-editor s, 0/left, 10/right 1693 # start on first line (no newline before), press ctrl-u 1694 assume-console [ 1695 left-click 1, 2 @@ -1773,7 +1773,7 @@ if ('onhashchange' in window) { 1713 assume-screen 10/width, 5/height 1714 s:text <- new [123 1715 456] -1716 e:&:editor <- new-editor s, 0/left, 10/right +1716 e:&:editor <- new-editor s, 0/left, 10/right 1717 # start past end of line, press ctrl-u 1718 assume-console [ 1719 left-click 1, 3 @@ -1797,7 +1797,7 @@ if ('onhashchange' in window) { 1737 assume-screen 10/width, 5/height 1738 s:text <- new [123 1739 456] -1740 e:&:editor <- new-editor s, 0/left, 10/right +1740 e:&:editor <- new-editor s, 0/left, 10/right 1741 # start past end of final line, press ctrl-u 1742 assume-console [ 1743 left-click 2, 3 @@ -1823,7 +1823,7 @@ if ('onhashchange' in window) { 1763 assume-screen 10/width, 5/height 1764 s:text <- new [123 1765 456] -1766 e:&:editor <- new-editor s, 0/left, 10/right +1766 e:&:editor <- new-editor s, 0/left, 10/right 1767 # start on first line, press ctrl-k 1768 assume-console [ 1769 left-click 1, 1 @@ -1878,7 +1878,7 @@ if ('onhashchange' in window) { 1818 assume-screen 10/width, 5/height 1819 s:text <- new [123 1820 456] -1821 e:&:editor <- new-editor s, 0/left, 10/right +1821 e:&:editor <- new-editor s, 0/left, 10/right 1822 # start on second line (no newline after), press ctrl-k 1823 assume-console [ 1824 left-click 2, 1 @@ -1902,7 +1902,7 @@ if ('onhashchange' in window) { 1842 assume-screen 10/width, 5/height 1843 s:text <- new [123 1844 456] -1845 e:&:editor <- new-editor s, 0/left, 10/right +1845 e:&:editor <- new-editor s, 0/left, 10/right 1846 # start at end of line 1847 assume-console [ 1848 left-click 1, 2 @@ -1926,7 +1926,7 @@ if ('onhashchange' in window) { 1866 assume-screen 10/width, 5/height 1867 s:text <- new [123 1868 456] -1869 e:&:editor <- new-editor s, 0/left, 10/right +1869 e:&:editor <- new-editor s, 0/left, 10/right 1870 # start past end of line 1871 assume-console [ 1872 left-click 1, 3 @@ -1950,7 +1950,7 @@ if ('onhashchange' in window) { 1890 assume-screen 10/width, 5/height 1891 s:text <- new [123 1892 456] -1893 e:&:editor <- new-editor s, 0/left, 10/right +1893 e:&:editor <- new-editor s, 0/left, 10/right 1894 # start at end of text 1895 assume-console [ 1896 left-click 2, 2 @@ -1974,7 +1974,7 @@ if ('onhashchange' in window) { 1914 assume-screen 10/width, 5/height 1915 s:text <- new [123 1916 456] -1917 e:&:editor <- new-editor s, 0/left, 10/right +1917 e:&:editor <- new-editor s, 0/left, 10/right 1918 # start past end of text 1919 assume-console [ 1920 left-click 2, 3 @@ -2004,7 +2004,7 @@ if ('onhashchange' in window) { 1944 b 1945 c 1946 d] -1947 e:&:editor <- new-editor s, 0/left, 10/right +1947 e:&:editor <- new-editor s, 0/left, 10/right 1948 editor-render screen, e 1949 screen-should-contain [ 1950 . . @@ -2083,7 +2083,7 @@ if ('onhashchange' in window) { 2023 g 2024 h 2025 i] -2026 e:&:editor <- new-editor s, 0/left, 5/right +2026 e:&:editor <- new-editor s, 0/left, 5/right 2027 editor-render screen, e 2028 screen-should-contain [ 2029 . . @@ -2117,7 +2117,7 @@ if ('onhashchange' in window) { 2057 k 2058 l 2059 m] -2060 e:&:editor <- new-editor s, 0/left, 5/right +2060 e:&:editor <- new-editor s, 0/left, 5/right 2061 # position cursor at last line, then try to move further down 2062 assume-console [ 2063 left-click 3, 0 @@ -2157,7 +2157,7 @@ if ('onhashchange' in window) { 2097 s:text <- new [a 2098 b 2099 cdef] -2100 e:&:editor <- new-editor s, 0/left, 5/right +2100 e:&:editor <- new-editor s, 0/left, 5/right 2101 # position cursor at end, type a character 2102 assume-console [ 2103 left-click 3, 4 @@ -2188,7 +2188,7 @@ if ('onhashchange' in window) { 2128 s:text <- new [a 2129 b 2130 c] -2131 e:&:editor <- new-editor s, 0/left, 5/right +2131 e:&:editor <- new-editor s, 0/left, 5/right 2132 assume-console [ 2133 left-click 3, 4 2134 type [ @@ -2220,7 +2220,7 @@ if ('onhashchange' in window) { 2160 s:text <- new [a 2161 b 2162 cdefgh] -2163 e:&:editor <- new-editor s, 0/left, 5/right +2163 e:&:editor <- new-editor s, 0/left, 5/right 2164 # position cursor at end of screen and try to move right 2165 assume-console [ 2166 left-click 3, 3 @@ -2253,7 +2253,7 @@ if ('onhashchange' in window) { 2193 b 2194 c 2195 d] -2196 e:&:editor <- new-editor s, 0/left, 5/right +2196 e:&:editor <- new-editor s, 0/left, 5/right 2197 # position cursor at end of screen and try to move right 2198 assume-console [ 2199 left-click 3, 3 @@ -2282,7 +2282,7 @@ if ('onhashchange' in window) { 2222 assume-screen 10/width, 5/height 2223 s:text <- new [abc 2224 de] -2225 e:&:editor <- new-editor s, 0/left, 10/right +2225 e:&:editor <- new-editor s, 0/left, 10/right 2226 editor-render screen, e 2227 $clear-trace 2228 # try to move down past end of text @@ -2355,7 +2355,7 @@ if ('onhashchange' in window) { 2295 e 2296 f 2297 g] -2298 e:&:editor <- new-editor s, 0/left, 5/right +2298 e:&:editor <- new-editor s, 0/left, 5/right 2299 editor-render screen, e 2300 # scroll down one page and one line 2301 assume-console [ @@ -2386,7 +2386,7 @@ if ('onhashchange' in window) { 2326 b 2327 c 2328 d] -2329 e:&:editor <- new-editor s, 0/left, 10/right +2329 e:&:editor <- new-editor s, 0/left, 10/right 2330 editor-render screen, e 2331 screen-should-contain [ 2332 . . @@ -2475,7 +2475,7 @@ if ('onhashchange' in window) { 2415 g 2416 h 2417 i] -2418 e:&:editor <- new-editor s, 0/left, 5/right +2418 e:&:editor <- new-editor s, 0/left, 5/right 2419 editor-render screen, e 2420 screen-should-contain [ 2421 . . @@ -2521,7 +2521,7 @@ if ('onhashchange' in window) { 2461 k 2462 l 2463 m] -2464 e:&:editor <- new-editor s, 0/left, 5/right +2464 e:&:editor <- new-editor s, 0/left, 5/right 2465 editor-render screen, e 2466 # position cursor at top of second page 2467 assume-console [ @@ -2596,7 +2596,7 @@ if ('onhashchange' in window) { 2536 g 2537 h 2538 i] -2539 e:&:editor <- new-editor s, 0/left, 6/right +2539 e:&:editor <- new-editor s, 0/left, 6/right 2540 editor-render screen, e 2541 screen-should-contain [ 2542 . . @@ -2644,7 +2644,7 @@ if ('onhashchange' in window) { 2584 c 2585 d 2586 e] -2587 e:&:editor <- new-editor s, 0/left, 6/right +2587 e:&:editor <- new-editor s, 0/left, 6/right 2588 editor-render screen, e 2589 assume-console [ 2590 press page-down @@ -2694,7 +2694,7 @@ if ('onhashchange' in window) { 2634 c 2635 d 2636 e] -2637 e:&:editor <- new-editor s, 0/left, 5/right +2637 e:&:editor <- new-editor s, 0/left, 5/right 2638 editor-render screen, e 2639 # position cursor at top of second page 2640 assume-console [ @@ -2740,7 +2740,7 @@ if ('onhashchange' in window) { 2680 b 2681 c 2682 d] -2683 e:&:editor <- new-editor s, 0/left, 10/right +2683 e:&:editor <- new-editor s, 0/left, 10/right 2684 editor-render screen, e 2685 screen-should-contain [ 2686 . . @@ -2790,7 +2790,7 @@ if ('onhashchange' in window) { 2730 b 2731 c 2732 d] -2733 e:&:editor <- new-editor s, 0/left, 10/right +2733 e:&:editor <- new-editor s, 0/left, 10/right 2734 editor-render screen, e 2735 screen-should-contain [ 2736 . . @@ -2875,7 +2875,7 @@ if ('onhashchange' in window) { 2815 assume-screen 10/width, 4/height 2816 s:text <- new [a 2817 b] -2818 e:&:editor <- new-editor s, 0/left, 10/right +2818 e:&:editor <- new-editor s, 0/left, 10/right 2819 editor-render screen, e 2820 screen-should-contain [ 2821 . . @@ -2908,7 +2908,7 @@ if ('onhashchange' in window) { 2848 b 2849 cdefgh] 2850 # editor screen triggers wrap of last line -2851 e:&:editor <- new-editor s, 0/left, 4/right +2851 e:&:editor <- new-editor s, 0/left, 4/right 2852 editor-render screen, e 2853 # some part of last line is not displayed 2854 screen-should-contain [ @@ -2941,7 +2941,7 @@ if ('onhashchange' in window) { 2881 # and still has something left over 2882 s:text <- new [a 2883 bcdefgh] -2884 e:&:editor <- new-editor s, 0/left, 4/right +2884 e:&:editor <- new-editor s, 0/left, 4/right 2885 editor-render screen, e 2886 # some part of last line is not displayed 2887 screen-should-contain [ @@ -2975,7 +2975,7 @@ if ('onhashchange' in window) { 2915 b 2916 c 2917 d] -2918 e:&:editor <- new-editor s, 0/left, 10/right +2918 e:&:editor <- new-editor s, 0/left, 10/right 2919 editor-render screen, e 2920 screen-should-contain [ 2921 . . @@ -3075,7 +3075,7 @@ if ('onhashchange' in window) { 3015 f 3016 g 3017 h] -3018 e:&:editor <- new-editor s, 0/left, 10/right +3018 e:&:editor <- new-editor s, 0/left, 10/right 3019 editor-render screen, e 3020 screen-should-contain [ 3021 . . @@ -3144,7 +3144,7 @@ if ('onhashchange' in window) { 3084 n 3085 o] 3086 # editor screen triggers wrap of last line -3087 e:&:editor <- new-editor s, 0/left, 4/right +3087 e:&:editor <- new-editor s, 0/left, 4/right 3088 editor-render screen, e 3089 # some part of last line is not displayed 3090 screen-should-contain [ @@ -3199,7 +3199,7 @@ if ('onhashchange' in window) { 3139 # and still has something left over 3140 s:text <- new [a 3141 bcdefgh] -3142 e:&:editor <- new-editor s, 0/left, 4/right +3142 e:&:editor <- new-editor s, 0/left, 4/right 3143 editor-render screen, e 3144 # some part of last line is not displayed 3145 screen-should-contain [ @@ -3251,7 +3251,7 @@ if ('onhashchange' in window) { 3191 gxx 3192 hxx 3193 ] -3194 e:&:editor <- new-editor s, 0/left, 4/right +3194 e:&:editor <- new-editor s, 0/left, 4/right 3195 editor-render screen, e 3196 screen-should-contain [ 3197 . . @@ -3311,7 +3311,7 @@ if ('onhashchange' in window) { 3251 fxy 3252 gxy 3253 ] -3254 e:&:editor <- new-editor s, 0/left, 4/right +3254 e:&:editor <- new-editor s, 0/left, 4/right 3255 editor-render screen, e 3256 screen-should-contain [ 3257 . . diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 31bf0534..e543a1f1 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -68,7 +68,7 @@ if ('onhashchange' in window) { 7 local-scope 8 open-console 9 env:&:environment <- new-programming-environment 0/filesystem, 0/screen - 10 render-all 0/screen, env, render + 10 render-all 0/screen, env, render 11 event-loop 0/screen, 0/console, env, 0/filesystem 12 # never gets here 13 ] @@ -87,10 +87,10 @@ if ('onhashchange' in window) { 26 # recipe editor on the left 27 initial-recipe-contents:text <- slurp resources, [lesson/recipes.mu] # ignore errors 28 divider:num, _ <- divide-with-remainder width, 2 - 29 recipes:&:editor <- new-editor initial-recipe-contents, 0/left, divider/right + 29 recipes:&:editor <- new-editor initial-recipe-contents, 0/left, divider/right 30 # sandbox editor on the right 31 sandbox-left:num <- add divider, 1 - 32 current-sandbox:&:editor <- new-editor test-sandbox-editor-contents, sandbox-left, width/right + 32 current-sandbox:&:editor <- new-editor test-sandbox-editor-contents, sandbox-left, width/right 33 *result <- put *result, recipes:offset, recipes 34 *result <- put *result, current-sandbox:offset, current-sandbox 35 *result <- put *result, sandbox-in-focus?:offset, 0/false @@ -185,14 +185,14 @@ if ('onhashchange' in window) { 124 { 125 break-unless render-all-on-no-more-events? 126 # no more events, and we have to force render -127 screen <- render-all screen, env, render +127 screen <- render-all screen, env, render 128 render-all-on-no-more-events? <- copy 0/false 129 jump +finish-event 130 } 131 # no more events, no force render 132 { 133 break-unless render? -134 screen <- render-recipes screen, env, render +134 screen <- render-recipes screen, env, render 135 jump +finish-event 136 } 137 } @@ -213,14 +213,14 @@ if ('onhashchange' in window) { 152 { 153 break-unless render-all-on-no-more-events? 154 # no more events, and we have to force render -155 screen <- render-all screen, env, render +155 screen <- render-all screen, env, render 156 render-all-on-no-more-events? <- copy 0/false 157 jump +finish-event 158 } 159 # no more events, no force render 160 { 161 break-unless render? -162 screen <- render-sandbox-side screen, env, render +162 screen <- render-sandbox-side screen, env, render 163 jump +finish-event 164 } 165 } @@ -381,7 +381,7 @@ if ('onhashchange' in window) { 320 ] 321 ] 322 env:&:environment <- new-programming-environment resources, screen, [def] # contents of sandbox -323 render-all screen, env, render +323 render-all screen, env, render 324 # type one letter in each of them 325 assume-console [ 326 left-click 1, 1 @@ -431,7 +431,7 @@ if ('onhashchange' in window) { 370 ] 371 ] 372 env:&:environment <- new-programming-environment resources, screen, [def] -373 render-all screen, env, render +373 render-all screen, env, render 374 # initialize programming environment and highlight cursor 375 assume-console [] 376 run [ @@ -476,7 +476,7 @@ if ('onhashchange' in window) { 415 test-sandbox-editor-contents:text <- new [abc 416 def] 417 env:&:environment <- new-programming-environment resources, screen, test-sandbox-editor-contents -418 render-all screen, env, render +418 render-all screen, env, render 419 screen-should-contain [ 420 . run (F4) . 421 . ╎abc . @@ -550,7 +550,7 @@ if ('onhashchange' in window) { 489 # draw dotted line after recipes 490 draw-horizontal screen, row, left, right, 9480/horizontal-dotted 491 row <- add row, 1 -492 clear-screen-from screen, row, left, left, right +492 clear-screen-from screen, row, left, left, right 493 ] 494 495 # replaced in a later layer @@ -566,7 +566,7 @@ if ('onhashchange' in window) { 505 # draw solid line after code (you'll see why in later layers) 506 draw-horizontal screen, row, left, right 507 row <- add row, 1 -508 clear-screen-from screen, row, left, left, right +508 clear-screen-from screen, row, left, left, right 509 ] 510 511 def update-cursor screen:&:screen, recipes:&:editor, current-sandbox:&:editor, sandbox-in-focus?:bool, env:&:environment -> screen:&:screen [ @@ -655,7 +655,7 @@ if ('onhashchange' in window) { 594 { 595 redraw-screen?:bool <- equal c, 12/ctrl-l 596 break-unless redraw-screen? -597 screen <- render-all screen, env:&:environment, render +597 screen <- render-all screen, env:&:environment, render 598 sync-screen screen 599 loop +next-event 600 } diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 5c940763..7f27f164 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -73,7 +73,7 @@ if ('onhashchange' in window) { 12 open-console 13 env:&:environment <- new-programming-environment 0/filesystem, 0/screen 14 env <- restore-sandboxes env - 15 render-all 0/screen, env, render + 15 render-all 0/screen, env, render 16 event-loop 0/screen, 0/console, env, 0/filesystem 17 # never gets here 18 ] @@ -191,7 +191,7 @@ if ('onhashchange' in window) { 130 screen <- update-status screen, [running... ], 245/grey 131 error?:bool <- run-sandboxes env, resources, screen 132 # F4 might update warnings and results on both sides - 133 screen <- render-all screen, env, render + 133 screen <- render-all screen, env, render 134 { 135 break-if error? 136 screen <- update-status screen, [ ], 245/grey @@ -307,14 +307,14 @@ if ('onhashchange' in window) { 246 render-current-sandbox?:bool <- equal render-from, -1 247 break-unless render-current-sandbox? 248 row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox - 249 clear-screen-from screen, row, column, left, right + 249 clear-screen-from screen, row, column, left, right 250 row <- add row, 1 251 } 252 # render sandboxes 253 draw-horizontal screen, row, left, right 254 sandbox:&:sandbox <- get *env, sandbox:offset 255 row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from - 256 clear-rest-of-screen screen, row, left, right + 256 clear-rest-of-screen screen, row, left, right 257 ] 258 259 def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ @@ -689,7 +689,7 @@ if ('onhashchange' in window) { 628 scenario editor-provides-edited-contents [ 629 local-scope 630 assume-screen 10/width, 5/height - 631 e:&:editor <- new-editor [abc], 0/left, 10/right + 631 e:&:editor <- new-editor [abc], 0/left, 10/right 632 assume-console [ 633 left-click 1, 2 634 type [def] @@ -713,7 +713,7 @@ if ('onhashchange' in window) { 652 assume-resources [ 653 ] 654 env:&:environment <- new-programming-environment resources, screen, [] - 655 render-all screen, env, render + 655 render-all screen, env, render 656 assume-console [ 657 press enter 658 press down-arrow @@ -736,7 +736,7 @@ if ('onhashchange' in window) { 675 assume-resources [ 676 ] 677 env:&:environment <- new-programming-environment resources, screen, [] - 678 render-all screen, env, render + 678 render-all screen, env, render 679 assume-console [ 680 press enter 681 press up-arrow @@ -816,7 +816,7 @@ if ('onhashchange' in window) { 755 assume-resources [ 756 ] 757 env:&:environment <- new-programming-environment resources, screen, [] - 758 render-all screen, env, render + 758 render-all screen, env, render 759 assume-console [ 760 # add a line 761 press enter @@ -844,7 +844,7 @@ if ('onhashchange' in window) { 783 ] 784 env:&:environment <- new-programming-environment resources, screen, [ab 785 cd] - 786 render-all screen, env, render + 786 render-all screen, env, render 787 assume-console [ 788 # add a line 789 press enter @@ -876,7 +876,7 @@ if ('onhashchange' in window) { 815 assume-resources [ 816 ] 817 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] - 818 render-all screen, env, render + 818 render-all screen, env, render 819 assume-console [ 820 # create a sandbox 821 press F4 @@ -946,7 +946,7 @@ if ('onhashchange' in window) { 885 *env <- put *env, render-from:offset, render-from 886 } 887 hide-screen screen - 888 screen <- render-sandbox-side screen, env, render + 888 screen <- render-sandbox-side screen, env, render 889 show-screen screen 890 jump +finish-event 891 } @@ -977,7 +977,7 @@ if ('onhashchange' in window) { 916 render-from <- subtract render-from, 1 917 *env <- put *env, render-from:offset, render-from 918 hide-screen screen - 919 screen <- render-sandbox-side screen, env, render + 919 screen <- render-sandbox-side screen, env, render 920 show-screen screen 921 jump +finish-event 922 } @@ -1014,7 +1014,7 @@ if ('onhashchange' in window) { 953 ] 954 # create a sandbox 955 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] - 956 render-all screen, env, render + 956 render-all screen, env, render 957 assume-console [ 958 press F4 959 ] @@ -1046,7 +1046,7 @@ if ('onhashchange' in window) { 985 assume-resources [ 986 ] 987 env:&:environment <- new-programming-environment resources, screen, [] - 988 render-all screen, env, render + 988 render-all screen, env, render 989 # create 2 sandboxes 990 assume-console [ 991 press ctrl-n @@ -1199,7 +1199,7 @@ if ('onhashchange' in window) { 1138 assume-resources [ 1139 ] 1140 env:&:environment <- new-programming-environment resources, screen, [] -1141 render-all screen, env, render +1141 render-all screen, env, render 1142 # create a sandbox 1143 assume-console [ 1144 press ctrl-n diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index 7810c2b3..3e828969 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -189,7 +189,7 @@ if ('onhashchange' in window) { 129 copy?, env <- try-copy-sandbox click-row, env 130 break-unless copy? 131 hide-screen screen -132 screen <- render-sandbox-side screen, env, render +132 screen <- render-sandbox-side screen, env, render 133 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 134 show-screen screen 135 loop +next-event @@ -225,7 +225,7 @@ if ('onhashchange' in window) { 165 clicked-on-copy-button? <- copy 1/true 166 text:text <- get *sandbox, data:offset 167 current-sandbox:&:editor <- get *env, current-sandbox:offset -168 current-sandbox <- insert-text current-sandbox, text +168 current-sandbox <- insert-text current-sandbox, text 169 # reset scroll 170 *env <- put *env, render-from:offset, -1 171 # position cursor in sandbox editor diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index ab5dac63..496d7a94 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -133,7 +133,7 @@ if ('onhashchange' in window) { 73 delete?, env <- try-delete-sandbox click-row, env 74 break-unless delete? 75 hide-screen screen - 76 screen <- render-sandbox-side screen, env, render + 76 screen <- render-sandbox-side screen, env, render 77 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 78 show-screen screen 79 loop +next-event @@ -216,7 +216,7 @@ if ('onhashchange' in window) { 156 assume-resources [ 157 ] 158 env:&:environment <- new-programming-environment resources, screen, [] -159 render-all screen, env, render +159 render-all screen, env, render 160 # create 2 sandboxes and scroll to second 161 assume-console [ 162 press ctrl-n @@ -263,7 +263,7 @@ if ('onhashchange' in window) { 203 assume-resources [ 204 ] 205 env:&:environment <- new-programming-environment resources, screen, [] -206 render-all screen, env, render +206 render-all screen, env, render 207 # create 2 sandboxes and scroll to second 208 assume-console [ 209 press ctrl-n @@ -310,7 +310,7 @@ if ('onhashchange' in window) { 250 assume-resources [ 251 ] 252 env:&:environment <- new-programming-environment resources, screen, [] -253 render-all screen, env, render +253 render-all screen, env, render 254 # create 2 sandboxes and scroll to second 255 assume-console [ 256 press ctrl-n @@ -359,7 +359,7 @@ if ('onhashchange' in window) { 299 assume-resources [ 300 ] 301 env:&:environment <- new-programming-environment resources, screen, [] -302 render-all screen, env, render +302 render-all screen, env, render 303 # create 2 sandboxes 304 assume-console [ 305 press ctrl-n diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 70f0141f..a7482e8a 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -172,7 +172,7 @@ if ('onhashchange' in window) { 112 edit?, env <- try-edit-sandbox click-row, env 113 break-unless edit? 114 hide-screen screen -115 screen <- render-sandbox-side screen, env, render +115 screen <- render-sandbox-side screen, env, render 116 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 117 show-screen screen 118 loop +next-event @@ -209,7 +209,7 @@ if ('onhashchange' in window) { 149 # 'edit' button = 'copy' button + 'delete' button 150 text:text <- get *sandbox, data:offset 151 current-sandbox:&:editor <- get *env, current-sandbox:offset -152 current-sandbox <- insert-text current-sandbox, text +152 current-sandbox <- insert-text current-sandbox, text 153 env <- delete-sandbox env, sandbox 154 # reset scroll 155 *env <- put *env, render-from:offset, -1 @@ -270,7 +270,7 @@ if ('onhashchange' in window) { 210 assume-resources [ 211 ] 212 env:&:environment <- new-programming-environment resources, screen, [] -213 render-all screen, env, render +213 render-all screen, env, render 214 # create 2 sandboxes and scroll to second 215 assume-console [ 216 press ctrl-n @@ -319,7 +319,7 @@ if ('onhashchange' in window) { 259 assume-resources [ 260 ] 261 env:&:environment <- new-programming-environment resources, screen, [] -262 render-all screen, env, render +262 render-all screen, env, render 263 # create 2 sandboxes 264 assume-console [ 265 press ctrl-n diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index c2774b98..7a0f1a16 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -192,7 +192,7 @@ if ('onhashchange' in window) { 131 sandbox <- toggle-expected-response sandbox 132 save-sandboxes env, resources 133 hide-screen screen -134 screen <- render-sandbox-side screen, env, render +134 screen <- render-sandbox-side screen, env, render 135 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 136 # no change in cursor 137 show-screen screen diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 1d33d9a5..472a7698 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -262,7 +262,7 @@ if ('onhashchange' in window) { 201 x <- not x 202 *sandbox <- put *sandbox, display-trace?:offset, x 203 hide-screen screen -204 screen <- render-sandbox-side screen, env, render +204 screen <- render-sandbox-side screen, env, render 205 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 206 # no change in cursor 207 show-screen screen diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index ee653626..1bd96e45 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -187,7 +187,7 @@ if ('onhashchange' in window) { 126 ] 127 ] 128 env:&:environment <- new-programming-environment resources, screen, [foo] -129 render-all screen, env, render +129 render-all screen, env, render 130 screen-should-contain [ 131 . run (F4) . 132 .recipe foo [ ╎foo . diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index aa6ef95e..023ecc94 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -163,7 +163,7 @@ if ('onhashchange' in window) { 102 local-scope 103 # create an editor and type a character 104 assume-screen 10/width, 5/height - 105 e:&:editor <- new-editor [], 0/left, 10/right + 105 e:&:editor <- new-editor [], 0/left, 10/right 106 editor-render screen, e 107 assume-console [ 108 type [0] @@ -292,7 +292,7 @@ if ('onhashchange' in window) { 231 local-scope 232 # create an editor and type multiple characters 233 assume-screen 10/width, 5/height - 234 e:&:editor <- new-editor [], 0/left, 10/right + 234 e:&:editor <- new-editor [], 0/left, 10/right 235 editor-render screen, e 236 assume-console [ 237 type [012] @@ -318,7 +318,7 @@ if ('onhashchange' in window) { 257 local-scope 258 # create an editor with some text 259 assume-screen 10/width, 5/height - 260 e:&:editor <- new-editor [a], 0/left, 10/right + 260 e:&:editor <- new-editor [a], 0/left, 10/right 261 editor-render screen, e 262 # type some characters 263 assume-console [ @@ -364,7 +364,7 @@ if ('onhashchange' in window) { 303 local-scope 304 # create an editor with some text 305 assume-screen 10/width, 5/height - 306 e:&:editor <- new-editor [ abc], 0/left, 10/right + 306 e:&:editor <- new-editor [ abc], 0/left, 10/right 307 editor-render screen, e 308 # new line 309 assume-console [ @@ -427,7 +427,7 @@ if ('onhashchange' in window) { 366 local-scope 367 # create an editor, type something, undo 368 assume-screen 10/width, 5/height - 369 e:&:editor <- new-editor [a], 0/left, 10/right + 369 e:&:editor <- new-editor [a], 0/left, 10/right 370 editor-render screen, e 371 assume-console [ 372 type [012] @@ -491,7 +491,7 @@ if ('onhashchange' in window) { 430 local-scope 431 # create an editor, type something, undo 432 assume-screen 10/width, 5/height - 433 e:&:editor <- new-editor [], 0/left, 10/right + 433 e:&:editor <- new-editor [], 0/left, 10/right 434 editor-render screen, e 435 assume-console [ 436 type [012] @@ -540,7 +540,7 @@ if ('onhashchange' in window) { 479 contents:text <- new [abc 480 def 481 ghi] - 482 e:&:editor <- new-editor contents, 0/left, 10/right + 482 e:&:editor <- new-editor contents, 0/left, 10/right 483 editor-render screen, e 484 assume-console [ 485 type [1] @@ -580,7 +580,7 @@ if ('onhashchange' in window) { 519 local-scope 520 # create an editor 521 assume-screen 10/width, 5/height - 522 e:&:editor <- new-editor [], 0/left, 10/right + 522 e:&:editor <- new-editor [], 0/left, 10/right 523 editor-render screen, e 524 # insert some text and tabs, hit enter, some more text and tabs 525 assume-console [ @@ -740,7 +740,7 @@ if ('onhashchange' in window) { 679 contents:text <- new [abc 680 def 681 ghi] - 682 e:&:editor <- new-editor contents, 0/left, 10/right + 682 e:&:editor <- new-editor contents, 0/left, 10/right 683 editor-render screen, e 684 # move the cursor 685 assume-console [ @@ -832,7 +832,7 @@ if ('onhashchange' in window) { 771 contents:text <- new [a 772 b 773 cdefgh] - 774 e:&:editor <- new-editor contents, 0/left, 5/right + 774 e:&:editor <- new-editor contents, 0/left, 5/right 775 # position cursor at end of screen and try to move right 776 assume-console [ 777 left-click 3, 3 @@ -895,7 +895,7 @@ if ('onhashchange' in window) { 834 contents:text <- new [abc 835 def 836 ghi] - 837 e:&:editor <- new-editor contents, 0/left, 10/right + 837 e:&:editor <- new-editor contents, 0/left, 10/right 838 editor-render screen, e 839 # move the cursor 840 assume-console [ @@ -940,7 +940,7 @@ if ('onhashchange' in window) { 879 contents:text <- new [abc 880 def 881 ghi] - 882 e:&:editor <- new-editor contents, 0/left, 10/right + 882 e:&:editor <- new-editor contents, 0/left, 10/right 883 editor-render screen, e 884 # move the cursor 885 assume-console [ @@ -991,7 +991,7 @@ if ('onhashchange' in window) { 930 contents:text <- new [abc 931 def 932 ghi] - 933 e:&:editor <- new-editor contents, 0/left, 10/right + 933 e:&:editor <- new-editor contents, 0/left, 10/right 934 editor-render screen, e 935 # move the cursor 936 assume-console [ @@ -1039,7 +1039,7 @@ if ('onhashchange' in window) { 978 d 979 e 980 f] - 981 e:&:editor <- new-editor contents, 0/left, 10/right + 981 e:&:editor <- new-editor contents, 0/left, 10/right 982 editor-render screen, e 983 # scroll the page 984 assume-console [ @@ -1073,7 +1073,7 @@ if ('onhashchange' in window) { 1012 d 1013 e 1014 f] -1015 e:&:editor <- new-editor contents, 0/left, 10/right +1015 e:&:editor <- new-editor contents, 0/left, 10/right 1016 editor-render screen, e 1017 # scroll the page 1018 assume-console [ @@ -1107,7 +1107,7 @@ if ('onhashchange' in window) { 1046 d 1047 e 1048 f] -1049 e:&:editor <- new-editor contents, 0/left, 10/right +1049 e:&:editor <- new-editor contents, 0/left, 10/right 1050 editor-render screen, e 1051 # scroll the page down and up 1052 assume-console [ @@ -1142,7 +1142,7 @@ if ('onhashchange' in window) { 1081 d 1082 e 1083 f] -1084 e:&:editor <- new-editor contents, 0/left, 10/right +1084 e:&:editor <- new-editor contents, 0/left, 10/right 1085 editor-render screen, e 1086 # scroll the page down and up 1087 assume-console [ @@ -1174,7 +1174,7 @@ if ('onhashchange' in window) { 1113 contents:text <- new [abc 1114 def 1115 ghi] -1116 e:&:editor <- new-editor contents, 0/left, 10/right +1116 e:&:editor <- new-editor contents, 0/left, 10/right 1117 editor-render screen, e 1118 # move the cursor, then to start of line 1119 assume-console [ @@ -1219,7 +1219,7 @@ if ('onhashchange' in window) { 1158 contents:text <- new [abc 1159 def 1160 ghi] -1161 e:&:editor <- new-editor contents, 0/left, 10/right +1161 e:&:editor <- new-editor contents, 0/left, 10/right 1162 editor-render screen, e 1163 # move the cursor, then to start of line 1164 assume-console [ @@ -1264,7 +1264,7 @@ if ('onhashchange' in window) { 1203 contents:text <- new [abc 1204 def 1205 ghi] -1206 e:&:editor <- new-editor contents, 0/left, 10/right +1206 e:&:editor <- new-editor contents, 0/left, 10/right 1207 editor-render screen, e 1208 # move the cursor, then to start of line 1209 assume-console [ @@ -1309,7 +1309,7 @@ if ('onhashchange' in window) { 1248 contents:text <- new [abc 1249 def 1250 ghi] -1251 e:&:editor <- new-editor contents, 0/left, 10/right +1251 e:&:editor <- new-editor contents, 0/left, 10/right 1252 editor-render screen, e 1253 # move the cursor, then to start of line 1254 assume-console [ @@ -1354,7 +1354,7 @@ if ('onhashchange' in window) { 1293 contents:text <- new [abc 1294 def 1295 ghi] -1296 e:&:editor <- new-editor contents, 0/left, 10/right +1296 e:&:editor <- new-editor contents, 0/left, 10/right 1297 editor-render screen, e 1298 # move the cursor 1299 assume-console [ @@ -1409,7 +1409,7 @@ if ('onhashchange' in window) { 1348 contents:text <- new [abc 1349 def 1350 ghi] -1351 e:&:editor <- new-editor contents, 0/left, 10/right +1351 e:&:editor <- new-editor contents, 0/left, 10/right 1352 editor-render screen, e 1353 assume-console [ 1354 left-click 3, 1 @@ -1464,7 +1464,7 @@ if ('onhashchange' in window) { 1403 local-scope 1404 # create an editor, type some text, move the cursor, type some more text 1405 assume-screen 10/width, 5/height -1406 e:&:editor <- new-editor [], 0/left, 10/right +1406 e:&:editor <- new-editor [], 0/left, 10/right 1407 editor-render screen, e 1408 assume-console [ 1409 type [abc] @@ -1613,7 +1613,7 @@ if ('onhashchange' in window) { 1552 local-scope 1553 # create an editor 1554 assume-screen 10/width, 5/height -1555 e:&:editor <- new-editor [], 0/left, 10/right +1555 e:&:editor <- new-editor [], 0/left, 10/right 1556 editor-render screen, e 1557 # insert some text and hit backspace 1558 assume-console [ @@ -1758,7 +1758,7 @@ if ('onhashchange' in window) { 1697 local-scope 1698 # create an editor 1699 assume-screen 10/width, 5/height -1700 e:&:editor <- new-editor [], 0/left, 10/right +1700 e:&:editor <- new-editor [], 0/left, 10/right 1701 editor-render screen, e 1702 # insert some text and hit delete and backspace a few times 1703 assume-console [ @@ -1949,7 +1949,7 @@ if ('onhashchange' in window) { 1888 assume-screen 10/width, 5/height 1889 contents:text <- new [abc 1890 def] -1891 e:&:editor <- new-editor contents, 0/left, 10/right +1891 e:&:editor <- new-editor contents, 0/left, 10/right 1892 editor-render screen, e 1893 # insert some text and hit delete and backspace a few times 1894 assume-console [ @@ -2052,7 +2052,7 @@ if ('onhashchange' in window) { 1991 assume-screen 10/width, 5/height 1992 contents:text <- new [abc 1993 def] -1994 e:&:editor <- new-editor contents, 0/left, 10/right +1994 e:&:editor <- new-editor contents, 0/left, 10/right 1995 editor-render screen, e 1996 # insert some text and hit delete and backspace a few times 1997 assume-console [ @@ -2152,7 +2152,7 @@ if ('onhashchange' in window) { 2091 local-scope 2092 # create an editor 2093 assume-screen 10/width, 5/height -2094 e:&:editor <- new-editor [], 0/left, 10/right +2094 e:&:editor <- new-editor [], 0/left, 10/right 2095 editor-render screen, e 2096 # insert some text and hit delete and backspace a few times 2097 assume-console [ -- cgit 1.4.1-2-gfad0