diff options
author | wm4 <wm4@nowhere> | 2018-05-01 03:19:50 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-05-03 01:20:01 +0300 |
commit | 9fa0e6bf6af287814d1d2e75634544df8eafafef (patch) | |
tree | cdc3882dbbce61c2debf1f836eb18d3ee537f870 /input/cmd.c | |
parent | e5f884e68cc58913a4d8f6409c474f917e2fd975 (diff) | |
download | mpv-9fa0e6bf6af287814d1d2e75634544df8eafafef.tar.bz2 mpv-9fa0e6bf6af287814d1d2e75634544df8eafafef.tar.xz |
input: merge cmd_list.c with cmd.c
It doesn't really make sense to keep a separate cmd_list.c file, which
does _not_ contain a command list, but only a few minor helper
functions.
Diffstat (limited to 'input/cmd.c')
-rw-r--r-- | input/cmd.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/input/cmd.c b/input/cmd.c index 95f9f9ac50..0bab03d1b8 100644 --- a/input/cmd.c +++ b/input/cmd.c @@ -23,7 +23,6 @@ #include "options/m_option.h" #include "cmd.h" -#include "cmd_list.h" #include "input.h" #include "libmpv/client.h" @@ -444,6 +443,61 @@ void mp_cmd_dump(struct mp_log *log, int msgl, char *header, struct mp_cmd *cmd) mp_msg(log, msgl, "]\n"); } +// 0: no, 1: maybe, 2: sure +static int is_abort_cmd(struct mp_cmd *cmd) +{ + if (cmd->def->is_abort) + return 2; + if (cmd->def->is_soft_abort) + return 1; + if (cmd->def == &mp_cmd_list) { + int r = 0; + for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next) { + int x = is_abort_cmd(sub); + r = MPMAX(r, x); + } + return r; + } + return 0; +} + +bool mp_input_is_maybe_abort_cmd(struct mp_cmd *cmd) +{ + return is_abort_cmd(cmd) >= 1; +} + +bool mp_input_is_abort_cmd(struct mp_cmd *cmd) +{ + return is_abort_cmd(cmd) >= 2; +} + +bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd) +{ + return (cmd->def->allow_auto_repeat) || cmd->def == &mp_cmd_list || + (cmd->flags & MP_ALLOW_REPEAT); +} + +bool mp_input_is_scalable_cmd(struct mp_cmd *cmd) +{ + return cmd->def->scalable; +} + +void mp_print_cmd_list(struct mp_log *out) +{ + for (int i = 0; mp_cmds[i].name; i++) { + const struct mp_cmd_def *def = &mp_cmds[i]; + mp_info(out, "%-20.20s", def->name); + for (int j = 0; j < MP_CMD_DEF_MAX_ARGS && def->args[j].type; j++) { + const char *type = def->args[j].type->name; + if (def->args[j].defval) + mp_info(out, " [%s]", type); + else + mp_info(out, " %s", type); + } + mp_info(out, "\n"); + } +} + static int parse_cycle_dir(struct mp_log *log, const struct m_option *opt, struct bstr name, struct bstr param, void *dst) { |