move

[?]
Aug 15, 2022, 11:07 PM
OYVFFWBK5IL7IPAF5HGFONJ2NEBRR3GTISPFROG7HJDEZYJAM7VQC

Dependencies

  • [2] EAEGCJV5 rename
  • [3] 7QQXO4YY bugfix: handle drawings when updating screen top
  • [4] M6TH7VSZ rip out notion of Line_width
  • [5] R53OF3ON one bug I've repeatedly run into while testing with Moby Dick
  • [6] AYE2VEGJ extract a couple of methods
  • [7] QCPXQ2E3 add state arg to a few functions
  • [8] 3OKKTUT4 up and down arrow now moving by screen line where possible
  • [9] CBPV5SSI stop handling nil screen_line_starting_pos everywhere
  • [10] LAW2O3NW extract variable Margin_left
  • [11] LF7BWEG4 group all editor globals
  • [12] KZ5GAYRP this fixes the immediate regression
  • [13] HOSPP2AN crisp font rendering
  • [14] 2ENZW7TV select text using mouse drag
  • [15] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [16] GCEF4N3V stop repeatedly checking for line wrapping
  • [17] HGC5RGJP switch to line index in a function
  • [18] MXA3RZYK deduce left/right from state where possible
  • [19] BULPIBEG beginnings of a module for the text editor
  • [20] UV4EWOLY add args to some functions
  • [21] P66MRF3U bugfix: don't append metadata when it already exists
  • [22] ILOA5BYF separate data structure for each line's cache data
  • [23] NDHQN23G done passing left/right margins everywhere
  • [24] ODLKHO7B switch to line index in a function
  • [25] TGHAJBES use line cache for drawings as well
  • [26] 2H67P75X switch arg for a function
  • [27] 4CTZOJPC stop pretending globals are local
  • [28] 4VKEE43Z bugfix
  • [*] X3F7ECSL add state arg to some functions
  • [*] 5DOC2CBM extract a function

Change contents

  • edit in text.lua at line 83
    [30.1551]
    [31.256]
    end
    function Text.populate_screen_line_starting_pos(State, line_index)
    local line = State.lines[line_index]
    if line.mode ~= 'text' then return end
    local line_cache = State.line_cache[line_index]
    if line_cache.screen_line_starting_pos then
    return
    end
    -- duplicate some logic from Text.draw
    if line_cache.fragments == nil then
    Text.compute_fragments(State, line_index)
    end
    line_cache.screen_line_starting_pos = {1}
    local x = State.left
    local pos = 1
    for _, f in ipairs(line_cache.fragments) do
    local frag, frag_text = f.data, f.text
    -- render fragment
    local frag_width = App.width(frag_text)
    if x + frag_width > State.right then
    x = State.left
    table.insert(line_cache.screen_line_starting_pos, pos)
    end
    x = x + frag_width
    local frag_len = utf8.len(frag)
    pos = pos + frag_len
    end
  • edit in text.lua at line 942
    [4.630][4.1960:1966](),[2.1229][4.1960:1966](),[4.1498][4.1960:1966](),[4.4957][4.1960:1966](),[4.6840][4.1960:1966](),[4.77528][4.1960:1966](),[4.1960][4.1960:1966](),[4.1966][4.8443:8448](),[4.8443][4.8443:8448](),[4.8448][4.606:712](),[4.712][3.3:44](),[3.44][4.1499:1549](),[4.712][4.1499:1549](),[4.1549][4.6896:6942](),[4.6896][4.6896:6942](),[4.6942][4.110:168](),[4.110][4.110:168](),[4.168][4.6943:6981](),[4.6981][4.780:826](),[4.2315][4.780:826](),[4.715][4.2360:2366](),[4.771][4.2360:2366](),[4.826][4.2360:2366](),[4.1878][4.2360:2366](),[4.2360][4.2360:2366](),[4.2366][4.6982:7026](),[4.7026][4.772:795](),[4.129][4.772:795](),[4.795][4.2381:2397](),[4.814][4.2381:2397](),[4.2566][4.2381:2397](),[4.2381][4.2381:2397](),[4.2397][4.7027:7073](),[4.7073][4.2437:2480](),[4.2437][4.2437:2480](),[4.2503][4.2503:2526](),[4.2526][4.3942:3986](),[4.3986][4.796:858](),[4.858][4.7074:7135](),[4.249][4.2818:2910](),[4.1997][4.2818:2910](),[4.7135][4.2818:2910](),[4.2818][4.2818:2910]()
    end
    end
    function Text.populate_screen_line_starting_pos(State, line_index)
    local line = State.lines[line_index]
    if line.mode ~= 'text' then return end
    local line_cache = State.line_cache[line_index]
    if line_cache.screen_line_starting_pos then
    return
    end
    -- duplicate some logic from Text.draw
    if line_cache.fragments == nil then
    Text.compute_fragments(State, line_index)
    end
    line_cache.screen_line_starting_pos = {1}
    local x = State.left
    local pos = 1
    for _, f in ipairs(line_cache.fragments) do
    local frag, frag_text = f.data, f.text
    -- render fragment
    local frag_width = App.width(frag_text)
    if x + frag_width > State.right then
    x = State.left
    table.insert(line_cache.screen_line_starting_pos, pos)
    end
    x = x + frag_width
    local frag_len = utf8.len(frag)
    pos = pos + frag_len