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_verticalfor pane_index, pane in ipairs(column) doif sy > Display_settings.y + App.screen.height - Header_height thenbreakend--? print('bounds:', column_index, pane_index, sx,sy)if should_show_pane(pane, sy) thentable.insert(Panes_to_draw, pane)-- stash some short-lived variablespane.column_index = column_indexpane.pane_index = pane_indexlocal y_offset = 0local body_sy = syif column[pane_index].title thenbody_sy = body_sy + 5+Line_height+5endif body_sy < Display_settings.y thenpane.screen_top1, y_offset = schema1_of_y(pane, Display_settings.y - body_sy)elsepane.screen_top1 = {line=1, pos=1}endif body_sy < Display_settings.y thenpane.top = Margin_aboveelsepane.top = body_sy - Display_settings.y + Margin_aboveendpane.top = Header_height + pane.top - y_offset--? print('bounds: =>', pane.top)pane.left = sx - Display_settings.xpane.right = pane.left + Display_settings.column_widthpane.width = pane.right - pane.leftelse-- clear bounds to catch issues earlypane.top = nil--? print('bounds: =>', pane.top)endsy = sy + Margin_above + height(pane) + Margin_below + Padding_verticalendelse-- clear bounds to catch issues earlyfor _, pane in ipairs(column) dopane.top = nilendendsx = sx + Margin_right + Display_settings.column_width + Padding_horizontal + Margin_leftendend-- keep the structure of this function sync'd with refresh_pane_heightfunction 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_leftfor column_index, column in ipairs(Surface) doif should_show_column(sx) then
return including_cursor_pane
-- update the cursor pane either if it's not editable, or-- if it was explicitly requestedif not pane.editable then return true endif options == nil then return true endif not options.ignore_editable_cursor_pane then return true endif not Editable_cursor_pane_updated_screen_top then return true endreturn false
if chord == 'C-e' thencommand.exit_editing()elseif pane.cursor_x == nil then-- ignore if cursor is not visible on screenassert(pane.cursor_y == nil)panning_keychord_pressed(chord, key)plan_draw()elselocal 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 = nilplan_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' thencommand.exit_editing()elseif pane.cursor_x == nil then-- ignore if cursor is not visible on screenassert(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 = nilendend