From 2becb971e9d73ad2262b985f0d40e45dc94e0998 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 7 Jun 2024 22:34:03 +0200 Subject: [PATCH] console.lua: prettify unselected track log messages After d49879f1f7 terminal escape sequences are printed in the console log for unselected tracks. Remove them and make those lines grey. --- player/lua/console.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/player/lua/console.lua b/player/lua/console.lua index 0fb1640364..2a0a5031ac 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -1781,8 +1781,20 @@ mp.register_event('log-message', function(e) if e.level == 'trace' then return end -- Use color for debug/v/warn/error/fatal messages. - log_add('[' .. e.prefix .. '] ' .. e.text, styles[e.level], - terminal_styles[e.level]) + local style = styles[e.level] + local terminal_style = terminal_styles[e.level] + + -- Strip the terminal escape sequence from unselected tracks. + if e.prefix == 'cplayer' and e.level == 'info' then + local found + e.text, found = e.text:gsub('^\027%[38;5;8m', '') + if found == 1 then + style = styles.disabled + terminal_style = terminal_styles.disabled + end + end + + log_add('[' .. e.prefix .. '] ' .. e.text, style, terminal_style) end) collectgarbage()