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TFWALBXSO3EQ4JCABRZM2TOQEJOGB6QC
Y36LOGR5X6S6AEJJ3EBVDC4I3RRFRCZ6GXPXSEIOMVXY2B7UCCGQC
5DOC2CBMBDMAOJ7IKLDGVRCY4SNPCJTTF7DK7WGNLPGNV4AWVJNAC
JY4VK7L2JKRWRV45QEMGLWPFAQRUWKFHMAL6DWNYEDCKO5Y4W5FQC
CVGE3SIGJRGCLY3A2RBPGFXAEKVZXUUIZQLRHJLM4VPUM4SHEZIAC
M6TH7VSZQGKDB7SFNN5K52WWAX5VTVNT6GOKNKTXPVZBT6NEYDOQC
local x = State.left
local pos = 1
local overflows_screen, x, y, pos, screen_line_starting_pos = Text.draw_wrapping_line(State, line_index, State.left, y, startpos)
if overflows_screen then
return y, screen_line_starting_pos
end
if line.data2 and #line.data2 > 0 then
if not line_cache.expanded then
button('expand', {x=x+5, y=y+2, w=App.width(State.em), h=State.line_height-4, color={1,1,1},
icon = function(x,y)
App.color(Fold_background_color)
love.graphics.rectangle('fill', x, y, App.width(State.em), State.line_height-4, 2,2)
end,
onpress1 = function()
line_cache.expanded = true
end,
})
else
App.color(Fold_color)
App.screen.print(line.data2, x+5+5,y)
end
end
if State.search_term == nil then
if line_index == State.cursor1.line and State.cursor1.pos == pos then
Text.draw_cursor(State, x, y)
end
end
return y, screen_line_starting_pos
end
-- manual tests:
-- draw with small screen width of 100
-- Given an array of fragments, draw the subset starting from pos to screen
-- starting from (x,y).
-- Return:
-- - whether we got to bottom of screen before end of line
-- - the final (x,y)
-- - the final pos
-- - starting pos of the final screen line drawn
function Text.draw_wrapping_line(State, line_index, x,y, startpos)
local line = State.lines[line_index]
local line_cache = State.line_cache[line_index]
if line.data2 and #line.data2 > 0 then
if not line_cache.expanded then
button('expand', {x=x+5, y=y+2, w=App.width(State.em), h=State.line_height-4, color={1,1,1},
icon = function(x,y)
App.color(Fold_background_color)
love.graphics.rectangle('fill', x, y, App.width(State.em), State.line_height-4, 2,2)
end,
onpress1 = function()
line_cache.expanded = true
end,
})
else
App.color(Fold_color)
App.screen.print(line.data2, x+5+5,y)
end
end
if State.search_term == nil then
if line_index == State.cursor1.line and State.cursor1.pos == pos then
Text.draw_cursor(State, x, y)
end
end
return y, screen_line_starting_pos
return false, x,y, pos, screen_line_starting_pos