up and down arrow now moving by screen line where possible

[?]
May 22, 2022, 6:02 AM
3OKKTUT4Q7W44JHILOFV5BVUA7ZOBIHBCEXGZ65CPXV4PRLI2W4QC

Dependencies

  • [2] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [3] TRNWIQN6 more precise height calculation when scrolling up as much as possible while keeping cursor on screen
  • [4] DXT4QTAH a few more integer coordinates
  • [5] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [6] BULPIBEG beginnings of a module for the text editor
  • [7] PYGMASTV disable some debug prints
  • [8] PR4KIAZD first stab at equally hacky cursor down support
  • [9] 242L3OQX bugfix: ensure Cursor_line is always on a text line

Change contents

  • replacement in text.lua at line 315
    [3.6080][2.925:982]()
    print('cursor pos is now '..tostring(Cursor1.pos))
    [3.6080]
    [3.6141]
    print('cursor pos is now', Cursor1.line, Cursor1.pos)
  • replacement in text.lua at line 366
    [3.589][2.1267:1484]()
    local cursor2 = Text.to2(Cursor1)
    print('cursor pos '..tostring(Cursor1.pos)..' is on the #'..tostring(cursor2.screen_line)..' screen line down')
    local y = Screen_height - cursor2.screen_pos*math.floor(15*Zoom)
    [3.589]
    [3.455]
    local top2 = Text.to2(Cursor1)
    --? print('cursor pos '..tostring(Cursor1.pos)..' is on the #'..tostring(top2.screen_line)..' screen line down')
    local y = Screen_height - math.floor(15*Zoom)
  • replacement in text.lua at line 371
    [3.660][3.7076:7120](),[3.7120][2.1485:1503](),[2.1503][3.515:531](),[3.1741][3.515:531](),[3.515][3.515:531](),[3.531][3.7121:7310](),[3.7310][3.717:767](),[3.717][3.717:767]()
    if Screen_top1.line == 1 then break end
    print('y', y)
    local h = 0
    if Lines[Screen_top1.line-1].mode == 'drawing' then
    h = 20 + Drawing.pixels(Lines[Screen_top1.line-1].h)
    elseif Lines[Screen_top1.line-1].screen_line_starting_pos == nil then
    h = h + math.floor(15*Zoom) -- text height
    [3.660]
    [3.767]
    --? print(y, 'top2:', top2.line, top2.screen_line, top2.screen_pos)
    if top2.line == 1 and top2.screen_line == 1 then break end
    if top2.screen_line > 1 or Lines[top2.line-1].mode == 'text' then
    local h = math.floor(15*Zoom)
    if y - h < 15 then -- top margin = 15
    break
    end
    y = y - h
  • replacement in text.lua at line 380
    [3.776][3.7311:7379](),[3.7379][3.843:903](),[3.843][3.843:903](),[3.903][2.1504:1528](),[2.1528][3.927:961](),[3.1770][3.927:961](),[3.927][3.927:961](),[3.961][3.831:839](),[3.831][3.831:839](),[3.839][3.962:976](),[3.976][3.102:138](),[3.839][3.102:138](),[3.138][3.863:875](),[3.863][3.863:875]()
    local n = #Lines[Screen_top1.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
    end
    y = y - h
    if y < math.floor(15*Zoom) then
    break
    [3.776]
    [3.875]
    assert(top2.line > 1)
    assert(Lines[top2.line-1].mode == 'drawing')
    -- We currently can't draw partial drawings, so either skip it entirely
    -- or not at all.
    local h = 20 + Drawing.pixels(Lines[Screen_top1.line-1].h)
    if y - h < 15 then
    break
    end
    --? print('skipping drawing of height', h)
    y = y - h
  • replacement in text.lua at line 391
    [3.883][3.7380:7424]()
    Screen_top1.line = Screen_top1.line - 1
    [3.883]
    [3.925]
    top2 = Text.previous_screen_line(top2)
  • edit in text.lua at line 393
    [3.931]
    [3.931]
    --? print('top2 finally:', top2.line, top2.screen_line, top2.screen_pos)
    Screen_top1 = Text.to1(top2)
    --? print('top1 finally:', Screen_top1.line, Screen_top1.pos)
  • edit in text.lua at line 493
    [3.7759]
    [3.7759]
    assert(Lines[pos1.line].mode == 'text')
  • replacement in text.lua at line 500
    [3.8031][3.8031:8065]()
    if spos <= Cursor1.pos then
    [3.8031]
    [3.8065]
    if spos <= pos1.pos then
  • replacement in text.lua at line 502
    [3.8096][3.8096:8129]()
    result.screen_pos = spos
    [3.8096]
    [3.8129]
    result.screen_pos = pos1.pos - spos + 1
  • replacement in text.lua at line 514
    [3.8326][3.8326:8421]()
    result.pos = Lines[pos2.line].screen_line_starting_pos[pos2.screen_line] + pos2.screen_pos
    [3.8326]
    [3.8421]
    result.pos = Lines[pos2.line].screen_line_starting_pos[pos2.screen_line] + pos2.screen_pos - 1
  • edit in text.lua at line 517
    [3.8443]
    [3.8443]
    end
    function Text.previous_screen_line(pos2)
    if pos2.screen_line > 1 then
    return {line=pos2.line, screen_line=pos2.screen_line-1, screen_pos=1}
    elseif pos2.line == 1 then
    return pos2
    elseif Lines[pos2.line-1].mode == 'drawing' then
    return {line=pos2.line-1, screen_line=1, screen_pos=1}
    else
    local l = Lines[pos2.line-1]
    if l.screen_line_starting_pos == nil then
    return {line=pos2.line-1, screen_line=1, screen_pos=1}
    else
    return {line=pos2.line-1, screen_line=#Lines[pos2.line-1].screen_line_starting_pos, screen_pos=1}
    end
    end