scroll on backspace
[?]
May 28, 2022, 4:41 PM
HMODUNJEQLZ3W46GKYIDL55F6COVXHTIC6UW4AK3SXOOKOPE6NNACDependencies
- [2]
WY3JD6W6bugfix - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
2RXZ3PGObeginning of a new approach to scroll+wrap - [*]
XNFTJHC4split keyboard handling between Text and Drawing
Change contents
- edit in text.lua at line 771
endfunction test_backspace_can_scroll_up()io.write('\ntest_backspace_can_scroll_up')-- 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_backspace_can_scroll_up/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_backspace_can_scroll_up/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_backspace_can_scroll_up/baseline/screen:3')-- after hitting backspace the screen scrolls up by one lineApp.run_after_keychord('backspace')check_eq(Screen_top1.line, 1, 'F - test_backspace_can_scroll_up/screen_top')check_eq(Cursor1.line, 1, 'F - test_backspace_can_scroll_up/cursor')y = screen_top_marginApp.screen.check(y, 'abcdef', 'F - test_backspace_can_scroll_up/screen:1')y = y + line_heightApp.screen.check(y, 'ghi', 'F - test_backspace_can_scroll_up/screen:2')y = y + line_heightApp.screen.check(y, 'jkl', 'F - test_backspace_can_scroll_up/screen:3')endfunction test_backspace_can_scroll_up_screen_line()io.write('\ntest_backspace_can_scroll_up_screen_line')-- display lines starting from second screen line of a lineApp.screen.init{width=25+30, height=60}Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}Line_width = App.screen.widthCursor1 = {line=3, pos=5}Screen_top1 = {line=3, pos=5}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, 'jkl', 'F - test_backspace_can_scroll_up_screen_line/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'mno', 'F - test_backspace_can_scroll_up_screen_line/baseline/screen:2')-- after hitting backspace the screen scrolls up by one screen lineApp.run_after_keychord('backspace')y = screen_top_marginApp.screen.check(y, 'ghijk', 'F - test_backspace_can_scroll_up_screen_line/screen:1')y = y + line_heightApp.screen.check(y, 'l', 'F - test_backspace_can_scroll_up_screen_line/screen:2')y = y + line_heightApp.screen.check(y, 'mno', 'F - test_backspace_can_scroll_up_screen_line/screen:3')check_eq(Screen_top1.line, 3, 'F - test_backspace_can_scroll_up_screen_line/screen_top')check_eq(Screen_top1.pos, 1, 'F - test_backspace_can_scroll_up_screen_line/screen_top')check_eq(Cursor1.line, 3, 'F - test_backspace_can_scroll_up_screen_line/cursor:line')check_eq(Cursor1.pos, 4, 'F - test_backspace_can_scroll_up_screen_line/cursor:pos') - edit in text.lua at line 974[5.2804][6.2992]
endif Cursor1.line < Screen_top1.line or (Cursor1.line == Screen_top1.line and Cursor1.pos < Screen_top1.pos) thenlocal top2 = Text.to2(Screen_top1)top2 = Text.previous_screen_line(top2)Screen_top1 = Text.to1(top2) - edit in text.lua at line 980[6.3000][6.3000]
assert(Cursor1.line > Screen_top1.line or (Cursor1.line == Screen_top1.line and Cursor1.pos >= Screen_top1.pos))