bugfix: scrolling in left/right movements
[?]
Jun 29, 2022, 1:48 AM
HTWAM4NZFOY463TNSKYIM2EWB7QNBGDRRTTGHF5N3Z4TGC7Q3SFACDependencies
- [2]
NZKYPBSKcheck for scroll when just typing - [3]
EBBFOW4Xbugfix: clear selection in a couple more places - [4]
MDXGMZU2disable all debug prints - [5]
XNFTJHC4split keyboard handling between Text and Drawing - [6]
ZPUQSPQPextract a few methods - [7]
KECEMMMRextract couple of functions - [8]
SVJZZDC3snapshot - no, that's all wrong - [9]
AVLAYODPmuch simpler - [10]
DHI6IJCNselecting text and deleting selections - [11]
X75QPYVWmove Selection1 clearing past business logic - [12]
CG3264MMmove - [13]
4KOI3E6Rremove some redundant checks - [*]
LXTTOB33extract a couple of files - [*]
BULPIBEGbeginnings of a module for the text editor
Change contents
- edit in text_tests.lua at line 1153
endfunction test_left_arrow_scrolls_up_in_wrapped_line()io.write('\ntest_left_arrow_scrolls_up_in_wrapped_line')-- display lines starting from second screen line of a lineApp.screen.init{width=Margin_left+30, height=60}Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}Line_width = App.screen.widthScreen_top1 = {line=3, pos=5}Screen_bottom1 = {}-- cursor is at top of screenCursor1 = {line=3, pos=5}App.draw()local y = Margin_topApp.screen.check(y, 'jkl', 'F - test_left_arrow_scrolls_up_in_wrapped_line/baseline/screen:1')y = y + Line_heightApp.screen.check(y, 'mno', 'F - test_left_arrow_scrolls_up_in_wrapped_line/baseline/screen:2')-- after hitting the left arrow the screen scrolls up to first screen lineApp.run_after_keychord('left')y = Margin_topApp.screen.check(y, 'ghi ', 'F - test_left_arrow_scrolls_up_in_wrapped_line/screen:1')y = y + Line_heightApp.screen.check(y, 'jkl', 'F - test_left_arrow_scrolls_up_in_wrapped_line/screen:2')y = y + Line_heightApp.screen.check(y, 'mno', 'F - test_left_arrow_scrolls_up_in_wrapped_line/screen:3')check_eq(Screen_top1.line, 3, 'F - test_left_arrow_scrolls_up_in_wrapped_line/screen_top')check_eq(Screen_top1.pos, 1, 'F - test_left_arrow_scrolls_up_in_wrapped_line/screen_top')check_eq(Cursor1.line, 3, 'F - test_left_arrow_scrolls_up_in_wrapped_line/cursor:line')check_eq(Cursor1.pos, 4, 'F - test_left_arrow_scrolls_up_in_wrapped_line/cursor:pos')endfunction test_right_arrow_scrolls_down_in_wrapped_line()io.write('\ntest_right_arrow_scrolls_down_in_wrapped_line')-- display the first three lines with the cursor on the bottom lineApp.screen.init{width=Margin_left+30, height=60}Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}Line_width = App.screen.widthScreen_top1 = {line=1, pos=1}Screen_bottom1 = {}-- cursor is at bottom right of screenCursor1 = {line=3, pos=5}App.draw()local y = Margin_topApp.screen.check(y, 'abc', 'F - test_right_arrow_scrolls_down_in_wrapped_line/baseline/screen:1')y = y + Line_heightApp.screen.check(y, 'def', 'F - test_right_arrow_scrolls_down_in_wrapped_line/baseline/screen:2')y = y + Line_heightApp.screen.check(y, 'ghi ', 'F - test_right_arrow_scrolls_down_in_wrapped_line/baseline/screen:3') -- line wrapping includes trailing whitespace-- after hitting the right arrow the screen scrolls down by one lineApp.run_after_keychord('right')check_eq(Screen_top1.line, 2, 'F - test_right_arrow_scrolls_down_in_wrapped_line/screen_top')check_eq(Cursor1.line, 3, 'F - test_right_arrow_scrolls_down_in_wrapped_line/cursor:line')check_eq(Cursor1.pos, 6, 'F - test_right_arrow_scrolls_down_in_wrapped_line/cursor:pos')y = Margin_topApp.screen.check(y, 'def', 'F - test_right_arrow_scrolls_down_in_wrapped_line/screen:1')y = y + Line_heightApp.screen.check(y, 'ghi ', 'F - test_right_arrow_scrolls_down_in_wrapped_line/screen:2')y = y + Line_heightApp.screen.check(y, 'jkl', 'F - test_right_arrow_scrolls_down_in_wrapped_line/screen:3')endfunction test_home_scrolls_up_in_wrapped_line()io.write('\ntest_home_scrolls_up_in_wrapped_line')-- display lines starting from second screen line of a lineApp.screen.init{width=Margin_left+30, height=60}Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}Line_width = App.screen.widthScreen_top1 = {line=3, pos=5}Screen_bottom1 = {}-- cursor is at top of screenCursor1 = {line=3, pos=5}App.draw()local y = Margin_topApp.screen.check(y, 'jkl', 'F - test_home_scrolls_up_in_wrapped_line/baseline/screen:1')y = y + Line_heightApp.screen.check(y, 'mno', 'F - test_home_scrolls_up_in_wrapped_line/baseline/screen:2')-- after hitting home the screen scrolls up to first screen lineApp.run_after_keychord('home')y = Margin_topApp.screen.check(y, 'ghi ', 'F - test_home_scrolls_up_in_wrapped_line/screen:1')y = y + Line_heightApp.screen.check(y, 'jkl', 'F - test_home_scrolls_up_in_wrapped_line/screen:2')y = y + Line_heightApp.screen.check(y, 'mno', 'F - test_home_scrolls_up_in_wrapped_line/screen:3')check_eq(Screen_top1.line, 3, 'F - test_home_scrolls_up_in_wrapped_line/screen_top')check_eq(Screen_top1.pos, 1, 'F - test_home_scrolls_up_in_wrapped_line/screen_top')check_eq(Cursor1.line, 3, 'F - test_home_scrolls_up_in_wrapped_line/cursor:line')check_eq(Cursor1.pos, 1, 'F - test_home_scrolls_up_in_wrapped_line/cursor:pos') - edit in text_tests.lua at line 1243
function test_end_scrolls_down_in_wrapped_line()io.write('\ntest_end_scrolls_down_in_wrapped_line')-- display the first three lines with the cursor on the bottom lineApp.screen.init{width=Margin_left+30, height=60}Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}Line_width = App.screen.widthScreen_top1 = {line=1, pos=1}Screen_bottom1 = {}-- cursor is at bottom right of screenCursor1 = {line=3, pos=5}App.draw()local y = Margin_topApp.screen.check(y, 'abc', 'F - test_end_scrolls_down_in_wrapped_line/baseline/screen:1')y = y + Line_heightApp.screen.check(y, 'def', 'F - test_end_scrolls_down_in_wrapped_line/baseline/screen:2')y = y + Line_heightApp.screen.check(y, 'ghi ', 'F - test_end_scrolls_down_in_wrapped_line/baseline/screen:3') -- line wrapping includes trailing whitespace-- after hitting end the screen scrolls down by one lineApp.run_after_keychord('end')check_eq(Screen_top1.line, 2, 'F - test_end_scrolls_down_in_wrapped_line/screen_top')check_eq(Cursor1.line, 3, 'F - test_end_scrolls_down_in_wrapped_line/cursor:line')check_eq(Cursor1.pos, 8, 'F - test_end_scrolls_down_in_wrapped_line/cursor:pos')y = Margin_topApp.screen.check(y, 'def', 'F - test_end_scrolls_down_in_wrapped_line/screen:1')y = y + Line_heightApp.screen.check(y, 'ghi ', 'F - test_end_scrolls_down_in_wrapped_line/screen:2')y = y + Line_heightApp.screen.check(y, 'jkl', 'F - test_end_scrolls_down_in_wrapped_line/screen:3')end - replacement in text.lua at line 297
Cursor1.pos = 1Text.start_of_line() - replacement in text.lua at line 300[4.115]→[4.1152:1209](∅→∅),[4.128]→[4.1152:1209](∅→∅),[4.9516]→[4.1152:1209](∅→∅),[4.1152]→[4.1152:1209](∅→∅)
Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1Text.end_of_line() - replacement in text.lua at line 306
Cursor1.pos = 1Text.start_of_line() - replacement in text.lua at line 311
Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1Text.end_of_line() - edit in text.lua at line 500
endfunction Text.start_of_line()Cursor1.pos = 1if Text.lt1(Cursor1, Screen_top1) thenScreen_top1 = {line=Cursor1.line, pos=Cursor1.pos} -- copyendendfunction Text.end_of_line()Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1local _,botpos = Text.pos_at_start_of_cursor_screen_line()local botline1 = {line=Cursor1.line, pos=botpos}if Text.lt1(Screen_bottom1, botline1) thenText.snap_cursor_to_bottom_of_screen()end - edit in text.lua at line 555
endif Cursor1.line < Screen_top1.line thenScreen_top1.line = Cursor1.line - edit in text.lua at line 556
endif Text.lt1(Cursor1, Screen_top1) thenlocal top2 = Text.to2(Screen_top1)top2 = Text.previous_screen_line(top2)Screen_top1 = Text.to1(top2) - edit in text.lua at line 577
endif Cursor1.line > Screen_bottom1.line thenScreen_top1.line = Cursor1.line - edit in text.lua at line 579
local _,botpos = Text.pos_at_start_of_cursor_screen_line()local botline1 = {line=Cursor1.line, pos=botpos}if Text.lt1(Screen_bottom1, botline1) thenText.snap_cursor_to_bottom_of_screen()end