support other whitespace chars in word movements

[?]
Jul 12, 2022, 1:56 AM
2LC3BM2NCIR76UILI5D4DVC5KYJSBVHDNMOC5G3TOJNCRLX6PZEQC

Dependencies

  • [2] MP2TBKU6 bugfix: crash in Text.up() after return
  • [3] NUZFHX6I flesh out some tests for word movements
  • [4] 62PZGSUC optimization: moving cursor to next word
  • [5] ZPUQSPQP extract a few methods
  • [6] DHI6IJCN selecting text and deleting selections
  • [7] ZHLO7K3M add args to some functions
  • [*] LXTTOB33 extract a couple of files
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] KECEMMMR extract couple of functions

Change contents

  • edit in text_tests.lua at line 142
    [3.2609]
    [3.2609]
    end
    function test_skip_past_tab_to_previous_word()
    io.write('\ntest_skip_past_tab_to_previous_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def\tghi'}
    Cursor1 = {line=1, pos=10} -- within third word
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-left')
    check_eq(Cursor1.pos, 9, 'F - test_skip_past_tab_to_previous_word')
  • edit in text_tests.lua at line 189
    [3.3807]
    [3.3807]
    function test_skip_past_tab_to_next_word()
    io.write('\ntest_skip_past_tab_to_next_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc\tdef'}
    Cursor1 = {line=1, pos=1} -- at the space between words
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-right')
    check_eq(Cursor1.pos, 4, 'F - test_skip_past_tab_to_next_word')
    end
  • replacement in text.lua at line 522
    [4.5061][2.598:668](),[2.668][4.5131:5221](),[4.5131][4.5131:5221]()
    local offset = Text.offset(Lines[Cursor1.line].data, Cursor1.pos)
    assert(offset > 1)
    if Lines[Cursor1.line].data:sub(offset-1,offset-1) == ' ' then
    [4.5061]
    [4.5221]
    if Text.match(Lines[Cursor1.line].data, Cursor1.pos-1, '%s') then
  • replacement in text.lua at line 532
    [4.5383][2.669:739](),[2.739][4.10688:10784](),[4.5453][4.10688:10784]()
    local offset = Text.offset(Lines[Cursor1.line].data, Cursor1.pos)
    if Lines[Cursor1.line].data:sub(offset,offset) == ' ' then -- TODO: other space characters
    [4.5383]
    [4.5516]
    if Text.match(Lines[Cursor1.line].data, Cursor1.pos, '%s') then
  • edit in text.lua at line 539
    [11.42]
    [11.42]
    end
    function Text.match(s, pos, pat)
    local start_offset = Text.offset(s, pos)
    assert(start_offset)
    local end_offset = Text.offset(s, pos+1)
    assert(end_offset > start_offset)
    local curr = s:sub(start_offset, end_offset-1)
    return curr:match(pat)