From 1d93ccb330dca438322a0438b79eea718c4cf73b Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 6 Feb 2026 14:04:11 -0800 Subject: common goto path function --- rt.lua | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'rt.lua') diff --git a/rt.lua b/rt.lua index 4a90e6e..73b5b9d 100644 --- a/rt.lua +++ b/rt.lua @@ -578,6 +578,24 @@ function rt.open_option_info(opt) end end +local function goto_path(path, opt, reverse) + local start, stop, step = 1, #path, 1 + if reverse then + start, stop, step = stop, start, -1 + end + + for i = start, stop, step do + cursor_to_id(path[i].id) + if i == stop and opt.type == 'programme' then + open_option_channel_epg(path[i]) + else + rt.push_group_menu(path[i]) + end + end + + cursor_to_id(opt.id) +end + function rt.goto_option() local menu = state:menu() local opt = menu.options[menu.cursor] @@ -594,34 +612,20 @@ function rt.goto_option() end end - for i = 1, #opt.path do - cursor_to_id(opt.path[i].id) - if i == #opt.path and opt.type == 'programme' then - open_option_channel_epg(opt.path[i]) - else - rt.push_group_menu(opt.path[i]) - end - end - cursor_to_id(opt.id) - + goto_path(opt.path, opt) osd:dirty() end function rt.goto_playing() local id = state.playing_id - local obj = id and ctx.catalogue:get(id) - local path = obj and ctx.catalogue:path_to_root(obj) + local opt = id and ctx.catalogue:get(id) + local path = opt and ctx.catalogue:path_to_root(opt) if not path then return end state.depth = 1 - for i = #path, 1, -1 do - cursor_to_id(path[i].id) - rt.push_group_menu(path[i]) - end - cursor_to_id(id) - + goto_path(path, opt, true) osd:dirty() end -- cgit v1.2.3-70-g09d2