change data model; text can now have metadata

[?]
May 17, 2022, 5:20 AM
VVXVV2D2F5Y6D6N5VVPUPK3N6GMDTG2YCYPQDYTYEKVKBYHRRYEAC

Dependencies

  • [2] GVOFXXIT delete drawing using backspace
  • [3] 3SYFA5JQ show cursor even on empty lines
  • [4] KHFU5NFD bugfix: up/down across drawings
  • [5] HJ3PM2VT .
  • [6] TEIKBO2T don't try to append text to drawings
  • [7] OTIBCAUJ love2d scaffold
  • [8] 7RN3AETY bugfix: text sometimes getting colored like drawing borders
  • [9] KCIM5UTV revert: back to freehand
  • [10] Z4KNS42N to open a file without a terminal, drag it on!
  • [11] ZD63LJ2T bugfix: keep the click to create a new drawing from creating a new shape in the drawing
  • [12] EDY3RQUL gracefully handle a non-existent filename at the commandline
  • [13] G77XIN7M selecting a stroke
  • [14] QU7NHFOV show cursor
  • [15] Z2CJVAPV lighter border for figures
  • [16] MNWHXPBL more lightweight; select just the stroke at the mouse
  • [17] H7OEU6WP experimental approach to combining keyboard and mouse while drawing
  • [18] IYW7X3WL left/right cursor movement, deleting characters
  • [19] TNTYISW6 rename
  • [20] R3WSFYGY spacing
  • [21] NL5J7Z5H new mode: polygon
  • [22] QW5KQQTD fix a comment
  • [23] XX7G2FFJ intermingle freehand line drawings with text
  • [24] JS6JSYOT online contextual help
  • [25] YKRF5V3Z starting to load/save
  • [26] RJGZD4IN binary search to most natural up/down with proportional fonts
  • [27] FBDRL6LH delete points or shapes
  • [28] JCSLDGAH beginnings of support for multiple shapes
  • [29] ZOOY3ME4 new mode: circle arc
  • [30] 6PUNJS5B backspace
  • [31] TRCAEE2A clip drawings inside the border
  • [32] K6HMLFLZ color close to drawing
  • [33] LBQAAJN4 load/save freehand strokes
  • [34] 3CS5KKCI up/down cursor movement
  • [35] 6LJZN727 handle chords
  • [36] JVRL5TWL store device-independent coordinates inside drawings
  • [37] WDWXNW7V slightly strange way to move points
  • [38] OFA3PRBS autosave on keystrokes
  • [39] PRPPZGDY speed up some obvious common cases
  • [40] EFMLTMZG bugfix: restrict strokes to the drawing they started in
  • [41] HWPK4SMP new mode: manhattan
  • [42] 3XD6M3CF refactor
  • [43] 6F6DF5T3 .
  • [44] IFGAJAF7 add a level of indirection to vertices of shapes

