diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-05-29 13:37:02 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-05-29 13:37:02 -0700 |
commit | e8eea70ab1f70822f756be3750817ac5e24bf24d (patch) | |
tree | 6d9c1104d9e9d750822152f475eb954556ca87d7 | |
parent | eea17dee20781db0e1aabacd736632d1f788994d (diff) | |
download | mu-e8eea70ab1f70822f756be3750817ac5e24bf24d.tar.gz |
3025 - fix a minor annoyance in edit/
When I floor the down-arrow too much, don't scroll unnecessarily off the bottom of the screen. But *do* scroll if there's errors to show.
-rw-r--r-- | 082scenario_screen.cc | 4 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 160 |
2 files changed, 158 insertions, 6 deletions
diff --git a/082scenario_screen.cc b/082scenario_screen.cc index f90b926b..9c2cfe71 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -149,7 +149,7 @@ Name[r]["screen"] = SCREEN; if (curr.name == "assume-screen") { curr.name = "new-fake-screen"; assert(curr.products.empty()); - curr.products.push_back(reagent("screen:address:screen")); + curr.products.push_back(reagent("screen:address:screen/raw")); // only allowed in scenario blocks curr.products.at(0).set_value(SCREEN); } @@ -203,7 +203,6 @@ struct raw_string_stream { :(code) void check_screen(const string& expected_contents, const int color) { - assert(!current_call().default_space); // not supported int screen_location = get_or_insert(Memory, SCREEN)+/*skip refcount*/1; int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); @@ -339,7 +338,6 @@ case _DUMP_SCREEN: { :(code) void dump_screen() { - assert(!current_call().default_space); // not supported int screen_location = get_or_insert(Memory, SCREEN) + /*skip refcount*/1; int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); int screen_width = get_or_insert(Memory, screen_location+width_offset); diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 655d3eca..fadf0d68 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -576,6 +576,160 @@ scenario editor-provides-edited-contents [ ] ] +# keep the bottom of recipes from scrolling off the screen + +scenario scrolling-down-past-bottom-of-recipe-editor [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [] + render-all screen, env + assume-console [ + press enter + press down-arrow + ] + event-loop screen, console:address:console, env + # no scroll + screen-should-contain [ + . run (F4) . + . ┊ . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . + . ┊ . + ] +] + +scenario cursor-down-in-recipe-editor [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [] + render-all screen, env + assume-console [ + press enter + press up-arrow + press down-arrow # while cursor isn't at bottom + ] + event-loop screen, console:address:console, env + cursor:character <- copy 9251/␣ + print screen:address:screen, cursor + # cursor moves back to bottom + screen-should-contain [ + . run (F4) . + . ┊ . + .␣ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . + . ┊ . + ] +] + +# we'll not use the recipe-editor's 'bottom' element directly, because later +# layers will add other stuff to the left side below the editor (error messages) + +container programming-environment-data [ + recipe-bottom:number +] + +after <render-recipe-components-end> [ + *env <- put *env, recipe-bottom:offset, row +] + +after <global-keypress> [ + { + break-if sandbox-in-focus? + down-arrow?:boolean <- equal k, 65516/down-arrow + break-unless down-arrow? + recipe-editor:address:editor-data <- get *env, recipes:offset + recipe-cursor-row:number <- get *recipe-editor, cursor-row:offset + recipe-editor-bottom:number <- get *recipe-editor, bottom:offset + at-bottom-of-editor?:boolean <- greater-or-equal recipe-cursor-row, recipe-editor-bottom + break-unless at-bottom-of-editor? + more-to-scroll?:boolean <- more-to-scroll? env, screen + break-if more-to-scroll? + loop +next-event:label + } + { + break-if sandbox-in-focus? + page-down?:boolean <- equal k, 65518/page-down + break-unless page-down? + more-to-scroll?:boolean <- more-to-scroll? env, screen + break-if more-to-scroll? + loop +next-event:label + } +] + +after <global-type> [ + { + break-if sandbox-in-focus? + page-down?:boolean <- equal k, 6/ctrl-f + break-unless page-down? + more-to-scroll?:boolean <- more-to-scroll? env, screen + break-if more-to-scroll? + loop +next-event:label + } +] + +def more-to-scroll? env:address:programming-environment-data, screen:address:screen -> result:boolean [ + local-scope + load-ingredients + recipe-bottom:number <- get *env, recipe-bottom:offset + height:number <- screen-height screen + result <- greater-or-equal recipe-bottom, height +] + +scenario scrolling-down-past-bottom-of-recipe-editor-2 [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [] + render-all screen, env + assume-console [ + # add a line + press enter + # cursor back to top line + press up-arrow + # try to scroll + press page-down # or ctrl-f + ] + event-loop screen, console:address:console, env + # no scroll, and cursor remains at top line + screen-should-contain [ + . run (F4) . + . ┊ . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . + . ┊ . + ] +] + +scenario scrolling-down-past-bottom-of-recipe-editor-3 [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [ab +cd] + render-all screen, env + assume-console [ + # add a line + press enter + # switch to sandbox + press ctrl-n + # move cursor + press down-arrow + ] + event-loop screen, console:address:console, env + cursor:character <- copy 9251/␣ + print screen:address:screen, cursor + # no scroll on recipe side, cursor moves on sandbox side + screen-should-contain [ + . run (F4) . + . ┊ab . + . ┊␣d . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] +] + # scrolling through sandboxes scenario scrolling-down-past-bottom-of-sandbox-editor [ @@ -727,7 +881,7 @@ scenario scrolling-down-on-recipe-side [ event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data # hit 'down' in recipe editor assume-console [ - press down-arrow + press page-down ] run [ event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data @@ -737,8 +891,8 @@ scenario scrolling-down-on-recipe-side [ # cursor moves down on recipe side screen-should-contain [ . run (F4) . - . ┊ . - .␣ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .␣ ┊ . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 edit copy delete . . ┊add 2, 2 . ] |