QDN3KO6L3ILGTUUVTJGQ2BF4AXAIQYAXJNPOGCG7CYLDNJAJVADQC
on.initialize = function(arg)
Input_filename = arg[1]
A(Input_filename)
Cursor_node = Root
if #arg >= 2 then
local initial_id = arg[2]
if Nodes[initial_id] then
Cursor_node = Nodes[initial_id]
end
end
ensure_cursor_node_within_viewport()
end
{"copy_shape":396,"Surface":588,"on.draw":632,"add_node":650,"to_node":611,"render_node_and_descendants":646,"vy":8,"add_edge":575,"update_editor_box":430,"on.mouse_press":618,"box_height":345,"on.mouse_release":586,"line_height":365,"on.code_change":578,"Input_filename":436,"on.keychord_press":644,"schema1_of_y":366,"initialize_editor":338,"on.initialize":657,"y_of_schema1":364,"A":582,"ntracks":600,"compute_ntracks":598,"B":379,"render_thread_to_surface":655,"dehtml":456,"on":1,"on.text_input":587,"fw_app":"mastodon-unfurl","ensure_cursor_node_within_viewport":643,"scale":7,"to_text":180,"load_from_iterator":463,"compute_layout":619,"header":651,"Viewport":303,"vx":5,"fw_parent":656,"font":353,"split_lines":469,"Nodes":593,"Root":654,"on.update":368,"add_thick_line":400,"Cursor_node":172}
on.initialize = function(arg)
Input_filename = arg[1]
A(Input_filename)
Cursor_node = Root
ensure_cursor_node_within_viewport()
end
{"Input_filename":436,"on.update":368,"scale":7,"on.keychord_press":644,"render_thread_to_surface":655,"on.initialize":656,"dehtml":456,"add_thick_line":400,"line_height":365,"initialize_editor":338,"copy_shape":396,"header":651,"load_from_iterator":463,"ntracks":600,"Nodes":593,"compute_ntracks":598,"Root":654,"split_lines":469,"on.text_input":587,"ensure_cursor_node_within_viewport":643,"on.code_change":578,"vy":8,"Surface":588,"Cursor_node":172,"update_editor_box":430,"to_node":611,"fw_parent":655,"B":379,"fw_app":"mastodon-unfurl","add_node":650,"on.draw":632,"A":582,"to_text":180,"render_node_and_descendants":646,"y_of_schema1":364,"vx":5,"Viewport":303,"box_height":345,"schema1_of_y":366,"compute_layout":619,"font":353,"on":1,"on.mouse_press":618,"add_edge":575,"on.mouse_release":586}
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
Root = thread_data
-- 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
{"Input_filename":436,"on.update":368,"scale":7,"on.keychord_press":644,"render_thread_to_surface":655,"on.initialize":446,"dehtml":456,"add_thick_line":400,"line_height":365,"initialize_editor":338,"copy_shape":396,"header":651,"load_from_iterator":463,"ntracks":600,"Nodes":593,"compute_ntracks":598,"Root":654,"split_lines":469,"on.text_input":587,"ensure_cursor_node_within_viewport":643,"on.code_change":578,"vy":8,"Surface":588,"Cursor_node":172,"update_editor_box":430,"to_node":611,"fw_parent":654,"B":379,"fw_app":"mastodon-unfurl","add_node":650,"on.draw":632,"A":582,"to_text":180,"render_node_and_descendants":646,"y_of_schema1":364,"vx":5,"Viewport":303,"box_height":345,"schema1_of_y":366,"compute_layout":619,"font":353,"on":1,"on.mouse_press":618,"add_edge":575,"on.mouse_release":586}
{"Input_filename":436,"on.update":368,"scale":7,"on.keychord_press":644,"render_thread_to_surface":653,"on.initialize":446,"dehtml":456,"add_thick_line":400,"line_height":365,"initialize_editor":338,"copy_shape":396,"header":651,"load_from_iterator":463,"ntracks":600,"Nodes":593,"compute_ntracks":598,"Root":654,"split_lines":469,"on.text_input":587,"ensure_cursor_node_within_viewport":643,"on.code_change":578,"vy":8,"Surface":588,"Cursor_node":172,"update_editor_box":430,"to_node":611,"fw_parent":653,"B":379,"fw_app":"mastodon-unfurl","add_node":650,"on.draw":632,"A":582,"to_text":180,"render_node_and_descendants":646,"y_of_schema1":364,"vx":5,"Viewport":303,"box_height":345,"schema1_of_y":366,"compute_layout":619,"font":353,"on":1,"on.mouse_press":618,"add_edge":575,"on.mouse_release":586}
Root = nil
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
-- 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
{"Input_filename":436,"on.update":368,"scale":7,"on.keychord_press":644,"render_thread_to_surface":653,"on.initialize":446,"dehtml":456,"add_thick_line":400,"line_height":365,"initialize_editor":338,"copy_shape":396,"header":651,"load_from_iterator":463,"ntracks":600,"Nodes":593,"compute_ntracks":598,"split_lines":469,"on.text_input":587,"ensure_cursor_node_within_viewport":643,"on.code_change":578,"vy":8,"Surface":588,"Cursor_node":172,"update_editor_box":430,"to_node":611,"fw_parent":652,"B":379,"fw_app":"mastodon-unfurl","add_node":650,"on.draw":632,"A":582,"to_text":180,"render_node_and_descendants":646,"y_of_schema1":364,"vx":5,"Viewport":303,"box_height":345,"schema1_of_y":366,"compute_layout":619,"font":353,"on":1,"on.mouse_press":618,"add_edge":575,"on.mouse_release":586}