diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-07-31 08:49:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-07-31 08:49:24 -0700 |
commit | 8879fd6f29c1c997a87afe33167d634f7294e397 (patch) | |
tree | 3f442aac8b9e04e8dda17ef5e3618726426381a8 | |
parent | d6c06db97a89efff37d9d1c1d92669c5ab945dba (diff) | |
download | lines.love-8879fd6f29c1c997a87afe33167d634f7294e397.tar.gz |
extract a variable
-rw-r--r-- | source_text.lua | 3 | ||||
-rw-r--r-- | text.lua | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/source_text.lua b/source_text.lua index 98045be..2c33159 100644 --- a/source_text.lua +++ b/source_text.lua @@ -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 diff --git a/text.lua b/text.lua index 2825dac..a477c4f 100644 --- a/text.lua +++ b/text.lua @@ -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 |