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EOCJWUBHZOO4AFSYAJCKGCZZ4O52ILICF6DBQC
NP3LZH44LOWL2RPT7MOXWX5HJADZRFT7YFZKXSTEQ4JMFQDZPE7QC
A = function()
B()
-- TODO: ugly that we're manipulating editor objects twice
compute_layout(Page, Page.x,Page.y, Surface)
compute_layout(Page2, Page2.x,Page2.y, Surface)
-- continue the pipeline
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
compute_layout = function(node, x,y, nodes_to_render)
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
update_editor_box(node)
end
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
-- render background if necessary
elseif chord == 'C-up' then
if Cursor_node.in_reply_to_id then
Cursor_node = Nodes[Cursor_node.in_reply_to_id]
ensure_cursor_node_within_viewport()
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
ensure_cursor_node_within_viewport()
end
elseif chord == 'C-left' then
if Cursor_node.in_reply_to_id then
local parent = Nodes[Cursor_node.in_reply_to_id]
assert(parent.children)
if #parent.children > 1 then
local idx = array.find(parent.children, Cursor_node.id)
if idx > 1 then
Cursor_node = Nodes[parent.children[idx-1]]
ensure_cursor_node_within_viewport()
end
end
elseif chord == 'C-right' then
if Cursor_node.in_reply_to_id then
local parent = Nodes[Cursor_node.in_reply_to_id]
assert(parent.children)
if #parent.children > 1 then
local idx = array.find(parent.children, Cursor_node.id)
if idx < #parent.children then
Cursor_node = Nodes[parent.children[idx+1]]
ensure_cursor_node_within_viewport()
end
end