From f2299cb422d0fc07a1b01f0c31f88e9ae5ab168f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 11 Jun 2024 06:58:07 -0700 Subject: stop caching screen_bottom1 I'm not sure this is very useful. I had an initial idea to stop using screen_bottom1 in final_text_loc_on_screen, by starting from screen_top1 rather than screen_bottom1. But that changes the direction in which we scan for the text line in situations where there is somehow no text on screen (something that should never happen but I have zero confidence in that). Still, it doesn't seem like a bad thing to drastically reduce the lifetime of some derived state. Really what I need to do is throw this whole UX out and allow the cursor to be on a drawing as a whole. So up arrow or left arrow below a drawing would focus the whole drawing in a red border, and another up arrow and left arrow would skip the drawing and continue upward. I think that change to the UX will eliminate a whole class of special cases in the code. --- search.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'search.lua') diff --git a/search.lua b/search.lua index 54bab14..d3a5fea 100644 --- a/search.lua +++ b/search.lua @@ -62,7 +62,8 @@ function Text.search_next(State) State.screen_top1.line = State.search_backup.screen_top.line State.screen_top1.pos = State.search_backup.screen_top.pos end - if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(State.screen_bottom1, State.cursor1) then + local screen_bottom1 = Text.screen_bottom1(State) + if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(screen_bottom1, State.cursor1) then State.screen_top1.line = State.cursor1.line local pos = Text.pos_at_start_of_screen_line(State, State.cursor1) State.screen_top1.pos = pos @@ -115,7 +116,8 @@ function Text.search_previous(State) State.screen_top1.line = State.search_backup.screen_top.line State.screen_top1.pos = State.search_backup.screen_top.pos end - if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(State.screen_bottom1, State.cursor1) then + local screen_bottom1 = Text.screen_bottom1(State) + if Text.lt1(State.cursor1, State.screen_top1) or Text.lt1(screen_bottom1, State.cursor1) then State.screen_top1.line = State.cursor1.line local pos = Text.pos_at_start_of_screen_line(State, State.cursor1) State.screen_top1.pos = pos -- cgit 1.4.1-2-gfad0