1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-20 22:26:30 +00:00

input: allow - as separator between commands, instead of _

Wnile it seems quite logical to me that commands use _ as word
separator, while properties use -, I can't really explain the
difference, and it tends to confuse users as well. So always
prefer - as separator for everything.

Using _ still works, and will probably forever. Not doing so would
probably create too much chaos and confusion.
This commit is contained in:
wm4 2015-05-25 21:59:44 +02:00
parent 6bfbd4ebdc
commit 289705daaf
6 changed files with 127 additions and 119 deletions

View File

@ -65,11 +65,11 @@ C-style escaping can be used.
You can bind multiple commands to one key. For example: You can bind multiple commands to one key. For example:
| a show_text "command 1" ; show_text "command 2" | a show-text "command 1" ; show-text "command 2"
It's also possible to bind a command to a sequence of keys: It's also possible to bind a command to a sequence of keys:
| a-b-c show_text "command run after a, b, c have been pressed" | a-b-c show-text "command run after a, b, c have been pressed"
(This is not shown in the general command syntax.) (This is not shown in the general command syntax.)
@ -114,25 +114,25 @@ List of Input Commands
3rd parameter (essentially using a space instead of ``+``). The 3rd 3rd parameter (essentially using a space instead of ``+``). The 3rd
parameter is still parsed, but is considered deprecated. parameter is still parsed, but is considered deprecated.
``revert_seek [mode]`` ``revert-seek [mode]``
Undoes the ``seek`` command, and some other commands that seek (but not Undoes the ``seek`` command, and some other commands that seek (but not
necessarily all of them). Calling this command once will jump to the necessarily all of them). Calling this command once will jump to the
playback position before the seek. Calling it a second time undoes the playback position before the seek. Calling it a second time undoes the
``revert_seek`` command itself. This only works within a single file. ``revert-seek`` command itself. This only works within a single file.
The first argument is optional, and can change the behavior: The first argument is optional, and can change the behavior:
mark mark
Mark the current time position. The next normal ``revert_seek`` command Mark the current time position. The next normal ``revert-seek`` command
will seek back to this point, no matter how many seeks happened since will seek back to this point, no matter how many seeks happened since
last time. last time.
Using it without any arguments gives you the default behavior. Using it without any arguments gives you the default behavior.
``frame_step`` ``frame-step``
Play one frame, then pause. Does nothing with audio-only playback. Play one frame, then pause. Does nothing with audio-only playback.
``frame_back_step`` ``frame-back-step``
Go back by one frame, then pause. Note that this can be very slow (it tries Go back by one frame, then pause. Note that this can be very slow (it tries
to be precise, not fast), and sometimes fails to behave as expected. How to be precise, not fast), and sometimes fails to behave as expected. How
well this works depends on whether precise seeking works correctly (e.g. well this works depends on whether precise seeking works correctly (e.g.
@ -182,7 +182,7 @@ List of Input Commands
frame was dropped. This flag can be combined with the other flags, frame was dropped. This flag can be combined with the other flags,
e.g. ``video+each-frame``. e.g. ``video+each-frame``.
``screenshot_to_file "<filename>" [subtitles|video|window]`` ``screenshot-to-file "<filename>" [subtitles|video|window]``
Take a screenshot and save it to a given file. The format of the file will Take a screenshot and save it to a given file. The format of the file will
be guessed by the extension (and ``--screenshot-format`` is ignored - the be guessed by the extension (and ``--screenshot-format`` is ignored - the
behavior when the extension is missing or unknown is arbitrary). behavior when the extension is missing or unknown is arbitrary).
@ -194,7 +194,7 @@ List of Input Commands
Like all input command parameters, the filename is subject to property Like all input command parameters, the filename is subject to property
expansion as described in `Property Expansion`_. expansion as described in `Property Expansion`_.
``playlist_next [weak|force]`` ``playlist-next [weak|force]``
Go to the next entry on the playlist. Go to the next entry on the playlist.
weak (default) weak (default)
@ -202,7 +202,7 @@ List of Input Commands
force force
Terminate playback if there are no more files on the playlist. Terminate playback if there are no more files on the playlist.
``playlist_prev [weak|force]`` ``playlist-prev [weak|force]``
Go to the previous entry on the playlist. Go to the previous entry on the playlist.
weak (default) weak (default)
@ -232,23 +232,23 @@ List of Input Commands
``loadlist "<playlist>" [replace|append]`` ``loadlist "<playlist>" [replace|append]``
Load the given playlist file (like ``--playlist``). Load the given playlist file (like ``--playlist``).
``playlist_clear`` ``playlist-clear``
Clear the playlist, except the currently played file. Clear the playlist, except the currently played file.
``playlist_remove current|<index>`` ``playlist-remove current|<index>``
Remove the playlist entry at the given index. Index values start counting Remove the playlist entry at the given index. Index values start counting
with 0. The special value ``current`` removes the current entry. Note that with 0. The special value ``current`` removes the current entry. Note that
removing the current entry also stops playback and starts playing the next removing the current entry also stops playback and starts playing the next
entry. entry.
``playlist_move <index1> <index2>`` ``playlist-move <index1> <index2>``
Move the playlist entry at index1, so that it takes the place of the Move the playlist entry at index1, so that it takes the place of the
entry index2. (Paradoxically, the moved playlist entry will not have entry index2. (Paradoxically, the moved playlist entry will not have
the index value index2 after moving if index1 was lower than index2, the index value index2 after moving if index1 was lower than index2,
because index2 refers to the target entry, not the index the entry because index2 refers to the target entry, not the index the entry
will have after moving.) will have after moving.)
``playlist_shuffle`` ``playlist-shuffle``
Shuffle the playlist. This is similar to what is done on start if the Shuffle the playlist. This is similar to what is done on start if the
``--shuffle`` option is used. ``--shuffle`` option is used.
@ -277,12 +277,12 @@ List of Input Commands
``quit [<code>]`` ``quit [<code>]``
Exit the player. If an argument is given, it's used as process exit code. Exit the player. If an argument is given, it's used as process exit code.
``quit_watch_later [<code>]`` ``quit-watch-later [<code>]``
Exit player, and store current playback position. Playing that file later Exit player, and store current playback position. Playing that file later
will seek to the previous position on start. The (optional) argument is will seek to the previous position on start. The (optional) argument is
exactly as in the ``quit`` command. exactly as in the ``quit`` command.
``sub_add "<file>" [<flags> [<title> [<lang>]]]`` ``sub-add "<file>" [<flags> [<title> [<lang>]]]``
Load the given subtitle file. It is selected as current subtitle after Load the given subtitle file. It is selected as current subtitle after
loading. loading.
@ -309,27 +309,27 @@ List of Input Commands
The ``lang`` argument sets the track language, and can also influence The ``lang`` argument sets the track language, and can also influence
stream selection with ``flags`` set to ``auto``. stream selection with ``flags`` set to ``auto``.
``sub_remove [<id>]`` ``sub-remove [<id>]``
Remove the given subtitle track. If the ``id`` argument is missing, remove Remove the given subtitle track. If the ``id`` argument is missing, remove
the current track. (Works on external subtitle files only.) the current track. (Works on external subtitle files only.)
``sub_reload [<id>]`` ``sub-reload [<id>]``
Reload the given subtitle tracks. If the ``id`` argument is missing, reload Reload the given subtitle tracks. If the ``id`` argument is missing, reload
the current track. (Works on external subtitle files only.) the current track. (Works on external subtitle files only.)
This works by unloading and re-adding the subtitle track. This works by unloading and re-adding the subtitle track.
``sub_step <skip>`` ``sub-step <skip>``
Change subtitle timing such, that the subtitle event after the next Change subtitle timing such, that the subtitle event after the next
``<skip>`` subtitle events is displayed. ``<skip>`` can be negative to step ``<skip>`` subtitle events is displayed. ``<skip>`` can be negative to step
backwards. backwards.
``sub_seek <skip>`` ``sub-seek <skip>``
Seek to the next (skip set to 1) or the previous (skip set to -1) subtitle. Seek to the next (skip set to 1) or the previous (skip set to -1) subtitle.
This is similar to ``sub_step``, except that it seeks video and audio This is similar to ``sub-step``, except that it seeks video and audio
instead of adjusting the subtitle delay. instead of adjusting the subtitle delay.
Like with ``sub_step``, this works with external text subtitles only. For Like with ``sub-step``, this works with external text subtitles only. For
embedded text subtitles (like with Matroska), this works only with subtitle embedded text subtitles (like with Matroska), this works only with subtitle
events that have already been displayed. events that have already been displayed.
@ -337,11 +337,11 @@ List of Input Commands
Toggle OSD level. If ``<level>`` is specified, set the OSD mode Toggle OSD level. If ``<level>`` is specified, set the OSD mode
(see ``--osd-level`` for valid values). (see ``--osd-level`` for valid values).
``print_text "<string>"`` ``print-text "<string>"``
Print text to stdout. The string can contain properties (see Print text to stdout. The string can contain properties (see
`Property Expansion`_). `Property Expansion`_).
``show_text "<string>" [<duration>|- [<level>]]`` ``show-text "<string>" [<duration>|- [<level>]]``
Show text on the OSD. The string can contain properties, which are expanded Show text on the OSD. The string can contain properties, which are expanded
as described in `Property Expansion`_. This can be used to show playback as described in `Property Expansion`_. This can be used to show playback
time, filename, and so on. time, filename, and so on.
@ -353,7 +353,7 @@ List of Input Commands
<level> <level>
The minimum OSD level to show the text at (see ``--osd-level``). The minimum OSD level to show the text at (see ``--osd-level``).
``show_progress`` ``show-progress``
Show the progress bar, the elapsed time and the total duration of the file Show the progress bar, the elapsed time and the total duration of the file
on the OSD. on the OSD.
@ -369,8 +369,8 @@ List of Input Commands
Note that while the menu is active, the input section ``discnav-menu`` will Note that while the menu is active, the input section ``discnav-menu`` will
be enabled, so different key bindings can be mapped for menu mode. be enabled, so different key bindings can be mapped for menu mode.
``write_watch_later_config`` ``write-watch-later-config``
Write the resume config file that the ``quit_watch_later`` command writes, Write the resume config file that the ``quit-watch-later`` command writes,
but continue playback normally. but continue playback normally.
``stop`` ``stop``
@ -395,16 +395,16 @@ List of Input Commands
<double> <double>
The mouse event represents double-click. The mouse event represents double-click.
``audio_add "<file>" [<flags> [<title> [<lang>]]]`` ``audio-add "<file>" [<flags> [<title> [<lang>]]]``
Load the given audio file. See ``sub_add`` command. Load the given audio file. See ``sub-add`` command.
``audio_remove [<id>]`` ``audio-remove [<id>]``
Remove the given audio track. See ``sub_remove`` command. Remove the given audio track. See ``sub-remove`` command.
``audio_reload [<id>]`` ``audio-reload [<id>]``
Reload the given audio tracks. See ``sub_reload`` command. Reload the given audio tracks. See ``sub-reload`` command.
``rescan_external_files [<mode>]`` ``rescan-external-files [<mode>]``
Rescan external files according to the current ``--sub-auto`` and Rescan external files according to the current ``--sub-auto`` and
``--audio-file-auto`` settings. This can be used to auto-load external ``--audio-file-auto`` settings. This can be used to auto-load external
files *after* the file was loaded. files *after* the file was loaded.
@ -461,7 +461,7 @@ Input Commands that are Possibly Subject to Change
The ``vf`` command shows the list of requested filters on the OSD after The ``vf`` command shows the list of requested filters on the OSD after
changing the filter chain. This is roughly equivalent to changing the filter chain. This is roughly equivalent to
``show_text ${vf}``. Note that auto-inserted filters for format conversion ``show-text ${vf}``. Note that auto-inserted filters for format conversion
are not shown on the list, only what was requested by the user. are not shown on the list, only what was requested by the user.
Normally, the commands will check whether the video chain is recreated Normally, the commands will check whether the video chain is recreated
@ -762,7 +762,7 @@ Properties
Properties are used to set mpv options during runtime, or to query arbitrary Properties are used to set mpv options during runtime, or to query arbitrary
information. They can be manipulated with the ``set``/``add``/``cycle`` information. They can be manipulated with the ``set``/``add``/``cycle``
commands, and retrieved with ``show_text``, or anything else that uses property commands, and retrieved with ``show-text``, or anything else that uses property
expansion. (See `Property Expansion`_.) expansion. (See `Property Expansion`_.)
The property name is annotated with RW to indicate whether the property is The property name is annotated with RW to indicate whether the property is
@ -1667,7 +1667,7 @@ Property list
``osd-sym-cc`` ``osd-sym-cc``
Inserts the current OSD symbol as opaque OSD control code (cc). This makes Inserts the current OSD symbol as opaque OSD control code (cc). This makes
sense only with the ``show_text`` command or options which set OSD messages. sense only with the ``show-text`` command or options which set OSD messages.
The control code is implementation specific and is useless for anything else. The control code is implementation specific and is useless for anything else.
``osd-ass-cc`` ``osd-ass-cc``
@ -1675,13 +1675,13 @@ Property list
``${osd-ass-cc/1}`` enables it again. By default, ASS sequences are ``${osd-ass-cc/1}`` enables it again. By default, ASS sequences are
escaped to avoid accidental formatting, and this property can disable escaped to avoid accidental formatting, and this property can disable
this behavior. Note that the properties return an opaque OSD control this behavior. Note that the properties return an opaque OSD control
code, which only makes sense for the ``show_text`` command or options code, which only makes sense for the ``show-text`` command or options
which set OSD messages. which set OSD messages.
.. admonition:: Example .. admonition:: Example
- ``--osd-status-msg='This is ${osd-ass-cc/0}{\\b1}bold text'`` - ``--osd-status-msg='This is ${osd-ass-cc/0}{\\b1}bold text'``
- ``show_text "This is ${osd-ass-cc/0}{\b1}bold text"`` - ``show-text "This is ${osd-ass-cc/0}{\b1}bold text"``
Any ASS override tags as understood by libass can be used. Any ASS override tags as understood by libass can be used.
@ -1860,7 +1860,7 @@ command is an exception and not a general rule.)
.. admonition:: Example for input.conf .. admonition:: Example for input.conf
``i show_text "Filename: ${filename}"`` ``i show-text "Filename: ${filename}"``
shows the filename of the current file when pressing the ``i`` key shows the filename of the current file when pressing the ``i`` key
Within ``input.conf``, property expansion can be inhibited by putting the Within ``input.conf``, property expansion can be inhibited by putting the

View File

@ -12,7 +12,7 @@
# Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore'). # Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore').
# #
# Strings need to be quoted and escaped: # Strings need to be quoted and escaped:
# KEY show_text "This is a single backslash: \\ and a quote: \" !" # KEY show-text "This is a single backslash: \\ and a quote: \" !"
# #
# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with # You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with
# the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal). # the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal).
@ -56,8 +56,8 @@
#Shift+UP no-osd seek 5 exact #Shift+UP no-osd seek 5 exact
#Shift+DOWN no-osd seek -5 exact #Shift+DOWN no-osd seek -5 exact
# Skip to previous/next subtitle (subject to some restrictions; see manpage) # Skip to previous/next subtitle (subject to some restrictions; see manpage)
#Ctrl+LEFT no-osd sub_seek -1 #Ctrl+LEFT no-osd sub-seek -1
#Ctrl+RIGHT no-osd sub_seek 1 #Ctrl+RIGHT no-osd sub-seek 1
#PGUP add chapter 1 # skip to next chapter #PGUP add chapter 1 # skip to next chapter
#PGDWN add chapter -1 # skip to previous chapter #PGDWN add chapter -1 # skip to previous chapter
#Shift+PGUP seek 600 #Shift+PGUP seek 600
@ -68,21 +68,21 @@
#} multiply speed 2.0 #} multiply speed 2.0
#BS set speed 1.0 # reset speed to normal #BS set speed 1.0 # reset speed to normal
#q quit #q quit
#Q quit_watch_later #Q quit-watch-later
#q {encode} quit #q {encode} quit
#ESC set fullscreen no #ESC set fullscreen no
#ESC {encode} quit #ESC {encode} quit
#p cycle pause # toggle pause/playback mode #p cycle pause # toggle pause/playback mode
#. frame_step # advance one frame and pause #. frame-step # advance one frame and pause
#, frame_back_step # go back by one frame and pause #, frame-back-step # go back by one frame and pause
#SPACE cycle pause #SPACE cycle pause
#> playlist_next # skip to next file #> playlist-next # skip to next file
#ENTER playlist_next # skip to next file #ENTER playlist-next # skip to next file
#< playlist_prev # skip to previous file #< playlist-prev # skip to previous file
#O osd # cycle through OSD mode #O osd # cycle through OSD mode
#o show_progress #o show-progress
#P show_progress #P show-progress
#I show_text "${filename}" # display filename in osd #I show-text "${filename}" # display filename in osd
#z add sub-delay -0.1 # subtract 100 ms delay from subs #z add sub-delay -0.1 # subtract 100 ms delay from subs
#x add sub-delay +0.1 # add #x add sub-delay +0.1 # add
#ctrl++ add audio-delay 0.100 # this changes audio/video sync #ctrl++ add audio-delay 0.100 # this changes audio/video sync
@ -110,7 +110,7 @@
#V cycle ass-vsfilter-aspect-compat #V cycle ass-vsfilter-aspect-compat
# switch between applying no style overrides to SSA/ASS subtitles, and # switch between applying no style overrides to SSA/ASS subtitles, and
# overriding them almost completely with the normal subtitle style # overriding them almost completely with the normal subtitle style
#u cycle_values ass-style-override "force" "no" #u cycle-values ass-style-override "force" "no"
#j cycle sub # cycle through subtitles #j cycle sub # cycle through subtitles
#J cycle sub down # ...backwards #J cycle sub down # ...backwards
#SHARP cycle audio # switch audio streams #SHARP cycle audio # switch audio streams
@ -124,7 +124,7 @@
#w add panscan -0.1 # zoom out with -panscan 0 -fs #w add panscan -0.1 # zoom out with -panscan 0 -fs
#e add panscan +0.1 # in #e add panscan +0.1 # in
# cycle video aspect ratios; "-1" is the container aspect # cycle video aspect ratios; "-1" is the container aspect
#A cycle_values video-aspect "16:9" "4:3" "2.35:1" "-1" #A cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
#POWER quit #POWER quit
#PLAY cycle pause #PLAY cycle pause
#PAUSE cycle pause #PAUSE cycle pause
@ -132,8 +132,8 @@
#STOP quit #STOP quit
#FORWARD seek 60 #FORWARD seek 60
#REWIND seek -60 #REWIND seek -60
#NEXT playlist_next #NEXT playlist-next
#PREV playlist_prev #PREV playlist-prev
#VOLUME_UP add volume 2 #VOLUME_UP add volume 2
#VOLUME_DOWN add volume -2 #VOLUME_DOWN add volume -2
#MUTE cycle mute #MUTE cycle mute
@ -141,7 +141,7 @@
#CLOSE_WIN {encode} quit #CLOSE_WIN {encode} quit
#E cycle edition # next edition #E cycle edition # next edition
#l ab_loop # Set/clear A-B loop points #l ab_loop # Set/clear A-B loop points
#L cycle_values loop "inf" "no" # toggle infinite looping #L cycle-values loop "inf" "no" # toggle infinite looping
#ctrl+c quit #ctrl+c quit
# Apple Remote section # Apple Remote section
@ -153,7 +153,7 @@
#AR_NEXT_HOLD seek 120 #AR_NEXT_HOLD seek 120
#AR_PREV seek -10 #AR_PREV seek -10
#AR_PREV_HOLD seek -120 #AR_PREV_HOLD seek -120
#AR_MENU show_progress #AR_MENU show-progress
#AR_MENU_HOLD cycle mute #AR_MENU_HOLD cycle mute
#AR_VUP add volume 2 #AR_VUP add volume 2
#AR_VUP_HOLD add chapter 1 #AR_VUP_HOLD add chapter 1
@ -191,9 +191,9 @@
# ? add sub-scale +0.1 # increase subtitle font size # ? add sub-scale +0.1 # increase subtitle font size
# ? add sub-scale -0.1 # decrease subtitle font size # ? add sub-scale -0.1 # decrease subtitle font size
# ? sub_step -1 # immediately display next subtitle # ? sub-step -1 # immediately display next subtitle
# ? sub_step +1 # previous # ? sub-step +1 # previous
# ? cycle_values window-scale 0.5 2 1 # switch between 1/2, 2x, unresized window size # ? cycle-values window-scale 0.5 2 1 # switch between 1/2, 2x, unresized window size
# ? cycle colormatrix # ? cycle colormatrix
# ? add audio-delay 0.100 # this changes audio/video sync # ? add audio-delay 0.100 # this changes audio/video sync
# ? add audio-delay -0.100 # ? add audio-delay -0.100

View File

@ -73,38 +73,38 @@ const struct mp_cmd_def mp_cmds[] = {
}, },
.allow_auto_repeat = true, .allow_auto_repeat = true,
}, },
{ MP_CMD_REVERT_SEEK, "revert_seek", { { MP_CMD_REVERT_SEEK, "revert-seek", {
OARG_FLAGS(0, ({"mark", 1})), OARG_FLAGS(0, ({"mark", 1})),
}}, }},
{ MP_CMD_QUIT, "quit", { OARG_INT(0) } }, { MP_CMD_QUIT, "quit", { OARG_INT(0) } },
{ MP_CMD_QUIT_WATCH_LATER, "quit_watch_later", { OARG_INT(0) } }, { MP_CMD_QUIT_WATCH_LATER, "quit-watch-later", { OARG_INT(0) } },
{ MP_CMD_STOP, "stop", }, { MP_CMD_STOP, "stop", },
{ MP_CMD_FRAME_STEP, "frame_step", .allow_auto_repeat = true, { MP_CMD_FRAME_STEP, "frame-step", .allow_auto_repeat = true,
.on_updown = true }, .on_updown = true },
{ MP_CMD_FRAME_BACK_STEP, "frame_back_step", .allow_auto_repeat = true }, { MP_CMD_FRAME_BACK_STEP, "frame-back-step", .allow_auto_repeat = true },
{ MP_CMD_PLAYLIST_NEXT, "playlist_next", { { MP_CMD_PLAYLIST_NEXT, "playlist-next", {
OARG_CHOICE(0, ({"weak", 0}, OARG_CHOICE(0, ({"weak", 0},
{"force", 1})), {"force", 1})),
}}, }},
{ MP_CMD_PLAYLIST_PREV, "playlist_prev", { { MP_CMD_PLAYLIST_PREV, "playlist-prev", {
OARG_CHOICE(0, ({"weak", 0}, OARG_CHOICE(0, ({"weak", 0},
{"force", 1})), {"force", 1})),
}}, }},
{ MP_CMD_PLAYLIST_SHUFFLE, "playlist_shuffle", }, { MP_CMD_PLAYLIST_SHUFFLE, "playlist-shuffle", },
{ MP_CMD_SUB_STEP, "sub_step", { ARG_INT }, .allow_auto_repeat = true }, { MP_CMD_SUB_STEP, "sub-step", { ARG_INT }, .allow_auto_repeat = true },
{ MP_CMD_SUB_SEEK, "sub_seek", { ARG_INT }, .allow_auto_repeat = true }, { MP_CMD_SUB_SEEK, "sub-seek", { ARG_INT }, .allow_auto_repeat = true },
{ MP_CMD_OSD, "osd", { OARG_INT(-1) } }, { MP_CMD_OSD, "osd", { OARG_INT(-1) } },
{ MP_CMD_PRINT_TEXT, "print_text", { ARG_STRING }, .allow_auto_repeat = true }, { MP_CMD_PRINT_TEXT, "print-text", { ARG_STRING }, .allow_auto_repeat = true },
{ MP_CMD_SHOW_TEXT, "show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) }, { MP_CMD_SHOW_TEXT, "show-text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) },
.allow_auto_repeat = true}, .allow_auto_repeat = true},
{ MP_CMD_SHOW_PROGRESS, "show_progress", .allow_auto_repeat = true}, { MP_CMD_SHOW_PROGRESS, "show-progress", .allow_auto_repeat = true},
{ MP_CMD_SUB_ADD, "sub_add", { ARG_STRING, { MP_CMD_SUB_ADD, "sub-add", { ARG_STRING,
OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})), OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
OARG_STRING(""), OARG_STRING("") } }, OARG_STRING(""), OARG_STRING("") } },
{ MP_CMD_SUB_REMOVE, "sub_remove", { OARG_INT(-1) } }, { MP_CMD_SUB_REMOVE, "sub-remove", { OARG_INT(-1) } },
{ MP_CMD_SUB_RELOAD, "sub_reload", { OARG_INT(-1) } }, { MP_CMD_SUB_RELOAD, "sub-reload", { OARG_INT(-1) } },
{ MP_CMD_TV_LAST_CHANNEL, "tv_last_channel", }, { MP_CMD_TV_LAST_CHANNEL, "tv-last-channel", },
{ MP_CMD_SCREENSHOT, "screenshot", { { MP_CMD_SCREENSHOT, "screenshot", {
OARG_FLAGS(4|2, ({"video", 4|0}, {"-", 4|0}, OARG_FLAGS(4|2, ({"video", 4|0}, {"-", 4|0},
@ -115,13 +115,13 @@ const struct mp_cmd_def mp_cmds[] = {
OARG_CHOICE(0, ({"unused", 0}, {"single", 0}, OARG_CHOICE(0, ({"unused", 0}, {"single", 0},
{"each-frame", 8})), {"each-frame", 8})),
}}, }},
{ MP_CMD_SCREENSHOT_TO_FILE, "screenshot_to_file", { { MP_CMD_SCREENSHOT_TO_FILE, "screenshot-to-file", {
ARG_STRING, ARG_STRING,
OARG_CHOICE(2, ({"video", 0}, OARG_CHOICE(2, ({"video", 0},
{"window", 1}, {"window", 1},
{"subtitles", 2})), {"subtitles", 2})),
}}, }},
{ MP_CMD_SCREENSHOT_RAW, "screenshot_raw", { { MP_CMD_SCREENSHOT_RAW, "screenshot-raw", {
OARG_CHOICE(2, ({"video", 0}, OARG_CHOICE(2, ({"video", 0},
{"window", 1}, {"window", 1},
{"subtitles", 2})), {"subtitles", 2})),
@ -138,15 +138,15 @@ const struct mp_cmd_def mp_cmds[] = {
OARG_CHOICE(0, ({"replace", 0}, OARG_CHOICE(0, ({"replace", 0},
{"append", 1})), {"append", 1})),
}}, }},
{ MP_CMD_PLAYLIST_CLEAR, "playlist_clear", }, { MP_CMD_PLAYLIST_CLEAR, "playlist-clear", },
{ MP_CMD_PLAYLIST_REMOVE, "playlist_remove", { { MP_CMD_PLAYLIST_REMOVE, "playlist-remove", {
ARG_CHOICE_OR_INT(0, INT_MAX, ({"current", -1})), ARG_CHOICE_OR_INT(0, INT_MAX, ({"current", -1})),
}}, }},
{ MP_CMD_PLAYLIST_MOVE, "playlist_move", { ARG_INT, ARG_INT } }, { MP_CMD_PLAYLIST_MOVE, "playlist-move", { ARG_INT, ARG_INT } },
{ MP_CMD_RUN, "run", { ARG_STRING, ARG_STRING }, .vararg = true }, { MP_CMD_RUN, "run", { ARG_STRING, ARG_STRING }, .vararg = true },
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } }, { MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } }, { MP_CMD_GET_PROPERTY, "get-property", { ARG_STRING } },
{ MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(0) }, { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(0) },
.allow_auto_repeat = true}, .allow_auto_repeat = true},
{ MP_CMD_CYCLE, "cycle", { { MP_CMD_CYCLE, "cycle", {
@ -158,45 +158,45 @@ const struct mp_cmd_def mp_cmds[] = {
{ MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE }, { MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE },
.allow_auto_repeat = true}, .allow_auto_repeat = true},
{ MP_CMD_CYCLE_VALUES, "cycle_values", { ARG_STRING, ARG_STRING, ARG_STRING }, { MP_CMD_CYCLE_VALUES, "cycle-values", { ARG_STRING, ARG_STRING, ARG_STRING },
.vararg = true}, .vararg = true},
{ MP_CMD_ENABLE_INPUT_SECTION, "enable_section", { { MP_CMD_ENABLE_INPUT_SECTION, "enable-section", {
ARG_STRING, ARG_STRING,
OARG_CHOICE(0, ({"default", 0}, OARG_CHOICE(0, ({"default", 0},
{"exclusive", 1})), {"exclusive", 1})),
}}, }},
{ MP_CMD_DISABLE_INPUT_SECTION, "disable_section", { ARG_STRING } }, { MP_CMD_DISABLE_INPUT_SECTION, "disable-section", { ARG_STRING } },
{ MP_CMD_DISCNAV, "discnav", { ARG_STRING } }, { MP_CMD_DISCNAV, "discnav", { ARG_STRING } },
{ MP_CMD_AB_LOOP, "ab_loop", }, { MP_CMD_AB_LOOP, "ab-loop", },
{ MP_CMD_DROP_BUFFERS, "drop_buffers", }, { MP_CMD_DROP_BUFFERS, "drop-buffers", },
{ MP_CMD_AF, "af", { ARG_STRING, ARG_STRING } }, { MP_CMD_AF, "af", { ARG_STRING, ARG_STRING } },
{ MP_CMD_AO_RELOAD, "ao_reload", }, { MP_CMD_AO_RELOAD, "ao-reload", },
{ MP_CMD_VF, "vf", { ARG_STRING, ARG_STRING } }, { MP_CMD_VF, "vf", { ARG_STRING, ARG_STRING } },
{ MP_CMD_VO_CMDLINE, "vo_cmdline", { ARG_STRING } }, { MP_CMD_VO_CMDLINE, "vo-cmdline", { ARG_STRING } },
{ MP_CMD_SCRIPT_BINDING, "script_binding", { ARG_STRING }, { MP_CMD_SCRIPT_BINDING, "script-binding", { ARG_STRING },
.allow_auto_repeat = true, .on_updown = true}, .allow_auto_repeat = true, .on_updown = true},
{ MP_CMD_SCRIPT_MESSAGE, "script_message", { ARG_STRING }, .vararg = true }, { MP_CMD_SCRIPT_MESSAGE, "script-message", { ARG_STRING }, .vararg = true },
{ MP_CMD_SCRIPT_MESSAGE_TO, "script_message_to", { ARG_STRING, ARG_STRING }, { MP_CMD_SCRIPT_MESSAGE_TO, "script-message-to", { ARG_STRING, ARG_STRING },
.vararg = true }, .vararg = true },
{ MP_CMD_OVERLAY_ADD, "overlay_add", { MP_CMD_OVERLAY_ADD, "overlay-add",
{ ARG_INT, ARG_INT, ARG_INT, ARG_STRING, ARG_INT, ARG_STRING, ARG_INT, { ARG_INT, ARG_INT, ARG_INT, ARG_STRING, ARG_INT, ARG_STRING, ARG_INT,
ARG_INT, ARG_INT }}, ARG_INT, ARG_INT }},
{ MP_CMD_OVERLAY_REMOVE, "overlay_remove", { ARG_INT } }, { MP_CMD_OVERLAY_REMOVE, "overlay-remove", { ARG_INT } },
{ MP_CMD_WRITE_WATCH_LATER_CONFIG, "write_watch_later_config", }, { MP_CMD_WRITE_WATCH_LATER_CONFIG, "write-watch-later-config", },
{ MP_CMD_HOOK_ADD, "hook_add", { ARG_STRING, ARG_INT, ARG_INT } }, { MP_CMD_HOOK_ADD, "hook-add", { ARG_STRING, ARG_INT, ARG_INT } },
{ MP_CMD_HOOK_ACK, "hook_ack", { ARG_STRING } }, { MP_CMD_HOOK_ACK, "hook-ack", { ARG_STRING } },
{ MP_CMD_MOUSE, "mouse", { { MP_CMD_MOUSE, "mouse", {
ARG_INT, ARG_INT, // coordinate (x, y) ARG_INT, ARG_INT, // coordinate (x, y)
@ -205,13 +205,13 @@ const struct mp_cmd_def mp_cmds[] = {
{"double", 1})), {"double", 1})),
}}, }},
{ MP_CMD_AUDIO_ADD, "audio_add", { ARG_STRING, { MP_CMD_AUDIO_ADD, "audio-add", { ARG_STRING,
OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})), OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
OARG_STRING(""), OARG_STRING("") } }, OARG_STRING(""), OARG_STRING("") } },
{ MP_CMD_AUDIO_REMOVE, "audio_remove", { OARG_INT(-1) } }, { MP_CMD_AUDIO_REMOVE, "audio-remove", { OARG_INT(-1) } },
{ MP_CMD_AUDIO_RELOAD, "audio_reload", { OARG_INT(-1) } }, { MP_CMD_AUDIO_RELOAD, "audio-reload", { OARG_INT(-1) } },
{ MP_CMD_RESCAN_EXTERNAL_FILES, "rescan_external_files", { { MP_CMD_RESCAN_EXTERNAL_FILES, "rescan-external-files", {
OARG_CHOICE(1, ({"keep-selection", 0}, OARG_CHOICE(1, ({"keep-selection", 0},
{"reselect", 1})), {"reselect", 1})),
}}, }},
@ -264,20 +264,20 @@ static const struct legacy_cmd legacy_cmds[] = {
{"set_property", "no-osd set"}, {"set_property", "no-osd set"},
{"set_property_osd", "set"}, {"set_property_osd", "set"},
{"speed_set", "set speed"}, {"speed_set", "set speed"},
{"osd_show_text", "show_text"}, {"osd_show_text", "show-text"},
{"osd_show_property_text", "show_text"}, {"osd_show_property_text", "show-text"},
{"osd_show_progression", "show_progress"}, {"osd_show_progression", "show-progress"},
{"show_chapters_osd", "show_text ${chapter-list}"}, {"show_chapters_osd", "show-text ${chapter-list}"},
{"show_chapters", "show_text ${chapter-list}"}, {"show_chapters", "show-text ${chapter-list}"},
{"show_tracks_osd", "show_text ${track-list}"}, {"show_tracks_osd", "show-text ${track-list}"},
{"show_tracks", "show_text ${track-list}"}, {"show_tracks", "show-text ${track-list}"},
{"show_playlist", "show_text ${playlist}"}, {"show_playlist", "show-text ${playlist}"},
{"speed_mult", "multiply speed"}, {"speed_mult", "multiply speed"},
{"dvdnav", "discnav"}, {"dvdnav", "discnav"},
// Approximate (can fail if user added additional whitespace) // Approximate (can fail if user added additional whitespace)
{"pt_step 1", "playlist_next"}, {"pt_step 1", "playlist-next"},
{"pt_step -1", "playlist_prev"}, {"pt_step -1", "playlist-prev"},
// Switch_ratio without argument resets aspect ratio // Switch_ratio without argument resets aspect ratio
{"switch_ratio ", "set aspect "}, {"switch_ratio ", "set aspect "},
{"switch_ratio", "set aspect 0"}, {"switch_ratio", "set aspect 0"},

View File

@ -69,8 +69,16 @@ static bool find_cmd(struct mp_log *log, struct mp_cmd *cmd, bstr name)
mp_err(log, "Command name missing.\n"); mp_err(log, "Command name missing.\n");
return false; return false;
} }
char nname[80];
snprintf(nname, sizeof(nname), "%.*s", BSTR_P(name));
for (int n = 0; nname[n]; n++) {
if (nname[n] == '_')
nname[n] = '-';
}
for (int n = 0; mp_cmds[n].name; n++) { for (int n = 0; mp_cmds[n].name; n++) {
if (bstr_equals0(name, mp_cmds[n].name)) { if (strcmp(nname, mp_cmds[n].name) == 0) {
cmd->def = &mp_cmds[n]; cmd->def = &mp_cmds[n];
cmd->name = (char *)cmd->def->name; cmd->name = (char *)cmd->def->name;
cmd->id = cmd->def->id; cmd->id = cmd->def->id;

View File

@ -319,7 +319,7 @@ static mp_cmd_t *handle_test(struct input_ctx *ictx, int code)
msg = talloc_asprintf_append(msg, "(nothing)"); msg = talloc_asprintf_append(msg, "(nothing)");
MP_INFO(ictx, "%s\n", msg); MP_INFO(ictx, "%s\n", msg);
const char *args[] = {"show_text", msg, NULL}; const char *args[] = {"show-text", msg, NULL};
mp_cmd_t *res = mp_input_parse_cmd_strv(ictx->log, args); mp_cmd_t *res = mp_input_parse_cmd_strv(ictx->log, args);
talloc_free(msg); talloc_free(msg);
return res; return res;

View File

@ -89,7 +89,7 @@ function mp.set_key_bindings(list, section, flags)
cb() cb()
end end
end end
cfg = cfg .. key .. " script_binding " .. cfg = cfg .. key .. " script-binding " ..
mp.script_name .. "/" .. mangle .. "\n" mp.script_name .. "/" .. mangle .. "\n"
else else
cfg = cfg .. key .. " " .. cb .. "\n" cfg = cfg .. key .. " " .. cb .. "\n"
@ -187,7 +187,7 @@ local function add_binding(attrs, key, name, fn, rp)
end end
msg_cb = fn msg_cb = fn
end end
attrs.bind = bind .. " script_binding " .. mp.script_name .. "/" .. name attrs.bind = bind .. " script-binding " .. mp.script_name .. "/" .. name
attrs.name = name attrs.name = name
key_bindings[name] = attrs key_bindings[name] = attrs
update_key_bindings() update_key_bindings()
@ -464,7 +464,7 @@ function mp.osd_message(text, duration)
else else
duration = tostring(math.floor(duration * 1000)) duration = tostring(math.floor(duration * 1000))
end end
mp.commandv("show_text", text, duration) mp.commandv("show-text", text, duration)
end end
local hook_table = {} local hook_table = {}
@ -475,7 +475,7 @@ local function hook_run(id, cont)
if fn then if fn then
fn() fn()
end end
mp.commandv("hook_ack", cont) mp.commandv("hook-ack", cont)
end end
function mp.add_hook(name, pri, cb) function mp.add_hook(name, pri, cb)
@ -485,7 +485,7 @@ function mp.add_hook(name, pri, cb)
end end
local id = #hook_table + 1 local id = #hook_table + 1
hook_table[id] = cb hook_table[id] = cb
mp.commandv("hook_add", name, id, pri) mp.commandv("hook-add", name, id, pri)
end end
local mp_utils = package.loaded["mp.utils"] local mp_utils = package.loaded["mp.utils"]