summaryrefslogtreecommitdiff
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
parent2dc4809f5cba14838def5abea3220793ae0d8e4a (diff)
downloadmpv-iptv-menu-83b4d6ff1dac0d483ad1a470fef80485c151a0ea.tar.gz
mpv-iptv-menu-83b4d6ff1dac0d483ad1a470fef80485c151a0ea.tar.xz
don't redraw when cursor position doesn't change
-rw-r--r--main.lua13
-rw-r--r--state.lua11
2 files changed, 18 insertions, 6 deletions
diff --git a/main.lua b/main.lua
index 57a4e12..c139c07 100644
--- a/main.lua
+++ b/main.lua
@@ -101,9 +101,9 @@ local function save_favourites()
end
local function set_cursor(pos, opts)
- state:menu():set_cursor(pos, osd_menu_lines(), opts)
+ local moved = state:menu():set_cursor(pos, osd_menu_lines(), opts)
- if not (opts and opts.skip_redraw) then
+ if moved and not (opts and opts.skip_redraw) then
update_osd()
end
end
@@ -117,7 +117,7 @@ local function cursor_down()
end
local function cursor_start()
- set_cursor(0)
+ set_cursor(1)
end
local function cursor_end()
@@ -179,7 +179,7 @@ local function move_option_down()
end
local function move_option_start()
- move_option(0)
+ move_option(1)
end
local function move_option_end()
@@ -608,7 +608,8 @@ local function open_option_epg(opt)
title = 'EPG: ' .. opt.name .. ' (' .. ch .. ')',
type = 'epg',
})
- set_cursor(curr, {centre = true})
+ set_cursor(curr, {centre = true, skip_redraw = true})
+ update_osd()
end
local function add_info_field(dst, k, v, fmt)
@@ -890,7 +891,7 @@ local function start_search()
menu.title = title
menu.search_active = true
menu:set_search_cursor(#menu.search_text + 1)
- menu:set_cursor(1, osd_menu_lines())
+ menu:set_cursor(1)
else
menu = state:push_menu({
title = title,
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)