In various edge cases, this causes an assertion that was added later in
8816e1117e to be hit. The actual purpose
of the special case is not really clear. mp_seek already will change the
mpctx->stop_play value, so there shouldn't be any need to do it in
queue_seek. And it is known to cause problems so revert it. Also, remove
the special play direction logic that works around this behavior.
Fixes#13778.
This reverts commit dbdc46c97a.
Reading an entire file is a common operation, meanwhile
stream_file will happily open a directory. This doesn't match well.
Analogously for open_output_stream().
This adds script messages to select playlist entries, tracks, chapters,
subtitle lines, bindings and properties using the newly introduced
mp.input.select().
This fully closes#13964.
When you select an item, due to the submit handler being called
asynchronously, the default item list is redrawn before the console
closes, which is jarring. Fix this by always closing the console as soon
as enter is pressed, as keeping it open is unlikely to be useful with a
fuzzy selector (unlike with input.get() where it can be used e.g. to
implement a Lua REPL). If desired we can later add a close_on_submit
flag defaulting to true.
Also fix a crash when pressing enter without any match.
With mp.input.select() these keybindings were both scrolling and moving
the cursor because of how the condition was written and
handle_pgup()/handle_pgdown() not returning a truthy value.
selected_match can become 0 when pressing certain scrolling
keybindings without any match, and
for i = first_match_to_print, last_match_to_print do
in populate_log_with_matches() runs from 0 to 0 and accessing
matches[0].text crashes console.lua. Return early when it is 0.
Avoid messing up the max_log_lines calculation when mp.input.select() is
called with very long items.
This doesn't work with Japanese characters because they are bigger.
I misunderstood CogentRedTester's review in
https://github.com/mpv-player/mpv/pull/10282#discussion_r1428972352 as
referring to the cursor_position in mp.input's arguments instead of the
one received by the closed callback.
The cursor_position passed to input.get doesn't need to be converted to
a number because it was already JSON, while the cursor_position received
by the closed callback is currently a string, and we need to pass JSON
in input-event script messages to keep it as an integer to work around
mpv converting integer script message arguments to string.
This is more noticeable after implementing mp.input.select(): its submit
argument currently receives the selected index as a string, and this
makes Lua error if you use it as an index of a numerical table, e.g.:
submit = function (id)
mp.set_property(property, tracks[tonumber(id)].selected and "no"
or tracks[tonumber(id)].id)
...
end,
This commit avoids having to call tonumber(id).
If g-p is a builtin binding and p is bound in input.conf, pressing g-p
triggers the p binding. Fix this by searching for builtin bindings that
match a longer key sequence even after a user-defined binding has been
found.
Even after changing the condition from >= to > bindings of the same key
defined later in input.conf are still preferred over earlier ones,
because bind_keys() overwrites duplicate bindings. Bindings defined by
later mp.add_key_binding calls are also still preferred.
This allows more completions than patterns:
Both single and double quotes are recognized.
Quotes around the first token are recognized.
Command prefixes are recognized.
Choice options are completed after change-list/vf/af add/append/pre/set.
File paths are completed after set/cycle-values/change-list with options
that expect files, including cycling between paths with spaces, e.g.
cycle-values glsl-shaders 'foo bar' 'baz qux'.
File paths are completed in the fourth argument of dump-cache.
Items that have been set are completed after change-list remove.
This is unused since 4e013afd37 because the mpv logo and the "Drop files
or URLs to play here." message are shown instead of the OSC controls. It
has the adverse affect of making the OSC twice as big when playing
videos with --lavfi-complex, because that makes the video property which
osc.lua checks unavailable.