Cursor doesn't move yet in response, but I'd like it to stay on screen.
TZ3ZNGRMZ3DG33VVEZI74W5W5T73JYMEIYQ3SO6Y4A6FN3OUZIKQC if chord == 'up' thenDisplay_settings.y = math.max(Display_settings.y - Pan_step, 0)elseif chord == 'down' thenlocal visible_column_max_y = most(column_height, visible_columns())if visible_column_max_y - Display_settings.y > App.screen.height/2 thenDisplay_settings.y = Display_settings.y + Pan_stependelseif chord == 'left' thenDisplay_settings.x = math.max(Display_settings.x - Pan_step, 0)elseif chord == 'right' thenif Display_settings.x < (#Surface-1) * (Display_settings.column_width + Padding_horizontal) thenDisplay_settings.x = Display_settings.x + Pan_stependelseif chord == 'pageup' or chord == 'S-up' thenDisplay_settings.y = math.max(Display_settings.y - App.screen.height + Line_height*2, 0)elseif chord == 'pagedown' or chord == 'S-down' thenlocal visible_column_max_y = most(column_height, visible_columns())if visible_column_max_y - Display_settings.y > App.screen.height thenDisplay_settings.y = Display_settings.y + App.screen.height - Line_height*2endelseif chord == 'S-left' thenDisplay_settings.x = math.max(Display_settings.x - Display_settings.column_width - Padding_horizontal, 0)elseif chord == 'S-right' thenif Display_settings.x < (#Surface-1) * (Display_settings.column_width + Padding_horizontal) thenDisplay_settings.x = Display_settings.x + Display_settings.column_width + Padding_horizontalendend
endendfunction visible_columns()local result = {}local col = col(Display_settings.x)local x = left_edge_sx(col) - Display_settings.xwhile col <= #Surface dox = x + Padding_horizontaltable.insert(result, col)x = x + Display_settings.column_width + Padding_horizontalif x > App.screen.width thenbreakendcol = col+1
-- convert x surface pixel coordinate into column indexfunction col(x)return 1 + math.floor(x / (Padding_horizontal + Display_settings.column_width))end-- col is 1-indexed-- returns x surface pixel coordinate of left edge of column colfunction left_edge_sx(col)return Margin_right + (col-1)*(Padding_horizontal + Display_settings.column_width)endfunction column_height(col)local result = Margin_topfor pane_index, pane in ipairs(Surface[col]) doresult = result + Margin_above + Cache[pane.id].height + Margin_below + Padding_verticalendreturn resultendfunction most(f, arr)local result = nilfor _,x in ipairs(arr) dolocal curr = f(x)if result == nil or result < curr thenresult = currendendreturn resultend