I've adjusted mouse_wheel_move to work even when there's no editable pane. It could be improved though. This app really wants some sense of acceleration.
I've also had to hack in a check for cursor_x/cursor_y being nil when scrolling in an editable pane.
JOSUB6GIULB27TORKZW7APTW5W6NQ3AYMN3BM5SSDFB7KT5P2MQQC
UCFOE6KJM4USAO3SATXQQQBF3H6ERZCEWIKTYYYSLJK5TASKZOVAC
GFXWHTE6POBIOBUMRAWD5QS22JEO52EF4VTLMB4CDK4RLSCK7HCAC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
JMUE7GSN6QDQZ6NDRB55MRJMKJN6LBD6MVQPKROYPDOIXM7I3XNQC
LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
TT6LGCRBUZA4LC26FNDCBKUWAZUEOW4CZ45LEOZPIZFL2NNYYGJAC
YQFI33IHRSWTQMOOPYC2NWBFE7G3SXSCRVNRIYVXG3SQO7UFI5PQC
KTU3P32MXZW2FOGAWCAT75OCETKNARCIBI2DAYEHYGHACQTII5LQC
BJ5X5O4ACBBJ56LRBBSTCW6IBQP4HAEOOOPNH3SKTA4F66YTOIDAC
return edit.mouse_wheel_move(Editor_state, x,y)
if Cursor_pane.col >= 1 then
local pane = Surface[Cursor_pane.col][Cursor_pane.row]
if pane then
if pane.editable then
if pane.cursor_x then
edit.mouse_wheel_move(pane, dx,dy)
plan_draw()
return
end
end
end
end
-- shift+scroll wheel doesn't set dx for me; manually do so if necessary
if App.shift_down() then
if dx == 0 then
dx,dy = dy,dx
end
end
if dy > 0 then
for i=1,math.floor(dy) do
pan_up()
end
plan_draw()
elseif dy < 0 then
for i=1,math.floor(-dy) do
pan_down()
end
plan_draw()
end
if dx > 0 then
for i=1,math.floor(dx) do
pan_left()
end
plan_draw()
elseif dx < 0 then
for i=1,math.floor(-dx) do
pan_right()
end
plan_draw()
end
Display_settings.y = math.max(Display_settings.y - Pan_step, 0)
local up_sy = up_edge_sy(Cursor_pane.col, Cursor_pane.row)
local up_py = up_sy - Display_settings.y
if up_py > 2/3*App.screen.height then
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], row(Cursor_pane.col, Display_settings.y + App.screen.height/3))
end
pan_up()
local visible_column_max_y = most(column_height, visible_columns())
if visible_column_max_y - Display_settings.y > App.screen.height/2 then
Display_settings.y = Display_settings.y + Pan_step
end
local down_sx = down_edge_sx(Cursor_pane.col, Cursor_pane.row)
local down_px = down_sx - Display_settings.y
if down_px < App.screen.height/3 then
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], row(Cursor_pane.col, Display_settings.y + App.screen.height/3))
end
pan_down()
Display_settings.x = math.max(Display_settings.x - Pan_step, 0)
local left_sx = left_edge_sx(Cursor_pane.col)
local left_px = left_sx - Display_settings.x
if left_px > App.screen.width - Margin_right - Display_settings.column_width/2 then
Cursor_pane.col = math.min(#Surface, col(Display_settings.x + App.screen.width - Margin_right - Display_settings.column_width/2))
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], Cursor_pane.row)
end
pan_left()
if Display_settings.x < (#Surface-1) * (Padding_horizontal + Margin_left + Display_settings.column_width + Margin_right) then
Display_settings.x = Display_settings.x + Pan_step
end
local right_sx = left_edge_sx(Cursor_pane.col) + Display_settings.column_width
local right_px = right_sx - Display_settings.x
if right_px < Margin_left + Display_settings.column_width/2 then
Cursor_pane.col = math.min(#Surface, col(Display_settings.x + Margin_left + Display_settings.column_width/2))
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], Cursor_pane.row)
end
pan_right()
end
function pan_up()
Display_settings.y = math.max(Display_settings.y - Pan_step, 0)
local up_sy = up_edge_sy(Cursor_pane.col, Cursor_pane.row)
local up_py = up_sy - Display_settings.y
if up_py > 2/3*App.screen.height then
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], row(Cursor_pane.col, Display_settings.y + App.screen.height/3))
end
end
function pan_down()
local visible_column_max_y = most(column_height, visible_columns())
if visible_column_max_y - Display_settings.y > App.screen.height/2 then
Display_settings.y = Display_settings.y + Pan_step
end
local down_sx = down_edge_sx(Cursor_pane.col, Cursor_pane.row)
local down_px = down_sx - Display_settings.y
if down_px < App.screen.height/3 then
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], row(Cursor_pane.col, Display_settings.y + App.screen.height/3))
end
end
function pan_left()
Display_settings.x = math.max(Display_settings.x - Pan_step, 0)
local left_sx = left_edge_sx(Cursor_pane.col)
local left_px = left_sx - Display_settings.x
if left_px > App.screen.width - Margin_right - Display_settings.column_width/2 then
Cursor_pane.col = math.min(#Surface, col(Display_settings.x + App.screen.width - Margin_right - Display_settings.column_width/2))
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], Cursor_pane.row)
end
function pan_right()
if Display_settings.x < (#Surface-1) * (Padding_horizontal + Margin_left + Display_settings.column_width + Margin_right) then
Display_settings.x = Display_settings.x + Pan_step
end
local right_sx = left_edge_sx(Cursor_pane.col) + Display_settings.column_width
local right_px = right_sx - Display_settings.x
if right_px < Margin_left + Display_settings.column_width/2 then
Cursor_pane.col = math.min(#Surface, col(Display_settings.x + Margin_left + Display_settings.column_width/2))
Cursor_pane.row = math.min(#Surface[Cursor_pane.col], Cursor_pane.row)
end
end
end
end
function edit.mouse_wheel_move(State, dx,dy)
if dy > 0 then
State.cursor1 = {line=State.screen_top1.line, pos=State.screen_top1.pos}
for i=1,math.floor(dy) do
Text.up(State)
end
else
State.cursor1 = {line=State.screen_bottom1.line, pos=State.screen_bottom1.pos}
for i=1,math.floor(-dy) do
Text.down(State)
end