more precise height calculation when scrolling up as much as possible while keeping cursor on screen

[?]
May 21, 2022, 5:43 AM
TRNWIQN6RPLDLYWULLKG5L255E7E3DPNGLCSLAF6IJWYQRCCLARQC

Dependencies

  • [2] 2POFQQLW keep cursor on screen when pressing 'down'
  • [3] 242L3OQX bugfix: ensure Cursor_line is always on a text line
  • [4] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [5] PR4KIAZD first stab at equally hacky cursor down support
  • [6] DXT4QTAH a few more integer coordinates
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] XNFTJHC4 split keyboard handling between Text and Drawing
  • [*] SVJZZDC3 snapshot - no, that's all wrong

Change contents

  • edit in text.lua at line 297
    [9.4909]
    [3.923]
    print('=>', Cursor_line, Cursor_pos, Screen_bottom_line)
  • edit in text.lua at line 308
    [2.158]
    [3.1620]
    print('scroll up preserving cursor')
  • edit in text.lua at line 310
    [3.1666]
    [10.1313]
    print('screen top after:', Screen_top_line, Top_screen_line_starting_pos)
  • replacement in text.lua at line 356
    [3.589][3.1:68]()
    local y = Screen_height - math.floor(15*Zoom) -- for Cursor_line
    [3.589]
    [3.644]
    local cursor_pos_screen_lines = Text.pos_at_start_of_cursor_screen_line()
    print('cursor pos '..tostring(Cursor_pos)..' is on the #'..tostring(cursor_pos_screen_lines)..' screen line down')
    local y = Screen_height - cursor_pos_screen_lines*math.floor(15*Zoom)
    -- duplicate some logic from love.draw
  • replacement in text.lua at line 362
    [3.703][3.69:101](),[3.101][3.723:831](),[3.723][3.723:831]()
    y = y - math.floor(15*Zoom)
    if Lines[Screen_top_line].mode == 'drawing' then
    y = y - Drawing.pixels(Lines[Screen_top_line].h)
    [3.703]
    [3.831]
    print('y', y)
    local h = 0
    if Lines[Screen_top_line-1].mode == 'drawing' then
    h = 20 + Drawing.pixels(Lines[Screen_top_line-1].h)
    elseif Lines[Screen_top_line-1].screen_line_starting_pos == nil then
    h = h + math.floor(15*Zoom) -- text height
    else
    local n = #Lines[Screen_top_line-1].screen_line_starting_pos
    h = h + n*math.floor(15*Zoom) -- text height
    end
    print('height:', h)
    if y - h < 0 then
    break
  • edit in text.lua at line 376
    [3.839]
    [3.102]
    y = y - h