It's kinda ugly that I'm mutating any app state inside draw(), but there's some benefit to keep all drawing-related code nearby.
HCLCAFHPRUDGNFOYXKNHME2ELQKSXUTN3E4NV3PT4DGG2VJV7KOAC
NR4MDLT4RL46HGPFOH24XD5TWF4WJIWJZQGQEQAGZ2EUM5C7FUZQC
7AKT7IKOP6VQW3CABAVXCEZTHYNAETVXGFIQWB2L6I7LM7T57HAAC
VSMPAAJDBVZXZIUFCXY53VM5F63B3ZOS63MCIHH43OA3SKVMJJ7AC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
J3ER7DFO2TXYUMJAXZUFEHQNLFDNIXSYDTE7HEFGQ2RYB3A6RFPAC
SYS77RM72TL7SLUQIJBN6D7DI5I6HSHCHXLPXREPADUNBBFM5TYAC
4BX4GJEWW7Z5LA4SJUXADYLAHOYFL4IBOYH4J4DJYRAVKKGGFHGQC
DUQDA3U7VNWZSKRVACS6G3FTEB5VXRR7FJQU5NYZ4EFSGL3XUU5QC
X22MOJHFLXMZQJN4IP2HAXIIVD2ALPR4EO5V5YDYF6QPXS7ZNB6QC
DGMHQDVOII6WF2OJNHP42AYYMCMAIM266I3KHED74OBYMIWWAQXQC
pane.top = y - Display_settings.y + Margin_above
pane.left = x - Display_settings.x
pane.right = pane.left + Display_settings.column_width
pane.width = pane.right - pane.left
-- TODO: update pane.screen_top1 and pane.cursor1
if Surface.dirty then
print(('adjusting pane top %d; screen_top is at line %d (max %d)'):format(pane.top, pane.screen_top1.line, #pane.lines))
pane.top = y - Display_settings.y + Margin_above
pane.left = x - Display_settings.x
pane.right = pane.left + Display_settings.column_width
pane.width = pane.right - pane.left
-- TODO: update pane.screen_top1 and pane.cursor1
end