experiment: slightly adaptive scrolling

[?]
Jun 4, 2022, 9:55 PM
CVSRHMJ2BM4LPVG67ULIVQMP2NW3YY2JC2ZQBEA6EB5KVM4O2L5AC

Dependencies

  • [2] LXTTOB33 extract a couple of files
  • [3] ZPUQSPQP extract a few methods
  • [4] KOYAJWE4 extract a couple more methods
  • [5] ZLJGZYQG select text with shift + mouseclick
  • [*] BULPIBEG beginnings of a module for the text editor

Change contents

  • replacement in text_tests.lua at line 249
    [2.8522][2.8522:8691]()
    function test_pagedown_shows_one_screen_line_in_common()
    io.write('\ntest_pagedown_shows_one_screen_line_in_common')
    -- some lines of text with a drawing intermixed
    [2.8522]
    [2.8691]
    function test_pagedown_often_shows_start_of_wrapping_line()
    io.write('\ntest_pagedown_often_shows_start_of_wrapping_line')
    -- draw a few lines ending in part of a wrapping line
  • replacement in text_tests.lua at line 260
    [2.8930][2.8930:9030]()
    App.screen.check(y, 'abc', 'F - test_pagedown_shows_one_screen_line_in_common/baseline/screen:1')
    [2.8930]
    [2.9030]
    App.screen.check(y, 'abc', 'F - test_pagedown_often_shows_start_of_wrapping_line/baseline/screen:1')
  • replacement in text_tests.lua at line 262
    [2.9052][2.9052:9153]()
    App.screen.check(y, 'def ', 'F - test_pagedown_shows_one_screen_line_in_common/baseline/screen:2')
    [2.9052]
    [2.9153]
    App.screen.check(y, 'def ', 'F - test_pagedown_often_shows_start_of_wrapping_line/baseline/screen:2')
  • replacement in text_tests.lua at line 264
    [2.9175][2.9175:9335]()
    App.screen.check(y, 'ghi ', 'F - test_pagedown_shows_one_screen_line_in_common/baseline/screen:3')
    -- after pagedown the bottom screen line becomes the top
    [2.9175]
    [2.9335]
    App.screen.check(y, 'ghi ', 'F - test_pagedown_often_shows_start_of_wrapping_line/baseline/screen:3')
    -- after pagedown we start drawing from the bottom _line_ (multiple screen lines)
  • replacement in text_tests.lua at line 267
    [2.9372][2.9372:9756]()
    check_eq(Screen_top1.line, 2, 'F - test_pagedown_shows_one_screen_line_in_common/screen_top:line')
    check_eq(Screen_top1.pos, 5, 'F - test_pagedown_shows_one_screen_line_in_common/screen_top:pos')
    check_eq(Cursor1.line, 2, 'F - test_pagedown_shows_one_screen_line_in_common/cursor:line')
    check_eq(Cursor1.pos, 5, 'F - test_pagedown_shows_one_screen_line_in_common/cursor:pos')
    [2.9372]
    [2.9756]
    check_eq(Screen_top1.line, 2, 'F - test_pagedown_often_shows_start_of_wrapping_line/screen_top:line')
    check_eq(Screen_top1.pos, 1, 'F - test_pagedown_often_shows_start_of_wrapping_line/screen_top:pos')
    check_eq(Cursor1.line, 2, 'F - test_pagedown_often_shows_start_of_wrapping_line/cursor:line')
    check_eq(Cursor1.pos, 1, 'F - test_pagedown_often_shows_start_of_wrapping_line/cursor:pos')
  • replacement in text_tests.lua at line 272
    [2.9773][2.9773:9865]()
    App.screen.check(y, 'ghi ', 'F - test_pagedown_shows_one_screen_line_in_common/screen:1')
    [2.9773]
    [2.9865]
    App.screen.check(y, 'def ', 'F - test_pagedown_often_shows_start_of_wrapping_line/screen:1')
  • replacement in text_tests.lua at line 274
    [2.9887][2.9887:9978]()
    App.screen.check(y, 'jkl', 'F - test_pagedown_shows_one_screen_line_in_common/screen:2')
    [2.9887]
    [2.9978]
    App.screen.check(y, 'ghi ', 'F - test_pagedown_often_shows_start_of_wrapping_line/screen:2')
  • replacement in text_tests.lua at line 276
    [2.10000][2.10000:10090]()
    App.screen.check(y, 'mn', 'F - test_pagedown_shows_one_screen_line_in_common/screen:3')
    [2.10000]
    [2.10090]
    App.screen.check(y, 'jkl', 'F - test_pagedown_often_shows_start_of_wrapping_line/screen:3')
    end
    function test_pagedown_can_start_from_middle_of_long_wrapping_line()
    io.write('\ntest_pagedown_can_start_from_middle_of_long_wrapping_line')
    -- draw a few lines starting from a very long wrapping line
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc def ghi jkl mno pqr stu vwx yza bcd efg hij', 'XYZ'}
    Line_width = App.screen.width
    Cursor1 = {line=1, pos=2}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    App.draw()
    local y = Margin_top
    App.screen.check(y, 'abc ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/baseline/screen:1')
    y = y + Line_height
    App.screen.check(y, 'def ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/baseline/screen:2')
    y = y + Line_height
    App.screen.check(y, 'ghi ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/baseline/screen:3')
    -- after pagedown we scroll down the very long wrapping line
    App.run_after_keychord('pagedown')
    check_eq(Screen_top1.line, 1, 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/screen_top:line')
    check_eq(Screen_top1.pos, 9, 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/screen_top:pos')
    y = Margin_top
    App.screen.check(y, 'ghi ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/screen:1')
    y = y + Line_height
    App.screen.check(y, 'jkl m', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/screen:2')
    y = y + Line_height
    App.screen.check(y, 'no ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/screen:3')
  • replacement in text.lua at line 398
    [3.883][3.883:963]()
    Screen_top1.line = Screen_bottom1.line
    Screen_top1.pos = Screen_bottom1.pos
    [3.883]
    [3.963]
    -- If a line/paragraph gets to a page boundary, I often want to scroll
    -- before I get to the bottom.
    -- However, only do this if it makes forward progress.
    local top2 = Text.to2(Screen_bottom1)
    if top2.screen_line > 1 then
    top2.screen_line = math.max(top2.screen_line-10, 1)
    end
    local new_top1 = Text.to1(top2)
    if Text.lt1(Screen_top1, new_top1) then
    Screen_top1 = new_top1
    else
    Screen_top1.line = Screen_bottom1.line
    Screen_top1.pos = Screen_bottom1.pos
    end