I haven't tested the first experiment yet. Let's make both versions so it's easy to swap.
All these approaches add complexity in some place and remove it somewhere else.
B3DXRFR34ASOJPIYXNKV27XXLRW2METE7TDN3IWLPE7AOSWVSXAAC
DYAYOMDPEQEUGTUPXWKICPBICZ67D6OW773FVIMS7XPIYPOYY2DQC
JMUE7GSN6QDQZ6NDRB55MRJMKJN6LBD6MVQPKROYPDOIXM7I3XNQC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
GO534NHJW3FC4FNJXTA5QZYZJ5A7UHVTGPNB7G73GA2YJRX4D54AC
F3DV7MD3AGOBXDBGFQXB5SK7ASMNGQSTN52P5AJ4MJEETMVTKYWQC
2PKE7XOMF2FI7SA6PLBSQSLJ6ADJIJJIJAZWI4AE6AJEUBV7FK6QC
3IBO5P7DVWMJM42VZL5HIFAJH55FK77K2IKPGMNI55GRXDXT4WUQC
IUS4EW7KL6ZJR2LN5VG7SW6DI7TTPVYYRFOLPHEON36HHVS4YWZQC
4QO6B26XGYLK254OLKF6BJUHJUT6QV5JDI3JI4ANUFV647UO3COQC
QK2IFQMAAXJUXKKVEF732Q665DTLPWGLA7BNO4KJ3AFOXX5YKBCAC
MLYPMK3EHHM6DV4HJ33NKTDQFCMKPSH3Y5O5FRJEP4L7W2QJY2JQC
local sy = Padding_vertical
for pane_index, pane in ipairs(column) do
if sy > Display_settings.y + App.screen.height - Header_height then
break
end
--? print('bounds:', column_index, pane_index, sx,sy)
if should_show_pane(pane, sy) then
table.insert(Panes_to_draw, pane)
-- stash some short-lived variables
pane.column_index = column_index
pane.pane_index = pane_index
local y_offset = 0
local body_sy = sy
if column[pane_index].title then
body_sy = body_sy + 5+Line_height+5
end
if body_sy < Display_settings.y then
pane.screen_top1, y_offset = schema1_of_y(pane, Display_settings.y - body_sy)
else
pane.screen_top1 = {line=1, pos=1}
end
if body_sy < Display_settings.y then
pane.top = Margin_above
else
pane.top = body_sy - Display_settings.y + Margin_above
end
pane.top = Header_height + pane.top - y_offset
--? print('bounds: =>', pane.top)
pane.left = sx - Display_settings.x
pane.right = pane.left + Display_settings.column_width
pane.width = pane.right - pane.left
else
-- clear bounds to catch issues early
pane.top = nil
--? print('bounds: =>', pane.top)
end
sy = sy + Margin_above + height(pane) + Margin_below + Padding_vertical
end
else
-- clear bounds to catch issues early
for _, pane in ipairs(column) do
pane.top = nil
end
end
sx = sx + Margin_right + Display_settings.column_width + Padding_horizontal + Margin_left
end
end
-- keep the structure of this function sync'd with refresh_pane_height
function plan_draw_maybe_updating_screen_top_in_cursor_pane(update_screen_top_in_cursor_pane)
--? print('update pane bounds')
--? print(#Surface, 'columns;', num_panes(), 'panes')
Panes_to_draw = {}
local sx = Padding_horizontal + Margin_left
for column_index, column in ipairs(Surface) do
if should_show_column(sx) then
return including_cursor_pane
-- update the cursor pane either if it's not editable, or
-- if it was explicitly requested
if not pane.editable then return true end
if options == nil then return true end
if not options.ignore_editable_cursor_pane then return true end
if not Editable_cursor_pane_updated_screen_top then return true end
return false
if chord == 'C-e' then
command.exit_editing()
elseif pane.cursor_x == nil then
-- ignore if cursor is not visible on screen
assert(pane.cursor_y == nil)
panning_keychord_pressed(chord, key)
plan_draw()
else
local old_top = {line=pane.screen_top1.line, pos=pane.screen_top1.pos}
edit.keychord_pressed(pane, chord, key)
local cursor_pane_updated_screen_top = maybe_update_screen_top_of_cursor_pane(pane, old_top)
pane._height = nil
plan_draw_maybe_updating_screen_top_in_cursor_pane(not cursor_pane_updated_screen_top)
end
keychord_pressed_on_editable_pane(pane, chord, key)
function keychord_pressed_on_editable_pane(pane, chord, key)
if chord == 'C-e' then
command.exit_editing()
elseif pane.cursor_x == nil then
-- ignore if cursor is not visible on screen
assert(pane.cursor_y == nil)
panning_keychord_pressed(chord, key)
else
--? print(('%s pressed in editor pane'):format(chord))
--? print(pane.cursor_x, pane.cursor_y)
local old_top = {line=pane.screen_top1.line, pos=pane.screen_top1.pos}
edit.keychord_pressed(pane, chord, key)
maybe_update_screen_top_of_cursor_pane(pane, old_top)
pane._height = nil
end
end