From b4db5fced9b408306097f1103d7fd58b6a0312a7 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Thu, 8 May 2025 22:32:29 -0700 Subject: allow favouriting --- main.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'main.lua') diff --git a/main.lua b/main.lua index a9d3cfb..8e8f3e1 100644 --- a/main.lua +++ b/main.lua @@ -21,6 +21,7 @@ osd_bg.data = '{\\alpha&H44&\\c&H&\\pos(0,0)}' .. local categories = {} local streams = {} +local favourites = {} local playing_stream_id local depth = 0 @@ -86,6 +87,16 @@ local function update_osd() col = '{\\c&H99DDFF&}' end + local id + if opt.type == 'category' then + id = opt.category_id + else + id = opt.stream_id + end + if favourites[opt.type .. ':' .. id] then + icons = icons .. '{\\c&HFF00FF&&}★ ' + end + if opt.hl then local buf = '' local n = 0 @@ -233,6 +244,26 @@ local function select_option() end end +local function favourite_option() + local menu = menus[depth] + local opt = menu.options[menu.cursor_pos] + + local id + if opt.type == 'category' then + id = opt.category_id + else + id = opt.stream_id + end + local key = opt.type .. ':' .. id + if favourites[key] then + favourites[key] = nil + else + favourites[key] = true + end + + update_osd() +end + local function prev_menu() if depth > 1 then depth = depth - 1 @@ -475,6 +506,7 @@ function bind_menu_keys() bind_key('HOME', 'first-option', first_option) bind_key('END', 'last-option', last_option) bind_key('ENTER', 'select-option', select_option) + bind_key('Ctrl+f', 'favourite-option', favourite_option) bind_key('BS', 'prev-menu', prev_menu) bind_key('/', 'start-search', search_start) end -- cgit v1.2.3-70-g09d2