unify two similar functions

[?]
Jul 20, 2022, 12:13 AM
356GY7IQ467QQMIPFMEETHTXLSZE65HA36PXSOW4KKXBUHSMBQTAC

Dependencies

  • [2] EKKFWP4D bugfix: couple of margin-relative computations
  • [3] GL4Q5WCV keep text from overflowing right margin
  • [4] MP2TBKU6 bugfix: crash in Text.up() after return
  • [5] WAR3HXHT test both ways of selecting text with mouse
  • [6] DRFE3B3Z mouse buttons are integers, not strings
  • [7] QYIFOHW3 first test!
  • [8] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [9] JFFUF5AL override mouse state lookups in tests
  • [10] LAW2O3NW extract variable Margin_left
  • [11] APYPFFS3 call edit rather than App callbacks in tests
  • [12] QCPXQ2E3 add state arg to a few functions
  • [13] HOSPP2AN crisp font rendering
  • [14] IMEJA43L snapshot
  • [15] BULPIBEG beginnings of a module for the text editor
  • [16] UHB4GARJ left/right margin -> left/right coordinates
  • [17] LXTTOB33 extract a couple of files
  • [18] RMKMPFT5 fix a corner case when selecting text
  • [19] LF7BWEG4 group all editor globals
  • [20] ULKLJBN6 couple of renames
  • [21] DFSDPDO7 bugfix
  • [22] EGH7XDBK support non-text lines in Text.to2
  • [23] Y2ZIPXEM new test
  • [24] ZLJGZYQG select text with shift + mouseclick
  • [25] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [26] MXA3RZYK deduce left/right from state where possible
  • [27] 5OALPNN3 add args to some functions
  • [28] 4CTZOJPC stop pretending globals are local
  • [29] H3ECRBXF bugfix: clicking on empty lines
  • [30] LNUHQOGH start passing in Editor_state explicitly

Change contents

  • edit in text_tests.lua at line 269
    [2.84][2.84:164]()
    check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse/cursor:pos')
  • replacement in text_tests.lua at line 288
    [2.957][2.957:1064]()
    check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos')
    [2.957]
    [2.1064]
    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
    [2.1942][2.1942:2039]()
    check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos')
    [2.1942]
    [2.2039]
    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
    [2.3041][2.3041:3165]()
    check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos')
    [2.3041]
    [2.3165]
    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
    [4.19632][4.19632:19719]()
    check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')
    [4.19632]
    [4.19719]
    check_eq(Editor_state.cursor1.pos, 1, 'F - test_move_cursor_using_mouse/cursor:pos')
  • replacement in text_tests.lua at line 858
    [4.20562][4.20562:20655]()
    check_eq(Editor_state.selection1.pos, 2, 'F - test_select_text_using_mouse/selection:pos')
    [4.20562]
    [4.20655]
    check_eq(Editor_state.selection1.pos, 1, 'F - test_select_text_using_mouse/selection:pos')
  • replacement in text_tests.lua at line 883
    [4.21674][4.21674:21777]()
    check_eq(Editor_state.selection1.pos, 2, 'F - test_select_text_using_mouse_and_shift/selection:pos')
    [4.21674]
    [4.21777]
    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
    [4.23026][4.23026:23140]()
    check_eq(Editor_state.selection1.pos, 2, 'F - test_select_text_repeatedly_using_mouse_and_shift/selection:pos')
    [4.23026]
    [4.23140]
    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
    [4.23250][4.23250:23358]()
    check_eq(Editor_state.cursor1.pos, 2, 'F - test_select_text_repeatedly_using_mouse_and_shift/cursor:pos')
    [4.23250]
    [4.6250]
    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
    [4.28919][4.28919:29025]()
    check_eq(Editor_state.cursor1.pos, 5, 'F - test_down_arrow_scrolls_down_by_one_screen_line/cursor:pos')
    [4.28919]
    [4.8650]
    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
    [4.5226][4.44858:44946](),[4.32440][4.44858:44946]()
    check_eq(Editor_state.cursor1.pos, 28, 'F - test_move_cursor_using_mouse/cursor:pos')
    [4.5226]
    [4.12445]
    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
    [4.33154][4.45164:45341]()
    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')
    [4.33154]
    [4.33305]
    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
    [4.7300][3.3519:3559]()
    local max_x = Text.x_after(line, len)
    [4.7300]
    [4.7344]
    local max_x = Text.x(line, len)
  • replacement in text.lua at line 825
    [4.7496][3.3560:3656]()
    local currxmin = Text.x_after(line, curr+1)
    local currxmax = Text.x_after(line, curr+2)
    [4.7496]
    [4.7596]
    local currxmin = Text.x(line, curr+1)
    local currxmax = Text.x(line, curr+2)
  • replacement in text.lua at line 843
    [3.3662][3.3662:3692]()
    function Text.x_after(s, pos)
    [3.3662]
    [3.3692]
    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