summaryrefslogtreecommitdiff
path: root/state.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-10 14:57:32 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-10 14:57:32 -0800
commit15f3f7f7a7428e97b483ba3c3d0f146e6f77f1e7 (patch)
tree176894060388d0a6b200315554aafe98aeb195f3 /state.lua
parente370163b4a8f7e02901ec4f004a965ee5e7e4942 (diff)
downloadmpv-iptv-menu-15f3f7f7a7428e97b483ba3c3d0f146e6f77f1e7.tar.gz
mpv-iptv-menu-15f3f7f7a7428e97b483ba3c3d0f146e6f77f1e7.tar.xz
respect scroll margin on page up/down
Diffstat (limited to 'state.lua')
-rw-r--r--state.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/state.lua b/state.lua
index 41c317c..da26a9a 100644
--- a/state.lua
+++ b/state.lua
@@ -92,14 +92,17 @@ function menu_mt:set_cursor(pos, lines, opts)
goto update
end
+ if opts and opts.margin then
+ margin = math.min(opts.margin, math.floor((lines - 1) / 2))
+ end
+
if opts and opts.centre then
top = pos - math.floor((lines - 1) / 2)
elseif opts and opts.keep_offset then
top = top + pos - self.cursor
- elseif opts and opts.margin then
+ elseif margin > 0 then
margin = math.max(0, math.min(
- opts.margin,
- math.floor((lines - 1) / 2),
+ margin,
self.cursor - self.view_top,
self.view_top + lines - 1 - self.cursor))
end