avoid scrolling down if possible

[?]
May 31, 2022, 12:24 AM
QVDQMJXVTM3BBMQDYIAIZMFLBQ56Q27U7H2OYRFE53MEMOCIXIAQC

Dependencies

  • [2] WY3JD6W6 bugfix
  • [3] PHFWIFYK scroll on enter
  • [4] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [5] XNFTJHC4 split keyboard handling between Text and Drawing
  • [6] 2ZYV7D3W handle tab characters
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] 4RUI5X52 a few tests for pageup, and a bugfix

Change contents

  • edit in text.lua at line 865
    [9.4097]
    [2.1]
    function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom()
    io.write('\ntest_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom')
    -- display just the bottom line on screen
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
    Line_width = App.screen.width
    Cursor1 = {line=4, pos=2}
    Screen_top1 = {line=4, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    local screen_top_margin = 15 -- pixels
    local line_height = math.floor(15*Zoom) -- pixels
    App.draw()
    local y = screen_top_margin
    App.screen.check(y, 'jkl', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/baseline/screen:1')
    -- after hitting the enter key the screen does not scroll down
    App.run_after_keychord('return')
    check_eq(Screen_top1.line, 4, 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen_top')
    check_eq(Cursor1.line, 5, 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:line')
    check_eq(Cursor1.pos, 1, 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/cursor:pos')
    y = screen_top_margin
    App.screen.check(y, 'j', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen:1')
    y = y + line_height
    App.screen.check(y, 'kl', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen:2')
    end
  • edit in text.lua at line 1164
    [4.950]
    [4.950]
    local scroll_down = (Cursor_y + math.floor(15*Zoom)) > App.screen.height
  • replacement in text.lua at line 1170
    [4.134][3.1509:1556]()
    if Cursor1.line > Screen_bottom1.line then
    [4.134]
    [3.1556]
    if scroll_down then