From ef41e8c9a54119628aa8cffb193e42782e69563f Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Thu, 5 Feb 2026 20:50:31 -0800 Subject: support searching currently playing programmes --- osd.lua | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'osd.lua') diff --git a/osd.lua b/osd.lua index b9be340..2152863 100644 --- a/osd.lua +++ b/osd.lua @@ -244,6 +244,21 @@ function mt:draw_progress_bar(prog, fg, bg) '{\\fsp'..-filled..'}\xe2\x80\x8b{\\fsp0}' end +local function hl_matches(str, matches, col, hl_col) + if not matches then + return col .. asscape(str) + end + + local buf = '' + local n = 0 + for _, match in ipairs(matches) do + buf = buf .. col .. asscape(str:sub(n + 1, match.start - 1)) .. + hl_col .. asscape(str:sub(match.start, match.stop)) + n = match.stop + end + return buf .. col .. asscape(str:sub(n + 1)) +end + function mt:option_text(opt, info) local str = opt.name local col = opt.ended and colour.option_dim or colour.option @@ -255,23 +270,9 @@ function mt:option_text(opt, info) col = colour.group end - if opt.matches then - local buf = '' - local hl_col = info.empty and colour.search_hl_empty or - colour.search_hl - local n = 0 - - for _, match in ipairs(opt.matches) do - buf = buf .. col .. - asscape(str:sub(n + 1, match.start - 1)) .. - hl_col .. - asscape(str:sub(match.start, match.stop)) - n = match.stop - end - str = buf .. col .. asscape(str:sub(n + 1)) - else - str = col .. asscape(str) - end + local hl_col = info.empty and colour.search_hl_empty or + colour.search_hl + str = hl_matches(str, opt.matches, col, hl_col) if opt.type == 'group' and opt.group_type ~= 'series' then str = col .. '[' .. str .. ']' @@ -285,7 +286,11 @@ function mt:option_text(opt, info) local opt_info = opt.info if opt_info and #opt_info > 0 then - str = str .. colour.info .. ' (' .. asscape(opt_info) .. ')' + str = str .. colour.info .. ' (' .. + hl_matches( + opt_info, opt.info_matches, colour.info, + hl_col) .. + ')' end if opt.active_programme then -- cgit v1.2.3-70-g09d2