diff options
| -rw-r--r-- | main.lua | 1 | ||||
| -rw-r--r-- | rt.lua | 41 | ||||
| -rw-r--r-- | state.lua | 24 |
3 files changed, 56 insertions, 10 deletions
@@ -128,6 +128,7 @@ input.set_persistent_mapping({ }) input.define_mapping('MENU', { ['BS'] = {rt.prev_menu}, + ['Ctrl+BS'] = {rt.goto_origin}, ['/'] = {rt.start_search}, ['E'] = {rt.start_epg_search}, ['Ctrl+s'] = {rt.toggle_menu_sort}, @@ -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 @@ -49,6 +49,30 @@ function mt:push_menu(t) return menu end +function mt:capture_origin(d) + local m = self.menus[d] + return { + menus = util.copy_table(self.menus), + depth = self.depth, + div_depth = d, + div_cursor = m.cursor, + div_view_top = m.view_top, + div_sort_f = m.sort_f, + } +end + +function mt:restore_origin(t) + self.menus = t.menus + self.depth = t.depth + local m = self.menus[t.div_depth] + m.cursor = t.div_cursor + m.view_top = t.div_view_top + + if m.sort_f ~= t.div_sort_f then + m:set_sort(t.div_sort_f) + end +end + -- returns index if found function mt:favourited(id) for i, v in ipairs(self.favourites) do |
