summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/console.lua14
-rw-r--r--player/lua/stats.lua14
2 files changed, 2 insertions, 26 deletions
diff --git a/player/lua/console.lua b/player/lua/console.lua
index 02cf890791..238216445d 100644
--- a/player/lua/console.lua
+++ b/player/lua/console.lua
@@ -229,19 +229,7 @@ end
-- Escape a string for verbatim display on the OSD
function ass_escape(str)
- -- There is no escape for '\' in ASS (I think?) but '\' is used verbatim if
- -- it isn't followed by a recognised character, so add a zero-width
- -- non-breaking space
- str = str:gsub('\\', '\\\239\187\191')
- str = str:gsub('{', '\\{')
- str = str:gsub('}', '\\}')
- -- Precede newlines with a ZWNBSP to prevent ASS's weird collapsing of
- -- consecutive newlines
- str = str:gsub('\n', '\239\187\191\\N')
- -- Turn leading spaces into hard spaces to prevent ASS from stripping them
- str = str:gsub('\\N ', '\\N\\h')
- str = str:gsub('^ ', '\\h')
- return str
+ return mp.command_native({'escape-ass', str})
end
-- Takes a list of strings, a max width in characters and
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 4d25a6c6bf..2feded2808 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -129,9 +129,6 @@ local function graph_add_value(graph, value)
graph.max = max(graph.max, value)
end
--- "\\<U+2060>" in UTF-8 (U+2060 is WORD-JOINER)
-local ESC_BACKSLASH = "\\" .. string.char(0xE2, 0x81, 0xA0)
-
local function no_ASS(t)
if not o.use_ass then
return t
@@ -139,16 +136,7 @@ local function no_ASS(t)
-- mp.osd_message supports ass-escape using osd-ass-cc/{0|1}
return ass_stop .. t .. ass_start
else
- -- mp.set_osd_ass doesn't support ass-escape. roll our own.
- -- similar to mpv's sub/osd_libass.c:mangle_ass(...), excluding
- -- space after newlines because no_ASS is not used with multi-line.
- -- space at the beginning is replaced with "\\h" because it matters
- -- at the beginning of a line, and we can't know where our output
- -- ends up. no issue if it ends up at the middle of a line.
- return tostring(t)
- :gsub("\\", ESC_BACKSLASH)
- :gsub("{", "\\{")
- :gsub("^ ", "\\h")
+ return mp.command_native({"escape-ass", tostring(t)})
end
end