find text

[?]
Jun 3, 2022, 5:53 AM
Z4XRNDTRTGSZHNB65WNHOVUBFW4QWQABLVSK4RM3QJHGK33DMRJAC

Dependencies

  • [2] ULKLJBN6 couple of renames
  • [3] 73OCE2MC after much struggle, a brute-force undo
  • [4] OTIBCAUJ love2d scaffold
  • [5] 3TFEAQSW start using some globals
  • [6] BULPIBEG beginnings of a module for the text editor
  • [7] XX7G2FFJ intermingle freehand line drawings with text
  • [8] B3IWYWSR delete another arg that can be deduced
  • [9] EWMPYCDO bugfix
  • [10] 5DOC2CBM extract a function
  • [11] AVTNUQYR basic test-enabled framework
  • [12] XNFTJHC4 split keyboard handling between Text and Drawing
  • [13] 252M2QMD forgot to move this special case out
  • [14] CVGE3SIG I feel confident now that page-down is working.
  • [15] DLQMM265 scroll past first page
  • [16] XVR2O5PI change text cursor shape
  • [17] MDXGMZU2 disable all debug prints
  • [18] OYXDYPGS get rid of debug variables
  • [19] 6LJZN727 handle chords
  • [20] QU7NHFOV show cursor
  • [21] 3CS5KKCI up/down cursor movement
  • [22] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [23] BYG5CEMV support for naming points
  • [24] YTSPVDZH first successful pagedown test, first bug found by test
  • [25] 242L3OQX bugfix: ensure Cursor_line is always on a text line
  • [26] JCSLDGAH beginnings of support for multiple shapes
  • [27] Y36LOGR5 bugfix: show cursor when past end of line
  • [28] ESETRNLB bugfix: printing the first part of a line at the bottom made it seem non-wrapping
  • [29] U7M4M2F7 bugfix: don't rely on Screen_bottom1 while scrolling
  • [30] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [*] DHI6IJCN selecting text and deleting selections
  • [*] OAHNWDYG .
  • [*] 6DE7RBZ6 move mouse_released events to Drawing

