extract a couple more methods
This commit is contained in:
parent
86532eef4b
commit
d58aabe867
60
text.lua
60
text.lua
|
@ -993,36 +993,44 @@ 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
|
||||||
-- duplicate some logic from love.draw
|
Text.pageup()
|
||||||
local top2 = Text.to2(Screen_top1)
|
|
||||||
--? print(App.screen.height)
|
|
||||||
local y = App.screen.height - math.floor(15*Zoom)
|
|
||||||
while y >= 15 do
|
|
||||||
--? print(y, top2.line)
|
|
||||||
if Screen_top1.line == 1 and Screen_top1.pos == 1 then break end
|
|
||||||
if Lines[Screen_top1.line].mode == 'text' then
|
|
||||||
y = y - math.floor(15*Zoom)
|
|
||||||
elseif Lines[Screen_top1.line].mode == 'drawing' then
|
|
||||||
y = y - 20 - Drawing.pixels(Lines[Screen_top1.line].h)
|
|
||||||
end
|
|
||||||
top2 = Text.previous_screen_line(top2)
|
|
||||||
end
|
|
||||||
Screen_top1 = Text.to1(top2)
|
|
||||||
Cursor1.line = Screen_top1.line
|
|
||||||
Cursor1.pos = Screen_top1.pos
|
|
||||||
Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
|
|
||||||
--? print(Cursor1.line, Cursor1.pos, Screen_top1.line, Screen_top1.pos)
|
|
||||||
elseif chord == 'pagedown' then
|
elseif chord == 'pagedown' then
|
||||||
Screen_top1.line = Screen_bottom1.line
|
Text.pagedown()
|
||||||
Screen_top1.pos = Screen_bottom1.pos
|
|
||||||
--? print('setting top to', Screen_top1.line, Screen_top1.pos)
|
|
||||||
Cursor1.line = Screen_top1.line
|
|
||||||
Cursor1.pos = Screen_top1.pos
|
|
||||||
Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
|
|
||||||
--? print('top now', Screen_top1.line)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Text.pageup()
|
||||||
|
-- duplicate some logic from love.draw
|
||||||
|
local top2 = Text.to2(Screen_top1)
|
||||||
|
--? print(App.screen.height)
|
||||||
|
local y = App.screen.height - math.floor(15*Zoom)
|
||||||
|
while y >= 15 do
|
||||||
|
--? print(y, top2.line)
|
||||||
|
if Screen_top1.line == 1 and Screen_top1.pos == 1 then break end
|
||||||
|
if Lines[Screen_top1.line].mode == 'text' then
|
||||||
|
y = y - math.floor(15*Zoom)
|
||||||
|
elseif Lines[Screen_top1.line].mode == 'drawing' then
|
||||||
|
y = y - 20 - Drawing.pixels(Lines[Screen_top1.line].h)
|
||||||
|
end
|
||||||
|
top2 = Text.previous_screen_line(top2)
|
||||||
|
end
|
||||||
|
Screen_top1 = Text.to1(top2)
|
||||||
|
Cursor1.line = Screen_top1.line
|
||||||
|
Cursor1.pos = Screen_top1.pos
|
||||||
|
Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
|
||||||
|
--? print(Cursor1.line, Cursor1.pos, Screen_top1.line, Screen_top1.pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Text.pagedown()
|
||||||
|
Screen_top1.line = Screen_bottom1.line
|
||||||
|
Screen_top1.pos = Screen_bottom1.pos
|
||||||
|
--? print('setting top to', Screen_top1.line, Screen_top1.pos)
|
||||||
|
Cursor1.line = Screen_top1.line
|
||||||
|
Cursor1.pos = Screen_top1.pos
|
||||||
|
Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary()
|
||||||
|
--? print('top now', Screen_top1.line)
|
||||||
|
end
|
||||||
|
|
||||||
function Text.up()
|
function Text.up()
|
||||||
assert(Lines[Cursor1.line].mode == 'text')
|
assert(Lines[Cursor1.line].mode == 'text')
|
||||||
--? print('up', Cursor1.pos, Screen_top1.pos)
|
--? print('up', Cursor1.pos, Screen_top1.pos)
|
||||||
|
|
Loading…
Reference in New Issue