highlight selection while dragging

[?]
Jun 3, 2022, 8:22 PM
5FW7YOFTLKHRND6IOR4HG4X3C5BO2WV5KTEUW3PPKCRU5L5GXKXQC

Dependencies

  • [2] TKFSYQ2Z up arrow to search previous
  • [3] 2ENZW7TV select text using mouse drag
  • [4] YPHKZVWM extract a new variable
  • [5] BULPIBEG beginnings of a module for the text editor
  • [6] GE56XURA bugfix: cursor past end of screen line
  • [7] 2INHXC3K position cursor by clicking on text
  • [8] HIH47LNB drop unused arg
  • [9] 4NDYV4WD fix 2 bugs in line selection
  • [10] PHQPLJUQ rename
  • [11] DHI6IJCN selecting text and deleting selections
  • [12] UWNHC4AA redo y computations
  • [13] DHCLUDCW .
  • [14] NZ7V4BVS note card
  • [15] Z4XRNDTR find text
  • [16] HDC3AAQP silly reason my screenshots had an ugly black line down the left
  • [17] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [18] 2C7CTIQY make space for multiple kinds of width
  • [19] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [20] OTIBCAUJ love2d scaffold
  • [21] IRV65LZP fold variables for screen dimensions into the app framework
  • [22] AVQ5MC5D finish uppercasing all globals
  • [23] DXT4QTAH a few more integer coordinates
  • [24] HJ3PM2VT .
  • [25] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [26] 7IKRRESB longer names for indices in long loops
  • [27] BYG5CEMV support for naming points
  • [28] DLQMM265 scroll past first page
  • [29] 5L7K4GBD clicking to the right of a wrapped line
  • [30] XX7G2FFJ intermingle freehand line drawings with text
  • [31] OYXDYPGS get rid of debug variables
  • [32] VJ3ODCHR assert for a bug I saw a while ago but can no longer reproduce
  • [33] HOSPP2AN crisp font rendering
  • [34] EDY3RQUL gracefully handle a non-existent filename at the commandline
  • [35] ULKLJBN6 couple of renames
  • [36] VJ77YABH more efficient undo/redo
  • [37] QU7NHFOV show cursor
  • [38] BOFNXP5G clicking now moves the cursor even on long, wrapped lines
  • [*] OIB2QPRC start remembering where the cursor is drawn in px
  • [*] AVTNUQYR basic test-enabled framework

Change contents

  • replacement in text.lua at line 216
    [2.1240][4.1068:1224](),[4.1068][4.1068:1224]()
    -- Return any intersection of the region from Selection1 to Cursor1 with the
    -- region between {line=line_index, pos=apos} and {line=line_index, pos=bpos}.
    [2.1240]
    [4.1224]
    -- Return any intersection of the region from Selection1 to Cursor1 (or
    -- current mouse, if mouse is pressed; or recent mouse if mouse is pressed and
    -- currently over a drawing) with the region between {line=line_index, pos=apos}
    -- and {line=line_index, pos=bpos}.
  • replacement in text.lua at line 226
    [4.1556][4.1556:1601]()
    local maxl,maxp = Cursor1.line,Cursor1.pos
    [4.1556]
    [4.1601]
    local maxl,maxp
    if love.mouse.isDown('1') then
    maxl,maxp = Text.mouse_pos()
    else
    maxl,maxp = Cursor1.line,Cursor1.pos
    end
  • edit in text.lua at line 261
    [4.2613]
    [4.2613]
    end
    end
    -- inefficient for some reason, so don't do it on every frame
    function Text.mouse_pos()
    local time = love.timer.getTime()
    if Recent_mouse.time and Recent_mouse.time > time-0.1 then
    return Recent_mouse.line, Recent_mouse.pos
    end
    Recent_mouse.time = time
    local line,pos = Text.to_pos(love.mouse.getX(), love.mouse.getY())
    if line then
    Recent_mouse.line = line
    Recent_mouse.pos = pos
  • edit in text.lua at line 276
    [4.2619]
    [4.2619]
    return Recent_mouse.line, Recent_mouse.pos
  • edit in text.lua at line 279
    [4.2624]
    [4.2624]
    function Text.to_pos(x,y)
    for line_index,line in ipairs(Lines) do
    if line.mode == 'text' then
    if Text.in_line(line, x,y) then
    return line_index, Text.to_pos_on_line(line, x,y)
    end
    end
    end
    end
  • replacement in text.lua at line 1864
    [4.100][4.65:84](),[4.84][4.419:471](),[4.100][4.419:471](),[4.471][4.7425:7453]()
    -- mx,my in pixels
    function Text.move_cursor(line_index, line, mx, my)
    Cursor1.line = line_index
    [4.100]
    [4.472]
    -- convert mx,my in pixels to schema-1 coordinates
    function Text.to_pos_on_line(line, mx, my)
  • replacement in text.lua at line 1867
    [4.519][4.7454:7511](),[4.7511][4.611:622](),[4.611][4.611:622]()
    Cursor1.pos = Text.nearest_cursor_pos(line.data, mx)
    return
    [4.519]
    [4.622]
    return Text.nearest_cursor_pos(line.data, mx)
  • replacement in text.lua at line 1880
    [4.437][4.7512:7585](),[4.73][4.513:528](),[4.7585][4.513:528](),[4.513][4.513:528]()
    Cursor1.pos = line.screen_line_starting_pos[screen_line_index+1]
    return
    [4.437]
    [4.528]
    return line.screen_line_starting_pos[screen_line_index+1]
  • replacement in text.lua at line 1883
    [4.1185][4.7586:7668](),[4.7668][4.1266:1279](),[4.1266][4.1266:1279]()
    Cursor1.pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1
    return
    [4.1185]
    [4.1279]
    return screen_line_starting_pos + Text.nearest_cursor_pos(s, mx) - 1
  • edit in main.lua at line 58
    [4.10940]
    [40.54]
    Recent_mouse = {} -- when selecting text, avoid recomputing some state on every single frame
  • edit in main.lua at line 142
    [4.336][4.480:545]()
    for line_index,line in ipairs(Lines) do
    line.y = nil
    end
  • replacement in main.lua at line 199
    [4.11240][4.1788:1837](),[4.492][4.1788:1837]()
    Text.move_cursor(line_index, line, x, y)
    [4.492]
    [3.234]
    Cursor1.line = line_index
    Cursor1.pos = Text.to_pos_on_line(line, x, y)
  • replacement in main.lua at line 219
    [3.490][3.490:541]()
    Text.move_cursor(line_index, line, x, y)
    [3.490]
    [3.541]
    Cursor1.line = line_index
    Cursor1.pos = Text.to_pos_on_line(line, x, y)
  • edit in main.lua at line 231
    [41.1512]
    [4.2944]
    for _,line in ipairs(Lines) do line.y = nil end -- just in case we scroll
  • edit in main.lua at line 247
    [41.1550]
    [4.3090]
    for _,line in ipairs(Lines) do line.y = nil end -- just in case we scroll