From dd899d20964342f22f4a82912d5722a5c9f5e663 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 17 Aug 2022 09:40:44 -0700 Subject: standardize scroll check in a few places I'm taking some lessons from pensieve.love here. It seem like specific pixel thresholds don't matter too much for plain lines.love. I'd probably feel safer if I just used Text.cursor_out_of_screen in these places, but it means we draw the screen twice for most events[1]. Let's see if we can get by with the current approach. [1] Or we have to start scheduling things for the next draw, which is more complex to orchestrate. --- text.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'text.lua') diff --git a/text.lua b/text.lua index 2063512..c67f327 100644 --- a/text.lua +++ b/text.lua @@ -156,7 +156,7 @@ function Text.textinput(State, t) local before = snapshot(State, State.cursor1.line) --? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos) Text.insert_at_cursor(State, t) - if State.cursor_y >= App.screen.height - State.line_height then + if State.cursor_y > App.screen.height - State.line_height then Text.populate_screen_line_starting_pos(State, State.cursor1.line) Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) --? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos) @@ -180,7 +180,7 @@ function Text.keychord_pressed(State, chord) local before = snapshot(State, before_line) Text.insert_return(State) State.selection1 = {} - if (State.cursor_y + State.line_height) > App.screen.height then + if State.cursor_y > App.screen.height - State.line_height then Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) end schedule_save(State) @@ -189,7 +189,7 @@ function Text.keychord_pressed(State, chord) local before = snapshot(State, State.cursor1.line) --? print(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos) Text.insert_at_cursor(State, '\t') - if State.cursor_y >= App.screen.height - State.line_height then + if State.cursor_y > App.screen.height - State.line_height then Text.populate_screen_line_starting_pos(State, State.cursor1.line) Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right) --? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos) -- cgit 1.4.1-2-gfad0