History

osc.lua: add visibility_modes script opt

This allows users to choose what visibility modes they want to cycle through when calling the osc-visibilty cycle script binding.

Dudemanguy committed 1 year ago

Commit 8d665ac1 parent fd4aa9b3 files · +25 −6Browse files

Unified · Split

3 files
  1. DOCS/interface-changes/osc-script-messages.txt +1 −0
  2. DOCS/man/osc.rst +6 −0
  3. player/lua/osc.lua +18 −6
DOCS/interface-changes/osc-script-messages.txt+1−0
@@ -2,3 +2,4 @@ deprecate `osc-message` script message in favor of `show-text` command · 1 unmodified line
2deprecate `osc-chapterlist` script message in favor of `show-text ${chapter-list}`2deprecate `osc-chapterlist` script message in favor of `show-text ${chapter-list}`
3deprecate `osc-playlist` script message in favor of `show-text ${playlist}`3deprecate `osc-playlist` script message in favor of `show-text ${playlist}`
4deprecate `osc-tracklist` script message in favor of `show-text ${track-list}`4deprecate `osc-tracklist` script message in favor of `show-text ${track-list}`
5add `visibility_modes` script-opt to osc
DOCS/man/osc.rst+6−0
@@ -358,6 +358,12 @@ Configurable Options · 357 unmodified lines
358 358
359 Also supports ``never`` and ``always``359 Also supports ``never`` and ``always``
360 360
361``visibility_modes``
362 Default: never_auto_always
363
364 The list of visibility modes to cycle through when calling the
365 osc-visibility cycle script message. Modes are separated by ``_``.
366
361``boxmaxchars``367``boxmaxchars``
362 Default: 80368 Default: 80
363 369
player/lua/osc.lua+18−6
@@ -44,6 +44,7 @@ local user_opts = { · 43 unmodified lines
44 timems = false, -- display timecodes with milliseconds?44 timems = false, -- display timecodes with milliseconds?
45 tcspace = 100, -- timecode spacing (compensate font size estimation)45 tcspace = 100, -- timecode spacing (compensate font size estimation)
46 visibility = "auto", -- only used at init to set visibility_mode(...)46 visibility = "auto", -- only used at init to set visibility_mode(...)
47 visibility_modes = "never_auto_always", -- visibility modes to cycle through
47 boxmaxchars = 80, -- title crop threshold for box layout48 boxmaxchars = 80, -- title crop threshold for box layout
48 boxvideo = false, -- apply osc_param.video_margins to video49 boxvideo = false, -- apply osc_param.video_margins to video
49 windowcontrols = "auto", -- whether to show window controls50 windowcontrols = "auto", -- whether to show window controls
@@ -255,6 +256,7 @@ local state = { · 205 unmodified lines
255 maximized = false,256 maximized = false,
256 osd = mp.create_osd_overlay("ass-events"),257 osd = mp.create_osd_overlay("ass-events"),
257 chapter_list = {}, -- sorted by time258 chapter_list = {}, -- sorted by time
259 visibility_modes = {}, -- visibility_modes to cycle through
258 osc_message_warned = false, -- deprecation warnings260 osc_message_warned = false, -- deprecation warnings
259 osc_chapterlist_warned = false,261 osc_chapterlist_warned = false,
260 osc_playlist_warned = false,262 osc_playlist_warned = false,
@@ -2774,12 +2776,14 @@ end · 2513 unmodified lines
2774-- the modes only affect internal variables and not stored on its own.2776-- the modes only affect internal variables and not stored on its own.
2775local function visibility_mode(mode, no_osd)2777local function visibility_mode(mode, no_osd)
2776 if mode == "cycle" then2778 if mode == "cycle" then
2777 if not state.enabled then2779 for i, allowed_mode in ipairs(state.visibility_modes) do
2778 mode = "auto"2780 if i == #state.visibility_modes then
2779 elseif user_opts.visibility ~= "always" then2781 mode = state.visibility_modes[1]
2780 mode = "always"2782 break
2781 else2783 elseif user_opts.visibility == allowed_mode then
2782 mode = "never"2784 mode = state.visibility_modes[i + 1]
2785 break
2786 end
2783 end2787 end
2784 end2788 end
2785 2789
@@ -2907,6 +2911,14 @@ local function validate_user_opts() · 121 unmodified lines
2907 msg.warn("'" .. color .. "' is not a valid color")2911 msg.warn("'" .. color .. "' is not a valid color")
2908 end2912 end
2909 end2913 end
2914
2915 for str in string.gmatch(user_opts.visibility_modes, "([^_]+)") do
2916 if str ~= "auto" and str ~= "always" and str ~= "never" then
2917 msg.warn("Ignoring unknown visibility mode '" .. str .."' in list")
2918 else
2919 table.insert(state.visibility_modes, str)
2920 end
2921 end
2910end2922end
2911 2923
2912-- read options from config and command-line2924-- read options from config and command-line

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t