summaryrefslogtreecommitdiff
path: root/state.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-06 12:30:32 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-06 12:30:32 -0800
commite1f7209131cafab74f0665599a13d668ebeb410c (patch)
tree33d7d8c0beb9d91a5bd7ab5b51d4e1389ce97794 /state.lua
parentef41e8c9a54119628aa8cffb193e42782e69563f (diff)
downloadmpv-iptv-menu-e1f7209131cafab74f0665599a13d668ebeb410c.tar.gz
mpv-iptv-menu-e1f7209131cafab74f0665599a13d668ebeb410c.tar.xz
implement global EPG search
Diffstat (limited to 'state.lua')
-rw-r--r--state.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/state.lua b/state.lua
index 4db4837..4d97fe3 100644
--- a/state.lua
+++ b/state.lua
@@ -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