console.lua: show completions as you type

Show available completion suggestions as you type without having to
press Tab.

This is fast even on a 2011 CPU, so we can get away with doing this in
the same thread that draws the console. The one case where it could make
the console hang is file completion of network drives, but in general it
is convenient for loadfile.

mp.input.get clients also get a request to complete on each character
typed, but those run in a different thread so performance is always
fine, and completions were already rejected if the input line or cursor
changed after the request. If I ever make running mpv commands an
mp.input client in the future, command completion will also benefit from
running in a different thread.
This commit is contained in:
Guido Cella
2024-11-22 22:10:13 +01:00
committed by Kacper Michajłow
parent 2e265f33e3
commit 57b73f1af6
2 changed files with 47 additions and 72 deletions

View File

@@ -89,8 +89,7 @@ Shift+INSERT
Paste text (uses the primary selection on X11 and Wayland).
TAB and Ctrl+i
Complete the text at the cursor. The first press inserts the longest common
prefix of the completions, and subsequent presses cycle through them.
Cycle through completion suggestions.
Shift+TAB
Cycle through the completions backwards.
@@ -124,7 +123,8 @@ Commands
Enter a percent position to seek to and close the console.
``Ctrl+o script-message-to console type "loadfile ''; keypress ESC" 11``
Enter a file or URL to play. Tab completes paths in the filesystem.
Enter a file or URL to play, with autocompletion of paths in the
filesystem.
Known issues
------------
@@ -177,7 +177,7 @@ Configurable Options
``case_sensitive``
Default: no on Windows, yes on other platforms.
Whether Tab completion is case sensitive. Only works with ASCII characters.
Whether autocompletion is case sensitive. Only works with ASCII characters.
``history_dedup``
Default: true