diff options
-rw-r--r-- | 020run.cc | 13 | ||||
-rw-r--r-- | edit.mu | 35 |
2 files changed, 34 insertions, 14 deletions
diff --git a/020run.cc b/020run.cc index c981349f..1c76bbdb 100644 --- a/020run.cc +++ b/020run.cc @@ -54,10 +54,8 @@ void run(recipe_ordinal r) { void run_current_routine() { // curly on a separate line, because later layers will modify header -//? cerr << "AAA 6\n"; //? 3 while (!Current_routine->completed()) // later layers will modify condition { -//? cerr << "AAA 7: " << current_step_index() << '\n'; //? 1 // Running One Instruction if (current_instruction().is_label) { ++current_step_index(); continue; } trace(Initial_callstack_depth+Callstack_depth, "run") << current_instruction().to_string() << end(); @@ -74,12 +72,9 @@ void run_current_routine() } // Instructions below will write to 'products'. vector<vector<double> > products; -//? cerr << "AAA 8: " << current_instruction().operation << " ^" << Recipe[current_instruction().operation].name << "$\n"; //? 1 -//? cerr << "% " << current_recipe_name() << "/" << current_step_index() << ": " << Memory[1013] << ' ' << Memory[1014] << '\n'; //? 1 switch (current_instruction().operation) { // Primitive Recipe Implementations case COPY: { -//? if (!ingredients.empty()) cerr << current_instruction().ingredients.at(0).to_string() << ' ' << ingredients.at(0).at(0) << '\n'; //? 1 copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin())); break; } @@ -99,7 +94,6 @@ void run_current_routine() // End of Instruction ++current_step_index(); } -//? cerr << "AAA 9\n"; //? 2 stop_running_current_routine:; } @@ -146,7 +140,7 @@ if (!Run_tests) { :(code) void cleanup_main() { - if (!Trace_file.empty()) { + if (!Trace_file.empty() && Trace_stream) { ofstream fout(Trace_file.c_str()); fout << Trace_stream->readable_contents(""); fout.close(); @@ -159,8 +153,6 @@ atexit(cleanup_main); void load_permanently(string filename) { ifstream fin(filename.c_str()); fin.peek(); -//? cerr << "AAA: " << filename << ' ' << static_cast<bool>(fin) << ' ' << fin.fail() << '\n'; //? 1 -//? return; //? 1 if (!fin) { raise << "no such file " << filename << '\n' << end(); return; @@ -181,14 +173,11 @@ load_permanently("core.mu"); :(code) // helper for tests void run(string form) { -//? cerr << "AAA 2\n"; //? 2 //? cerr << form << '\n'; //? 1 vector<recipe_ordinal> tmp = load(form); if (tmp.empty()) return; transform_all(); -//? cerr << "AAA 3\n"; //? 2 run(tmp.front()); -//? cerr << "YYY\n"; //? 2 } //:: Reading from memory, writing to memory. diff --git a/edit.mu b/edit.mu index 14a19e27..a6359b4f 100644 --- a/edit.mu +++ b/edit.mu @@ -592,6 +592,7 @@ recipe handle-keyboard-event [ { c:address:character <- maybe-convert e, text:variant break-unless c +#? trace [app], [handle-keyboard-event: special character] #? 1 # exceptions for special characters go here +handle-special-character # otherwise type it in @@ -1235,6 +1236,7 @@ recipe delete-before-cursor [ # if at start of text (before-cursor at § sentinel), return prev:address:duplex-list <- prev-duplex *before-cursor reply-unless prev +#? trace [app], [delete-before-cursor] #? 1 editor <- move-cursor-coordinates-left editor remove-duplex *before-cursor *before-cursor <- copy prev @@ -1246,9 +1248,10 @@ recipe move-cursor-coordinates-left [ before-cursor:address:duplex-list <- get *editor, before-cursor:offset cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset + left:number <- get *editor, left:offset # if not at left margin, move one character left { - at-left-margin?:boolean <- equal *cursor-column, 0 + at-left-margin?:boolean <- equal *cursor-column, left break-if at-left-margin? #? trace [app], [decrementing cursor column] #? 1 *cursor-column <- subtract *cursor-column, 1 @@ -1266,7 +1269,7 @@ recipe move-cursor-coordinates-left [ #? trace [app], [switching to previous line] #? 1 d:address:duplex-list <- get *editor, data:offset end-of-line:number <- previous-line-length before-cursor, d - *cursor-column <- copy end-of-line + *cursor-column <- add left, end-of-line reply editor/same-as-ingredient:0 } # case 2: if previous-character was not newline, we're just at a wrapped line @@ -3004,6 +3007,34 @@ scenario editor-in-focus-keeps-cursor [ ] ] +scenario backspace-in-sandbox-editor-joins-lines [ + $close-trace + assume-screen 30/width, 5/height + # initialize sandbox side with two lines + 1:address:array:character <- new [] + 2:address:array:character <- new [abc +def] + # position cursor at start of second line and hit backspace + assume-console [ + left-click 2, 16 + type [«] + ] + 3:event/backspace <- merge 0/text, 8/backspace, 0/dummy, 0/dummy + replace-in-console 171/«, 3:event/backspace + run [ + 4:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character + event-loop screen:address, console:address, 4:address:programming-environment-data + screen:address <- print-character screen:address, 9251/␣ + ] + # cursor moves to end of old line + screen-should-contain [ + . run (F4) . + . ┊abc␣ef . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━. + . ┊ . + ] +] + recipe render-all [ local-scope screen:address <- next-ingredient |