bugfix: down arrow doesn't scroll up unnecessarily
[?]
May 24, 2022, 10:01 PM
V5MJRFOZRVVDCPOWTLXPHS2HZBZKOOCPPKFMRP6MWZN6N62QLFAACDependencies
- [2]
MDXGMZU2disable all debug prints - [3]
2POFQQLWkeep cursor on screen when pressing 'down' - [4]
3OKKTUT4up and down arrow now moving by screen line where possible - [5]
PR4KIAZDfirst stab at equally hacky cursor down support - [6]
TRNWIQN6more precise height calculation when scrolling up as much as possible while keeping cursor on screen - [7]
2RXZ3PGObeginning of a new approach to scroll+wrap - [8]
ESETRNLBbugfix: printing the first part of a line at the bottom made it seem non-wrapping - [9]
PYGMASTVdisable some debug prints - [10]
SVJZZDC3snapshot - no, that's all wrong - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
IMEJA43Lsnapshot - [*]
XOAHJ6M3similar tests for cursor up
Change contents
- edit in text.lua at line 313[13.4789][14.279]
endfunction test_page_down_followed_by_down_arrow_does_not_scroll_screen_up()io.write('\ntest_page_down_followed_by_down_arrow_does_not_scroll_screen_up')App.screen.init{width=25+30, height=60}Lines = load_array{'abc', 'def', 'ghijkl', 'mno'}Line_width = App.screen.widthCursor1 = {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_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:1')y = y + line_heightApp.screen.check(y, 'def', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:2')y = y + line_heightApp.screen.check(y, 'ghijk', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline/screen:3')-- after hitting pagedown the screen scrolls down to start of a long lineApp.run_after_keychord('pagedown')check_eq(Screen_top1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/screen_top')check_eq(Cursor1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:line')check_eq(Cursor1.pos, 1, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/baseline2/cursor:pos')-- after hitting down arrow the screen doesn't scroll down further, and certainly doesn't scroll upApp.run_after_keychord('down')check_eq(Screen_top1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen_top')check_eq(Cursor1.line, 3, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/cursor:line')check_eq(Cursor1.pos, 6, 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/cursor:pos')y = screen_top_marginApp.screen.check(y, 'ghijk', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:1')y = y + line_heightApp.screen.check(y, 'l', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:2')y = y + line_heightApp.screen.check(y, 'mno', 'F - test_page_down_followed_by_down_arrow_does_not_scroll_screen_up/screen:3') - edit in text.lua at line 835
local scroll_up = falseif Cursor1.line > Screen_bottom1.line or (Cursor1.line == Screen_bottom1.line and Cursor1.pos >= Screen_bottom1.pos) thenscroll_up = trueend - replacement in text.lua at line 846[3.61]→[3.6141:6179](∅→∅),[3.982]→[3.6141:6179](∅→∅),[2.1208]→[3.6141:6179](∅→∅),[3.6141]→[3.6141:6179](∅→∅),[3.6179]→[2.1209:1256](∅→∅),[3.108]→[3.1620:1666](∅→∅),[3.158]→[3.1620:1666](∅→∅),[3.1026]→[3.1620:1666](∅→∅),[2.1256]→[3.1620:1666](∅→∅),[3.1511]→[3.1620:1666](∅→∅),[3.1620]→[3.1620:1666](∅→∅),[3.1666]→[2.1257:1329](∅→∅)
Screen_top1.line = Cursor1.line--? print('scroll up preserving cursor')Text.scroll_up_while_cursor_on_screen()--? print('screen top after:', Screen_top1.line, Screen_top1.pos)if scroll_up thenScreen_top1.line = Cursor1.line--? print('scroll up preserving cursor')Text.scroll_up_while_cursor_on_screen()--? print('screen top after:', Screen_top1.line, Screen_top1.pos)end