Change contents

  • replacement in text.lua at line 79
    [4.326][2.1:64]()
    Text.draw_cursor(x+Text.x(frag, Cursor1.pos-pos+1), y)
    [4.326]
    [4.2594]
    if Search_term then
    if Lines[Cursor1.line].data:sub(Cursor1.pos, Cursor1.pos+utf8.len(Search_term)-1) == Search_term then
    if Search_text == nil then
    Search_text = App.newText(love.graphics.getFont(), Search_term)
    end
    love.graphics.setColor(0.7,1,1)
    love.graphics.rectangle('fill', x,y, math.floor(App.width(Search_text)*Zoom),math.floor(15*Zoom))
    love.graphics.setColor(0,0,0)
    love.graphics.print(Search_term, x,y, 0, Zoom)
    end
    else
    Text.draw_cursor(x+Text.x(frag, Cursor1.pos-pos+1), y)
    end
  • replacement in text.lua at line 97
    [4.37][4.398:458](),[4.59][4.72:99](),[4.282][4.72:99](),[4.458][4.72:99](),[4.29][4.72:99]()
    if line_index == Cursor1.line and Cursor1.pos == pos then
    Text.draw_cursor(x, y)
    [4.37]
    [4.138]
    if Search_term == nil then
    if line_index == Cursor1.line and Cursor1.pos == pos then
    Text.draw_cursor(x, y)
    end
  • edit in text.lua at line 106
    [4.2728]
    [32.1067]
    function Text.draw_search_bar()
    local h = math.floor(15*Zoom)+2
    local y = App.screen.height-h
    love.graphics.setColor(0.9,0.9,0.9)
    love.graphics.rectangle('fill', 0, y-10, App.screen.width-1, h+8)
    love.graphics.setColor(0.6,0.6,0.6)
    love.graphics.line(0, y-10, App.screen.width-1, y-10)
    love.graphics.setColor(1,1,1)
    love.graphics.rectangle('fill', 20, y-6, App.screen.width-40, h+2, 2,2)
    love.graphics.setColor(0.6,0.6,0.6)
    love.graphics.rectangle('line', 20, y-6, App.screen.width-40, h+2, 2,2)
    love.graphics.setColor(0,0,0)
    App.screen.print(Search_term, 25,y-5, 0, Zoom)
    love.graphics.setColor(1,0,0)
    if Search_text == nil then
    Search_text = App.newText(love.graphics.getFont(), Search_term)
    end
    love.graphics.circle('fill', 25+math.floor(App.width(Search_text)*Zoom),y-5+h, 2)
    love.graphics.setColor(0,0,0)
    end
    function Text.search_next()
    -- search current line
    local pos = Lines[Cursor1.line].data:find(Search_term, Cursor1.pos)
    if pos then
    Cursor1.pos = pos
    end
    if pos == nil then
    for i=Cursor1.line+1,#Lines do
    pos = Lines[i].data:find(Search_term)
    if pos then
    Cursor1.line = i
    Cursor1.pos = pos
    break
    end
    end
    end
    if pos == nil then
    -- wrap around
    for i=1,Cursor1.line-1 do
    pos = Lines[i].data:find(Search_term)
    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
  • edit in text.lua at line 1899
    [4.936][4.936:985]()
    --? if Cursor1.line > Screen_bottom1.line then
  • edit in main.lua at line 71
    [3.8163]
    [3.8163]
    -- search
    Search_term = nil
    Search_text = nil
    Search_backup_cursor1 = nil -- where to position the cursor if search term was not found
  • replacement in main.lua at line 156
    [4.1175][4.9444:9489](),[4.9489][4.263:299](),[4.1219][4.263:299]()
    if line_index == Cursor1.line then
    Text.draw_cursor(25, y)
    [4.1175]
    [4.1377]
    if Search_term == nil then
    if line_index == Cursor1.line then
    Text.draw_cursor(25, y)
    end
  • replacement in main.lua at line 177
    [4.520][4.3453:3470](),[4.416][4.3453:3470]()
    --? os.exit(1)
    [4.520]
    [4.416]
    if Search_term then
    Text.draw_search_bar()
    end
  • edit in main.lua at line 187
    [4.1444]
    [33.49]
    if Search_term then return end
  • edit in main.lua at line 213
    [4.1485]
    [34.3]
    if Search_term then return end
  • replacement in main.lua at line 218
    [4.1512][4.162:203](),[4.162][4.162:203]()
    if Current_drawing_mode == 'name' then
    [4.1512]
    [4.203]
    if Search_term then
    Search_term = Search_term..t
    Search_text = nil
    Text.search_next()
    elseif Current_drawing_mode == 'name' then
  • replacement in main.lua at line 233
    [4.2196][4.4920:4979](),[4.2494][4.4920:4979](),[4.123][4.4920:4979]()
    if love.mouse.isDown('1') or chord:sub(1,2) == 'C-' then
    [4.1550]
    [4.4979]
    if Search_term then
    if chord == 'escape' then
    Search_term = nil
    Search_text = nil
    Cursor1 = Search_backup_cursor1
    Search_backup_cursor1 = nil
    elseif chord == 'return' then
    Search_term = nil
    Search_text = nil
    elseif chord == 'backspace' then
    local len = utf8.len(Search_term)
    local byte_offset = utf8.offset(Search_term, len)
    Search_term = string.sub(Search_term, 1, byte_offset-1)
    Search_text = nil
    elseif chord == 'down' then
    Cursor1.pos = Cursor1.pos+1
    Text.search_next()
    end
    return
    elseif chord == 'C-f' then
    Search_term = ''
    Search_backup_cursor1 = {line=Cursor1.line, pos=Cursor1.pos}
    assert(Search_text == nil)
    elseif love.mouse.isDown('1') or chord:sub(1,2) == 'C-' then