summaryrefslogtreecommitdiff
path: root/state.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-07 15:46:45 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-07 15:46:45 -0800
commit83b4d6ff1dac0d483ad1a470fef80485c151a0ea (patch)
tree309f44a0613becd0c4292edcc6b1b30c3d06cd47 /state.lua
parent2dc4809f5cba14838def5abea3220793ae0d8e4a (diff)
downloadmpv-iptv-menu-83b4d6ff1dac0d483ad1a470fef80485c151a0ea.tar.gz
mpv-iptv-menu-83b4d6ff1dac0d483ad1a470fef80485c151a0ea.tar.xz
don't redraw when cursor position doesn't change
Diffstat (limited to 'state.lua')
-rw-r--r--state.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/state.lua b/state.lua
index 2f609c9..8bf4ddd 100644
--- a/state.lua
+++ b/state.lua
@@ -85,6 +85,12 @@ end
function menu_mt:set_cursor(pos, lines, opts)
local pos = math.max(1, math.min(pos, #self.options))
local top = self.view_top
+
+ if not lines then
+ top = pos
+ goto update
+ end
+
if opts and opts.centre then
top = pos - math.floor((lines - 1) / 2)
elseif opts and opts.keep_offset then
@@ -100,8 +106,13 @@ function menu_mt:set_cursor(pos, lines, opts)
top = math.max(1, math.min(top, #self.options - lines + 1))
+ ::update::
+ if pos == self.cursor and top == self.view_top then
+ return false
+ end
self.cursor = pos
self.view_top = top
+ return true
end
function menu_mt:set_sort(bool, f)