From eadc96008ca6fa0a335ab35daaff0cfd24546cf9 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 27 Dec 2010 14:50:48 +0100 Subject: Erase current line before printing new message Parts of the current song's time didn't get erased when renaming a station. --- src/ui.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index 3edccc7..c1aadab 100644 --- a/src/ui.c +++ b/src/ui.c @@ -48,31 +48,32 @@ typedef int (*BarSortFunc_t) (const void *, const void *); * @param message */ inline void BarUiMsg (uiMsg_t type, const char *format, ...) { + #define ANSI_CLEAR_LINE "\033[2K" va_list fmtargs; switch (type) { case MSG_INFO: - printf ("(i) "); + printf (ANSI_CLEAR_LINE "(i) "); break; case MSG_PLAYING: - printf ("|> "); + printf (ANSI_CLEAR_LINE "|> "); break; case MSG_TIME: - printf ("# "); + printf (ANSI_CLEAR_LINE "# "); break; case MSG_ERR: - printf ("/!\\ "); + printf (ANSI_CLEAR_LINE "/!\\ "); break; case MSG_QUESTION: - printf ("[?] "); + printf (ANSI_CLEAR_LINE "[?] "); break; case MSG_LIST: - printf (" "); + printf (ANSI_CLEAR_LINE "\t"); break; default: @@ -83,6 +84,8 @@ inline void BarUiMsg (uiMsg_t type, const char *format, ...) { va_end (fmtargs); fflush (stdout); + + #undef ANSI_CLEAR_LINE } /* prints human readable status message based on return value -- cgit v1.2.3