unify two similar functions
[?]
Jul 20, 2022, 12:13 AM
356GY7IQ467QQMIPFMEETHTXLSZE65HA36PXSOW4KKXBUHSMBQTACDependencies
- [2]
EKKFWP4Dbugfix: couple of margin-relative computations - [3]
GL4Q5WCVkeep text from overflowing right margin - [4]
MP2TBKU6bugfix: crash in Text.up() after return - [5]
WAR3HXHTtest both ways of selecting text with mouse - [6]
DRFE3B3Zmouse buttons are integers, not strings - [7]
QYIFOHW3first test! - [8]
H2DPLWMVsnapshot: wrapping long lines at word boundaries - [9]
JFFUF5ALoverride mouse state lookups in tests - [10]
LAW2O3NWextract variable Margin_left - [11]
APYPFFS3call edit rather than App callbacks in tests - [12]
QCPXQ2E3add state arg to a few functions - [13]
HOSPP2ANcrisp font rendering - [14]
IMEJA43Lsnapshot - [15]
BULPIBEGbeginnings of a module for the text editor - [16]
UHB4GARJleft/right margin -> left/right coordinates - [17]
LXTTOB33extract a couple of files - [18]
RMKMPFT5fix a corner case when selecting text - [19]
LF7BWEG4group all editor globals - [20]
ULKLJBN6couple of renames - [21]
DFSDPDO7bugfix - [22]
EGH7XDBKsupport non-text lines in Text.to2 - [23]
Y2ZIPXEMnew test - [24]
ZLJGZYQGselect text with shift + mouseclick - [25]
2RXZ3PGObeginning of a new approach to scroll+wrap - [26]
MXA3RZYKdeduce left/right from state where possible - [27]
5OALPNN3add args to some functions - [28]
4CTZOJPCstop pretending globals are local - [29]
H3ECRBXFbugfix: clicking on empty lines - [30]
LNUHQOGHstart passing in Editor_state explicitly
Change contents
- edit in text_tests.lua at line 269
check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse/cursor:pos') - replacement in text_tests.lua at line 288
check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos')check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos') - replacement in text_tests.lua at line 378
check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos')check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos') - replacement in text_tests.lua at line 398
check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos')check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos') - replacement in text_tests.lua at line 837
check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')check_eq(Editor_state.cursor1.pos, 1, 'F - test_move_cursor_using_mouse/cursor:pos') - replacement in text_tests.lua at line 858
check_eq(Editor_state.selection1.pos, 2, 'F - test_select_text_using_mouse/selection:pos')check_eq(Editor_state.selection1.pos, 1, 'F - test_select_text_using_mouse/selection:pos') - replacement in text_tests.lua at line 883
check_eq(Editor_state.selection1.pos, 2, 'F - test_select_text_using_mouse_and_shift/selection:pos')check_eq(Editor_state.selection1.pos, 1, 'F - test_select_text_using_mouse_and_shift/selection:pos') - replacement in text_tests.lua at line 914
check_eq(Editor_state.selection1.pos, 2, 'F - test_select_text_repeatedly_using_mouse_and_shift/selection:pos')check_eq(Editor_state.selection1.pos, 1, 'F - test_select_text_repeatedly_using_mouse_and_shift/selection:pos') - replacement in text_tests.lua at line 916
check_eq(Editor_state.cursor1.pos, 2, 'F - test_select_text_repeatedly_using_mouse_and_shift/cursor:pos')check_eq(Editor_state.cursor1.pos, 1, 'F - test_select_text_repeatedly_using_mouse_and_shift/cursor:pos') - replacement in text_tests.lua at line 1132
check_eq(Editor_state.cursor1.pos, 5, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:pos')check_eq(Editor_state.cursor1.pos, 6, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:pos') - replacement in text_tests.lua at line 1685
check_eq(Editor_state.cursor1.pos, 28, 'F - test_move_cursor_using_mouse/cursor:pos')check_eq(Editor_state.cursor1.pos, 28, 'F - test_position_cursor_on_recently_edited_wrapping_line/cursor:pos') - replacement in text_tests.lua at line 1695
check_eq(Editor_state.cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line')check_eq(Editor_state.cursor1.pos, 26, 'F - test_move_cursor_using_mouse/cursor:pos')check_eq(Editor_state.cursor1.line, 1, 'F - test_position_cursor_on_recently_edited_wrapping_line/cursor:line')check_eq(Editor_state.cursor1.pos, 25, 'F - test_position_cursor_on_recently_edited_wrapping_line/cursor:pos') - replacement in text.lua at line 818
local max_x = Text.x_after(line, len)local max_x = Text.x(line, len) - replacement in text.lua at line 825
local currxmin = Text.x_after(line, curr+1)local currxmax = Text.x_after(line, curr+2)local currxmin = Text.x(line, curr+1)local currxmax = Text.x(line, curr+2) - replacement in text.lua at line 843
function Text.x_after(s, pos)function Text.x(s, pos) - edit in text.lua at line 851[4.7881]→[4.336:360](∅→∅),[4.360]→[4.837:874](∅→∅),[4.874]→[4.414:521](∅→∅),[4.414]→[4.414:521](∅→∅),[4.521]→[4.3909:3941](∅→∅),[4.570]→[4.3290:3295](∅→∅),[4.1366]→[4.3290:3295](∅→∅),[4.3941]→[4.3290:3295](∅→∅),[4.3290]→[4.3290:3295](∅→∅)
function Text.x(s, pos)local offset = Text.offset(s, pos)local s_before = s:sub(1, offset-1)local text_before = App.newText(love.graphics.getFont(), s_before)return App.width(text_before)end