extract a variable

This commit is contained in:
Kartik K. Agaram 2023-07-31 08:49:24 -07:00
parent d6c06db97a
commit 8879fd6f29
2 changed files with 4 additions and 2 deletions

View File

@ -58,7 +58,8 @@ function Text.draw(State, line_index, y, startpos, hide_cursor)
local data = State.lines[State.cursor1.line].data
local cursor_offset = Text.offset(data, State.cursor1.pos)
if data:sub(cursor_offset, cursor_offset+#State.search_term-1) == State.search_term then
local lo_px = Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term))
local hi = State.cursor1.pos+utf8.len(State.search_term)
local lo_px = Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, hi)
App.color(Text_color)
love.graphics.print(State.search_term, State.left+lo_px,y)
end

View File

@ -36,7 +36,8 @@ function Text.draw(State, line_index, y, startpos)
local data = State.lines[State.cursor1.line].data
local cursor_offset = Text.offset(data, State.cursor1.pos)
if data:sub(cursor_offset, cursor_offset+#State.search_term-1) == State.search_term then
local lo_px = Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term))
local hi = State.cursor1.pos+utf8.len(State.search_term)
local lo_px = Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, hi)
App.color(Text_color)
love.graphics.print(State.search_term, State.left+lo_px,y)
end