diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-05 20:50:31 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-05 21:15:42 -0800 |
| commit | ef41e8c9a54119628aa8cffb193e42782e69563f (patch) | |
| tree | 1e3492386a7e038850962003157eb42d3becacbb /osd.lua | |
| parent | f3ebbfd63352865d07441d1165b4816be3d78b6d (diff) | |
| download | mpv-iptv-menu-ef41e8c9a54119628aa8cffb193e42782e69563f.tar.gz mpv-iptv-menu-ef41e8c9a54119628aa8cffb193e42782e69563f.tar.xz | |
support searching currently playing programmes
Diffstat (limited to 'osd.lua')
| -rw-r--r-- | osd.lua | 41 |
1 files changed, 23 insertions, 18 deletions
@@ -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 |
