clean up debug prints
I'm feeling pretty good about this; hopefully we've fixed this for good.
This commit is contained in:
parent
f78557e5e5
commit
e258a27a65
|
@ -17,9 +17,7 @@ on.keychord_press = function(chord, key)
|
||||||
elseif chord == 'C-z' then
|
elseif chord == 'C-z' then
|
||||||
dump_state()
|
dump_state()
|
||||||
elseif Cursor_node and Cursor_node.editor.cursor_x then
|
elseif Cursor_node and Cursor_node.editor.cursor_x then
|
||||||
print('cursor before', Cursor_node.editor.cursor1.line, Cursor_node.editor.cursor1.pos)
|
|
||||||
edit.keychord_press(Cursor_node.editor, chord, key)
|
edit.keychord_press(Cursor_node.editor, chord, key)
|
||||||
print('cursor after', Cursor_node.editor.cursor1.line, Cursor_node.editor.cursor1.pos)
|
|
||||||
pan_viewport_to_contain_cursor(Cursor_node)
|
pan_viewport_to_contain_cursor(Cursor_node)
|
||||||
A()
|
A()
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,61 +1,48 @@
|
||||||
function pan_viewport_to_contain_cursor(node)
|
function pan_viewport_to_contain_cursor(node)
|
||||||
print('viewport', Viewport.y)
|
|
||||||
local safety_margin = 2*node.editor.line_height
|
local safety_margin = 2*node.editor.line_height
|
||||||
cursor1 = {39, 1}
|
cursor1 = {39, 1}
|
||||||
print('safety margin', safety_margin, 'dvpx')
|
|
||||||
print('node', node.y)
|
|
||||||
local cursor_sy = node.y + y_of_schema1(node.editor, node.editor.cursor1)/Viewport.zoom
|
local cursor_sy = node.y + y_of_schema1(node.editor, node.editor.cursor1)/Viewport.zoom
|
||||||
if Text.lt1({line=1, pos=1}, node.editor.screen_top1) then
|
if Text.lt1({line=1, pos=1}, node.editor.screen_top1) then
|
||||||
Viewport.y = node.y + y_of_schema1(node.editor, node.editor.screen_top1)/Viewport.zoom
|
Viewport.y = node.y + y_of_schema1(node.editor, node.editor.screen_top1)/Viewport.zoom
|
||||||
end
|
end
|
||||||
if cursor_sy > Viewport.y + App.screen.height/Viewport.zoom - safety_margin then
|
if cursor_sy > Viewport.y + App.screen.height/Viewport.zoom - safety_margin then
|
||||||
print('cursor below viewport')
|
|
||||||
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
|
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
|
||||||
if Viewport.y < node.y then
|
if Viewport.y < node.y then
|
||||||
-- node starts within Viewport
|
-- node starts within Viewport
|
||||||
print('node starts within viewport')
|
|
||||||
local max_cursor_y = App.screen.height - scale(node.y - Viewport.y) - safety_margin
|
local max_cursor_y = App.screen.height - scale(node.y - Viewport.y) - safety_margin
|
||||||
if cursor_y > max_cursor_y then
|
if cursor_y > max_cursor_y then
|
||||||
-- set Viewport.y so cursor_y == max_cursor_y
|
-- set Viewport.y so cursor_y == max_cursor_y
|
||||||
-- equation: cursor_y == App.screen.height - (node.y - Viewport.y)*Viewport.zoom - safety_margin
|
-- equation: cursor_y == App.screen.height - (node.y - Viewport.y)*Viewport.zoom - safety_margin
|
||||||
-- solve for Viewport.y
|
-- solve for Viewport.y
|
||||||
Viewport.y = node.y - (App.screen.height - cursor_y - safety_margin)/Viewport.zoom
|
Viewport.y = node.y - (App.screen.height - cursor_y - safety_margin)/Viewport.zoom
|
||||||
print('adjusting Viewport to', Viewport.y)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- node extends above Viewport
|
-- node extends above Viewport
|
||||||
print('node extends above viewport')
|
|
||||||
local screen_top_y = y_of_schema1(node.editor, node.editor.screen_top1)
|
local screen_top_y = y_of_schema1(node.editor, node.editor.screen_top1)
|
||||||
local min_screen_top_y = cursor_y + safety_margin - App.screen.height
|
local min_screen_top_y = cursor_y + safety_margin - App.screen.height
|
||||||
if screen_top_y < min_screen_top_y then
|
if screen_top_y < min_screen_top_y then
|
||||||
screen_top_y = min_screen_top_y
|
screen_top_y = min_screen_top_y
|
||||||
Viewport.y = node.y + screen_top_y/Viewport.zoom
|
Viewport.y = node.y + screen_top_y/Viewport.zoom
|
||||||
print('adjusting Viewport to', Viewport.y)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif cursor_sy < Viewport.y + safety_margin then
|
elseif cursor_sy < Viewport.y + safety_margin then
|
||||||
print('cursor above viewport')
|
|
||||||
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
|
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
|
||||||
if Viewport.y < node.y then
|
if Viewport.y < node.y then
|
||||||
-- node starts within Viewport
|
-- node starts within Viewport
|
||||||
print('node starts within viewport')
|
|
||||||
local max_cursor_y = App.screen.height - scale(node.y - Viewport.y) - safety_margin
|
local max_cursor_y = App.screen.height - scale(node.y - Viewport.y) - safety_margin
|
||||||
if cursor_y > max_cursor_y then
|
if cursor_y > max_cursor_y then
|
||||||
-- set Viewport.y so cursor_y == max_cursor_y
|
-- set Viewport.y so cursor_y == max_cursor_y
|
||||||
-- equation: cursor_y == App.screen.height - (node.y - Viewport.y)*Viewport.zoom - safety_margin
|
-- equation: cursor_y == App.screen.height - (node.y - Viewport.y)*Viewport.zoom - safety_margin
|
||||||
-- solve for Viewport.y
|
-- solve for Viewport.y
|
||||||
Viewport.y = node.y - (App.screen.height - cursor_y - safety_margin)/Viewport.zoom
|
Viewport.y = node.y - (App.screen.height - cursor_y - safety_margin)/Viewport.zoom
|
||||||
print('adjusting Viewport to', Viewport.y)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- node extends above Viewport
|
-- node extends above Viewport
|
||||||
print('node extends above viewport')
|
|
||||||
local screen_top_y = y_of_schema1(node.editor, node.editor.screen_top1)
|
local screen_top_y = y_of_schema1(node.editor, node.editor.screen_top1)
|
||||||
local max_screen_top_y = cursor_y - safety_margin
|
local max_screen_top_y = cursor_y - safety_margin
|
||||||
if screen_top_y > max_screen_top_y then
|
if screen_top_y > max_screen_top_y then
|
||||||
screen_top_y = max_screen_top_y
|
screen_top_y = max_screen_top_y
|
||||||
Viewport.y = node.y + screen_top_y/Viewport.zoom
|
Viewport.y = node.y + screen_top_y/Viewport.zoom
|
||||||
print('adjusting Viewport to', Viewport.y)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue