From 18930ba7ddf1af59b20bfafd4f9a87f140e16832 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 20 Dec 2013 18:01:04 +0100 Subject: input, lua: add functions to take pre-split input commands So you can pass a command as list of strings (each item is an argument), instead of having to worry about escaping and such. These functions also take an argument for the default command flags. In particular, this allows setting saner defaults for commands sent by program code. Expose this to Lua as mp.send_commandv command (suggestions for a better name welcome). The Lua version doesn't allow setting the default command flags, but it can still use command prefixes. The default flags are different from input.conf, and disable OSD and property expansion. --- input/input.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'input/input.h') diff --git a/input/input.h b/input/input.h index 3c6d8dccbd..77afeebac6 100644 --- a/input/input.h +++ b/input/input.h @@ -136,6 +136,7 @@ enum mp_input_section_flags { }; struct input_ctx; +struct mp_log; struct mp_cmd_arg { const struct m_option *type; @@ -228,6 +229,18 @@ struct mp_cmd *mp_input_get_cmd(struct input_ctx *ictx, int time, struct mp_cmd *mp_input_parse_cmd(struct input_ctx *ictx, bstr str, const char *location); +// Similar to mp_input_parse_cmd(), but takes a list of strings instead. +// Also, def_flags contains initial command flags (see mp_cmd_flags; the default +// as used by mp_input_parse_cmd is MP_ON_OSD_AUTO | MP_EXPAND_PROPERTIES). +// Keep in mind that these functions (naturally) don't take multiple commands, +// i.e. a ";" argument does not start a new command. +// The _strv version is limitted to MP_CMD_MAX_ARGS argv array items. +struct mp_cmd *mp_input_parse_cmd_strv(struct mp_log *log, int def_flags, + char **argv, const char *location); +struct mp_cmd *mp_input_parse_cmd_bstrv(struct mp_log *log, int def_flags, + int argc, bstr *argv, + const char *location); + // After getting a command from mp_input_get_cmd you need to free it using this // function void mp_cmd_free(struct mp_cmd *cmd); -- cgit v1.2.3