summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-25 21:59:44 +0200
committerwm4 <wm4@nowhere>2015-05-25 21:59:44 +0200
commit289705daaf2986cedd0a1ae994aeda73c4b4249e (patch)
treeb1062e4a31fc7f8b734046e7cd9c54697193de7a /input
parent6bfbd4ebdcadd5c94e4e47ba9712bf550293274f (diff)
downloadmpv-289705daaf2986cedd0a1ae994aeda73c4b4249e.tar.bz2
mpv-289705daaf2986cedd0a1ae994aeda73c4b4249e.tar.xz
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.
Diffstat (limited to 'input')
-rw-r--r--input/cmd_list.c102
-rw-r--r--input/cmd_parse.c10
-rw-r--r--input/input.c2
3 files changed, 61 insertions, 53 deletions
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;