Thanks Mikoláš Štrajt.
LK4ZW4BBDD5LC4JK4XK5DJESSDFAIRVFPDM324S7SCAUXEXYVTLQC
2LEXWUW3EQUVE6IZTQROWRU6GDKZER35TGVDL3HFYYSEMA2RZEHAC
ORRSP7FVCHI2TF5GXBRGQYYJAA3JFYXZBM3T663BKSBV22FCZVCAC
LXTTOB33N2HCUZFIUDRQGGBVHK2HODRG4NBLH6RXRQZDCHF27BSAC
62JEPVQ34SOTQI6VQNLGLKS5O4KFU52UKAVDHN6N7G5T6Z5EZO5QC
JJDT2X4FKYC5I3CPTV4PNOALPFXQNG2SSLZJ36QFZIBUXY2ZAXXAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
SPSW74Y5OJ54Y7VQ3SJFCJR5CYDKTR4A3TOEVZODDZLUSDDU2GZAC
UHB4GARJI5AB5UCDCZRFSCJNXGJSLU5DYGUGX5ITYEXI7Q43Z4CAC
QCPXQ2E3USF3Z6R6WJ2JKHTRMPKA6QWXFKKRMLXA3MXABJEL543AC
F65ADDGLR2PNXVSM2XBHM3OSLQC2OTRR3GQBI7DJWIKPJCJ5CSOAC
MXA3RZYKUI4UF2ISY7JEF6VKX6NOPZMZH5SLLCZHRJKFIXXXDPSAC
KECEMMMRW2VVBZ567HJQPGLC57LTSBKWH7UFP32IW43D23X6WTEQC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
end
function test_up_arrow_scrolls_up_by_one_line_skipping_drawing()
-- display lines 3/4/5 with a drawing just off screen at line 2
App.screen.init{width=120, height=60}
Editor_state = edit.initialize_test_state()
Editor_state.lines = load_array{'abc', '```lines', '```', 'def', 'ghi', 'jkl'}
Text.redraw_all(Editor_state)
Editor_state.cursor1 = {line=3, pos=1}
Editor_state.screen_top1 = {line=3, pos=1}
Editor_state.screen_bottom1 = {}
edit.draw(Editor_state)
local y = Editor_state.top
App.screen.check(y, 'def', 'baseline/screen:1')
y = y + Editor_state.line_height
App.screen.check(y, 'ghi', 'baseline/screen:2')
y = y + Editor_state.line_height
App.screen.check(y, 'jkl', 'baseline/screen:3')
-- after hitting the up arrow the screen scrolls up to previous text line
edit.run_after_keychord(Editor_state, 'up')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
local top2 = Text.to2(State, State.screen_top1)
top2 = Text.previous_screen_line(State, top2, State.left, State.right)
State.screen_top1 = Text.to1(State, top2)
State.screen_top1 = {
line=State.cursor1.line,
pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
}
local top2 = Text.to2(State, State.screen_top1)
top2 = Text.previous_screen_line(State, top2)
State.screen_top1 = Text.to1(State, top2)
State.screen_top1 = {
line=State.cursor1.line,
pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
}
Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
local top2 = Text.to2(State, State.screen_top1)
top2 = Text.previous_screen_line(State, top2)
State.screen_top1 = Text.to1(State, top2)
State.screen_top1 = {
line=State.cursor1.line,
pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
}
Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
end
function test_up_arrow_scrolls_up_by_one_line_skipping_drawing()
-- display lines 3/4/5 with a drawing just off screen at line 2
App.screen.init{width=120, height=60}
Editor_state = edit.initialize_test_state()
Editor_state.lines = load_array{'abc', '```lines', '```', 'def', 'ghi', 'jkl'}
Text.redraw_all(Editor_state)
Editor_state.cursor1 = {line=3, pos=1}
Editor_state.screen_top1 = {line=3, pos=1}
Editor_state.screen_bottom1 = {}
edit.draw(Editor_state)
local y = Editor_state.top
App.screen.check(y, 'def', 'baseline/screen:1')
y = y + Editor_state.line_height
App.screen.check(y, 'ghi', 'baseline/screen:2')
y = y + Editor_state.line_height
App.screen.check(y, 'jkl', 'baseline/screen:3')
-- after hitting the up arrow the screen scrolls up to previous text line
edit.run_after_keychord(Editor_state, 'up')
check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
check_eq(Editor_state.cursor1.line, 1, 'cursor')
local top2 = Text.to2(State, State.screen_top1)
top2 = Text.previous_screen_line(State, top2, State.left, State.right)
State.screen_top1 = Text.to1(State, top2)
State.screen_top1 = {
line=State.cursor1.line,
pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
}
local top2 = Text.to2(State, State.screen_top1)
top2 = Text.previous_screen_line(State, top2)
State.screen_top1 = Text.to1(State, top2)
State.screen_top1 = {
line=State.cursor1.line,
pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
}
Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks
local top2 = Text.to2(State, State.screen_top1)
top2 = Text.previous_screen_line(State, top2)
State.screen_top1 = Text.to1(State, top2)
State.screen_top1 = {
line=State.cursor1.line,
pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
}
Text.redraw_all(State) -- if we're scrolling, reclaim all fragments to avoid memory leaks