1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

mp_msg: avoid mangling other output with status line

Output a '\n' when printing a message after a status line to move the
terminal to the next line instead of writing on top of the status one.

Patch by Dan Oscarsson [Dan.Oscarsson tieto com]

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31691 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2010-07-11 08:02:26 +00:00 committed by Uoti Urpala
parent 747a30b81b
commit aa82817945

View File

@ -194,6 +194,8 @@ void mp_msg_va(int mod, int lev, const char *format, va_list va)
char tmp[MSGSIZE_MAX];
FILE *stream = lev <= MSGL_WARN ? stderr : stdout;
static int header = 1;
// indicates if last line printed was a status line
static int statusline;
if (!mp_msg_test(mod, lev)) return; // do not display
vsnprintf(tmp, MSGSIZE_MAX, format, va);
@ -231,6 +233,13 @@ void mp_msg_va(int mod, int lev, const char *format, va_list va)
}
#endif
/* A status line is normally intended to be overwritten by the next
* status line, and does not end with a '\n'. If we're printing a normal
* line instead after the status one print '\n' to change line. */
if (statusline && lev != MSGL_STATUS)
fprintf(stream, "\n");
statusline = lev == MSGL_STATUS;
if (header)
print_msg_module(stream, mod);
set_msg_color(stream, lev);