summaryrefslogtreecommitdiff
path: root/rt.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-06 17:43:10 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-06 17:43:10 -0800
commit0cc08ff142621dac444d84be05bf9b6f4acd602b (patch)
tree41b1b716c555efa5da8363077affd47ee2edc62b /rt.lua
parent1d93ccb330dca438322a0438b79eea718c4cf73b (diff)
downloadmpv-iptv-menu-0cc08ff142621dac444d84be05bf9b6f4acd602b.tar.gz
mpv-iptv-menu-0cc08ff142621dac444d84be05bf9b6f4acd602b.tar.xz
allow teleporting back after a gotoHEADmaster
Diffstat (limited to 'rt.lua')
-rw-r--r--rt.lua41
1 files changed, 31 insertions, 10 deletions
diff --git a/rt.lua b/rt.lua
index 73b5b9d..f5a47ac 100644
--- a/rt.lua
+++ b/rt.lua
@@ -578,7 +578,7 @@ function rt.open_option_info(opt)
end
end
-local function goto_path(path, opt, reverse)
+local function goto_path_traverse(path, opt, reverse)
local start, stop, step = 1, #path, 1
if reverse then
start, stop, step = stop, start, -1
@@ -596,6 +596,14 @@ local function goto_path(path, opt, reverse)
cursor_to_id(opt.id)
end
+local function goto_path(d, ...)
+ local origin = state:capture_origin(d)
+ state.depth = d
+ goto_path_traverse(...)
+ state:menu().origin = origin
+ osd:dirty()
+end
+
function rt.goto_option()
local menu = state:menu()
local opt = menu.options[menu.cursor]
@@ -603,17 +611,17 @@ function rt.goto_option()
return
end
+ local d = state.depth
if menu.group_id == 'favourites' then
- state.depth = 1
+ d = 1
elseif menu.type == 'search' then
- state.depth = state.depth - 1
- if state:menu().group_id == 'favourites' then
- merge_refreshed_menu_options()
- end
+ d = d - 1
end
- goto_path(opt.path, opt)
- osd:dirty()
+ goto_path(d, opt.path, opt)
+ if state:menu().group_id == 'favourites' then
+ merge_refreshed_menu_options()
+ end
end
function rt.goto_playing()
@@ -624,8 +632,21 @@ function rt.goto_playing()
return
end
- state.depth = 1
- goto_path(path, opt, true)
+ goto_path(1, path, opt, true)
+end
+
+function rt.goto_origin()
+ local menu = state:menu()
+ local origin = menu.origin
+ if not origin then
+ return
+ end
+
+ menu.origin = nil
+ state:restore_origin(origin)
+ if state:menu().group_id == 'favourites' then
+ merge_refreshed_menu_options()
+ end
osd:dirty()
end