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JCKGCZZ4O52ILICF6DBQC NP3LZH44LOWL2RPT7MOXWX5HJADZRFT7YFZKXSTEQ4JMFQDZPE7QC A = function()B()-- TODO: ugly that we're manipulating editor objects twicecompute_layout(Page, Page.x,Page.y, Surface)compute_layout(Page2, Page2.x,Page2.y, Surface)-- continue the pipelinelove.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.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendupdate_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 textnode.x = xnode.y = y-- render background if necessary
elseif chord == 'C-up' thenif Cursor_node.in_reply_to_id thenCursor_node = Nodes[Cursor_node.in_reply_to_id]ensure_cursor_node_within_viewport()endelseif chord == 'C-down' thenif Cursor_node.children and #Cursor_node.children > 0 thenCursor_node = Nodes[Cursor_node.children[1]]ensure_cursor_node_within_viewport()endelseif chord == 'C-left' thenif Cursor_node.in_reply_to_id thenlocal parent = Nodes[Cursor_node.in_reply_to_id]assert(parent.children)if #parent.children > 1 thenlocal idx = array.find(parent.children, Cursor_node.id)if idx > 1 thenCursor_node = Nodes[parent.children[idx-1]]ensure_cursor_node_within_viewport()endendelseif chord == 'C-right' thenif Cursor_node.in_reply_to_id thenlocal parent = Nodes[Cursor_node.in_reply_to_id]assert(parent.children)if #parent.children > 1 thenlocal idx = array.find(parent.children, Cursor_node.id)if idx < #parent.children thenCursor_node = Nodes[parent.children[idx+1]]ensure_cursor_node_within_viewport()endend