-- helpers for selecting portions of text
-- draw highlight for line corresponding to (lo,hi) given an approximate x,y and pos on the same screen line
-- Creates text objects every time, so use this sparingly.
-- Returns some intermediate computation useful elsewhere.
if lo then
local lo_px
if pos == lo then
lo_px = 0
else
local before_text = App.newText(love.graphics.getFont(), before)
lo_px = App.width(before_text)
end
--? print(lo,pos,hi, '--', lo_offset,pos_offset,hi_offset, '--', lo_px)
local text = App.newText(love.graphics.getFont(), s)
local text_width = App.width(text)
App.color(Text_color)
return lo_px
end
end
App.color(Highlight_color)
love.graphics.rectangle('fill', x+lo_px,y, text_width,State.line_height)
local s = line.data:sub(lo_offset, hi_offset-1)
local before = line.data:sub(pos_offset, lo_offset-1)
local lo_offset = Text.offset(line.data, lo)
local hi_offset = Text.offset(line.data, hi)
local pos_offset = Text.offset(line.data, pos)
function Text.draw_highlight(State, line, x,y, pos, lo,hi)