support for naming points

[?]
May 21, 2022, 9:03 PM
BYG5CEMVXANDTBI2ORNVMEY6K3EBRIHZHS4QBK27VONJC5537COQC

Dependencies

  • [2] 2ZYV7D3W handle tab characters
  • [3] DXT4QTAH a few more integer coordinates
  • [4] PFT5Y2ZY move
  • [5] 2XLZCWZC bugfix: rectangles and squares are now saved
  • [6] F63Q4OV7 several bugfixes
  • [7] IDGP4BJZ new known issue with drawings
  • [8] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [9] VHQCNMAR several more modules
  • [10] XNFTJHC4 split keyboard handling between Text and Drawing
  • [11] 5DOC2CBM extract a function
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] BJ5X5O4A let's prevent the text cursor from ever getting on a drawing
  • [*] FEEGTRGQ bugfix: duplicate character on enter
  • [*] OTIBCAUJ love2d scaffold
  • [*] 6DE7RBZ6 move mouse_released events to Drawing
  • [*] JCSLDGAH beginnings of support for multiple shapes
  • [*] DLQMM265 scroll past first page
  • [*] BLWAYPKV extract a module
  • [*] NYQ7HD4D move
  • [*] FS2ITYYH record a known issue

Change contents

  • replacement in text.lua at line 105
    [4.1568][8.42:69](),[8.42][8.42:69]()
    function love.textinput(t)
    [4.1568]
    [8.69]
    function Text.textinput(t)
  • edit in text.lua at line 107
    [8.113][8.113:171]()
    if Lines[Cursor_line].mode == 'drawing' then return end
  • edit in text.lua at line 108
    [2.28][2.28:60]()
    save_to_disk(Lines, Filename)
  • edit in manual_tests at line 18
    [6.90]
    [15.2]
    select a point and name it
  • edit in manual_tests at line 37
    [5.131]
    select a point and name it, quit, restart. Name is still visible.
  • edit in main.lua at line 168
    [17.41]
    [18.3116]
    end
    function love.textinput(t)
    if Current_drawing_mode == 'name' then
    local drawing = Lines.current
    local p = drawing.points[drawing.pending.target_point]
    p.name = p.name..t
    else
    Text.textinput(t)
    end
    save_to_disk(Lines, Filename)
  • edit in main.lua at line 189
    [19.1593]
    [19.1593]
    elseif Current_drawing_mode == 'name' then
    if chord == 'return' then
    Current_drawing_mode = Previous_drawing_mode
    Previous_drawing_mode = nil
    else
    local drawing = Lines.current
    local p = drawing.points[drawing.pending.target_point]
    if chord == 'escape' then
    p.name = nil
    elseif chord == 'backspace' then
    local len = utf8.len(p.name)
    local byte_offset = utf8.offset(p.name, len-1)
    p.name = string.sub(p.name, 1, byte_offset)
    end
    end
    save_to_disk(Lines, Filename)
  • edit in help.lua at line 9
    [8.7032]
    [3.375]
    y = y + math.floor(15*Zoom)
    love.graphics.print("* Hover on a point and press 'ctrl+n' to name it,", 16+30,y, 0, Zoom)
  • replacement in file.lua at line 51
    [8.16524][8.16524:16586]()
    if shape.mode == 'line' or shape.mode == 'manhattan' then
    [8.16524]
    [8.16586]
    if shape.mode == 'freehand' then
    -- no changes needed
    elseif shape.mode == 'line' or shape.mode == 'manhattan' then
    local name = shape.p1.name
  • edit in file.lua at line 56
    [8.16664]
    [8.16664]
    drawing.points[shape.p1].name = name
    name = shape.p2.name
  • edit in file.lua at line 59
    [8.16742]
    [5.139]
    drawing.points[shape.p2].name = name
  • edit in file.lua at line 62
    [8.16825]
    [8.16825]
    local name = p.name
  • edit in file.lua at line 64
    [8.16899]
    [8.16899]
    drawing.points[shape.vertices[i]].name = name
  • edit in file.lua at line 67
    [8.16971]
    [8.16971]
    local name = shape.center.name
  • edit in file.lua at line 69
    [8.17060]
    [5.235]
    drawing.point[shape.center].name = name
  • edit in drawing.lua at line 48
    [8.19025]
    [20.1459]
    end
    if p.name then
    -- todo: clip
    love.graphics.print(p.name, Drawing.pixels(p.x)+16+5,Drawing.pixels(p.y)+line.y+5, 0, Zoom)
  • edit in drawing.lua at line 85
    [21.1220]
    [21.1220]
    -- todo: clip
  • edit in drawing.lua at line 180
    [6.134]
    [6.134]
    -- nothing pending; changes are immediately committed
    elseif shape.mode == 'name' then
  • edit in drawing.lua at line 476
    [8.10650]
    [8.10650]
    Lines.current = drawing
    end
    elseif chord == 'C-n' and not love.mouse.isDown('1') then
    local drawing,point_index,p = Drawing.select_point_at_mouse()
    if drawing then
    Previous_drawing_mode = Current_drawing_mode
    Current_drawing_mode = 'name'
    p.name = ''
    drawing.pending = {mode=Current_drawing_mode, target_point=point_index}
  • edit in README.md at line 19
    [7.21]
    [7.21]
    * No clipping yet for drawings. In particular, circles and point labels can
    overflow a drawing.