Disable OSC visibility when input box is active (if supported)
This commit is contained in:
parent
3fd18366f1
commit
4a467faff0
@ -18,6 +18,7 @@ local MOOD_NEUTRAL = 0
|
||||
local MOOD_BAD = 1
|
||||
local MOOD_GOOD = 2
|
||||
local WORDWRAPIFY_MAGICWORD = "{\\\\fscx0} {\\\\fscx100}"
|
||||
local default_oscvisibility_state = "never"
|
||||
|
||||
local ALPHA_WARNING_TEXT_COLOUR = "FF00FF" -- RBG
|
||||
local HINT_TEXT_COLOUR = "00FFFF" -- RBG
|
||||
@ -30,6 +31,8 @@ local chat_log = {}
|
||||
|
||||
local assdraw = require "mp.assdraw"
|
||||
|
||||
local opt = require 'mp.options'
|
||||
|
||||
function format_scrolling(xpos, ypos, text)
|
||||
local chat_message = chat_format .. "{\\pos("..xpos..","..ypos..")}"..text.."\n"
|
||||
return string.format(chat_message)
|
||||
@ -306,6 +309,7 @@ opts = {
|
||||
-- Enable/Disable
|
||||
['chatInputEnabled'] = true,
|
||||
['chatOutputEnabled'] = true,
|
||||
['OscVisibilityChangeCompatible'] = false,
|
||||
-- Set the font size used for the REPL and the console. This will be
|
||||
-- multiplied by "scale."
|
||||
['chatInputFontSize'] = 20,
|
||||
@ -481,6 +485,13 @@ function set_active(active)
|
||||
repl_active = false
|
||||
mp.disable_key_bindings('repl-input')
|
||||
end
|
||||
if default_oscvisibility_state ~= "never" and opts['OscVisibilityChangeCompatible'] == true then
|
||||
if active then
|
||||
mp.commandv("script-message", "osc-visibility","never", "no-osd")
|
||||
else
|
||||
mp.commandv("script-message", "osc-visibility",default_oscvisibility_state, "no-osd")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Show the repl if hidden and replace its contents with 'text'
|
||||
@ -877,7 +888,7 @@ end)
|
||||
mp.command('print-text "<get_syncplayintf_options>"')
|
||||
|
||||
function set_syncplayintf_options(input)
|
||||
---mp.command('print-text "<chat>...'..input..'</chat>"')
|
||||
--mp.command('print-text "<chat>...'..input..'</chat>"')
|
||||
for option, value in string.gmatch(input, "([^ ,=]+)=([^,]+)") do
|
||||
local valueType = type(opts[option])
|
||||
if valueType == "number" then
|
||||
@ -895,6 +906,9 @@ function set_syncplayintf_options(input)
|
||||
chat_format = get_output_style()
|
||||
local vertical_output_area = CANVAS_HEIGHT-(opts['chatTopMargin']+opts['chatBottomMargin']+(opts['chatOutputFontSize']+opts['scrollingFirstRowOffset']))
|
||||
max_scrolling_rows = math.floor(vertical_output_area/opts['chatOutputFontSize'])
|
||||
local user_opts = { visibility = "auto", }
|
||||
opt.read_options(user_opts, "osc")
|
||||
default_oscvisibility_state = user_opts.visibility
|
||||
if opts['chatInputEnabled'] == true then
|
||||
mp.add_forced_key_binding('enter', handle_enter)
|
||||
mp.add_forced_key_binding('kp_enter', handle_enter)
|
||||
|
||||
@ -185,6 +185,7 @@ MPV_ARGS = ['--force-window', '--idle', '--hr-seek=always', '--keep-open']
|
||||
MPV_SLAVE_ARGS = ['--msg-level=all=error,cplayer=info,term-msg=info', '--input-terminal=no', '--input-file=/dev/stdin']
|
||||
MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=<SyncplayUpdateFile>\nANS_filename=${filename}\nANS_length=${=length:${=duration:0}}\nANS_path=${path}\n</SyncplayUpdateFile>', '--terminal=yes']
|
||||
MPV_NEW_VERSION = False
|
||||
MPV_OSC_VISIBILITY_CHANGE_VERSION = False
|
||||
MPV_SYNCPLAYINTF_OPTIONS_TO_SEND = ["chatInputEnabled","chatInputFontFamily", "chatInputFontSize", "chatInputFontWeight","chatInputFontUnderline",
|
||||
"chatInputFontColor", "chatInputPosition","chatOutputFontFamily","chatOutputFontSize",
|
||||
"chatOutputFontWeight","chatOutputFontUnderline","chatOutputMode","chatMaxLines",
|
||||
|
||||
@ -18,6 +18,9 @@ class MpvPlayer(MplayerPlayer):
|
||||
except:
|
||||
ver = None
|
||||
constants.MPV_NEW_VERSION = ver is None or int(ver.group(1)) > 0 or int(ver.group(2)) >= 6
|
||||
constants.MPV_OSC_VISIBILITY_CHANGE_VERSION = False if ver is None else int(ver.group(1)) > 0 or int(ver.group(2)) >= 28
|
||||
if not constants.MPV_OSC_VISIBILITY_CHANGE_VERSION:
|
||||
client.ui.showDebugMessage(u"This version of mpv is not known to be compatible with changing the OSC visibility. Please use mpv >=0.28.0.")
|
||||
if constants.MPV_NEW_VERSION:
|
||||
return NewMpvPlayer(client, MpvPlayer.getExpandedPath(playerPath), filePath, args)
|
||||
else:
|
||||
@ -257,6 +260,7 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
options.append(option)
|
||||
for option in constants.MPV_SYNCPLAYINTF_LANGUAGE_TO_SEND:
|
||||
options.append(u"{}={}".format(option,getMessage(option)))
|
||||
options.append(u"OscVisibilityChangeCompatible={}".format(constants.MPV_OSC_VISIBILITY_CHANGE_VERSION))
|
||||
options_string = ", ".join(options)
|
||||
self._listener.sendLine(u'script-message-to syncplayintf set_syncplayintf_options "{}"'.format(options_string))
|
||||
self._setOSDPosition()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user