From 2335ee55146caebd40698596484befa867470188 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Fri, 16 Jul 2021 12:06:20 +0300 Subject: stats.lua: page 4 (keys): support help-like terminal printout While --input-test is useful, and so is page 4 of stats, until now there was no way to simply print the list in a help-like fashion. This commit adds such printout, invoked by the script opt stats-bindlist=yes, which uses the existing page 4 code. This prints the list on startup and quits immediately - like any help page. It's awkward to invoke compared to other help pages, and it does require the stats page to be enabled (it is by default), however it is a script-generated output, and currently there's no other method to print a help page generated by a script. The printout itself is performed using lua's io.write. While reliable, it's not the standard way for mpv to print to the terminal. Other possible printout methods are mp.msg.info - which also prints "[stats]" prefix on each line (ugly), or forcing term-osd and setting an osd-message which mpv will then print at the terminal - however that's printed to stderr, and could also be subject to timing concerns since we quit right afterwards. In the future we can consider changing/integrating the invocation so that mpv itself could print a help page generated by a script, thus solving both the awkward invocation and printout-method issues. --- DOCS/man/stats.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'DOCS/man/stats.rst') diff --git a/DOCS/man/stats.rst b/DOCS/man/stats.rst index 3684922189..9e6b7bc453 100644 --- a/DOCS/man/stats.rst +++ b/DOCS/man/stats.rst @@ -197,6 +197,12 @@ The keys are grouped automatically using a simple analysis of the command string, and one should not expect documentation-level grouping accuracy, however, it should still be reasonably useful. +Using ``--idle --script-opts=stats-bindlist=yes`` will print the list to the +terminal and quit immediately. By default long lines are shortened to 79 chars, +and terminal escape sequences are enabled. A different length limit can be +set by changing ``yes`` to a number (at least 40), and escape sequences can be +disabled by adding ``-`` before the value, e.g. ``...=-yes`` or ``...=-120``. + Like with ``--input-test``, the list includes bindings from ``input.conf`` and from user scripts. Use `--no-config`` to list only built-in bindings. -- cgit v1.2.3