summaryrefslogtreecommitdiffstats
path: root/input/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'input/cmd.c')
-rw-r--r--input/cmd.c56
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)
{