Still not perfect. Pressing ctrl+down can sometimes cause the cursor node to go too far left or right. I'm only checking the direction of movement so far.
O5F2HG2RYJ4L623VRQBXXJHTMTEAO3ZSUJYY3L7ECVD63TYVKO6AC
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]
if Cursor_node.surface_node.y < Viewport.y then
Viewport.y = Cursor_node.surface_node.y - 50
B()
end
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
local snode = Cursor_node.surface_node
local limit = snode.y + box_height(snode)
if Viewport.y < limit - App.screen.height/Viewport.zoom then
Viewport.y = limit - (App.screen.height-50)/Viewport.zoom
B()
end
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]]
if Cursor_node.surface_node.x < Viewport.x then
Viewport.x = Cursor_node.surface_node.x - 50
B()
end
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]]
local snode = Cursor_node.surface_node
local limit = snode.x + 600
if Viewport.x < limit - App.screen.width/Viewport.zoom then
Viewport.x = limit - (App.screen.width-50)/Viewport.zoom
B()
end
end
end
end
end
end
{"on.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":641,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":642,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
if Cursor_node.surface_node.y < Viewport.y then
Viewport.y = Cursor_node.surface_node.y - 50
B()
end
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
local snode = Cursor_node.surface_node
local limit = snode.y + box_height(snode)
if Viewport.y < limit - App.screen.height/Viewport.zoom then
Viewport.y = limit - (App.screen.height-50)/Viewport.zoom
B()
end
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]]
if Cursor_node.surface_node.x < Viewport.x then
Viewport.x = Cursor_node.surface_node.x - 50
B()
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":640,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":641,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
if Cursor_node.surface_node.y < Viewport.y then
Viewport.y = Cursor_node.surface_node.y - 50
B()
end
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
local snode = Cursor_node.surface_node
local limit = snode.y + box_height(snode)
if Viewport.y < limit - App.screen.height/Viewport.zoom then
Viewport.y = limit - (App.screen.height-50)/Viewport.zoom
B()
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":639,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":640,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
if Cursor_node.surface_node.y < Viewport.y then
Viewport.y = Cursor_node.surface_node.y - 50
B()
end
end
elseif chord == 'C-down' then
if Cursor_node.children and #Cursor_node.children > 0 then
Cursor_node = Nodes[Cursor_node.children[1]]
local snode = Cursor_node.surface_node
local limit = snode.y + box_height(snode)
if Viewport.y < limit - App.screen.height/Viewport.zoom then
Viewport.y = limit - (App.screen.height-50)/Viewport.zoom
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":638,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":639,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
if Cursor_node.surface_node.y < Viewport.y then
Viewport.y = Cursor_node.surface_node.y - 50
B()
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":637,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":638,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
print(Cursor_node.surface_node.y, Viewport.y)
if Cursor_node.surface_node.y < Viewport.y then
Viewport.y = Cursor_node.surface_node.y - 50
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":636,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":637,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
for k in pairs(Cursor_node) do
print(k)
end
print(Cursor_node.y, Viewport.y)
if Cursor_node.y < Viewport.y then
Viewport.y = Cursor_node.y - 50
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":635,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":636,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
for k in pairs(Cursor_node) do
print(k)
end
print(Cursor_node.y, Viewport.y)
if Cursor_node.y < Viewport.y then
Viewport.y = Cursor_node.y - 50
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":634,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":635,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}
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]
print(Cursor_node.y, Viewport.y)
if Cursor_node.y < Viewport.y then
Viewport.y = Cursor_node.y - 50
end
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.draw":632,"schema1_of_y":366,"vx":5,"Viewport":303,"on.initialize":446,"y_of_schema1":364,"A":582,"initialize_editor":338,"dehtml":456,"on.mouse_release":586,"box_height":345,"on.update":368,"render_thread_to_surface":626,"on.code_change":578,"Nodes":593,"line_height":365,"load_from_iterator":463,"split_lines":469,"to_node":611,"to_text":180,"scale":7,"fw_parent":633,"Input_filename":436,"add_node":590,"font":353,"Cursor_node":172,"B":379,"ntracks":600,"compute_ntracks":598,"on":1,"vy":8,"add_edge":575,"render_node_and_descendants":633,"on.text_input":587,"update_editor_box":430,"on.mouse_press":618,"on.keychord_press":634,"fw_app":"mastodon-unfurl","add_thick_line":400,"Surface":588,"copy_shape":396,"compute_layout":619}