up and down arrow now moving by screen line where possible
[?]
May 22, 2022, 6:02 AM
3OKKTUT4Q7W44JHILOFV5BVUA7ZOBIHBCEXGZ65CPXV4PRLI2W4QCDependencies
- [2]
ESETRNLBbugfix: printing the first part of a line at the bottom made it seem non-wrapping - [3]
TRNWIQN6more precise height calculation when scrolling up as much as possible while keeping cursor on screen - [4]
DXT4QTAHa few more integer coordinates - [5]
2RXZ3PGObeginning of a new approach to scroll+wrap - [6]
BULPIBEGbeginnings of a module for the text editor - [7]
PYGMASTVdisable some debug prints - [8]
PR4KIAZDfirst stab at equally hacky cursor down support - [9]
242L3OQXbugfix: ensure Cursor_line is always on a text line
Change contents
- replacement in text.lua at line 315
print('cursor pos is now '..tostring(Cursor1.pos))print('cursor pos is now', Cursor1.line, Cursor1.pos) - replacement in text.lua at line 366
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)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 endprint('y', y)local h = 0if Lines[Screen_top1.line-1].mode == 'drawing' thenh = 20 + Drawing.pixels(Lines[Screen_top1.line-1].h)elseif Lines[Screen_top1.line-1].screen_line_starting_pos == nil thenh = h + math.floor(15*Zoom) -- text height--? print(y, 'top2:', top2.line, top2.screen_line, top2.screen_pos)if top2.line == 1 and top2.screen_line == 1 then break endif top2.screen_line > 1 or Lines[top2.line-1].mode == 'text' thenlocal h = math.floor(15*Zoom)if y - h < 15 then -- top margin = 15breakendy = 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_posh = h + n*math.floor(15*Zoom) -- text heightendprint('height:', h)if y - h < 0 thenbreakendy = y - hif y < math.floor(15*Zoom) thenbreakassert(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 thenbreakend--? print('skipping drawing of height', h)y = y - h - replacement in text.lua at line 391
Screen_top1.line = Screen_top1.line - 1top2 = Text.previous_screen_line(top2) - edit in text.lua at line 393
--? 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
assert(Lines[pos1.line].mode == 'text') - replacement in text.lua at line 500
if spos <= Cursor1.pos thenif spos <= pos1.pos then - replacement in text.lua at line 502
result.screen_pos = sposresult.screen_pos = pos1.pos - spos + 1 - replacement in text.lua at line 514
result.pos = Lines[pos2.line].screen_line_starting_pos[pos2.screen_line] + pos2.screen_posresult.pos = Lines[pos2.line].screen_line_starting_pos[pos2.screen_line] + pos2.screen_pos - 1 - edit in text.lua at line 517
endfunction Text.previous_screen_line(pos2)if pos2.screen_line > 1 thenreturn {line=pos2.line, screen_line=pos2.screen_line-1, screen_pos=1}elseif pos2.line == 1 thenreturn pos2elseif Lines[pos2.line-1].mode == 'drawing' thenreturn {line=pos2.line-1, screen_line=1, screen_pos=1}elselocal l = Lines[pos2.line-1]if l.screen_line_starting_pos == nil thenreturn {line=pos2.line-1, screen_line=1, screen_pos=1}elsereturn {line=pos2.line-1, screen_line=#Lines[pos2.line-1].screen_line_starting_pos, screen_pos=1}endend