Drawings can't be drawn partially, which sometimes makes things jerky.
3OKKTUT4Q7W44JHILOFV5BVUA7ZOBIHBCEXGZ65CPXV4PRLI2W4QC
ESETRNLB3MIJ2SID6HJMMP52FEVUBLGK2HLWD75KDQZAKQMKSF2QC
2RXZ3PGOTTZ6M4R372JXIKPLBQKPVBMAXNPIEO2HZDN4EMYW4GNAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
242L3OQXTU2TCAINRJXQEEDSXQXM7Y7USUPBK37ZNM3A7V5TUDSAC
TRNWIQN6RPLDLYWULLKG5L255E7E3DPNGLCSLAF6IJWYQRCCLARQC
PYGMASTVHDTGX3LDTL364UWXEHVSWQ7STAJLZZI5YY6EA6EEICOAC
DXT4QTAH5G6J7ZB3SMOOXVECKWYUPZVE2ODMUFTPPNHLTOSZLQSAC
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)
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
--? 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
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
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
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