BOFNXP5GZDCUMQG3LQVTSSFEQP7REQ4RIRJLDLETFSAGFTVDVEKAC
DXT4QTAH5G6J7ZB3SMOOXVECKWYUPZVE2ODMUFTPPNHLTOSZLQSAC
DAENUOGV7KR6MZVXS36HEN3SZC4RFIS6REGAFVBOFEPO76EUDGIAC
PHQPLJUQZOYZ7B3IDADDANMVXLKIKTU5DRSSEWTSDYCSDKX7M7JAC
H2DPLWMVRFYTO2CQTG54FMT2LF3B6UKLXH32CUA22DNQJVP5XBNQC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
DLQMM2656JHXX3ONOEM6UIOXKFJFT5QT7RHWK7YS2W77PVZWHRSAC
HYEAFRZ2UEKDYTAE2GDQLHEJBPQASP2NDLMXB7F6MTVK2BKOXKEAC
VVXVV2D2F5Y6D6N5VVPUPK3N6GMDTG2YCYPQDYTYEKVKBYHRRYEAC
JCSLDGAH2F6AIY4Z6XM6K4LOMW7EFY3E4NF5YXLMHLTYTX3A4Z3QC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
UWNHC4AAO3SPOYLPANTO4WKCTZL7KAYC73Q2YUZFFW7K26FVJ7FQC
2INHXC3KRJVZTX2BQ63ZQLHIC5SWPUG4PQKCMLC7SQKN5R7LJZ6QC
return x >= 16 and y >= line.y and y < line.y + math.floor(15*Zoom)
if x < 16 then return false end
if y < line.y then return false end
if line.screen_line_starting_pos == nil then return y < line.y + math.floor(15*Zoom) end
return y < line.y + #line.screen_line_starting_pos * math.floor(15*Zoom)
Cursor_pos = Text.nearest_cursor_pos(line.data, mx)
if line.screen_line_starting_pos == nil then
--? print('single screen line')
Cursor_pos = Text.nearest_cursor_pos(line.data, mx)
return
end
assert(line.fragments)
assert(my >= line.y)
--? print('move_cursor', mx, my)
if my < line.y + math.floor(15*Zoom) then
--? print('first screen line')
Cursor_pos = Text.nearest_cursor_pos(line.data, mx)
return
end
-- duplicate some logic from Text.draw
local y = line.y
for _,screen_line_starting_pos in ipairs(line.screen_line_starting_pos) do
--? print('screen line:', screen_line_starting_pos)
local nexty = y + math.floor(15*Zoom)
if my < nexty then
local s = string.sub(line.data, screen_line_starting_pos)
Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1
return
end
y = nexty
end
assert(false)
-- manual test:
-- line: abc
-- def
-- gh
-- fragments: abc, def, gh
-- click inside e
-- line_starting_pos = 1 + 3 = 4
-- nearest_cursor_pos('defgh', mx) = 2
-- Cursor_pos = 4 + 2 - 1 = 5
-- manual test:
-- click inside h
-- line_starting_pos = 1 + 3 + 3 = 7
-- nearest_cursor_pos('gh', mx) = 2
-- Cursor_pos = 7 + 2 - 1 = 8