diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-12-15 19:38:07 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-12-27 20:59:22 +0000 |
commit | cadb68487e9c8f4237ba59b672180ad1460db514 (patch) | |
tree | 5dc379238569090600360e2f36340b9474147e27 | |
parent | 19a37f625fcd502acea42b4f27029c8be724d40c (diff) | |
download | mpv-cadb68487e9c8f4237ba59b672180ad1460db514.tar.bz2 mpv-cadb68487e9c8f4237ba59b672180ad1460db514.tar.xz |
msg: keep status line on the end of file
Apparently found useful by some users.
Fixes: #13092
-rw-r--r-- | common/msg.c | 11 | ||||
-rw-r--r-- | common/msg_control.h | 2 | ||||
-rw-r--r-- | player/command.c | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/common/msg.c b/common/msg.c index b14bd5ac24..797048620b 100644 --- a/common/msg.c +++ b/common/msg.c @@ -247,11 +247,17 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter root->blank_lines += root->status_lines; } -void mp_msg_flush_status_line(struct mp_log *log) +void mp_msg_flush_status_line(struct mp_log *log, bool clear) { if (log->root) { mp_mutex_lock(&log->root->lock); if (log->root->status_lines) { + if (!clear) { + fprintf(stderr, TERM_ESC_RESTORE_CURSOR "\n"); + log->root->blank_lines = 0; + log->root->status_lines = 0; + goto done; + } bstr term_msg = (bstr){0}; prepare_prefix(log->root, &term_msg, MSGL_STATUS, 0); if (term_msg.len) { @@ -259,6 +265,7 @@ void mp_msg_flush_status_line(struct mp_log *log) talloc_free(term_msg.start); } } +done: mp_mutex_unlock(&log->root->lock); } } @@ -836,7 +843,7 @@ bool mp_msg_has_log_file(struct mpv_global *global) void mp_msg_uninit(struct mpv_global *global) { struct mp_log_root *root = global->log->root; - mp_msg_flush_status_line(global->log); + mp_msg_flush_status_line(global->log, true); terminate_log_file_thread(root); mp_msg_log_buffer_destroy(root->early_buffer); mp_msg_log_buffer_destroy(root->early_filebuffer); diff --git a/common/msg_control.h b/common/msg_control.h index e4da59e870..0b52ce5a00 100644 --- a/common/msg_control.h +++ b/common/msg_control.h @@ -14,7 +14,7 @@ bool mp_msg_has_status_line(struct mpv_global *global); bool mp_msg_has_log_file(struct mpv_global *global); void mp_msg_set_early_logging(struct mpv_global *global, bool enable); -void mp_msg_flush_status_line(struct mp_log *log); +void mp_msg_flush_status_line(struct mp_log *log, bool clear); void mp_msg_set_term_title(struct mp_log *log, const char *title); struct mp_log_buffer_entry { diff --git a/player/command.c b/player/command.c index 7bd2380274..ad61d773e1 100644 --- a/player/command.c +++ b/player/command.c @@ -5770,7 +5770,7 @@ static void cmd_run(void *p) char **args = talloc_zero_array(NULL, char *, cmd->num_args + 1); for (int n = 0; n < cmd->num_args; n++) args[n] = cmd->args[n].v.s; - mp_msg_flush_status_line(mpctx->log); + mp_msg_flush_status_line(mpctx->log, true); struct mp_subprocess_opts opts = { .exe = args[0], .args = args, @@ -6878,6 +6878,9 @@ static void command_event(struct MPContext *mpctx, int event, void *arg) if (event == MPV_EVENT_PLAYBACK_RESTART) ctx->last_seek_time = mp_time_sec(); + if (event == MPV_EVENT_END_FILE) + mp_msg_flush_status_line(mpctx->log, false); + if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) { // Update chapters - does nothing if something else is visible. set_osd_bar_chapters(mpctx, OSD_BAR_SEEK); |