diff --git a/player/command.c b/player/command.c index fc7839418c..2d0f07dd5b 100644 --- a/player/command.c +++ b/player/command.c @@ -6749,6 +6749,17 @@ static void cmd_context_menu(void *p) vo_control(vo, VOCTRL_SHOW_MENU, NULL); } +static void cmd_flush_status_line(void *p) +{ + struct mp_cmd_ctx *cmd = p; + struct MPContext *mpctx = cmd->mpctx; + + if (!mpctx->log) + return; + + mp_msg_flush_status_line(mpctx->log, cmd->args[0].v.b); +} + /* This array defines all known commands. * The first field the command name used in libmpv and input.conf. * The second field is the handler function (see mp_cmd_def.handler and @@ -7224,6 +7235,8 @@ const struct mp_cmd_def mp_cmds[] = { { "context-menu", cmd_context_menu }, + { "flush-status-line", cmd_flush_status_line, { {"clear", OPT_BOOL(v.b)} } }, + {0} }; diff --git a/player/lua/stats.lua b/player/lua/stats.lua index f73e69041a..91d9102ed8 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -1795,19 +1795,29 @@ mp.register_event("video-reconfig", -- --script-opts=stats-bindlist=[-]{yes|} if o.bindlist ~= "no" then - mp.command("no-osd set really-quiet yes") - if o.bindlist:sub(1, 1) == "-" then - o.bindlist = o.bindlist:sub(2) - o.no_ass_b0 = "" - o.no_ass_b1 = "" - end - local width = max(40, math.floor(tonumber(o.bindlist) or 79)) - mp.add_timeout(0, function() -- wait for all other scripts to finish init + -- This is a special mode to print key bindings to the terminal, + -- Adjust the print format and level to make it print only the key bindings. + mp.set_property("msg-level", "all=no,statusline=status") + mp.set_property("term-osd", "force") + mp.set_property_bool("msg-module", false) + mp.set_property_bool("msg-time", false) + -- wait for all other scripts to finish init + mp.add_timeout(0, function() + if o.bindlist:sub(1, 1) == "-" then + o.bindlist = o.bindlist:sub(2) + o.no_ass_b0 = "" + o.no_ass_b1 = "" + end + local width = max(40, math.floor(tonumber(o.bindlist) or 79)) o.ass_formatting = false o.no_ass_indent = " " o.term_size = { w = width , h = 0} - io.write(keybinding_info(false, true) .. "\n") - mp.command("quit") + mp.osd_message(keybinding_info(false, true)) + -- wait for next tick to print status line and flush it without clearing + mp.add_timeout(0, function() + mp.command("flush-status-line no") + mp.command("quit") + end) end) end