zenwarr / mpv-config

Collection of my personalized mpv scripts and configuration files
20 stars 3 forks source link

search-subtitles: highlight only shows first part of line not after match #14

Closed mrfragger closed 1 year ago

mrfragger commented 1 year ago
-- highlight found text with colored text in ass syntax
-- todo: it breaks current item highlighting right now   

return before .. "{\\c&HFF00&}" .. match .. "{\\c&HFFFFFF&}" .. after

I spent hours trying to figure this out..mainly cuz I don't know lua....anyway I learned a bit about string.sub, string.gsub, string.match. So match is green and after is white to make it match the rest of the text.

I couldn't figure out where the light blue highlight color is coming from for

local cur_line = {sub}
    for _, line in ipairs(get_lines(data)) do
        line = trim(line)
        if state == "header" then
            if line == "" then
                state = "body"
            end
        elseif state == "body" then
            if line == "" then
                state = "header"
            elseif line:match("^NOTE") or line:match("^STYLE") then
                state = "comment"

Anyway I suggest to solve this issue is remove the light blue color and just bold the entire current line if that's possible.

zenwarr commented 1 year ago

It comes from script-modules/scroll-list.lua, and scroll_list:format_line function applies the style. Your proposed solution is good, but I personally prefer to keep selected line colored and plan to fix the script to work correctly, because bold selection leads to text jumps and can be not noticeable enough depending on a font.

But if you prefer to remove the color and use bold for the current line, you can edit script-modules/scroll-list.lua and set values for corresponding lines like this:

list_style = [[{\q2\fs25\c&Hffffff&\b0}]],

and

selected_style = [[{\b1\c&Hffffff&}]],
zenwarr commented 1 year ago

I've fixed color highlighting too

mrfragger commented 1 year ago

Awesome...much appreciated. I'm trying out the new one and it seems like it's returning results but it's all blank. Tried on mkv video and also opus audiobook. Screen Shot 2023-09-30 at 3 23 11 PM

mrfragger commented 1 year ago

ok I'm an idiot..updated the scroll-list.lua and input-console.lua and works fabulously Screen Shot 2023-09-30 at 3 37 19 PM