bugfix: couple of margin-relative computations
[?]
Jul 18, 2022, 5:15 AM
EKKFWP4D2MNOHU265UCJU37KIFQV424CRLVASQMHDYUYY5T67D3QCDependencies
- [2]
ILOA5BYFseparate data structure for each line's cache data - [3]
IWYLK45Kclicking to the right of a line within line width - [4]
WOXIYUTLbugfix: manage screen_top and cursor when resizing - [5]
QCPXQ2E3add state arg to a few functions - [6]
FKNXK2OAswitch to line index in a function - [7]
MXA3RZYKdeduce left/right from state where possible - [8]
4VKEE43Zbugfix - [9]
UHB4GARJleft/right margin -> left/right coordinates - [10]
WZFMGVDTswitch to line index in a function - [11]
J6WEC2D6. - [12]
BOFNXP5Gclicking now moves the cursor even on long, wrapped lines - [13]
5L7K4GBDclicking to the right of a wrapped line - [14]
LAW2O3NWextract variable Margin_left - [15]
LF7BWEG4group all editor globals - [16]
LNUHQOGHstart passing in Editor_state explicitly - [17]
DRFE3B3Zmouse buttons are integers, not strings - [18]
Y2ZIPXEMnew test - [19]
7NQCCB34. - [20]
QLTJG7Q3indent - [21]
H3ECRBXFbugfix: clicking on empty lines - [22]
APYPFFS3call edit rather than App callbacks in tests - [*]
LXTTOB33extract a couple of files - [*]
BULPIBEGbeginnings of a module for the text editor
Change contents
- replacement in text_tests.lua at line 268
check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse/cursor')check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse/cursor:line')check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse/cursor:pos') - edit in text_tests.lua at line 273
function test_click_with_mouse_takes_margins_into_account()io.write('\ntest_click_with_mouse_takes_margins_into_account')-- display two lines with cursor on one of themApp.screen.init{width=100, height=80}Editor_state = edit.initialize_test_state()Editor_state.left = 50 -- occupy only right side of screenEditor_state.lines = load_array{'abc', 'def'}Text.redraw_all(Editor_state)Editor_state.cursor1 = {line=2, pos=1}Editor_state.screen_top1 = {line=1, pos=1}Editor_state.screen_bottom1 = {}-- click on the other lineedit.draw(Editor_state)edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)-- cursor movescheck_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_takes_margins_into_account/cursor:line')check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos')check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_takes_margins_into_account/selection is empty to avoid perturbing future edits')end - edit in text_tests.lua at line 362
endfunction test_click_with_mouse_on_wrapping_line()io.write('\ntest_click_with_mouse_on_wrapping_line')-- display two lines with cursor on one of themApp.screen.init{width=50, height=80}Editor_state = edit.initialize_test_state()Editor_state.lines = load_array{'abc def ghi jkl mno pqr stu'}Text.redraw_all(Editor_state)Editor_state.cursor1 = {line=1, pos=20}Editor_state.screen_top1 = {line=1, pos=1}Editor_state.screen_bottom1 = {}-- click on the other lineedit.draw(Editor_state)edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)-- cursor movescheck_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line/cursor:line')check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos')check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line/selection is empty to avoid perturbing future edits') - edit in text_tests.lua at line 383
function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()io.write('\ntest_click_with_mouse_on_wrapping_line_takes_margins_into_account')-- display two lines with cursor on one of themApp.screen.init{width=100, height=80}Editor_state = edit.initialize_test_state()Editor_state.left = 50 -- occupy only right side of screenEditor_state.lines = load_array{'abc def ghi jkl mno pqr stu'}Text.redraw_all(Editor_state)Editor_state.cursor1 = {line=1, pos=20}Editor_state.screen_top1 = {line=1, pos=1}Editor_state.screen_bottom1 = {}-- click on the other lineedit.draw(Editor_state)edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)-- cursor movescheck_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:line')check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos')check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')end - replacement in text.lua at line 731
if screen_line_index < #line_cache.screen_line_starting_pos and mx > Text.screen_line_width(State, line_index, screen_line_index) thenif screen_line_index < #line_cache.screen_line_starting_pos and mx > State.left + Text.screen_line_width(State, line_index, screen_line_index) then - replacement in text.lua at line 981
pos=Text.to_pos_on_line(State, State.screen_bottom1.line, App.screen.width-5, App.screen.height-5),pos=Text.to_pos_on_line(State, State.screen_bottom1.line, State.right-5, App.screen.height-5),