RJGZD4INLQ3IAWLCBYBZQDMP4ICSMZWJX2TRYODDYVUNMGPL6GYAC
local line_before_cursor = lines[cursor_line]:sub(1, cursor_pos-1)
local text_before_cursor = love.graphics.newText(love.graphics.getFont(), line_before_cursor)
love.graphics.print('_', 25+text_before_cursor:getWidth()*1.5, y+6) -- drop the cursor down a bit to account for the increased font size
love.graphics.print('_', 25+cursor_x(lines[cursor_line], cursor_pos)*1.5, y+6) -- drop the cursor down a bit to account for the increased font size
end
end
end
function cursor_x(line, cursor_pos)
local line_before_cursor = line:sub(1, cursor_pos-1)
local text_before_cursor = love.graphics.newText(love.graphics.getFont(), line_before_cursor)
return text_before_cursor:getWidth()
end
function nearest_cursor_pos(line, x)
if x == 0 then
return 1
end
local left, right = 1, #line+1
while left < right-1 do
local curr = math.floor((left+right)/2)
local currx = cursor_x(line, curr)
if currx > x-2 and currx < x+2 then
return curr