summaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-05 20:50:31 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-02-05 21:15:42 -0800
commitef41e8c9a54119628aa8cffb193e42782e69563f (patch)
tree1e3492386a7e038850962003157eb42d3becacbb /util.lua
parentf3ebbfd63352865d07441d1165b4816be3d78b6d (diff)
downloadmpv-iptv-menu-ef41e8c9a54119628aa8cffb193e42782e69563f.tar.gz
mpv-iptv-menu-ef41e8c9a54119628aa8cffb193e42782e69563f.tar.xz
support searching currently playing programmes
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/util.lua b/util.lua
index d678a9e..ca693ba 100644
--- a/util.lua
+++ b/util.lua
@@ -155,6 +155,29 @@ function util.unflatten_table(src, dst)
return dst
end
+function util.find_matches(str, substr, case_sensitive)
+ if not str then
+ return
+ end
+
+ if not case_sensitive then
+ str = str:lower()
+ end
+
+ local matches
+ local i, j = 0, 0
+ while true do
+ i, j = str:find(substr, j + 1, true)
+ -- j < i avoids infinite loop on empty substr
+ if not i or j < i then
+ break
+ end
+ matches = matches or {}
+ matches[#matches+1] = {start = i, stop = j}
+ end
+ return matches or i and {}
+end
+
function util.str_seek_prev_char(str, pos)
return util.utf8_seek(str, pos, -1)
end