extract a couple more methods

This commit is contained in:
Kartik K. Agaram 2022-05-28 22:45:53 -07:00
parent 86532eef4b
commit d58aabe867
1 changed files with 34 additions and 26 deletions

View File

@ -993,6 +993,13 @@ function Text.keychord_pressed(chord)
elseif chord == 'down' then elseif chord == 'down' then
Text.down() Text.down()
elseif chord == 'pageup' then elseif chord == 'pageup' then
Text.pageup()
elseif chord == 'pagedown' then
Text.pagedown()
end
end
function Text.pageup()
-- duplicate some logic from love.draw -- duplicate some logic from love.draw
local top2 = Text.to2(Screen_top1) local top2 = Text.to2(Screen_top1)
--? print(App.screen.height) --? print(App.screen.height)
@ -1012,7 +1019,9 @@ function Text.keychord_pressed(chord)
Cursor1.pos = Screen_top1.pos Cursor1.pos = Screen_top1.pos
Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary() Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
--? print(Cursor1.line, Cursor1.pos, Screen_top1.line, Screen_top1.pos) --? print(Cursor1.line, Cursor1.pos, Screen_top1.line, Screen_top1.pos)
elseif chord == 'pagedown' then end
function Text.pagedown()
Screen_top1.line = Screen_bottom1.line Screen_top1.line = Screen_bottom1.line
Screen_top1.pos = Screen_bottom1.pos Screen_top1.pos = Screen_bottom1.pos
--? print('setting top to', Screen_top1.line, Screen_top1.pos) --? print('setting top to', Screen_top1.line, Screen_top1.pos)
@ -1021,7 +1030,6 @@ function Text.keychord_pressed(chord)
Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary() Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
--? print('top now', Screen_top1.line) --? print('top now', Screen_top1.line)
end end
end
function Text.up() function Text.up()
assert(Lines[Cursor1.line].mode == 'text') assert(Lines[Cursor1.line].mode == 'text')