Change contents

  • replacement in main.lua at line 5
    [7.22][7.3:104]()
    -- lines is an array of lines
    -- a line is either:
    -- a string containing text
    -- or a drawing
    [7.22]
    [7.104]
    -- a line is either text or a drawing
    -- a text is a table with:
    -- mode = 'text'
    -- string data
  • replacement in main.lua at line 10
    [7.134][7.134:163]()
    -- a (y) coord in pixels,
    [7.134]
    [7.163]
    -- mode = 'drawing'
    -- a (y) coord in pixels (updated while painting screen),
  • replacement in main.lua at line 32
    [7.1237][7.1:14]()
    lines = {''}
    [7.1237]
    [7.14]
    lines = {{mode='text', data=''}}
  • replacement in main.lua at line 39
    [7.148][7.148:183]()
    cursor_pos = #lines[cursor_line]+1
    [7.148]
    [7.1238]
    cursor_pos = #lines[cursor_line].data+1
  • replacement in main.lua at line 92
    [7.80][7.73:96]()
    if line == '' then
    [7.72]
    [7.96]
    if line.mode == 'text' and line.data == '' then
  • replacement in main.lua at line 102
    [7.500][7.3:97]()
    table.insert(lines, i, {y=y, h=256/2, points={}, shapes={}, pending={}})
    [7.500]
    [7.588]
    table.insert(lines, i, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}})
  • replacement in main.lua at line 108
    [3.200][7.613:651](),[7.613][7.613:651]()
    elseif type(line) == 'table' then
    [3.200]
    [7.651]
    elseif line.mode == 'drawing' then
  • replacement in main.lua at line 159
    [7.38][5.1:73]()
    local text = love.graphics.newText(love.graphics.getFont(), line)
    [7.38]
    [7.1249]
    local text = love.graphics.newText(love.graphics.getFont(), line.data)
  • replacement in main.lua at line 163
    [7.88][7.1:158]()
    love.graphics.print('_', 25+cursor_x(lines[cursor_line], cursor_pos)*1.5, y+6) -- drop the cursor down a bit to account for the increased font size
    [7.50]
    [7.411]
    love.graphics.print('_', 25+cursor_x(line.data, cursor_pos)*1.5, y+6) -- drop the cursor down a bit to account for the increased font size
  • replacement in main.lua at line 172
    [7.29][7.29:104]()
    local drawing = lines.current
    if type(drawing) == 'table' then
    [7.29]
    [7.2]
    if lines.current.mode == 'drawing' then
    local drawing = lines.current
  • replacement in main.lua at line 266
    [7.223][7.223:260]()
    if type(drawing) == 'table' then
    [7.223]
    [7.260]
    if drawing.mode == 'drawing' then
  • edit in main.lua at line 478
    [7.1633][7.1633:1691]()
    --? print(s,e, angle-math.pi*2, angle, angle+math.pi*2)
  • replacement in main.lua at line 497
    [7.41][6.1:58]()
    if type(lines[cursor_line]) == 'table' then return end
    [7.41]
    [7.490]
    if lines[cursor_line].mode == 'drawing' then return end
  • replacement in main.lua at line 500
    [7.534][7.534:597]()
    byteoffset = utf8.offset(lines[cursor_line], cursor_pos-1)
    [7.534]
    [7.597]
    byteoffset = utf8.offset(lines[cursor_line].data, cursor_pos-1)
  • replacement in main.lua at line 504
    [7.629][7.629:747]()
    lines[cursor_line] = string.sub(lines[cursor_line], 1, byteoffset)..t..string.sub(lines[cursor_line], byteoffset+1)
    [7.629]
    [7.747]
    lines[cursor_line].data = string.sub(lines[cursor_line].data, 1, byteoffset)..t..string.sub(lines[cursor_line].data, byteoffset+1)
  • replacement in main.lua at line 514
    [7.224][7.422:465]()
    table.insert(lines, cursor_line+1, '')
    [7.224]
    [7.465]
    table.insert(lines, cursor_line+1, {mode='text', data=''})
  • replacement in main.lua at line 518
    [7.66][7.66:139](),[7.139][2.2:99]()
    if #lines > 1 and lines[#lines] == '' then
    table.remove(lines)
    elseif type(lines[#lines]) == 'table' then
    table.remove(lines) -- we'll add undo soon
    [7.66]
    [7.139]
    if cursor_line > 1 and lines[cursor_line].data == '' then
    table.remove(lines, cursor_line)
    cursor_line = cursor_line-1
    if lines[cursor_line].mode == 'text' then
    cursor_pos = #lines[cursor_line].data+1
    else
    cursor_pos = 1
    end
    elseif lines[cursor_line].mode == 'drawing' then
    table.remove(lines, cursor_line) -- we'll add undo soon
    cursor_line = cursor_line-1
    if lines[cursor_line].mode == 'text' then
    cursor_pos = #lines[cursor_line].data+1
    else
    cursor_pos = 1
    end
  • replacement in main.lua at line 536
    [7.805][7.805:947]()
    local byte_start = utf8.offset(lines[cursor_line], cursor_pos-1)
    local byte_end = utf8.offset(lines[cursor_line], cursor_pos)
    [7.805]
    [7.947]
    local byte_start = utf8.offset(lines[cursor_line].data, cursor_pos-1)
    local byte_end = utf8.offset(lines[cursor_line].data, cursor_pos)
  • replacement in main.lua at line 540
    [7.1001][7.1001:1124]()
    lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)..string.sub(lines[cursor_line], byte_end)
    [7.1001]
    [7.1124]
    lines[cursor_line].data = string.sub(lines[cursor_line].data, 1, byte_start-1)..string.sub(lines[cursor_line].data, byte_end)
  • replacement in main.lua at line 542
    [7.1139][7.1139:1220]()
    lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)
    [7.1139]
    [7.1220]
    lines[cursor_line].data = string.sub(lines[cursor_line].data, 1, byte_start-1)
  • replacement in main.lua at line 553
    [7.1430][7.1430:1476]()
    if cursor_pos <= #lines[cursor_line] then
    [7.1430]
    [7.1476]
    if cursor_pos <= #lines[cursor_line].data then
  • replacement in main.lua at line 559
    [7.237][7.237:276]()
    cursor_pos = #lines[cursor_line]+1
    [7.237]
    [7.525]
    cursor_pos = #lines[cursor_line].data+1
  • replacement in main.lua at line 562
    [7.581][7.277:338]()
    local old_x = cursor_x(lines[cursor_line], cursor_pos)
    [7.581]
    [7.581]
    local old_x = cursor_x(lines[cursor_line].data, cursor_pos)
  • replacement in main.lua at line 564
    [7.615][7.1:78]()
    cursor_pos = nearest_cursor_pos(lines[cursor_line], old_x, cursor_pos)
    [7.615]
    [7.1510]
    cursor_pos = nearest_cursor_pos(lines[cursor_line].data, old_x, cursor_pos)
  • replacement in main.lua at line 568
    [7.779][7.405:466]()
    local old_x = cursor_x(lines[cursor_line], cursor_pos)
    [7.779]
    [7.779]
    local old_x = cursor_x(lines[cursor_line].data, cursor_pos)
  • replacement in main.lua at line 570
    [7.813][7.79:156]()
    cursor_pos = nearest_cursor_pos(lines[cursor_line], old_x, cursor_pos)
    [7.813]
    [7.913]
    cursor_pos = nearest_cursor_pos(lines[cursor_line].data, old_x, cursor_pos)
  • replacement in main.lua at line 573
    [7.1550][7.1550:1734]()
    if cursor_pos <= #lines[cursor_line] then
    local byte_start = utf8.offset(lines[cursor_line], cursor_pos)
    local byte_end = utf8.offset(lines[cursor_line], cursor_pos+1)
    [7.1550]
    [7.1734]
    if cursor_pos <= #lines[cursor_line].data then
    local byte_start = utf8.offset(lines[cursor_line].data, cursor_pos)
    local byte_end = utf8.offset(lines[cursor_line].data, cursor_pos+1)
  • replacement in main.lua at line 578
    [7.1784][7.1784:1905]()
    lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)..string.sub(lines[cursor_line], byte_end)
    [7.1784]
    [7.1905]
    lines[cursor_line].data = string.sub(lines[cursor_line].data, 1, byte_start-1)..string.sub(lines[cursor_line].data, byte_end)
  • replacement in main.lua at line 580
    [7.1918][7.1918:1997]()
    lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)
    [7.1918]
    [7.1997]
    lines[cursor_line].data = string.sub(lines[cursor_line].data, 1, byte_start-1)
  • replacement in main.lua at line 725
    [7.588][4.1:46]()
    if type(line) == 'table' then return 0 end
    [7.588]
    [7.588]
    if line.mode == 'drawing' then return 0 end
  • replacement in main.lua at line 732
    [7.200][4.47:95]()
    if type(line) == 'table' then return hint end
    [7.200]
    [7.820]
    if line.mode == 'drawing' then return hint end
  • replacement in main.lua at line 768
    [7.603][7.603:640]()
    if type(drawing) == 'table' then
    [7.603]
    [7.795]
    if drawing.mode == 'drawing' then
  • replacement in main.lua at line 780
    [7.918][7.918:955]()
    if type(drawing) == 'table' then
    [7.918]
    [7.895]
    if drawing.mode == 'drawing' then
  • replacement in main.lua at line 791
    [7.199][7.199:236]()
    if type(drawing) == 'table' then
    [7.199]
    [7.236]
    if drawing.mode == 'drawing' then
  • replacement in main.lua at line 808
    [7.1197][7.1197:1234]()
    if type(drawing) == 'table' then
    [7.1197]
    [7.1234]
    if drawing.mode == 'drawing' then
  • replacement in main.lua at line 825
    [7.1597][7.1597:1634]()
    if type(drawing) == 'table' then
    [7.1597]
    [7.1634]
    if drawing.mode == 'drawing' then
  • replacement in main.lua at line 949
    [7.554][7.554:589]()
    table.insert(result, line)
    [7.554]
    [7.589]
    table.insert(result, {mode='text', data=line})
  • replacement in main.lua at line 954
    [7.128][7.128:157]()
    table.insert(result, '')
    [7.128]
    [7.157]
    table.insert(result, {mode='text', data=''})
  • replacement in main.lua at line 962
    [7.747][7.747:781]()
    if type(line) == 'table' then
    [7.747]
    [7.781]
    if line.mode == 'drawing' then
  • replacement in main.lua at line 965
    [7.825][7.825:857]()
    outfile:write(line..'\n')
    [7.825]
    [7.857]
    outfile:write(line.data..'\n')
  • replacement in main.lua at line 973
    [7.544][7.928:990](),[7.928][7.928:990]()
    local drawing = {h=256/2, points={}, shapes={}, pending={}}
    [7.544]
    [7.990]
    local drawing = {mode='drawing', h=256/2, points={}, shapes={}, pending={}}