diff options
author | Julian <MyFakeAcc.4@googlemail.com> | 2017-07-02 13:23:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-10-09 20:40:32 +0200 |
commit | 21603dd5afedaccaf1f565f5b659b68343ab40db (patch) | |
tree | 63194b1cacc0074d9d2d72d2f3293d906d44b2e3 /player | |
parent | 98ddbf8c34a6c42f2dd15b61c7208f319aa87866 (diff) | |
download | mpv-21603dd5afedaccaf1f565f5b659b68343ab40db.tar.bz2 mpv-21603dd5afedaccaf1f565f5b659b68343ab40db.tar.xz |
stats: allow keybindings for specific page
A keybinding in input.conf like:
e script-binding stats/display-page-2
can be used to directly show the respective page (2, in this case)
Diffstat (limited to 'player')
-rw-r--r-- | player/lua/stats.lua | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua index ea6c73fd2a..c0ec4715ea 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -623,6 +623,18 @@ local function toggle_stats() end +local function oneshot_stats(page) + -- Ignore single invocations while stats are toggled + if toggle_timer:is_enabled() then + return + end + binding_timer:kill() + binding_timer:resume() + add_page_bindings() + print_page(page or curr_page) +end + + -- Current page and <page key>:<page function> mapping curr_page = o.key_page_1 pages = { @@ -642,21 +654,18 @@ binding_timer.oneshot = true binding_timer:kill() -- Single invocation key binding -mp.add_key_binding(o.key_oneshot, "display_stats", - function() - if toggle_timer:is_enabled() then - return - end - binding_timer:kill() - binding_timer:resume() - add_page_bindings() - print_page(curr_page) - end, {repeatable=true}) +mp.add_key_binding(o.key_oneshot, "display-stats", oneshot_stats, {repeatable=true}) + +-- 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() oneshot_stats(k) end, {repeatable=true}) +end -- Toggling key binding -mp.add_key_binding(o.key_toggle, "display_stats_toggle", toggle_stats, {repeatable=false}) +mp.add_key_binding(o.key_toggle, "display-stats-toggle", toggle_stats, {repeatable=false}) --- Reprint stats +-- Reprint stats immediately when VO was reconfigured, only when toggled mp.register_event("video-reconfig", function() if toggle_timer:is_enabled() then |