snapshot

[?]
May 23, 2022, 10:22 PM
IMEJA43L3OX7S5KIYLZJ4F3ITACLAA5SZBHSCIJMULCPRSW7LXBAC

Dependencies

  • [2] XOAHJ6M3 similar tests for cursor up
  • [3] PFT5Y2ZY move
  • [4] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [5] AVTNUQYR basic test-enabled framework
  • [6] YTSPVDZH first successful pagedown test, first bug found by test
  • [7] 76AIXR7H bugfix
  • [8] U7M4M2F7 bugfix: don't rely on Screen_bottom1 while scrolling
  • [9] QYIFOHW3 first test!
  • [10] BULPIBEG beginnings of a module for the text editor
  • [11] S5VCAFKY couple of tests for cursor down
  • [12] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [*] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [*] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [*] 3QNOKBFM beginnings of a test harness

Change contents

  • edit in text.lua at line 28
    [3.62]
    [14.2068]
    print(x, frag, frag_width, line_width)
  • edit in text.lua at line 31
    [14.2151]
    [3.1]
    -- I no longer remember why the fuck I added this
  • edit in text.lua at line 44
    [15.115]
    [15.115]
    print(line_index, Screen_top1.line, pos, Screen_top1.pos)
  • edit in text.lua at line 46
    [15.184]
    [3.109]
    print('a')
  • edit in text.lua at line 48
    [3.170]
    [15.241]
    print('b', y, App.screen.height)
  • replacement in text.lua at line 91
    [3.219][3.219:238]()
    Line_width = 120
    [3.219]
    [3.238]
    Line_width = App.screen.width
  • replacement in text.lua at line 111
    [3.330][3.330:349]()
    Line_width = 120
    [3.330]
    [3.349]
    Line_width = App.screen.width
  • edit in text.lua at line 126
    [3.876]
    [3.876]
    check_eq(Screen_top1.line, 2, 'F - test_pagedown/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_pagedown/cursor')
  • replacement in text.lua at line 156
    [3.254][3.1847:1902](),[3.1847][3.1847:1902]()
    -- after pagedown the screen draws the screen up top
    [3.254]
    [3.539]
    -- after pagedown the screen draws the drawing up top
  • replacement in text.lua at line 159
    [3.1939][3.255:299]()
    --? print('test: top:', Screen_top1.line)
    [3.1939]
    [3.1939]
    check_eq(Screen_top1.line, 2, 'F - test_pagedown_skips_drawings/screen_top')
    check_eq(Cursor1.line, 3, 'F - test_pagedown_skips_drawings/cursor')
  • replacement in text.lua at line 169
    [3.548][3.548:567]()
    Line_width = 120
    [3.548]
    [3.567]
    Line_width = App.screen.width
  • replacement in text.lua at line 184
    [3.1142][3.1142:1200]()
    -- after hitting the down arrow the screen is unchanged
    [3.1142]
    [3.1200]
    -- after hitting the down arrow, the cursor moves down by 1 line
  • edit in text.lua at line 186
    [3.1233]
    [3.1233]
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_down_arrow_moves_cursor/cursor')
    -- the screen is unchanged
  • edit in text.lua at line 195
    [3.1523][3.1523:1564](),[3.1564][2.27:104](),[2.104][3.1564:1635](),[3.1564][3.1564:1635]()
    -- but the cursor moves down by 1 line
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_down_arrow_moves_cursor/cursor')
  • replacement in text.lua at line 202
    [3.1903][3.1903:1922]()
    Line_width = 120
    [3.1903]
    [3.1922]
    Line_width = App.screen.width
  • edit in text.lua at line 218
    [3.2585]
    [3.2585]
    check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_line/screen_top')
    check_eq(Cursor1.line, 4, 'F - test_down_arrow_scrolls_down_by_one_line/cursor')
  • replacement in text.lua at line 226
    [3.2911][2.105:279]()
    check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_line/screen_top')
    check_eq(Cursor1.line, 4, 'F - test_down_arrow_scrolls_down_by_one_line/cursor')
    [3.2911]
    [2.279]
    end
    function test_down_arrow_scrolls_down_by_one_screen_line()
    print('test_down_arrow_scrolls_down_by_one_screen_line')
    -- display the first three lines with the cursor on the bottom line
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
    Line_width = App.screen.width
    Cursor1 = {line=3, pos=1}
    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_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi ', 'F - test_down_arrow_scrolls_down_by_one_screen_line/baseline/screen:3') -- line wrapping includes trailing whitespace
    -- after hitting the down arrow the screen scrolls down by one line
    App.run_after_keychord('down')
    check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen_top')
    check_eq(Cursor1.line, 3, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:line')
    check_eq(Cursor1.pos, 5, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:pos')
    y = screen_top_margin
    App.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen:1')
    y = y + line_height
    App.screen.check(y, 'ghi ', 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen:2')
    y = y + line_height
    -- HERE
    App.screen.check(y, 'jkl', 'F - test_down_arrow_scrolls_down_by_one_screen_line/screen:3')
    end
    function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word()
    print('test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word')
    -- display the first three lines with the cursor on the bottom line
    App.screen.init{width=25+30, height=60}
    Lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
    Line_width = App.screen.width
    Cursor1 = {line=3, pos=1}
    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_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghijk', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/baseline/screen:3')
    -- after hitting the down arrow the screen scrolls down by one line
    App.run_after_keychord('down')
    check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen_top')
    check_eq(Cursor1.line, 3, 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/cursor:line')
    check_eq(Cursor1.pos, 6, 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/cursor:pos')
    y = screen_top_margin
    App.screen.check(y, 'def', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:1')
    y = y + line_height
    App.screen.check(y, 'ghijk', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:2')
    y = y + line_height
    App.screen.check(y, 'l', 'F - test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word/screen:3')
  • replacement in text.lua at line 312
    [2.1052][2.1052:1108]()
    -- after hitting the up arrow the screen is unchanged
    [2.1052]
    [2.1108]
    -- after hitting the up arrow the cursor moves up by 1 line
  • edit in text.lua at line 314
    [2.1139]
    [2.1139]
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_up_arrow_moves_cursor/cursor')
    -- the screen is unchanged
  • edit in text.lua at line 323
    [2.1423][2.1423:1608]()
    -- but the cursor moves up by 1 line
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')
    check_eq(Cursor1.line, 2, 'F - test_up_arrow_moves_cursor/cursor')
  • edit in text.lua at line 346
    [2.2517]
    [2.2517]
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/screen_top')
    check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/cursor')
  • replacement in text.lua at line 354
    [2.2831][2.2831:2997]()
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/screen_top')
    check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/cursor')
    [2.2831]
    [3.2148]
    end
    function test_up_arrow_scrolls_up_by_one_screen_line()
    print('test_up_arrow_scrolls_up_by_one_screen_line')
    -- display the lines 2/3/4 with the cursor on line 2
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
    Line_width = App.screen.width
    Cursor1 = {line=2, pos=1}
    Screen_top1 = {line=2, 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, 'def', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:2')
    y = y + line_height
    App.screen.check(y, 'jkl', 'F - test_up_arrow_scrolls_up_by_one_screen_line/baseline/screen:3')
    -- after hitting the up arrow the screen scrolls up by one line
    App.run_after_keychord('up')
    y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen:3')
    check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_screen_line/screen_top')
    check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_screen_line/cursor')
  • edit in text.lua at line 388
    [3.51]
    [3.51]
    --? print('compute_fragments')
  • edit in text.lua at line 398
    [3.493]
    [3.493]
    assert(25 + frag_width > line_width) -- avoid infinite loop when window is too narrow
  • edit in text.lua at line 401
    [3.571]
    [3.571]
    print(frag, x, frag_width, line_width)
  • replacement in text.lua at line 404
    [3.672][3.672:738]()
    local b = Text.nearest_cursor_pos(frag, line_width - x)
    [3.672]
    [3.738]
    local b = Text.nearest_pos_less_than(frag, line_width - x)
  • replacement in text.lua at line 408
    [3.882][3.882:951]()
    local frag1_width = math.floor(frag1App.width(_text)*Zoom)
    [3.882]
    [3.998]
    local frag1_width = math.floor(App.width(frag1_text)*Zoom)
    print(frag, x, frag1_width, line_width)
    assert(x + frag1_width <= line_width)
  • replacement in text.lua at line 766
    [3.469][3.157:199]()
    function Text.nearest_cursor_pos(line, x)
    [3.469]
    [3.517]
    function Text.nearest_cursor_pos(line, x) -- x includes left margin
  • edit in text.lua at line 797
    [3.1184]
    [3.1184]
    function Text.nearest_pos_less_than(line, x) -- x DOES NOT include left margin
    if x == 0 then
    return 1
    end
    local len = utf8.len(line)
    local max_x = Text.cursor_x2(line, len+1)
    if x > max_x then
    return len+1
    end
    local left, right = 1, len+1
    --? print('--')
    while true do
    local curr = math.floor((left+right)/2)
    local currxmin = Text.cursor_x2(line, curr+1)
    local currxmax = Text.cursor_x2(line, curr+2)
    --? print(x, left, right, curr, currxmin, currxmax)
    if currxmin <= x and x < currxmax then
    return curr
    end
    if left >= right-1 then
    return left
    end
    if currxmin > x then
    right = curr
    else
    left = curr
    end
    end
    assert(false)
    end
  • edit in app.lua at line 202
    [3.7421]
    [3.7421]
    local sorted_names = {}
  • edit in app.lua at line 205
    [3.7492]
    [3.7492]
    table.insert(sorted_names, name)
    end
    end
    table.sort(sorted_names)
    for _,name in ipairs(sorted_names) do
    if name:find('test_') == 1 then
  • replacement in app.lua at line 212
    [3.7524][3.7524:7540]()
    binding()
    [3.7524]
    [3.7540]
    _G[name]()