1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-17 21:27:08 +00:00

msg: split mp_msg_flush_status_line into private and public variant

This commit is contained in:
Kacper Michajłow 2024-05-13 22:13:41 +02:00
parent 243c1d6d91
commit 895dd9e4e2

View File

@ -246,34 +246,39 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter
root->blank_lines += root->status_lines; root->blank_lines += root->status_lines;
} }
void mp_msg_flush_status_line(struct mp_log *log, bool clear) static void msg_flush_status_line(struct mp_log_root *root, bool clear)
{ {
if (!log->root) if (!root->status_lines)
return;
mp_mutex_lock(&log->root->lock);
if (!log->root->status_lines)
goto done; goto done;
FILE *fp = term_msg_fp(log->root, MSGL_STATUS); FILE *fp = term_msg_fp(root, MSGL_STATUS);
if (!clear) { if (!clear) {
if (log->root->isatty[term_msg_fileno(log->root, MSGL_STATUS)]) if (root->isatty[term_msg_fileno(root, MSGL_STATUS)])
fprintf(fp, TERM_ESC_RESTORE_CURSOR); fprintf(fp, TERM_ESC_RESTORE_CURSOR);
fprintf(fp, "\n"); fprintf(fp, "\n");
log->root->blank_lines = 0; root->blank_lines = 0;
log->root->status_lines = 0; root->status_lines = 0;
goto done; goto done;
} }
bstr term_msg = {0}; bstr term_msg = {0};
prepare_prefix(log->root, &term_msg, MSGL_STATUS, 0); prepare_prefix(root, &term_msg, MSGL_STATUS, 0);
if (term_msg.len) { if (term_msg.len) {
fprintf(fp, "%.*s", BSTR_P(term_msg)); fprintf(fp, "%.*s", BSTR_P(term_msg));
talloc_free(term_msg.start); talloc_free(term_msg.start);
} }
done: done:
log->root->status_line.len = 0; root->status_line.len = 0;
}
void mp_msg_flush_status_line(struct mp_log *log, bool clear)
{
if (!log->root)
return;
mp_mutex_lock(&log->root->lock);
msg_flush_status_line(log->root, clear);
mp_mutex_unlock(&log->root->lock); mp_mutex_unlock(&log->root->lock);
} }