keep one screen line of overlap on pagedown

[?]
May 24, 2022, 5:31 AM
LERERVPHE5SEWDHQ7IAGQSXUAI2QHQJ33NBNRMRXZ34X7P23I2IAC

Dependencies

  • [2] H22OAXWE couple of TODOs
  • [3] A2NV3WVO scrolling with up arrow
  • [4] 5L7K4GBD clicking to the right of a wrapped line
  • [5] 537TQ2QN some more logging
  • [6] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [7] CVGE3SIG I feel confident now that page-down is working.
  • [8] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [9] MDXGMZU2 disable all debug prints
  • [10] JY4VK7L2 rename
  • [11] JRGTJ2IW quite the frustrating bugfix
  • [12] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [13] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [14] MGT5FTJ3 first stab at supporting wrapping in cursor up
  • [15] WLHI7KD3 new globals: draw partial screen line up top
  • [16] U7M4M2F7 bugfix: don't rely on Screen_bottom1 while scrolling
  • [17] YTSPVDZH first successful pagedown test, first bug found by test
  • [18] S5VCAFKY couple of tests for cursor down
  • [19] QYIFOHW3 first test!
  • [20] IMEJA43L snapshot
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] OTIBCAUJ love2d scaffold

Change contents

  • replacement in text.lua at line 22
    [4.1901][2.1:84]()
    line.screen_line_starting_pos = nil -- TODO: avoid recomputing on every repaint
    [4.1901]
    [4.32]
    if line.screen_line_starting_pos == nil then
    Text.populate_screen_line_starting_pos(line_index)
    end
  • replacement in text.lua at line 31
    [4.22][4.1:184]()
    --? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(line_width)..') '..s(line_index)..' vs '..s(Screen_top1.line)..'; '..s(pos)..' vs '..s(Screen_top1.pos))
    [4.22]
    [4.2068]
    --? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(line_width)..') '..s(line_index)..' vs '..s(Screen_top1.line)..'; '..s(pos)..' vs '..s(Screen_top1.pos)..'; bottom: '..s(Screen_bottom1.line)..'/'..s(Screen_bottom1.pos))
  • replacement in text.lua at line 37
    [4.119][3.181:272]()
    --? print('text: new screen line', y, App.screen.height, screen_line_starting_pos)
    [4.119]
    [4.255]
    if y + math.floor(15*Zoom) > App.screen.height then
    --? print('b', y, App.screen.height, '=>', screen_line_starting_pos)
    return y, screen_line_starting_pos
    end
  • edit in text.lua at line 42
    [4.294]
    [4.76]
    --? print('text: new screen line', y, App.screen.height, screen_line_starting_pos)
  • edit in text.lua at line 46
    [4.2198][4.1:169](),[4.169][4.105:115](),[4.115][4.244:306](),[4.306][3.273:379](),[3.379][4.326:349](),[4.326][4.326:349](),[4.349][4.326:386](),[4.326][4.326:386](),[4.386][4.350:397](),[4.170][4.241:298](),[4.264][4.241:298](),[4.397][4.241:298](),[4.241][4.241:298](),[4.298][4.169:179](),[4.169][4.169:179]()
    if line.screen_line_starting_pos == nil then
    line.screen_line_starting_pos = {1, pos}
    else
    table.insert(line.screen_line_starting_pos, pos)
    end
    -- if we updated y, check if we're done with the screen
    if line_index > Screen_top1.line or (line_index == Screen_top1.line and pos > Screen_top1.pos) then
    --? print('a')
    if y + math.floor(15*Zoom) > App.screen.height then
    --? print('b', y, App.screen.height)
    return y, screen_line_starting_pos
    end
    end
  • replacement in text.lua at line 47
    [4.2206][4.71:152]()
    if Debug_new_render then print('checking to draw', pos, Screen_top1.pos) end
    [4.2206]
    [4.387]
    --? print('checking to draw', pos, Screen_top1.pos)
  • edit in text.lua at line 144
    [4.1590][4.283:308]()
    local text height = 15
  • edit in text.lua at line 159
    [4.379]
    [4.379]
    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
    App.screen.init{width=50, height=60}
    Lines = load_array{'abc', 'def ghi jkl', 'mno'}
    Line_width = App.screen.width
    Cursor1 = {line=1, 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_pagedown_shows_one_screen_line_in_common/baseline/screen:1')
    y = y + line_height
    App.screen.check(y, 'def ', 'F - test_pagedown_shows_one_screen_line_in_common/baseline/screen:2')
    y = y + line_height
    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
    App.run_after_keychord('pagedown')
    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')
    y = screen_top_margin
    App.screen.check(y, 'ghi ', 'F - test_pagedown_shows_one_screen_line_in_common/screen:1')
    y = y + line_height
    App.screen.check(y, 'jkl', 'F - test_pagedown_shows_one_screen_line_in_common/screen:2')
    y = y + line_height
    App.screen.check(y, 'mn', 'F - test_pagedown_shows_one_screen_line_in_common/screen:3')
    end
  • replacement in main.lua at line 238
    [4.562][4.1585:1635]()
    --? print('setting top to', Screen_top1.line)
    [4.562]
    [4.9557]
    --? print('setting top to', Screen_top1.line, Screen_top1.pos)