mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 13:14:36 +00:00
msg: keep status line on the end of file
Apparently found useful by some users. Fixes: #13092
This commit is contained in:
parent
19a37f625f
commit
cadb68487e
11
common/msg.c
11
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);
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user