diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2017-03-26 20:29:10 +0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-03-26 19:58:51 +0200 |
commit | afbd657bb8e955accf8022c96e867973c1fb0a41 (patch) | |
tree | 5a69d480206715caf730263a384916fac5367582 | |
parent | 6573b73462e336da0daca845ba4df02782afc2b6 (diff) | |
download | mpv-afbd657bb8e955accf8022c96e867973c1fb0a41.tar.bz2 mpv-afbd657bb8e955accf8022c96e867973c1fb0a41.tar.xz |
command: add expand-text command to property-expand a string
-rw-r--r-- | DOCS/man/input.rst | 5 | ||||
-rw-r--r-- | input/cmd_list.c | 1 | ||||
-rw-r--r-- | input/cmd_list.h | 1 | ||||
-rw-r--r-- | player/command.c | 10 |
4 files changed, 17 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 984b8db7d6..7dded1cca1 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -357,6 +357,11 @@ List of Input Commands <level> The minimum OSD level to show the text at (see ``--osd-level``). +``expand-text "<string>"`` + Property-expand the argument and return the expanded string. This can be + used only through the client API or from a script using + ``mp.command_native``. (see `Property Expansion`_). + ``show-progress`` Show the progress bar, the elapsed time and the total duration of the file on the OSD. diff --git a/input/cmd_list.c b/input/cmd_list.c index 53cc375b3a..33cf40f233 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -97,6 +97,7 @@ const struct mp_cmd_def mp_cmds[] = { { 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_EXPAND_TEXT, "expand-text", { 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})), diff --git a/input/cmd_list.h b/input/cmd_list.h index 1c2330b589..404df462f4 100644 --- a/input/cmd_list.h +++ b/input/cmd_list.h @@ -67,6 +67,7 @@ enum mp_command_type { MP_CMD_SET, MP_CMD_PRINT_TEXT, MP_CMD_SHOW_TEXT, + MP_CMD_EXPAND_TEXT, MP_CMD_SHOW_PROGRESS, MP_CMD_ADD, MP_CMD_CYCLE, diff --git a/player/command.c b/player/command.c index 28d331c97e..1732b7b3cd 100644 --- a/player/command.c +++ b/player/command.c @@ -5136,6 +5136,16 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re break; } + case MP_CMD_EXPAND_TEXT: { + if (!res) + return -1; + *res = (mpv_node){ + .format = MPV_FORMAT_STRING, + .u.string = mp_property_expand_string(mpctx, cmd->args[0].v.s) + }; + break; + } + case MP_CMD_LOADFILE: { char *filename = cmd->args[0].v.s; int append = cmd->args[1].v.i; |