mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
stats.lua: allow keybindings to toggle the display of a specific page
This lets you define bindings like h script-binding stats/display-page-4-toggle. Requested in #14966.
This commit is contained in:
committed by
Avi Halachmi
parent
be814e3753
commit
493cab7efc
@@ -1750,14 +1750,20 @@ mp.add_key_binding(nil, "display-stats", function() process_key_binding(true) en
|
||||
mp.add_key_binding(nil, "display-stats-toggle", function() process_key_binding(false) end,
|
||||
{repeatable=false})
|
||||
|
||||
-- Single invocation bindings without key, can be used in input.conf to create
|
||||
-- bindings for a specific page: "e script-binding stats/display-page-2"
|
||||
for k, _ in pairs(pages) do
|
||||
mp.add_key_binding(nil, "display-page-" .. k,
|
||||
function()
|
||||
curr_page = k
|
||||
process_key_binding(true)
|
||||
end, {repeatable=true})
|
||||
-- Single invocation key bindings for specific pages, e.g.:
|
||||
-- "e script-binding stats/display-page-2"
|
||||
mp.add_key_binding(nil, "display-page-" .. k, function()
|
||||
curr_page = k
|
||||
process_key_binding(true)
|
||||
end, {repeatable=true})
|
||||
|
||||
-- Key bindings to toggle a specific page, e.g.:
|
||||
-- "h script-binding stats/display-page-4-toggle".
|
||||
mp.add_key_binding(nil, "display-page-" .. k .. "-toggle", function()
|
||||
curr_page = k
|
||||
process_key_binding(false)
|
||||
end, {repeatable=true})
|
||||
end
|
||||
|
||||
-- Reprint stats immediately when VO was reconfigured, only when toggled
|
||||
|
||||
Reference in New Issue
Block a user