From 289705daaf2986cedd0a1ae994aeda73c4b4249e Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 May 2015 21:59:44 +0200 Subject: 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. --- DOCS/man/input.rst | 80 ++++++++++++++++++------------------- etc/input.conf | 42 ++++++++++---------- input/cmd_list.c | 102 ++++++++++++++++++++++++------------------------ input/cmd_parse.c | 10 ++++- input/input.c | 2 +- player/lua/defaults.lua | 10 ++--- 6 files changed, 127 insertions(+), 119 deletions(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 75742d8062..8268345cc4 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -65,11 +65,11 @@ C-style escaping can be used. 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: -| 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.) @@ -114,25 +114,25 @@ List of Input Commands 3rd parameter (essentially using a space instead of ``+``). The 3rd 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 necessarily all of them). Calling this command once will jump to 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: 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 last time. 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. -``frame_back_step`` +``frame-back-step`` 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 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, e.g. ``video+each-frame``. -``screenshot_to_file "" [subtitles|video|window]`` +``screenshot-to-file "" [subtitles|video|window]`` 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 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 expansion as described in `Property Expansion`_. -``playlist_next [weak|force]`` +``playlist-next [weak|force]`` Go to the next entry on the playlist. weak (default) @@ -202,7 +202,7 @@ List of Input Commands force 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. weak (default) @@ -232,23 +232,23 @@ List of Input Commands ``loadlist "" [replace|append]`` Load the given playlist file (like ``--playlist``). -``playlist_clear`` +``playlist-clear`` Clear the playlist, except the currently played file. -``playlist_remove current|`` +``playlist-remove current|`` Remove the playlist entry at the given index. Index values start counting with 0. The special value ``current`` removes the current entry. Note that removing the current entry also stops playback and starts playing the next entry. -``playlist_move `` +``playlist-move `` Move the playlist entry at index1, so that it takes the place of the entry index2. (Paradoxically, the moved playlist entry will not have the index value index2 after moving if index1 was lower than index2, because index2 refers to the target entry, not the index the entry will have after moving.) -``playlist_shuffle`` +``playlist-shuffle`` Shuffle the playlist. This is similar to what is done on start if the ``--shuffle`` option is used. @@ -277,12 +277,12 @@ List of Input Commands ``quit []`` Exit the player. If an argument is given, it's used as process exit code. -``quit_watch_later []`` +``quit-watch-later []`` Exit player, and store current playback position. Playing that file later will seek to the previous position on start. The (optional) argument is exactly as in the ``quit`` command. -``sub_add "" [ [ [<lang>]]]`` +``sub-add "<file>" [<flags> [<title> [<lang>]]]`` Load the given subtitle file. It is selected as current subtitle after loading. @@ -309,27 +309,27 @@ List of Input Commands The ``lang`` argument sets the track language, and can also influence 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 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 the current track. (Works on external subtitle files only.) 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 ``<skip>`` subtitle events is displayed. ``<skip>`` can be negative to step backwards. -``sub_seek <skip>`` +``sub-seek <skip>`` 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. - 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 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 (see ``--osd-level`` for valid values). -``print_text "<string>"`` +``print-text "<string>"`` Print text to stdout. The string can contain properties (see `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 as described in `Property Expansion`_. This can be used to show playback time, filename, and so on. @@ -353,7 +353,7 @@ List of Input Commands <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 on the OSD. @@ -369,8 +369,8 @@ List of Input Commands 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. -``write_watch_later_config`` - Write the resume config file that the ``quit_watch_later`` command writes, +``write-watch-later-config`` + Write the resume config file that the ``quit-watch-later`` command writes, but continue playback normally. ``stop`` @@ -395,16 +395,16 @@ List of Input Commands <double> The mouse event represents double-click. -``audio_add "<file>" [<flags> [<title> [<lang>]]]`` - Load the given audio file. See ``sub_add`` command. +``audio-add "<file>" [<flags> [<title> [<lang>]]]`` + Load the given audio file. See ``sub-add`` command. -``audio_remove [<id>]`` - Remove the given audio track. See ``sub_remove`` command. +``audio-remove [<id>]`` + Remove the given audio track. See ``sub-remove`` command. -``audio_reload [<id>]`` - Reload the given audio tracks. See ``sub_reload`` command. +``audio-reload [<id>]`` + 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 ``--audio-file-auto`` settings. This can be used to auto-load external 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 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. 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 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`_.) The property name is annotated with RW to indicate whether the property is @@ -1667,7 +1667,7 @@ Property list ``osd-sym-cc`` 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. ``osd-ass-cc`` @@ -1675,13 +1675,13 @@ Property list ``${osd-ass-cc/1}`` enables it again. By default, ASS sequences are escaped to avoid accidental formatting, and this property can disable 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. .. admonition:: Example - ``--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. @@ -1860,7 +1860,7 @@ command is an exception and not a general rule.) .. 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 Within ``input.conf``, property expansion can be inhibited by putting the diff --git a/etc/input.conf b/etc/input.conf index dc7ade1a5a..0972fbb752 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -12,7 +12,7 @@ # Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore'). # # 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 # 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+DOWN no-osd seek -5 exact # Skip to previous/next subtitle (subject to some restrictions; see manpage) -#Ctrl+LEFT no-osd sub_seek -1 -#Ctrl+RIGHT no-osd sub_seek 1 +#Ctrl+LEFT no-osd sub-seek -1 +#Ctrl+RIGHT no-osd sub-seek 1 #PGUP add chapter 1 # skip to next chapter #PGDWN add chapter -1 # skip to previous chapter #Shift+PGUP seek 600 @@ -68,21 +68,21 @@ #} multiply speed 2.0 #BS set speed 1.0 # reset speed to normal #q quit -#Q quit_watch_later +#Q quit-watch-later #q {encode} quit #ESC set fullscreen no #ESC {encode} quit #p cycle pause # toggle pause/playback mode -#. frame_step # advance one frame and pause -#, frame_back_step # go back by one frame and pause +#. frame-step # advance one frame and pause +#, frame-back-step # go back by one frame and pause #SPACE cycle pause -#> playlist_next # skip to next file -#ENTER playlist_next # skip to next file -#< playlist_prev # skip to previous file +#> playlist-next # skip to next file +#ENTER playlist-next # skip to next file +#< playlist-prev # skip to previous file #O osd # cycle through OSD mode -#o show_progress -#P show_progress -#I show_text "${filename}" # display filename in osd +#o show-progress +#P show-progress +#I show-text "${filename}" # display filename in osd #z add sub-delay -0.1 # subtract 100 ms delay from subs #x add sub-delay +0.1 # add #ctrl++ add audio-delay 0.100 # this changes audio/video sync @@ -110,7 +110,7 @@ #V cycle ass-vsfilter-aspect-compat # switch between applying no style overrides to SSA/ASS subtitles, and # 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 down # ...backwards #SHARP cycle audio # switch audio streams @@ -124,7 +124,7 @@ #w add panscan -0.1 # zoom out with -panscan 0 -fs #e add panscan +0.1 # in # 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 #PLAY cycle pause #PAUSE cycle pause @@ -132,8 +132,8 @@ #STOP quit #FORWARD seek 60 #REWIND seek -60 -#NEXT playlist_next -#PREV playlist_prev +#NEXT playlist-next +#PREV playlist-prev #VOLUME_UP add volume 2 #VOLUME_DOWN add volume -2 #MUTE cycle mute @@ -141,7 +141,7 @@ #CLOSE_WIN {encode} quit #E cycle edition # next edition #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 # Apple Remote section @@ -153,7 +153,7 @@ #AR_NEXT_HOLD seek 120 #AR_PREV seek -10 #AR_PREV_HOLD seek -120 -#AR_MENU show_progress +#AR_MENU show-progress #AR_MENU_HOLD cycle mute #AR_VUP add volume 2 #AR_VUP_HOLD add chapter 1 @@ -191,9 +191,9 @@ # ? add sub-scale +0.1 # increase subtitle font size # ? add sub-scale -0.1 # decrease subtitle font size -# ? sub_step -1 # immediately display next subtitle -# ? sub_step +1 # previous -# ? cycle_values window-scale 0.5 2 1 # switch between 1/2, 2x, unresized window size +# ? sub-step -1 # immediately display next subtitle +# ? sub-step +1 # previous +# ? cycle-values window-scale 0.5 2 1 # switch between 1/2, 2x, unresized window size # ? cycle colormatrix # ? add audio-delay 0.100 # this changes audio/video sync # ? add audio-delay -0.100 diff --git a/input/cmd_list.c b/input/cmd_list.c index d7dda48ad4..5f69878fb7 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -73,38 +73,38 @@ const struct mp_cmd_def mp_cmds[] = { }, .allow_auto_repeat = true, }, - { MP_CMD_REVERT_SEEK, "revert_seek", { + { MP_CMD_REVERT_SEEK, "revert-seek", { OARG_FLAGS(0, ({"mark", 1})), }}, { 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_FRAME_STEP, "frame_step", .allow_auto_repeat = true, + { MP_CMD_FRAME_STEP, "frame-step", .allow_auto_repeat = true, .on_updown = true }, - { MP_CMD_FRAME_BACK_STEP, "frame_back_step", .allow_auto_repeat = true }, - { MP_CMD_PLAYLIST_NEXT, "playlist_next", { + { MP_CMD_FRAME_BACK_STEP, "frame-back-step", .allow_auto_repeat = true }, + { MP_CMD_PLAYLIST_NEXT, "playlist-next", { OARG_CHOICE(0, ({"weak", 0}, {"force", 1})), }}, - { MP_CMD_PLAYLIST_PREV, "playlist_prev", { + { MP_CMD_PLAYLIST_PREV, "playlist-prev", { OARG_CHOICE(0, ({"weak", 0}, {"force", 1})), }}, - { MP_CMD_PLAYLIST_SHUFFLE, "playlist_shuffle", }, - { 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_PLAYLIST_SHUFFLE, "playlist-shuffle", }, + { 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_OSD, "osd", { OARG_INT(-1) } }, - { 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_PRINT_TEXT, "print-text", { ARG_STRING }, .allow_auto_repeat = true }, + { MP_CMD_SHOW_TEXT, "show-text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) }, .allow_auto_repeat = true}, - { MP_CMD_SHOW_PROGRESS, "show_progress", .allow_auto_repeat = true}, - { MP_CMD_SUB_ADD, "sub_add", { ARG_STRING, + { MP_CMD_SHOW_PROGRESS, "show-progress", .allow_auto_repeat = true}, + { MP_CMD_SUB_ADD, "sub-add", { ARG_STRING, OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})), OARG_STRING(""), OARG_STRING("") } }, - { MP_CMD_SUB_REMOVE, "sub_remove", { OARG_INT(-1) } }, - { MP_CMD_SUB_RELOAD, "sub_reload", { OARG_INT(-1) } }, + { MP_CMD_SUB_REMOVE, "sub-remove", { 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", { 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}, {"each-frame", 8})), }}, - { MP_CMD_SCREENSHOT_TO_FILE, "screenshot_to_file", { + { MP_CMD_SCREENSHOT_TO_FILE, "screenshot-to-file", { ARG_STRING, OARG_CHOICE(2, ({"video", 0}, {"window", 1}, {"subtitles", 2})), }}, - { MP_CMD_SCREENSHOT_RAW, "screenshot_raw", { + { MP_CMD_SCREENSHOT_RAW, "screenshot-raw", { OARG_CHOICE(2, ({"video", 0}, {"window", 1}, {"subtitles", 2})), @@ -138,15 +138,15 @@ const struct mp_cmd_def mp_cmds[] = { OARG_CHOICE(0, ({"replace", 0}, {"append", 1})), }}, - { MP_CMD_PLAYLIST_CLEAR, "playlist_clear", }, - { MP_CMD_PLAYLIST_REMOVE, "playlist_remove", { + { MP_CMD_PLAYLIST_CLEAR, "playlist-clear", }, + { MP_CMD_PLAYLIST_REMOVE, "playlist-remove", { 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_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) }, .allow_auto_repeat = true}, { MP_CMD_CYCLE, "cycle", { @@ -158,45 +158,45 @@ const struct mp_cmd_def mp_cmds[] = { { MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE }, .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}, - { MP_CMD_ENABLE_INPUT_SECTION, "enable_section", { + { MP_CMD_ENABLE_INPUT_SECTION, "enable-section", { ARG_STRING, OARG_CHOICE(0, ({"default", 0}, {"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_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_AO_RELOAD, "ao_reload", }, + { MP_CMD_AO_RELOAD, "ao-reload", }, { 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}, - { 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, "script-message", { ARG_STRING }, .vararg = true }, + { MP_CMD_SCRIPT_MESSAGE_TO, "script-message-to", { ARG_STRING, ARG_STRING }, .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 }}, - { 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_ACK, "hook_ack", { ARG_STRING } }, + { MP_CMD_HOOK_ADD, "hook-add", { ARG_STRING, ARG_INT, ARG_INT } }, + { MP_CMD_HOOK_ACK, "hook-ack", { ARG_STRING } }, { MP_CMD_MOUSE, "mouse", { ARG_INT, ARG_INT, // coordinate (x, y) @@ -205,13 +205,13 @@ const struct mp_cmd_def mp_cmds[] = { {"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_STRING(""), OARG_STRING("") } }, - { MP_CMD_AUDIO_REMOVE, "audio_remove", { OARG_INT(-1) } }, - { MP_CMD_AUDIO_RELOAD, "audio_reload", { OARG_INT(-1) } }, + { MP_CMD_AUDIO_REMOVE, "audio-remove", { 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}, {"reselect", 1})), }}, @@ -264,20 +264,20 @@ static const struct legacy_cmd legacy_cmds[] = { {"set_property", "no-osd set"}, {"set_property_osd", "set"}, {"speed_set", "set speed"}, - {"osd_show_text", "show_text"}, - {"osd_show_property_text", "show_text"}, - {"osd_show_progression", "show_progress"}, - {"show_chapters_osd", "show_text ${chapter-list}"}, - {"show_chapters", "show_text ${chapter-list}"}, - {"show_tracks_osd", "show_text ${track-list}"}, - {"show_tracks", "show_text ${track-list}"}, - {"show_playlist", "show_text ${playlist}"}, + {"osd_show_text", "show-text"}, + {"osd_show_property_text", "show-text"}, + {"osd_show_progression", "show-progress"}, + {"show_chapters_osd", "show-text ${chapter-list}"}, + {"show_chapters", "show-text ${chapter-list}"}, + {"show_tracks_osd", "show-text ${track-list}"}, + {"show_tracks", "show-text ${track-list}"}, + {"show_playlist", "show-text ${playlist}"}, {"speed_mult", "multiply speed"}, {"dvdnav", "discnav"}, // Approximate (can fail if user added additional whitespace) - {"pt_step 1", "playlist_next"}, - {"pt_step -1", "playlist_prev"}, + {"pt_step 1", "playlist-next"}, + {"pt_step -1", "playlist-prev"}, // Switch_ratio without argument resets aspect ratio {"switch_ratio ", "set aspect "}, {"switch_ratio", "set aspect 0"}, diff --git a/input/cmd_parse.c b/input/cmd_parse.c index f588bb7cf9..206bd4171f 100644 --- a/input/cmd_parse.c +++ b/input/cmd_parse.c @@ -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"); 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++) { - if (bstr_equals0(name, mp_cmds[n].name)) { + if (strcmp(nname, mp_cmds[n].name) == 0) { cmd->def = &mp_cmds[n]; cmd->name = (char *)cmd->def->name; cmd->id = cmd->def->id; diff --git a/input/input.c b/input/input.c index 1a6931a12a..29d5b7831e 100644 --- a/input/input.c +++ b/input/input.c @@ -319,7 +319,7 @@ static mp_cmd_t *handle_test(struct input_ctx *ictx, int code) msg = talloc_asprintf_append(msg, "(nothing)"); 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); talloc_free(msg); return res; diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index 265463a8f3..2ecb83fb77 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -89,7 +89,7 @@ function mp.set_key_bindings(list, section, flags) cb() end end - cfg = cfg .. key .. " script_binding " .. + cfg = cfg .. key .. " script-binding " .. mp.script_name .. "/" .. mangle .. "\n" else cfg = cfg .. key .. " " .. cb .. "\n" @@ -187,7 +187,7 @@ local function add_binding(attrs, key, name, fn, rp) end msg_cb = fn end - attrs.bind = bind .. " script_binding " .. mp.script_name .. "/" .. name + attrs.bind = bind .. " script-binding " .. mp.script_name .. "/" .. name attrs.name = name key_bindings[name] = attrs update_key_bindings() @@ -464,7 +464,7 @@ function mp.osd_message(text, duration) else duration = tostring(math.floor(duration * 1000)) end - mp.commandv("show_text", text, duration) + mp.commandv("show-text", text, duration) end local hook_table = {} @@ -475,7 +475,7 @@ local function hook_run(id, cont) if fn then fn() end - mp.commandv("hook_ack", cont) + mp.commandv("hook-ack", cont) end function mp.add_hook(name, pri, cb) @@ -485,7 +485,7 @@ function mp.add_hook(name, pri, cb) end local id = #hook_table + 1 hook_table[id] = cb - mp.commandv("hook_add", name, id, pri) + mp.commandv("hook-add", name, id, pri) end local mp_utils = package.loaded["mp.utils"] -- cgit v1.2.3