diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-06 12:30:32 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-02-06 12:30:32 -0800 |
| commit | e1f7209131cafab74f0665599a13d668ebeb410c (patch) | |
| tree | 33d7d8c0beb9d91a5bd7ab5b51d4e1389ce97794 /state.lua | |
| parent | ef41e8c9a54119628aa8cffb193e42782e69563f (diff) | |
| download | mpv-iptv-menu-e1f7209131cafab74f0665599a13d668ebeb410c.tar.gz mpv-iptv-menu-e1f7209131cafab74f0665599a13d668ebeb410c.tar.xz | |
implement global EPG search
Diffstat (limited to 'state.lua')
| -rw-r--r-- | state.lua | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -195,6 +195,42 @@ function menu_mt:set_options(options) self:set_cursor(1) end +function menu_mt:get_title() + if self.type == 'search' then + local str = self.search_active and 'Searching: ' or + 'Search results: ' + if self.title then + str = '(' .. self.title .. ') ' .. str + end + + local start = #self.search_text - #self.search_term + local prefix = self.search_text:sub(1, start) + local term = self.search_text:sub(start + 1) + if self.search_active then + local idx = self.search_cursor + if idx <= start then + prefix = prefix:sub(1, idx - 1) .. + '<reset_colour><cursor>' .. + '<colour.search_prefix>' .. + prefix:sub(idx) + else + idx = idx - start + term = term:sub(1, idx - 1) .. '<cursor>' .. + term:sub(idx) + end + end + str = str .. '<colour.search_prefix>' .. prefix .. + '<reset_colour>' .. term + + str = str .. ' <colour.info>(' .. #self.options .. '/' .. + #self.search_options .. ')' + + return str, true + end + + return self.title +end + function menu_mt:set_search_cursor(pos) local pos = math.max(1, math.min(#self.search_text + 1, pos)) if pos == self.search_cursor then |
