similar tests for cursor up
[?]
May 23, 2022, 6:02 PM
XOAHJ6M3QKHSE5F7ICLPXN3RMH7JQEZXDKTOTIOBYKJFVT6PMYRACDependencies
- [2]
S5VCAFKYcouple of tests for cursor down - [3]
BULPIBEGbeginnings of a module for the text editor - [4]
CVGE3SIGI feel confident now that page-down is working. - [5]
U7M4M2F7bugfix: don't rely on Screen_bottom1 while scrolling - [6]
3TFEAQSWstart using some globals - [7]
H2DPLWMVsnapshot: wrapping long lines at word boundaries - [*]
YTSPVDZHfirst successful pagedown test, first bug found by test
Change contents
- replacement in text.lua at line 12
print('text.draw')--? print('text.draw') - edit in text.lua at line 185
check_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top') - edit in text.lua at line 216[2.2911][9.2148]
check_eq(Screen_top1.line, 2, 'F - test_down_arrow_scrolls_down_by_one_line/screen_top')check_eq(Cursor1.line, 4, 'F - test_down_arrow_scrolls_down_by_one_line/cursor')endfunction test_up_arrow_moves_cursor()print('test_up_arrow_moves_cursor')-- display the first 3 lines with the cursor on the bottom lineApp.screen.init{width=120, height=60}Lines = load_array{'abc', 'def', 'ghi', 'jkl'}Line_width = 120Cursor1 = {line=3, pos=1}Screen_top1 = {line=1, pos=1}Screen_bottom1 = {}Zoom = 1local screen_top_margin = 15 -- pixelslocal line_height = math.floor(15*Zoom) -- pixelsApp.draw()local y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_up_arrow_moves_cursor/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_up_arrow_moves_cursor/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_moves_cursor/baseline/screen:3')-- after hitting the up arrow the screen is unchangedApp.run_after_keychord('up')y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_up_arrow_moves_cursor/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_up_arrow_moves_cursor/screen:2')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_moves_cursor/screen:3')-- but the cursor moves up by 1 linecheck_eq(Screen_top1.line, 1, 'F - test_up_arrow_moves_cursor/screen_top')check_eq(Cursor1.line, 2, 'F - test_up_arrow_moves_cursor/cursor')endfunction test_up_arrow_scrolls_up_by_one_line()print('test_up_arrow_scrolls_up_by_one_line')-- display the lines 2/3/4 with the cursor on line 2App.screen.init{width=120, height=60}Lines = load_array{'abc', 'def', 'ghi', 'jkl'}Line_width = 120Cursor1 = {line=2, pos=1}Screen_top1 = {line=2, pos=1}Screen_bottom1 = {}Zoom = 1local screen_top_margin = 15 -- pixelslocal line_height = math.floor(15*Zoom) -- pixelsApp.draw()local y = screen_top_marginApp.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_by_one_line/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_by_one_line/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_up_arrow_scrolls_up_by_one_line/baseline/screen:3')-- after hitting the up arrow the screen scrolls up by one lineApp.run_after_keychord('up')y = screen_top_marginApp.screen.check(y, 'abc', 'F - test_up_arrow_scrolls_up_by_one_line/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_up_arrow_scrolls_up_by_one_line/screen:2')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_up_arrow_scrolls_up_by_one_line/screen:3')check_eq(Screen_top1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/screen_top')check_eq(Cursor1.line, 1, 'F - test_up_arrow_scrolls_up_by_one_line/cursor')