Found while reading https://www.gutenberg.org/ebooks/52091
DFSDPDO7RHOLPVT4TD2Z3YZCKS6737LYIWBTJJI4BO73IIAJ5BYQC
4RUI5X52CSQODLT3WI4VBMXWZLACBYV5QANGDKRWS3VONZPVSEEQC
S5VCAFKYBM35HF3SI4MCAQROWBRUC7YHWJMKWC6GWTTV5PHUCEFAC
IMEJA43L3OX7S5KIYLZJ4F3ITACLAA5SZBHSCIJMULCPRSW7LXBAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
R53OF3ONKT5VL5BGK63YSN6GXIIAVNYDG4UMHITK72WXFWPJ25MQC
5Q6NIG66SI7CS33S2TVIWSLLICWVAINELJJTMNR2UBWVZPGB7DZAC
DAENUOGV7KR6MZVXS36HEN3SZC4RFIS6REGAFVBOFEPO76EUDGIAC
QYIFOHW3WDDQMK4ATY6IOSQRFHJOQ5QCPDKRC4GVGWLQEH4HGWVQC
H2DPLWMVRFYTO2CQTG54FMT2LF3B6UKLXH32CUA22DNQJVP5XBNQC
function test_up_arrow_scrolls_up_to_empty_line()
io.write('\ntest_up_arrow_scrolls_up_from_empty_line')
-- display a screenful of text with an empty line just above it outside the screen
App.screen.init{width=120, height=60}
Lines = load_array{'', 'abc', 'def', 'ghi', 'jkl'}
Line_width = 120
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, 'abc', 'F - test_up_arrow_scrolls_up_from_empty_line/baseline/screen:1')
y = y + line_height
App.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_from_empty_line/baseline/screen:2')
y = y + line_height
App.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_from_empty_line/baseline/screen:3')
-- after hitting the up arrow the screen scrolls up by one line
App.run_after_keychord('up')
check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_from_empty_line/screen_top')
check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_from_empty_line/cursor')
y = screen_top_margin
-- empty first line
y = y + line_height
App.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_from_empty_line/screen:2')
y = y + line_height
App.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_from_empty_line/screen:3')
end
local line_before_cursor = line_data:sub(1, cursor_pos-1)
--? print(cursor_pos, #line_data, line_data)
local cursor_offset = utf8.offset(line_data, cursor_pos)
--? print(cursor_offset)
assert(cursor_offset)
local line_before_cursor = line_data:sub(1, cursor_offset-1)