summaryrefslogtreecommitdiff
path: root/osd.lua
diff options
context:
space:
mode:
Diffstat (limited to 'osd.lua')
-rw-r--r--osd.lua41
1 files changed, 23 insertions, 18 deletions
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