Skip to content

Commit a16f653

Browse files
committed
msg: clear status line only if needed
1 parent 895dd9e commit a16f653

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

common/msg.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ static inline FILE *term_msg_fp(struct mp_log_root *root, int lev)
202202
return term_msg_fileno(root, lev) == STDERR_FILENO ? stderr : stdout;
203203
}
204204

205+
static inline bool is_status_output(struct mp_log_root *root, int lev)
206+
{
207+
if (lev == MSGL_STATUS)
208+
return true;
209+
int msg_out = term_msg_fileno(root, lev);
210+
int status_out = term_msg_fileno(root, MSGL_STATUS);
211+
if (msg_out != status_out && root->isatty[msg_out] != root->isatty[status_out])
212+
return false;
213+
return true;
214+
}
215+
205216
// Reposition cursor and clear lines for outputting the status line. In certain
206217
// cases, like term OSD and subtitle display, the status can consist of
207218
// multiple lines.
@@ -210,6 +221,9 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter
210221
int new_lines = lev == MSGL_STATUS ? term_lines : 0;
211222
out->len = 0;
212223

224+
if (!is_status_output(root, lev))
225+
return;
226+
213227
if (!root->isatty[term_msg_fileno(root, lev)]) {
214228
if (root->status_lines)
215229
bstr_xappend(root, out, bstr0("\n"));
@@ -563,7 +577,7 @@ void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va)
563577

564578
root->term_status_msg.len = 0;
565579
if (lev != MSGL_STATUS && root->status_line.len && root->status_log &&
566-
test_terminal_level(root->status_log, MSGL_STATUS))
580+
is_status_output(root, lev) && test_terminal_level(root->status_log, MSGL_STATUS))
567581
{
568582
write_term_msg(root->status_log, MSGL_STATUS, root->status_line,
569583
&root->term_status_msg);

0 commit comments

Comments
 (0)