diff options
author | wm4 <wm4@nowhere> | 2019-07-07 18:00:19 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:05 +0200 |
commit | c43846f2cb51054a5c74f95a1bc167542b8437f6 (patch) | |
tree | d4ed72a0741b4e494dcf9e01ead61aa3d518c222 /player/command.c | |
parent | b55b9cb98cf76443a24c7f7deae5853a4151e86d (diff) | |
download | mpv-c43846f2cb51054a5c74f95a1bc167542b8437f6.tar.bz2 mpv-c43846f2cb51054a5c74f95a1bc167542b8437f6.tar.xz |
screenshot: move message showing to common code
The screenshot command has this weird behavior that it shows messages
both on terminal and OSD by default, but that a command prefix can be
used to disable the OSD message.
Move this mechanism to common code, and make this available to other
commands too (although as of this commit only the screenshot commands
use it).
This gets rid of the weird screenshot_ctx.osd field too, which was sort
of set on a command, and sometimes inconsistently restored after the
command.
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c index c4d492cdf9..2472aab5e9 100644 --- a/player/command.c +++ b/player/command.c @@ -4575,6 +4575,24 @@ void run_command(struct MPContext *mpctx, struct mp_cmd *cmd, } } +// When a command shows a message. status is the level (e.g. MSGL_INFO), and +// msg+vararg is as in printf (don't include a trailing "\n"). +void mp_cmd_msg(struct mp_cmd_ctx *cmd, int status, const char *msg, ...) +{ + va_list ap; + char *s; + + va_start(ap, msg); + s = talloc_vasprintf(NULL, msg, ap); + va_end(ap); + + MP_MSG(cmd->mpctx, status, "%s\n", s); + if (cmd->msg_osd && status <= MSGL_INFO) + set_osd_msg(cmd->mpctx, 1, cmd->mpctx->opts->osd_duration, "%s", s); + + talloc_free(s); +} + static void cmd_seek(void *p) { struct mp_cmd_ctx *cmd = p; |