It wasn't screen-line aware. Now it is.
4RUI5X52CSQODLT3WI4VBMXWZLACBYV5QANGDKRWS3VONZPVSEEQC
R53OF3ONKT5VL5BGK63YSN6GXIIAVNYDG4UMHITK72WXFWPJ25MQC
PFT5Y2ZYGQA6XXOZ5HH75WVUGA4B3KTDRHSFOZRAUKTPSFOPMNRAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
IRV65LZPHFLLYPTMLTDO6OJDHVZQJ6MFXZ45IRXRDSRSEQNO5DIAC
OIB2QPRCB4MAVZV5NCEKSAL45ITT6V4BYSET3Q2VCT3WBOIC4QVQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
V5TP27FPD6GPATHPABRW2FKP7BIKY53KL47UVEU5DF4WXEZF7CKAC
DLQMM2656JHXX3ONOEM6UIOXKFJFT5QT7RHWK7YS2W77PVZWHRSAC
2RXZ3PGOTTZ6M4R372JXIKPLBQKPVBMAXNPIEO2HZDN4EMYW4GNAC
DXT4QTAH5G6J7ZB3SMOOXVECKWYUPZVE2ODMUFTPPNHLTOSZLQSAC
252M2QMDBMNWHBZY5MDSC7WVYO5JBLJYPVMW5W4IVJCZVYRQ5IQQC
242L3OQXTU2TCAINRJXQEEDSXQXM7Y7USUPBK37ZNM3A7V5TUDSAC
XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC
function test_pageup()
io.write('\ntest_pageup')
App.screen.init{width=120, height=45}
Lines = load_array{'abc', 'def', 'ghi'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {}
Zoom = 1
local screen_top_margin = 15 -- pixels
local line_height = math.floor(15*Zoom) -- pixels
-- initially the last two lines are displayed
App.draw()
local y = screen_top_margin
App.screen.check(y, 'def', 'F - test_pageup/baseline/screen:1')
y = y + line_height
App.screen.check(y, 'ghi', 'F - test_pageup/baseline/screen:2')
-- after pageup the cursor goes to first line
App.run_after_keychord('pageup')
check_eq(Screen_top1.line, 1, 'F - test_pageup/screen_top')
check_eq(Cursor1.line, 1, 'F - test_pageup/cursor')
y = screen_top_margin
App.screen.check(y, 'abc', 'F - test_pageup/screen:1')
y = y + line_height
App.screen.check(y, 'def', 'F - test_pageup/screen:2')
end
function test_pageup_scrolls_up_by_screen_line()
io.write('\ntest_pageup_scrolls_up_by_screen_line')
-- display the first three lines with the cursor on the bottom line
App.screen.init{width=25+30, height=60}
Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {}
Zoom = 1
local screen_top_margin = 15 -- pixels
local line_height = math.floor(15*Zoom) -- pixels
App.draw()
local y = screen_top_margin
App.screen.check(y, 'ghi', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:1')
y = y + line_height
App.screen.check(y, 'jkl', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:2')
y = y + line_height
App.screen.check(y, 'mno', 'F - test_pageup_scrolls_up_by_screen_line/baseline/screen:3') -- line wrapping includes trailing whitespace
-- after hitting the page-up key the screen scrolls up to top
App.run_after_keychord('pageup')
check_eq(Screen_top1.line, 1, 'F - test_pageup_scrolls_up_by_screen_line/screen_top')
check_eq(Cursor1.line, 1, 'F - test_pageup_scrolls_up_by_screen_line/cursor:line')
check_eq(Cursor1.pos, 1, 'F - test_pageup_scrolls_up_by_screen_line/cursor:pos')
y = screen_top_margin
App.screen.check(y, 'abc ', 'F - test_pageup_scrolls_up_by_screen_line/screen:1')
y = y + line_height
App.screen.check(y, 'def', 'F - test_pageup_scrolls_up_by_screen_line/screen:2')
y = y + line_height
App.screen.check(y, 'ghi', 'F - test_pageup_scrolls_up_by_screen_line/screen:3')
end
function test_pageup_scrolls_up_from_middle_screen_line()
io.write('\ntest_pageup_scrolls_up_from_middle_screen_line')
-- display a few lines starting from the middle of a line (Cursor1.pos > 1)
App.screen.init{width=25+30, height=60}
Lines = load_array{'abc def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=5}
Screen_top1 = {line=2, pos=5}
Screen_bottom1 = {}
Zoom = 1
local screen_top_margin = 15 -- pixels
local line_height = math.floor(15*Zoom) -- pixels
App.draw()
local y = screen_top_margin
App.screen.check(y, 'jkl', 'F - test_pageup_scrolls_up_from_middle_screen_line/baseline/screen:2')
y = y + line_height
App.screen.check(y, 'mno', 'F - test_pageup_scrolls_up_from_middle_screen_line/baseline/screen:3') -- line wrapping includes trailing whitespace
-- after hitting the page-up key the screen scrolls up to top
App.run_after_keychord('pageup')
check_eq(Screen_top1.line, 1, 'F - test_pageup_scrolls_up_from_middle_screen_line/screen_top')
check_eq(Cursor1.line, 1, 'F - test_pageup_scrolls_up_from_middle_screen_line/cursor:line')
check_eq(Cursor1.pos, 1, 'F - test_pageup_scrolls_up_from_middle_screen_line/cursor:pos')
y = screen_top_margin
App.screen.check(y, 'abc ', 'F - test_pageup_scrolls_up_from_middle_screen_line/screen:1')
y = y + line_height
App.screen.check(y, 'def', 'F - test_pageup_scrolls_up_from_middle_screen_line/screen:2')
y = y + line_height
App.screen.check(y, 'ghi ', 'F - test_pageup_scrolls_up_from_middle_screen_line/screen:3')
end
local y = App.screen.height
while y >= 0 do
if Screen_top1.line == 1 then break end
y = y - math.floor(15*Zoom)
if Lines[Screen_top1.line].mode == 'drawing' then
y = y - Drawing.pixels(Lines[Screen_top1.line].h)
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)