All nodes are still read-only.
NP3LZH44LOWL2RPT7MOXWX5HJADZRFT7YFZKXSTEQ4JMFQDZPE7QC on.keychord_press = function(chord, key)if chord == 'C-=' then-- zoom inViewport.zoom = Viewport.zoom+0.1B()elseif chord == 'C--' then-- zoom outViewport.zoom = Viewport.zoom-0.1B()elseif chord == 'C-0' then-- reset zoomViewport.zoom = 1.0B()elseif chord == 'C-up' thenif Cursor_node.in_reply_to_id thenCursor_node = Nodes[Cursor_node.in_reply_to_id]endelseif chord == 'C-down' thenif Cursor_node.children and #Cursor_node.children > 0 thenCursor_node = Nodes[Cursor_node.children[1]]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]]endendendelseif 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]]endendendendend
{"on.code_change":578,"line_height":365,"add_thick_line":400,"Surface":588,"on.keychord_press":631,"ntracks":600,"on.mouse_press":618,"A":582,"on.mouse_release":586,"on.text_input":587,"scale":7,"Nodes":593,"on":1,"schema1_of_y":366,"font":353,"to_node":611,"y_of_schema1":364,"add_edge":575,"on.draw":627,"render_thread_to_surface":626,"B":379,"box_height":345,"on.update":368,"dehtml":456,"copy_shape":396,"add_node":590,"Input_filename":436,"vy":8,"compute_layout":619,"Viewport":303,"load_from_iterator":463,"split_lines":469,"to_text":180,"on.initialize":446,"Cursor_node":172,"compute_ntracks":598,"fw_app":"mastodon-luaML","update_editor_box":430,"fw_parent":630,"initialize_editor":338,"vx":5,"render_node_and_descendants":614}
on.keychord_press = function(chord, key)if chord == 'C-=' then-- zoom inViewport.zoom = Viewport.zoom+0.1B()elseif chord == 'C--' then-- zoom outViewport.zoom = Viewport.zoom-0.1B()elseif chord == 'C-0' then-- reset zoomViewport.zoom = 1.0B()elseif chord == 'C-up' thenif Cursor_node.in_reply_to_id thenCursor_node = Nodes[Cursor_node.in_reply_to_id]endelseif chord == 'C-down' thenif Cursor_node.children and #Cursor_node.children > 0 thenCursor_node = Nodes[Cursor_node.children[1]]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]]endendendendend
{"on.code_change":578,"line_height":365,"add_thick_line":400,"Surface":588,"on.keychord_press":630,"ntracks":600,"on.mouse_press":618,"A":582,"on.mouse_release":586,"on.text_input":587,"scale":7,"Nodes":593,"on":1,"schema1_of_y":366,"font":353,"to_node":611,"y_of_schema1":364,"add_edge":575,"on.draw":627,"render_thread_to_surface":626,"B":379,"box_height":345,"on.update":368,"dehtml":456,"copy_shape":396,"add_node":590,"Input_filename":436,"vy":8,"compute_layout":619,"Viewport":303,"load_from_iterator":463,"split_lines":469,"to_text":180,"on.initialize":446,"Cursor_node":172,"compute_ntracks":598,"fw_app":"mastodon-luaML","update_editor_box":430,"fw_parent":629,"initialize_editor":338,"vx":5,"render_node_and_descendants":614}
on.keychord_press = function(chord, key)if chord == 'C-=' then-- zoom inViewport.zoom = Viewport.zoom+0.1B()elseif chord == 'C--' then-- zoom outViewport.zoom = Viewport.zoom-0.1B()elseif chord == 'C-0' then-- reset zoomViewport.zoom = 1.0B()elseif chord == 'C-up' thenif Cursor_node.in_reply_to_id thenCursor_node = Nodes[Cursor_node.in_reply_to_id]endelseif chord == 'C-down' thenif Cursor_node.children and #Cursor_node.children > 0 thenCursor_node = Nodes[Cursor_node.children[1]]endendend
{"on.code_change":578,"line_height":365,"add_thick_line":400,"Surface":588,"on.keychord_press":629,"ntracks":600,"on.mouse_press":618,"A":582,"on.mouse_release":586,"on.text_input":587,"scale":7,"Nodes":593,"on":1,"schema1_of_y":366,"font":353,"to_node":611,"y_of_schema1":364,"add_edge":575,"on.draw":627,"render_thread_to_surface":626,"B":379,"box_height":345,"on.update":368,"dehtml":456,"copy_shape":396,"add_node":590,"Input_filename":436,"vy":8,"compute_layout":619,"Viewport":303,"load_from_iterator":463,"split_lines":469,"to_text":180,"on.initialize":446,"Cursor_node":172,"compute_ntracks":598,"fw_app":"mastodon-luaML","update_editor_box":430,"fw_parent":628,"initialize_editor":338,"vx":5,"render_node_and_descendants":614}
on.keychord_press = function(chord, key)if chord == 'C-=' then-- zoom inViewport.zoom = Viewport.zoom+0.1B()elseif chord == 'C--' then-- zoom outViewport.zoom = Viewport.zoom-0.1B()elseif chord == 'C-0' then-- reset zoomViewport.zoom = 1.0B()elseif chord == 'C-up' thenif Cursor_node.in_reply_to_id thenCursor_node = Nodes[Cursor_node.in_reply_to_id]endendend
{"on.code_change":578,"line_height":365,"add_thick_line":400,"Surface":588,"on.keychord_press":628,"ntracks":600,"on.mouse_press":618,"A":582,"on.mouse_release":586,"on.text_input":587,"scale":7,"Nodes":593,"on":1,"schema1_of_y":366,"font":353,"to_node":611,"y_of_schema1":364,"add_edge":575,"on.draw":627,"render_thread_to_surface":626,"B":379,"box_height":345,"on.update":368,"dehtml":456,"copy_shape":396,"add_node":590,"Input_filename":436,"vy":8,"compute_layout":619,"Viewport":303,"load_from_iterator":463,"split_lines":469,"to_text":180,"on.initialize":446,"Cursor_node":172,"compute_ntracks":598,"fw_app":"mastodon-luaML","update_editor_box":430,"fw_parent":627,"initialize_editor":338,"vx":5,"render_node_and_descendants":614}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenif obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.7, 0.7, 0, 0.4)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.code_change":578,"line_height":365,"add_thick_line":400,"Surface":588,"on.keychord_press":584,"ntracks":600,"on.mouse_press":618,"A":582,"on.mouse_release":586,"on.text_input":587,"scale":7,"Nodes":593,"on":1,"schema1_of_y":366,"font":353,"to_node":611,"y_of_schema1":364,"add_edge":575,"on.draw":627,"render_thread_to_surface":626,"B":379,"box_height":345,"on.update":368,"dehtml":456,"copy_shape":396,"add_node":590,"Input_filename":436,"vy":8,"compute_layout":619,"Viewport":303,"load_from_iterator":463,"split_lines":469,"to_text":180,"on.initialize":446,"Cursor_node":172,"compute_ntracks":598,"fw_app":"mastodon-luaML","update_editor_box":430,"fw_parent":626,"initialize_editor":338,"vx":5,"render_node_and_descendants":614}
render_thread_to_surface = function(thread_data)-- design constraints:-- trees only, no graphs or DAGs-- parents above children-- a child shares its parent's column exactly only if it's an only child-- parents can overlap columns with children and more distant descendants-- siblings never share a column-- siblings never overlap columns-- siblings always occupy the same row-- cousins/aunts/nephews never overlap columnsSurface = {}-- we're going to be computing box heightslove.graphics.setFont(love.graphics.newFont(scale(20)))-- compute mapping from ids to nodesNodes = {} -- id to objectNodes[thread_data.id] = thread_datafor _,x in ipairs(thread_data.descendants) doNodes[x.id] = xendlocal root = thread_dataCursor_node = root-- compute childrenfor _,x in pairs(Nodes) doparent_id = x.in_reply_to_idif x.id ~= root.id thenassert(parent_id)local parent = Nodes[parent_id]if parent.children == nil thenparent.children = {}endtable.insert(parent.children, x.id)endend-- sort children by timefor _,x in pairs(Nodes) doif x.children thentable.sort(x.children)endend-- compute number of tracks neededfor _,x in pairs(Nodes) doif x.ntracks == nil thenx.ntracks = compute_ntracks(x)endend-- prepare the tracks-- each track is 600px + 20px of gutter between nodesrender_node_and_descendants(root.id, --[[y]] 0, --[[xlo]] 0, --[[xhi]] 620 * root.ntracks)end
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":625,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":625,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":626,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint(obj.text_node)if obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.7, 0.7, 0, 0.4)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":624,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":625,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint(obj.text_node)if obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.7, 0.7, 0, 0.1)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":623,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":624,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint(obj.text_node)if obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(1, 1, 0.4)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":622,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":623,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint(obj.text_node)if obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.8, 0.8, 0.4)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":621,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":622,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint(obj.text_node)if obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.8, 0.8, 0)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":620,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":621,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint(obj.text_node)if obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(1, 1, 0)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":619,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":620,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
{"on.initialize":446,"font":353,"A":582,"to_text":180,"to_node":611,"split_lines":469,"add_edge":575,"fw_app":"mastodon-luaML","line_height":365,"compute_layout":619,"add_thick_line":400,"load_from_iterator":463,"Cursor_node":172,"render_node_and_descendants":614,"Surface":588,"box_height":345,"fw_parent":618,"on.code_change":578,"ntracks":600,"compute_ntracks":598,"on.draw":617,"update_editor_box":430,"schema1_of_y":366,"vx":5,"on.keychord_press":584,"render_thread_to_surface":602,"on.mouse_press":618,"initialize_editor":338,"on.mouse_release":586,"Viewport":303,"on":1,"dehtml":456,"vy":8,"add_node":590,"Input_filename":436,"on.text_input":587,"y_of_schema1":364,"Nodes":593,"copy_shape":396,"on.update":368,"scale":7,"B":379}
compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cursor_node)-- 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 necessarylocal 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, text_node=node}table.insert(nodes_to_render, node_to_render)end-- render contentsif node.width thennode.w = node.widthelsenode.w = 0for i,s in ipairs(node.data) dolocal text = love.graphics.newText(font(20), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendif node.editor == nil theninitialize_editor(node)elseupdate_editor_box(node, preserve_screen_top_of_cursor_node)endnode.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal 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, text_node=node}table.insert(nodes_to_render, node_to_render)end-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendif not child.width thenchild.width = node.width -- HACK: should we set child.w or child.width? Neither is quite satisfactory.endsubx,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, text_node=node}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.marginendsubx,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 = hendendreturn x+node.w,y+node.hend
on.mouse_press = function(x,y, mouse_button)local node_id = to_node(x,y)if node_id thenApp.setClipboardText(Nodes[node_id].url)Cursor_node = Nodes[node_id]print(Cursor_node)elsePan = {x=Viewport.x+x,y=Viewport.y+y}endend
{"vy":8,"y_of_schema1":364,"A":582,"to_node":611,"on.mouse_press":618,"B":379,"on.mouse_release":586,"on.update":368,"on.keychord_press":584,"Input_filename":436,"on.text_input":587,"fw_parent":617,"fw_app":"mastodon-luaML","Cursor_node":172,"compute_layout":615,"font":353,"line_height":365,"on.code_change":578,"add_thick_line":400,"render_node_and_descendants":614,"copy_shape":396,"add_edge":575,"load_from_iterator":463,"box_height":345,"scale":7,"on":1,"to_text":180,"Nodes":593,"update_editor_box":430,"initialize_editor":338,"on.initialize":446,"split_lines":469,"Surface":588,"add_node":590,"ntracks":600,"on.draw":617,"compute_ntracks":598,"schema1_of_y":366,"render_thread_to_surface":602,"Viewport":303,"vx":5,"dehtml":456}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenif obj.text_node and obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.7, 0.7, 0)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"vy":8,"y_of_schema1":364,"A":582,"to_node":611,"on.mouse_press":613,"B":379,"on.mouse_release":586,"on.update":368,"on.keychord_press":584,"Input_filename":436,"on.text_input":587,"fw_parent":616,"fw_app":"mastodon-luaML","Cursor_node":172,"compute_layout":615,"font":353,"line_height":365,"on.code_change":578,"add_thick_line":400,"render_node_and_descendants":614,"copy_shape":396,"add_edge":575,"load_from_iterator":463,"box_height":345,"scale":7,"on":1,"to_text":180,"Nodes":593,"update_editor_box":430,"initialize_editor":338,"on.initialize":446,"split_lines":469,"Surface":588,"add_node":590,"ntracks":600,"on.draw":617,"compute_ntracks":598,"schema1_of_y":366,"render_thread_to_surface":602,"Viewport":303,"vx":5,"dehtml":456}
on.draw = function()love.graphics.setColor(1,0,0)for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenif obj.text_node == Cursor_node.surface_node thenlove.graphics.setColor(0.7, 0.7, 0)endlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)elseif obj.type == 'ellipse' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)endendendend
{"vy":8,"y_of_schema1":364,"A":582,"to_node":611,"on.mouse_press":613,"B":379,"on.mouse_release":586,"on.update":368,"on.keychord_press":584,"Input_filename":436,"on.text_input":587,"fw_parent":615,"fw_app":"mastodon-luaML","Cursor_node":172,"compute_layout":615,"font":353,"line_height":365,"on.code_change":578,"add_thick_line":400,"render_node_and_descendants":614,"copy_shape":396,"add_edge":575,"load_from_iterator":463,"box_height":345,"scale":7,"on":1,"to_text":180,"Nodes":593,"update_editor_box":430,"initialize_editor":338,"on.initialize":446,"split_lines":469,"Surface":588,"add_node":590,"ntracks":600,"on.draw":616,"compute_ntracks":598,"schema1_of_y":366,"render_thread_to_surface":602,"Viewport":303,"vx":5,"dehtml":456}
{"vy":8,"y_of_schema1":364,"A":582,"to_node":611,"on.mouse_press":613,"B":379,"on.mouse_release":586,"on.update":368,"on.keychord_press":584,"Input_filename":436,"on.text_input":587,"fw_parent":614,"fw_app":"mastodon-luaML","Cursor_node":172,"compute_layout":615,"font":353,"line_height":365,"on.code_change":578,"add_thick_line":400,"render_node_and_descendants":614,"copy_shape":396,"add_edge":575,"load_from_iterator":463,"box_height":345,"scale":7,"on":1,"to_text":180,"Nodes":593,"update_editor_box":430,"initialize_editor":338,"on.initialize":446,"split_lines":469,"Surface":588,"add_node":590,"ntracks":600,"on.draw":418,"compute_ntracks":598,"schema1_of_y":366,"render_thread_to_surface":602,"Viewport":303,"vx":5,"dehtml":456}
compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cursor_node)-- 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 necessarylocal 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)end-- render contentsif node.width thennode.w = node.widthelsenode.w = 0for i,s in ipairs(node.data) dolocal text = love.graphics.newText(font(20), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendif node.editor == nil theninitialize_editor(node)elseupdate_editor_box(node, preserve_screen_top_of_cursor_node)endnode.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal 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, text_node=node}table.insert(nodes_to_render, node_to_render)end-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendif not child.width thenchild.width = node.width -- HACK: should we set child.w or child.width? Neither is quite satisfactory.endsubx,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.marginendsubx,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 = hendendreturn x+node.w,y+node.hend
render_node_and_descendants = function(id, y, xlo, xhi, grandparent_surface_node)-- draw a parent 'id' and its children-- also draw an edge from grandparent to parent if provided-- position the root between xlo and xhi to be closer to children with fewer trackslocal parent = Nodes[id]if parent.children == nil thenadd_node(xlo, y, parent.content, parent.id, grandparent_surface_node)returnendlocal parent_xloif #parent.children <= 1 thenparent_xlo = xloelselocal total_boundaries = 0local curr_boundary = xlofor child_idx = 1,#parent.children-1 dolocal child_id = parent.children[child_idx]local child = Nodes[child_id]curr_boundary = curr_boundary + 620 * child.ntrackstotal_boundaries = total_boundaries + curr_boundaryendlocal parent_x = total_boundaries / (#parent.children-1)parent_xlo = parent_x - 620/2endparent.surface_node = add_node(parent_xlo, y, parent.content, parent.id, grandparent_surface_node)local parent_height = box_height(parent.surface_node)local curr_boundary = xlofor _,child_id in ipairs(parent.children) dolocal child = Nodes[child_id]render_node_and_descendants(child_id, y + parent_height + 50, curr_boundary, curr_boundary + 620*child.ntracks, parent.surface_node)curr_boundary = curr_boundary + 620*child.ntracksendend
{"vy":8,"y_of_schema1":364,"A":582,"to_node":611,"on.mouse_press":613,"B":379,"on.mouse_release":586,"on.update":368,"on.keychord_press":584,"Input_filename":436,"on.text_input":587,"fw_parent":613,"fw_app":"mastodon-luaML","Cursor_node":172,"compute_layout":385,"font":353,"line_height":365,"on.code_change":578,"add_thick_line":400,"render_node_and_descendants":614,"copy_shape":396,"add_edge":575,"load_from_iterator":463,"box_height":345,"scale":7,"on":1,"to_text":180,"Nodes":593,"update_editor_box":430,"initialize_editor":338,"on.initialize":446,"split_lines":469,"Surface":588,"add_node":590,"ntracks":600,"on.draw":418,"compute_ntracks":598,"schema1_of_y":366,"render_thread_to_surface":602,"Viewport":303,"vx":5,"dehtml":456}
on.mouse_press = function(x,y, mouse_button)local node_id = to_node(x,y)if node_id thenApp.setClipboardText(Nodes[node_id].url)Cursor_node = Nodes[node_id]elsePan = {x=Viewport.x+x,y=Viewport.y+y}endend
{"vy":8,"y_of_schema1":364,"A":582,"to_node":611,"on.mouse_press":613,"B":379,"on.mouse_release":586,"on.update":368,"on.keychord_press":584,"Input_filename":436,"on.text_input":587,"fw_parent":612,"fw_app":"mastodon-luaML","Cursor_node":172,"compute_layout":385,"font":353,"line_height":365,"on.code_change":578,"add_thick_line":400,"render_node_and_descendants":603,"copy_shape":396,"add_edge":575,"load_from_iterator":463,"box_height":345,"scale":7,"on":1,"to_text":180,"Nodes":593,"update_editor_box":430,"initialize_editor":338,"on.initialize":446,"split_lines":469,"Surface":588,"add_node":590,"ntracks":600,"on.draw":418,"compute_ntracks":598,"schema1_of_y":366,"render_thread_to_surface":602,"Viewport":303,"vx":5,"dehtml":456}