From ff25a8c65a1c6cf1e38a5e01a3ec47dbe2e65ab7 Mon Sep 17 00:00:00 2001 From: Ryan Hendrickson Date: Thu, 7 Jul 2022 15:55:43 -0400 Subject: [PATCH] osc.lua: add osc-unicodeminus script option This option enables the use of the Unicode U+2212 Minus Sign character when displaying the time remaining, instead of "-" (U+002D Hyphen-Minus). --- DOCS/man/osc.rst | 6 ++++++ player/lua/osc.lua | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst index 7097b2a7a9..41f89b2e35 100644 --- a/DOCS/man/osc.rst +++ b/DOCS/man/osc.rst @@ -400,6 +400,12 @@ Configurable Options Use ``no`` to disable chapter display on hover. Otherwise it's a lua ``string.format`` template and ``%s`` is replaced with the actual name. +``unicodeminus`` + Default: no + + Use a Unicode minus sign instead of an ASCII hyphen when displaying + the remaining playback time. + Script Commands ~~~~~~~~~~~~~~~ diff --git a/player/lua/osc.lua b/player/lua/osc.lua index bd9f36ec57..7a0da03971 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -53,6 +53,7 @@ local user_opts = { chapters_osd = true, -- whether to show chapters OSD on next/prev playlist_osd = true, -- whether to show playlist OSD on next/prev chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable + unicodeminus = false, -- whether to use the Unicode minus sign character } -- read options from config and command-line @@ -1731,6 +1732,8 @@ function update_options(list) request_init() end +local UNICODE_MINUS = string.char(0xe2, 0x88, 0x92) -- UTF-8 for U+2212 MINUS SIGN + -- OSC INIT function osc_init() msg.debug("osc_init") @@ -2060,10 +2063,11 @@ function osc_init() ne.visible = (mp.get_property_number("duration", 0) > 0) ne.content = function () if (state.rightTC_trem) then + local minus = user_opts.unicodeminus and UNICODE_MINUS or "-" if state.tc_ms then - return ("-"..mp.get_property_osd("playtime-remaining/full")) + return (minus..mp.get_property_osd("playtime-remaining/full")) else - return ("-"..mp.get_property_osd("playtime-remaining")) + return (minus..mp.get_property_osd("playtime-remaining")) end else if state.tc_ms then