first test!

[?]
May 23, 2022, 6:17 AM
QYIFOHW3WDDQMK4ATY6IOSQRFHJOQ5QCPDKRC4GVGWLQEH4HGWVQC

Dependencies

  • [2] PFT5Y2ZY move
  • [3] JY4VK7L2 rename
  • [4] MGT5FTJ3 first stab at supporting wrapping in cursor up
  • [5] WLHI7KD3 new globals: draw partial screen line up top
  • [6] 537TQ2QN some more logging
  • [7] DXT4QTAH a few more integer coordinates
  • [8] 5Q6NIG66 bugfix
  • [9] BYG5CEMV support for naming points
  • [10] 2RXZ3PGO beginning of a new approach to scroll+wrap
  • [11] 5L7K4GBD clicking to the right of a wrapped line
  • [12] XNFTJHC4 split keyboard handling between Text and Drawing
  • [13] H2DPLWMV snapshot: wrapping long lines at word boundaries
  • [14] BULPIBEG beginnings of a module for the text editor
  • [*] VHQCNMAR several more modules

Change contents

  • replacement in text.lua at line 26
    [4.2007][4.2007:2068]()
    local frag_width = math.floor(frag_text:getWidth()*Zoom)
    [4.2007]
    [4.2068]
    local frag_width = math.floor(App.width(frag_text)*Zoom)
  • replacement in text.lua at line 50
    [4.253][4.210:260](),[3.282][4.210:260](),[4.210][4.210:260]()
    love.graphics.draw(frag_text, x,y, 0, Zoom)
    [3.282]
    [4.260]
    App.screen.draw(frag_text, x,y, 0, Zoom)
  • edit in text.lua at line 81
    [4.42]
    [2.1]
    function test_draw_text()
    App.screen.init{width=120, height=60}
    Lines = load_array{'abc', 'def', 'ghi'}
    Line_width = 120
    Cursor1 = {line=1, pos=1}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    Zoom = 1
    App.draw()
    local screen_top_margin = 15 -- pixels
    local line_height = 15 -- pixels
    local y = screen_top_margin
    App.screen.check(y, 'abc', 'F - test_draw_text/screen:1')
    y = y + line_height
    App.screen.check(y, 'def', 'F - test_draw_text/screen:2')
    y = y + line_height
    App.screen.check(y, 'ghi', 'F - test_draw_text/screen:3')
    end
  • replacement in text.lua at line 105
    [2.168][2.168:304]()
    local frag_text = love.graphics.newText(love.graphics.getFont(), frag)
    local frag_width = math.floor(frag_text:getWidth()*Zoom)
    [2.168]
    [2.304]
    local frag_text = App.newText(love.graphics.getFont(), frag)
    local frag_width = math.floor(App.width(frag_text)*Zoom)
  • replacement in text.lua at line 117
    [2.846][2.846:998]()
    local frag1_text = love.graphics.newText(love.graphics.getFont(), frag1)
    local frag1_width = math.floor(frag1_text:getWidth()*Zoom)
    [2.846]
    [2.998]
    local frag1_text = App.newText(love.graphics.getFont(), frag1)
    local frag1_width = math.floor(frag1App.width(_text)*Zoom)
  • replacement in text.lua at line 122
    [2.1191][2.1191:1327]()
    frag_text = love.graphics.newText(love.graphics.getFont(), frag)
    frag_width = math.floor(frag_text:getWidth()*Zoom)
    [2.1191]
    [2.1327]
    frag_text = App.newText(love.graphics.getFont(), frag)
    frag_width = math.floor(App.width(frag_text)*Zoom)
  • replacement in text.lua at line 501
    [4.1290][4.1290:1386](),[4.1386][4.210:271]()
    local text_before_cursor = love.graphics.newText(love.graphics.getFont(), line_before_cursor)
    return 25 + math.floor(text_before_cursor:getWidth()*Zoom)
    [4.1290]
    [4.1433]
    local text_before_cursor = App.newText(love.graphics.getFont(), line_before_cursor)
    return 25 + math.floor(App.width(text_before_cursor)*Zoom)
  • replacement in text.lua at line 507
    [4.3141][4.3141:3290]()
    local text_before_cursor = love.graphics.newText(love.graphics.getFont(), s_before_cursor)
    return math.floor(text_before_cursor:getWidth()*Zoom)
    [4.3141]
    [4.3290]
    local text_before_cursor = App.newText(love.graphics.getFont(), s_before_cursor)
    return math.floor(App.width(text_before_cursor)*Zoom)
  • edit in file.lua at line 104
    [16.18207]
    [16.18207]
    end
    -- for tests
    function load_array(a)
    local result = {}
    local next_line = ipairs(a)
    local i,line = 0, ''
    while true do
    i,line = next_line(a, i)
    if i == nil then break end
    if line == '```lines' then -- inflexible with whitespace since these files are always autogenerated
    table.insert(result, load_drawing_from_array(next_line, a, i))
    else
    table.insert(result, {mode='text', data=line})
    end
    end
    if #result == 0 then
    table.insert(result, {mode='text', data=''})
    end
    return result
    end
    function load_drawing_from_array(iter, a, i)
    local drawing = {mode='drawing', h=256/2, points={}, shapes={}, pending={}}
    local line
    while true do
    i, line = iter(a, i)
    assert(i)
    if line == '```' then break end
    local shape = json.decode(line)
    if shape.mode == 'freehand' then
    -- no changes needed
    elseif shape.mode == 'line' or shape.mode == 'manhattan' then
    local name = shape.p1.name
    shape.p1 = Drawing.insert_point(drawing.points, shape.p1.x, shape.p1.y)
    drawing.points[shape.p1].name = name
    name = shape.p2.name
    shape.p2 = Drawing.insert_point(drawing.points, shape.p2.x, shape.p2.y)
    drawing.points[shape.p2].name = name
    elseif shape.mode == 'polygon' or shape.mode == 'rectangle' or shape.mode == 'square' then
    for i,p in ipairs(shape.vertices) do
    local name = p.name
    shape.vertices[i] = Drawing.insert_point(drawing.points, p.x,p.y)
    drawing.points[shape.vertices[i]].name = name
    end
    elseif shape.mode == 'circle' or shape.mode == 'arc' then
    local name = shape.center.name
    shape.center = Drawing.insert_point(drawing.points, shape.center.x,shape.center.y)
    drawing.point[shape.center].name = name
    else
    print(shape.mode)
    assert(false)
    end
    table.insert(drawing.shapes, shape)
    end
    return drawing