All nodes are still read-only.
NP3LZH44LOWL2RPT7MOXWX5HJADZRFT7YFZKXSTEQ4JMFQDZPE7QC
on.keychord_press = function(chord, key)
if chord == 'C-=' then
-- zoom in
Viewport.zoom = Viewport.zoom+0.1
B()
elseif chord == 'C--' then
-- zoom out
Viewport.zoom = Viewport.zoom-0.1
B()
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
B()
elseif chord == 'C-up' then
if Cursor_node.in_reply_to_id then
Cursor_node = Nodes[Cursor_node.in_reply_to_id]
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
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]]
end
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]]
end
end
end
end
end
{"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 in
Viewport.zoom = Viewport.zoom+0.1
B()
elseif chord == 'C--' then
-- zoom out
Viewport.zoom = Viewport.zoom-0.1
B()
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
B()
elseif chord == 'C-up' then
if Cursor_node.in_reply_to_id then
Cursor_node = Nodes[Cursor_node.in_reply_to_id]
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
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]]
end
end
end
end
end
{"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 in
Viewport.zoom = Viewport.zoom+0.1
B()
elseif chord == 'C--' then
-- zoom out
Viewport.zoom = Viewport.zoom-0.1
B()
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
B()
elseif chord == 'C-up' then
if Cursor_node.in_reply_to_id then
Cursor_node = Nodes[Cursor_node.in_reply_to_id]
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
end
end
end
{"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 in
Viewport.zoom = Viewport.zoom+0.1
B()
elseif chord == 'C--' then
-- zoom out
Viewport.zoom = Viewport.zoom-0.1
B()
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
B()
elseif chord == 'C-up' then
if Cursor_node.in_reply_to_id then
Cursor_node = Nodes[Cursor_node.in_reply_to_id]
end
end
end
{"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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.7, 0.7, 0, 0.4)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"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 columns
Surface = {}
-- we're going to be computing box heights
love.graphics.setFont(love.graphics.newFont(scale(20)))
-- compute mapping from ids to nodes
Nodes = {} -- id to object
Nodes[thread_data.id] = thread_data
for _,x in ipairs(thread_data.descendants) do
Nodes[x.id] = x
end
local root = thread_data
Cursor_node = root
-- compute children
for _,x in pairs(Nodes) do
parent_id = x.in_reply_to_id
if x.id ~= root.id then
assert(parent_id)
local parent = Nodes[parent_id]
if parent.children == nil then
parent.children = {}
end
table.insert(parent.children, x.id)
end
end
-- sort children by time
for _,x in pairs(Nodes) do
if x.children then
table.sort(x.children)
end
end
-- compute number of tracks needed
for _,x in pairs(Nodes) do
if x.ntracks == nil then
x.ntracks = compute_ntracks(x)
end
end
-- prepare the tracks
-- each track is 600px + 20px of gutter between nodes
render_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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
print(obj.text_node)
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.7, 0.7, 0, 0.4)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
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":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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
print(obj.text_node)
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.7, 0.7, 0, 0.1)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
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":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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
print(obj.text_node)
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(1, 1, 0.4)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
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":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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
print(obj.text_node)
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.8, 0.8, 0.4)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
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":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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
print(obj.text_node)
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.8, 0.8, 0)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
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":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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
print(obj.text_node)
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(1, 1, 0)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
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":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 text
node.x = x
node.y = y
-- render background if necessary
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, text_node=node}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
node.w = 0
for i,s in ipairs(node.data) do
local text = love.graphics.newText(font(20), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
if node.editor == nil then
initialize_editor(node)
else
update_editor_box(node, preserve_screen_top_of_cursor_node)
end
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
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, text_node=node}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
if not child.width then
child.width = node.width -- HACK: should we set child.w or child.width? Neither is quite satisfactory.
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, text_node=node}
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
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
return x+node.w,y+node.h
end
on.mouse_press = function(x,y, mouse_button)
local node_id = to_node(x,y)
if node_id then
App.setClipboardText(Nodes[node_id].url)
Cursor_node = Nodes[node_id]
print(Cursor_node)
else
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.7, 0.7, 0)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"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) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
if obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.7, 0.7, 0)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.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' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"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 text
node.x = x
node.y = y
-- render background if necessary
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
-- render contents
if node.width then
node.w = node.width
else
node.w = 0
for i,s in ipairs(node.data) do
local text = love.graphics.newText(font(20), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
if node.editor == nil then
initialize_editor(node)
else
update_editor_box(node, preserve_screen_top_of_cursor_node)
end
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
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, text_node=node}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
if not child.width then
child.width = node.width -- HACK: should we set child.w or child.width? Neither is quite satisfactory.
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
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
return x+node.w,y+node.h
end
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 tracks
local parent = Nodes[id]
if parent.children == nil then
add_node(xlo, y, parent.content, parent.id, grandparent_surface_node)
return
end
local parent_xlo
if #parent.children <= 1 then
parent_xlo = xlo
else
local total_boundaries = 0
local curr_boundary = xlo
for child_idx = 1,#parent.children-1 do
local child_id = parent.children[child_idx]
local child = Nodes[child_id]
curr_boundary = curr_boundary + 620 * child.ntracks
total_boundaries = total_boundaries + curr_boundary
end
local parent_x = total_boundaries / (#parent.children-1)
parent_xlo = parent_x - 620/2
end
parent.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 = xlo
for _,child_id in ipairs(parent.children) do
local 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.ntracks
end
end
{"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 then
App.setClipboardText(Nodes[node_id].url)
Cursor_node = Nodes[node_id]
else
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"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}