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.
This commit is contained in:
parent
f029c710b5
commit
dd899d2096
6
text.lua
6
text.lua
|
@ -156,7 +156,7 @@ function Text.textinput(State, t)
|
||||||
local before = snapshot(State, State.cursor1.line)
|
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)
|
--? 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)
|
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.populate_screen_line_starting_pos(State, State.cursor1.line)
|
||||||
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
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)
|
--? 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)
|
local before = snapshot(State, before_line)
|
||||||
Text.insert_return(State)
|
Text.insert_return(State)
|
||||||
State.selection1 = {}
|
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)
|
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
||||||
end
|
end
|
||||||
schedule_save(State)
|
schedule_save(State)
|
||||||
|
@ -189,7 +189,7 @@ function Text.keychord_pressed(State, chord)
|
||||||
local before = snapshot(State, State.cursor1.line)
|
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)
|
--? 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')
|
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.populate_screen_line_starting_pos(State, State.cursor1.line)
|
||||||
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
|
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)
|
--? print('=>', State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos, State.screen_bottom1.line, State.screen_bottom1.pos)
|
||||||
|
|
Loading…
Reference in New Issue