up arrow to search previous

[?]
Jun 3, 2022, 2:48 PM
TKFSYQ2ZTEPN27IGKGEYSUS7FQ2AUIC7DJWFF2RJ53AW6QRPMXWQC

Dependencies

  • [2] Z4XRNDTR find text
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] DHI6IJCN selecting text and deleting selections
  • [*] OTIBCAUJ love2d scaffold

Change contents

  • edit in text.lua at line 148
    [2.2104]
    [2.2104]
    if pos then
    Cursor1.line = i
    Cursor1.pos = pos
    break
    end
    end
    end
    if pos == nil then
    Cursor1.line = Search_backup_cursor1.line
    Cursor1.pos = Search_backup_cursor1.pos
    end
    if Text.lt1(Cursor1, Screen_top1) or Text.lt1(Screen_bottom1, Cursor1) then
    Screen_top1.line = Cursor1.line
    local _, pos = Text.pos_at_start_of_cursor_screen_line()
    Screen_top1.pos = pos
    end
    end
    function Text.search_previous()
    -- search current line
    local pos = rfind(Lines[Cursor1.line].data, Search_term, Cursor1.pos)
    if pos then
    Cursor1.pos = pos
    end
    if pos == nil then
    for i=Cursor1.line-1,1,-1 do
    pos = rfind(Lines[i].data, Search_term)
  • edit in text.lua at line 183
    [2.2232]
    [2.2232]
    -- wrap around
    for i=#Lines,Cursor1.line+1,-1 do
    pos = rfind(Lines[i].data, Search_term)
    if pos then
    Cursor1.line = i
    Cursor1.pos = pos
    break
    end
    end
    end
    if pos == nil then
  • edit in text.lua at line 204
    [5.1068]
    [5.1068]
    function rfind(s, pat, i)
    local rs = s:reverse()
    local rpat = pat:reverse()
    if i == nil then i = #s end
    local ri = #s - i + 1
    local rendpos = rs:find(rpat, ri)
    if rendpos == nil then return nil end
    local endpos = #s - rendpos + 1
    assert (endpos >= #pat)
    return endpos-#pat+1
    end
  • edit in main.lua at line 258
    [2.3654]
    [2.3654]
    elseif chord == 'up' then
    Text.search_previous()