diff options
Diffstat (limited to 'osd.lua')
| -rw-r--r-- | osd.lua | 36 |
1 files changed, 28 insertions, 8 deletions
@@ -159,18 +159,38 @@ function mt:menu_title(menu) local col = menu.search_active and colour.selected or colour.title if menu.type == 'search' then - str = str:gsub('<text>', asscape(menu.search_text)) + local start = #menu.search_text - #menu.search_term + local prefix = menu.search_text:sub(1, start) + local term = menu.search_text:sub(start + 1) + + if str:find('<text>', 1, true) then + str = str:gsub('<text>', function() + return colour.search_prefix .. + asscape(prefix) .. col .. asscape(term) + end) + end if str:find('<text_with_cursor>', 1, true) then - str = str:gsub('<text_with_cursor>', - asscape(menu.search_text:sub( - 1, menu.search_cursor - 1)) .. - cursor_glyph .. - asscape(menu.search_text:sub( - menu.search_cursor))) + local idx = menu.search_cursor + if idx <= start then + prefix = asscape(prefix:sub(1, idx - 1)) .. + col .. cursor_glyph .. + colour.search_prefix .. + asscape(prefix:sub(idx)) + term = asscape(term) + else + idx = idx - start + prefix = asscape(prefix) + term = asscape(term:sub(1, idx - 1)) .. + cursor_glyph .. asscape(term:sub(idx)) + end + str = str:gsub('<text_with_cursor>', function() + return colour.search_prefix .. prefix .. col .. + term + end) end - str = str:gsub('<colour.info>', colour.info) + str = str:gsub('<colour%.info>', colour.info) str = str:gsub('<num_matches>', #menu.options) str = str:gsub('<num_total>', #menu.search_options) end |
