Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions DOCS/man/stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ stats:
4 Active key bindings (scroll)
5 Selected Tracks Info (scroll)
0 Internal stuff (scroll)
==== ==================

If stats were displayed by toggling, these key bindings are also active:

==== ==================
ESC Close the stats
==== ==================

Expand Down
31 changes: 21 additions & 10 deletions player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1630,14 +1630,15 @@ local function unbind_search()
end

local function bind_exit()
-- Don't bind in oneshot mode because if ESC is pressed right when the stats
-- stop being displayed, it would unintentionally trigger any user-defined
-- ESC binding.
if not display_timer.oneshot then
mp.add_forced_key_binding(o.key_exit, "__forced_" .. o.key_exit, function ()
mp.add_forced_key_binding(o.key_exit, "__forced_" .. o.key_exit, function ()
if display_timer.oneshot then
display_timer:kill()
clear_screen()
remove_page_bindings()
else
process_key_binding(false)
end)
end
end
end)
end

local function unbind_exit()
Expand Down Expand Up @@ -1678,13 +1679,23 @@ end


-- Remove keybindings for every page
remove_page_bindings = function()
remove_page_bindings = function(delay_unbinding_exit)
for k, _ in pairs(pages) do
mp.remove_key_binding("__forced_"..k)
end
unbind_scroll()
unbind_search()
unbind_exit()
-- If ESC is pressed right after oneshot stats stop being displayed, don't
-- unintentionally trigger any user-defined ESC binding.
if delay_unbinding_exit then
mp.add_timeout(1, function ()
if not display_timer:is_enabled() then
unbind_exit()
end
end)
else
unbind_exit()
end
end


Expand Down Expand Up @@ -1746,7 +1757,7 @@ end
display_timer = mp.add_periodic_timer(o.duration,
function()
if display_timer.oneshot then
display_timer:kill() ; clear_screen() ; remove_page_bindings()
display_timer:kill() ; clear_screen() ; remove_page_bindings(true)
-- Close the console only if it was opened for searching bindings.
if searched_text then
input.terminate()
Expand Down
Loading