From 5c49fe97cba11bf6cd58b6e18577dbf8095a5222 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Mar 2015 17:21:02 +0100 Subject: input: use flag option type for some input commands This gets rid of the need for a second (or more) parameters; instead it can be all in one parameter. The (now) redundant parameter is still parsed for compatibility, though. The way the flags make each other conflict is a bit tricky: they have overlapping bits, and the option parser disallows setting already set bits. --- input/cmd_list.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'input/cmd_list.c') diff --git a/input/cmd_list.c b/input/cmd_list.c index 9eda21b5c9..2c502fd045 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -51,6 +51,7 @@ #define OARG_DOUBLE(def) OPT_DOUBLE(ARG(d), 0, OPTDEF_DOUBLE(def)) #define OARG_INT(def) OPT_INT(ARG(i), 0, OPTDEF_INT(def)) #define OARG_CHOICE(def, c) OPT_CHOICE(ARG(i), 0, c, OPTDEF_INT(def)) +#define OARG_FLAGS(def, c) OPT_FLAGS(ARG(i), 0, c, OPTDEF_INT(def)) #define OARG_STRING(def) OPT_STRING(ARG(s), 0, OPTDEF_STR(def)) #define OARG_CYCLEDIR(def) OPT_CYCLEDIR(ARG(d), 0, OPTDEF_DOUBLE(def)) @@ -60,17 +61,20 @@ const struct mp_cmd_def mp_cmds[] = { { MP_CMD_SEEK, "seek", { ARG_TIME, - OARG_CHOICE(0, ({"relative", 0},, {"-", 0}, - {"absolute-percent", 1}, - {"absolute", 2}, - OARG_CHOICE(0, ({"default-precise", 0}, - {"exact", 1}, - {"keyframes", -1})), + OARG_FLAGS(4|0, ({"relative", 4|0}, {"-", 4|0}, + {"absolute-percent", 4|1}, + {"absolute", 4|2}, + {"keyframes", 32|8}, + {"exact", 32|16})), + // backwards compatibility only + OARG_CHOICE(0, ({"unused", 0}, {"default-precise", 0}, + {"keyframes", 32|8}, + {"exact", 32|16})), }, .allow_auto_repeat = true, }, { MP_CMD_REVERT_SEEK, "revert_seek", { - OARG_CHOICE(0, ({"-", 0}, {"mark", 1})), + OARG_FLAGS(0, ({"mark", 1})), }}, { MP_CMD_QUIT, "quit", { OARG_INT(0) } }, { MP_CMD_QUIT_WATCH_LATER, "quit_watch_later", { OARG_INT(0) } }, @@ -79,7 +83,7 @@ const struct mp_cmd_def mp_cmds[] = { .on_updown = true }, { MP_CMD_FRAME_BACK_STEP, "frame_back_step", .allow_auto_repeat = true }, { MP_CMD_PLAYLIST_NEXT, "playlist_next", { - OARG_CHOICE(0, ({"weak", 0},, + OARG_CHOICE(0, ({"weak", 0}, {"force", 1})), }}, { MP_CMD_PLAYLIST_PREV, "playlist_prev", { @@ -102,11 +106,13 @@ const struct mp_cmd_def mp_cmds[] = { { MP_CMD_TV_LAST_CHANNEL, "tv_last_channel", }, { MP_CMD_SCREENSHOT, "screenshot", { - OARG_CHOICE(2, ({"video", 0}, - {"window", 1}, - {"subtitles", 2}, {"-", 2})), - OARG_CHOICE(0, ({"single", 0}, - {"each-frame", 1})), + OARG_FLAGS(4|2, ({"video", 4|0}, {"-", 4|0}, + {"window", 4|1}, + {"subtitles", 4|2}, + {"each-frame", 8})), + // backwards compatibility + OARG_CHOICE(0, ({"unused", 0}, {"single", 0}, + {"each-frame", 8})), }}, { MP_CMD_SCREENSHOT_TO_FILE, "screenshot_to_file", { ARG_STRING, -- cgit v1.2.3