This is probably not worth the effort. First sign of trouble, back it out.
PRPPZGDYFTLRYL4NHUXOXNQKF2LJ4XEOGJDN36DZWBQY6D3K3MGAC
RJGZD4INLQ3IAWLCBYBZQDMP4ICSMZWJX2TRYODDYVUNMGPL6GYAC
3CS5KKCIZQ6J4SBILINYZSOM6V3U2LE7YIXOZVKXXNBROF6Z6JWAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
IYW7X3WLOPYLSNO5IQNSULUNO4XFEM24DJ2VB5HPBUKWUYFPRCGQC
cursor_pos = nearest_cursor_pos(lines[cursor_line], old_x)
cursor_pos = nearest_cursor_pos(lines[cursor_line], old_x, cursor_pos)
function nearest_cursor_pos(line, x)
function nearest_cursor_pos(line, x, hint)
local max_x = cursor_x(line, #line+1) if x > max_x then return #line+1 end local currx = cursor_x(line, hint) if currx > x-2 and currx < x+2 then return hint end
local max_x = cursor_x(line, #line+1)
if x > max_x then
return #line+1
end
local currx = cursor_x(line, hint)
if currx > x-2 and currx < x+2 then
return hint
if currx > x then right = hint else left = hint end
if currx > x then
right = hint
else
left = hint