From 7f744c9a16f4cc9b56ba7f0089daf7440fdc9848 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 9 Feb 2014 00:45:26 +0100 Subject: [PATCH] msg: clear lines by printing spaces on MS Windows On Windows, no ANSI control sequences are available, so we can't easily clear lines, move the cursor, etc. It's yet to be decided how this should be handled (emulate ANSI escapes in osdep/terminal-win.c, or provide abstracted terminal API functions to unify the Linux and Windows code). For now, this fixes the regression that was introduced earlier by the status line rewrite. It doesn't fix all aspects of status line and terminal OSD handling, as can be clearly seen by the unconditional use of terminal_erase_to_end_of_line further down the changed code. Fixes github issue #499 (sort of). --- common/msg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/msg.c b/common/msg.c index 554ad0d762..7ac3d1b665 100644 --- a/common/msg.c +++ b/common/msg.c @@ -149,7 +149,13 @@ static void prepare_status_line(struct mp_log_root *root, char *new_status) size_t clear_lines = MPMIN(MPMAX(new_lines, old_lines), root->blank_lines); // clear the status line itself - fprintf(f, "\r%s", terminal_erase_to_end_of_line); + if (terminal_erase_to_end_of_line[0]) { + fprintf(f, "\r%s", terminal_erase_to_end_of_line); + } else { + // This code is for MS windows (no ANSI control sequences) + get_screen_size(); + fprintf(f, "\r%*s\r", screen_width - 1, ""); + } // and clear all previous old lines for (size_t n = 1; n < clear_lines; n++) fprintf(f, "%s\r%s", terminal_cursor_up, terminal_erase_to_end_of_line);