about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-08-17 09:40:44 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-17 09:40:44 -0700
commitdd899d20964342f22f4a82912d5722a5c9f5e663 (patch)
tree588c76329ee7101915237466292b822a21456db9 /text.lua
parentf029c710b5f9c8af00d4146af57cbfb8dcda29e8 (diff)
downloadlines.love-dd899d20964342f22f4a82912d5722a5c9f5e663.tar.gz
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.
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua6
1 files changed, 3 insertions, 3 deletions
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)