From b51713e8e7938978a675abf1bedc2ff2d9ae7319 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 14 Jan 2014 17:37:55 +0100 Subject: msg: don't clear term OSD lines that are not used --- common/msg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/msg.c b/common/msg.c index 6b5bf4de91..ebb5051900 100644 --- a/common/msg.c +++ b/common/msg.c @@ -125,7 +125,6 @@ bool mp_msg_test(struct mp_log *log, int lev) static void prepare_status_line(struct mp_log_root *root, char *new_status) { FILE *f = stderr; - size_t old_lines = root->blank_lines; size_t new_lines = 1; char *tmp = new_status; @@ -137,13 +136,16 @@ static void prepare_status_line(struct mp_log_root *root, char *new_status) tmp++; } + size_t old_lines = root->status_lines; + 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); // and clear all previous old lines - for (size_t n = 1; n < old_lines; n++) + for (size_t n = 1; n < clear_lines; n++) fprintf(f, "%s\r%s", terminal_cursor_up, terminal_erase_to_end_of_line); // skip "unused" blank lines, so that status is aligned to term bottom - for (size_t n = new_lines; n < old_lines; n++) + for (size_t n = new_lines; n < clear_lines; n++) fprintf(f, "\n"); root->status_lines = new_lines; -- cgit v1.2.3