diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-07-17 09:37:50 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-07-17 09:37:50 -0700 |
commit | 4ff6de99511e0b4c52acc49ec44d773aca63a2fd (patch) | |
tree | 6d25ff2f1d008ebcc1738f91d13109025cbe4b2a | |
parent | 7e7f5b9256078947f9a5cc9b651b6c878fab1627 (diff) | |
download | view.love-4ff6de99511e0b4c52acc49ec44d773aca63a2fd.tar.gz |
switch to line index in a function
- Text.screen_line_width
-rw-r--r-- | text.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/text.lua b/text.lua index 321432f..3af0a13 100644 --- a/text.lua +++ b/text.lua @@ -722,7 +722,7 @@ function Text.to_pos_on_line(State, line_index, mx, my) -- On all wrapped screen lines but the final one, clicks past end of -- line position cursor on final character of screen line. -- (The final screen line positions past end of screen line as always.) - if screen_line_index < #line.screen_line_starting_pos and mx > Text.screen_line_width(line, screen_line_index) then + if screen_line_index < #line.screen_line_starting_pos and mx > Text.screen_line_width(State, line_index, screen_line_index) then --? print('past end of non-final line; return') return line.screen_line_starting_pos[screen_line_index+1]-1 end @@ -735,7 +735,8 @@ function Text.to_pos_on_line(State, line_index, mx, my) assert(false) end -function Text.screen_line_width(line, i) +function Text.screen_line_width(State, line_index, i) + local line = State.lines[line_index] local start_pos = line.screen_line_starting_pos[i] local start_offset = Text.offset(line.data, start_pos) local screen_line |