summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-09 00:45:26 +0100
committerwm4 <wm4@nowhere>2014-02-09 00:45:26 +0100
commit7f744c9a16f4cc9b56ba7f0089daf7440fdc9848 (patch)
treed429fdcfbdd5938a715be9db32b67da2bd22165c
parent8eaf6c42ac9df1a3e5ef7385887b708d7cfbac28 (diff)
downloadmpv-7f744c9a16f4cc9b56ba7f0089daf7440fdc9848.tar.bz2
mpv-7f744c9a16f4cc9b56ba7f0089daf7440fdc9848.tar.xz
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).
-rw-r--r--common/msg.c8
1 files changed, 7 insertions, 1 deletions
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);