scroll on enter

[?]
May 28, 2022, 3:38 PM
PHFWIFYKFOGVX7CEAMGJ3FDY6LL5QSZ7T7CTCZ66WMNXV6C242FAC

Dependencies

  • [2] 4RUI5X52 a few tests for pageup, and a bugfix
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] 2ZYV7D3W handle tab characters

Change contents

  • edit in text.lua at line 658
    [2.4092]
    [2.4092]
    end
    function test_enter_on_bottom_line_scrolls_down()
    io.write('\ntest_enter_on_bottom_line_scrolls_down')
    -- display a few lines with cursor on bottom line
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
    Line_width = App.screen.width
    Cursor1 = {line=3, pos=2}
    Screen_top1 = {line=1, 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, 'abc', 'F - test_enter_on_bottom_line_scrolls_down/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_enter_on_bottom_line_scrolls_down/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_enter_on_bottom_line_scrolls_down/baseline/screen:3')
    -- after hitting the enter key the screen scrolls down
    App.run_after_keychord('return')
    check_eq(Screen_top1.line, 2, 'F - test_enter_on_bottom_line_scrolls_down/screen_top')
    check_eq(Cursor1.line, 4, 'F - test_enter_on_bottom_line_scrolls_down/cursor:line')
    check_eq(Cursor1.pos, 1, 'F - test_enter_on_bottom_line_scrolls_down/cursor:pos')
    y = screen_top_margin
    App.screen.check(y, 'def', 'F - test_enter_on_bottom_line_scrolls_down/screen:1')
    y = y + line_height
    App.screen.check(y, 'g', 'F - test_enter_on_bottom_line_scrolls_down/screen:2')
    y = y + line_height
    App.screen.check(y, 'hi', 'F - test_enter_on_bottom_line_scrolls_down/screen:3')
  • edit in text.lua at line 802
    [5.134]
    [5.134]
    if Cursor1.line > Screen_bottom1.line then
    Screen_top1.line = Cursor1.line
    Text.scroll_up_while_cursor_on_screen()
    end