From 32fe890cc1f9c90699fb9cd9eb5f42e597d9665a Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 11 Oct 2012 02:24:13 +0200 Subject: commands: add print_text input command to print text on the terminal In theory, this could take over the role of the get_property slave command, and is more general. --- DOCS/man/en/input.rst | 4 ++++ command.c | 9 +++++++++ input/input.c | 1 + input/input.h | 1 + 4 files changed, 15 insertions(+) diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 9a4e4dcc93..db16697bd7 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -160,6 +160,10 @@ osd [] Toggle OSD level. If is specified, set the OSD mode (see ``--osd-level`` for valid values). +print_text "" + Print text to stdout. The string can contain properties, which are expanded + like in ``--playing-msg``. + show_text "" [] [] Show text on the OSD. The string can contain properties, which are expanded like in ``--playing-msg``. This can be used to show playback time, filename, diff --git a/command.c b/command.c index 94625352af..4afc2104e4 100644 --- a/command.c +++ b/command.c @@ -1936,6 +1936,15 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) break; } + case MP_CMD_PRINT_TEXT: { + char *txt = mp_property_expand_string(mpctx, cmd->args[0].v.s); + if (txt) { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "%s\n", txt); + talloc_free(txt); + } + break; + } + case MP_CMD_SHOW_TEXT: { char *txt = mp_property_expand_string(mpctx, cmd->args[0].v.s); if (txt) { diff --git a/input/input.c b/input/input.c index 1a8f7e94e4..28a5af2112 100644 --- a/input/input.c +++ b/input/input.c @@ -132,6 +132,7 @@ static const mp_cmd_t mp_cmds[] = { }}, { MP_CMD_SUB_STEP, "sub_step", { ARG_INT } }, { MP_CMD_OSD, "osd", { OARG_INT(-1) } }, + { MP_CMD_PRINT_TEXT, "print_text", { ARG_STRING } }, { MP_CMD_SHOW_TEXT, "show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) } }, { MP_CMD_SHOW_PROGRESS, "show_progress", }, { MP_CMD_SUB_LOAD, "sub_load", { ARG_STRING } }, diff --git a/input/input.h b/input/input.h index a523020f43..988565cb40 100644 --- a/input/input.h +++ b/input/input.h @@ -51,6 +51,7 @@ enum mp_command_type { MP_CMD_KEYDOWN_EVENTS, MP_CMD_SET, MP_CMD_GET_PROPERTY, + MP_CMD_PRINT_TEXT, MP_CMD_SHOW_TEXT, MP_CMD_SHOW_PROGRESS, MP_CMD_RADIO_STEP_CHANNEL, -- cgit v1.2.3