skip multiple consecutive whitespace

[?]
Jul 12, 2022, 2:18 AM
V3EABA35RWCOOU5OMIYRWXAKZOLHO4XPGTPOKY24RR2LOAD7ZQAQC

Dependencies

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

Change contents

  • edit in text_tests.lua at line 153
    [3.399]
    [9.2609]
    end
    function test_skip_multiple_spaces_to_previous_word()
    io.write('\ntest_skip_multiple_spaces_to_previous_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def'}
    Cursor1 = {line=1, pos=6} -- at the start of second word
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-left')
    check_eq(Cursor1.pos, 1, 'F - test_skip_multiple_spaces_to_previous_word')
  • edit in text_tests.lua at line 211
    [3.790]
    [9.3807]
    function test_skip_multiple_spaces_to_next_word()
    io.write('\ntest_skip_multiple_spaces_to_next_word')
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc def'}
    Cursor1 = {line=1, pos=4} -- at the start of second word
    Margin_right = 0; Margin_width = Margin_left
    App.draw()
    App.run_after_keychord('M-right')
    check_eq(Cursor1.pos, 9, 'F - test_skip_multiple_spaces_to_next_word')
    end
  • edit in text.lua at line 518
    [2.1324]
    [4.4962]
    -- skip some whitespace
  • edit in text.lua at line 520
    [4.4978]
    [2.1325]
    if Cursor1.pos == 1 then
    break
    end
    if Text.match(Lines[Cursor1.line].data, Cursor1.pos-1, '%S') then
    break
    end
  • replacement in text.lua at line 527
    [2.1352][4.4994:5033](),[4.4994][4.4994:5033]()
    if Cursor1.pos == 1 then break end
    [2.1352]
    [4.5033]
    end
    -- skip some non-whitespace
    while true do
    Text.left(left, right)
    if Cursor1.pos == 1 then
    break
    end
  • edit in text.lua at line 542
    [2.1391]
    [4.5279]
    -- skip some whitespace
    while true do
    if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then
    break
    end
    if Text.match(Lines[Cursor1.line].data, Cursor1.pos, '%S') then
    break
    end
    Text.right_without_scroll()
    end
  • replacement in text.lua at line 554
    [4.35][4.5312:5383](),[4.5312][4.5312:5383]()
    if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then break end
    [4.35]
    [3.863]
    if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then
    break
    end