Commit Graph

12 Commits

Author SHA1 Message Date
Guido Cella 2f4c550b4b zsh-completion: complete --gpu-context
This is made by possible by 96e1f1dfa5 standardizing --gpu-context's
help output. This changes the check to complete any Object settings list
so it will automatically work with future options of this kind.
2024-04-27 03:01:06 +02:00
Guido Cella 5362ec9ec0 zsh-completion: complete options after --help 2023-11-15 15:08:30 +00:00
Philip Langdale a1c8bb2257 {zsh,bash}-completion: use config when autocompleting profiles
We were over-enthusiastic when introducing --no-config into the
autocompletions. When autocompleting profiles, you actually need the
config, because that's where the profiles come from.

zsh is untested - I don't use it.
2023-09-03 13:44:31 +02:00
Niklas Haas 1bf6abc62d {zsh,bash}-completion: add missing --no-config flags
Seemingly forgotten, even though the intent was to add them.

Fixes: 15252e13d5
2023-09-02 20:32:56 +02:00
sfan5 15252e13d5 {zsh,bash}-completion: run mpv with --no-config
Reading the config when we're just interested in the option list
(not sure why mpv does that anyway) only has the potential to mess
this process up when it prints errors or the user has funny options
like msg-level or log-file set, so avoid doing so.
2023-07-19 13:01:08 +02:00
sfan5 da9c94989a zsh-completion: do not complete removed options 2023-07-19 13:01:08 +02:00
Niklas Haas ea89e813f7 zsh completion: perform globbing on binary path
When trying to use completion for mpv binaries specified with some shell
glob, e.g. ~/dev/mpv/build/mpv, the current code doesn't substitute the
homedir prefix into the path name, resulting in runtime errors about
the file '~/dev/mpv/build/mpv' not being found.

The simple fixed is to use $~var instead of $var whenever expanding the
filename, which performs the same globbing that would otherwise be
performed when executing the command.
2021-05-07 22:18:23 +02:00
Ed Santiago 43cb89fca3 zsh completion: helper functions in private namespace
The generate_xxx() helpers, once defined, would appear as
user-visible functions; this would lead to unexpected and
confusing completion suggestions for gene<tab> after having
once run mpv in that shell.

This PR adds the prefix '_mpv_' to all completion functions
as a convention to make them less user-visible and less likely
to collide with other packages.
2020-05-17 12:47:12 +02:00
Philip Sequeira a6cb92c74a zsh completion: fix handling of aliases that are listed without --
Pretty sure they used to all have --, but I guess it was changed at some
point. More incentive to do this completion stuff in a more structured
way.
2019-12-15 14:17:00 +01:00
Philip Sequeira 0198bc13a1 zsh completion: use actual POSIX-compatible regex for whitespace
\s and \S aren't actually part of the spec, but it seems glibc supports
them anyway so I didn't notice when originally testing. This fixes the
script on Apple's libc and probably others that adhere more closely to
the spec.

The most direct replacement for \s would have been [[:space:]], but we
only expect to see spaces and tabs, so might as well just do that. Also
could have used [[:blank:]], which is basically a locale-aware version
of [ \t], but mpv isn't going to output anything but ASCII spaces and
tabs, so let's avoid unnecessary complexity and stick with the ASCII
literals.
2019-12-15 14:17:00 +01:00
Philip Sequeira a921c0628e zsh completion: actually make pcre optional
It was supposed to be optional already, but I misunderstood how the
re_match_pcre option worked. If it's set, it will try to use PCRE
matching whether it's available or not (and blow up if it's not). So,
first try to load the module it'll use, and only set the option if that
works.

Fixes #7240.
2019-12-15 14:17:00 +01:00
Philip Sequeira 2712db8238 zsh completion: move generation to runtime and improve
The completion function itself now parses --list-options on the first
tab press and caches the results. This does mean a slight delay on that
first tab press, but it will only do this if the argument being
completed looks like an option (i.e. starts with "-"), so there is never
a delay when just completing a file name. I've also put some effort into
making it reasonably fast; on my machine it's consistently under 100 ms,
more than half of which is mpv itself.

Installation of zsh completion is now done unconditionally because it's
nothing more than copying a file. If you really don't want it installed,
set zshdir to empty: `./waf configure --zshdir= ...`

Improvements in functionality compared to the old script:

 * Produces the right results for mpv binaries other than the one it was
   installed with (like a dev build for testing changes).

 * Does not require running mpv at build time, so it won't cause
   problems with cross compilation.

 * Handles aliases.

 * Slightly nicer handling of options that take comma-separated values
   and/or sub-options: A space is now inserted at the end instead of a
   comma, allowing you to immediately start typing the next argument,
   but typing a comma will still remove the automatically added space,
   and = and : will now do that too, so you can immediately add a
   sub-option.

 * More general/flexible handling of values for options that print their
   possible values with --option=help. The code as is could handle quite
   a few more options (*scale, demuxers, decoders, ...), but nobody
   wants to maintain that list here so we'll just stick with what the
   old completion script already did.
2019-09-27 13:19:29 +02:00