From: Thomas Jansen Date: Mon, 17 Aug 2009 10:19:37 +0000 (+0200) Subject: Fixed rogue character after volume change X-Git-Tag: release-0.15~31 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f4a47d5dc83c5c18ea41e172c775e2fbcd81a49a;p=ncmpc.git Fixed rogue character after volume change Volume changes that result in a shorter string length did not clean up the now unused characters. We check the expected (relative) string length before updating the screen and do a full repaint in that case. --- diff --git a/src/screen.c b/src/screen.c index 30a017d..1c44bf7 100644 --- a/src/screen.c +++ b/src/screen.c @@ -238,6 +238,18 @@ paint_top_window2(const char *header, mpdclient_t *c) wnoutrefresh(w); } +static inline int +volume_length(int volume) +{ + if (volume == 100) + return 3; + if (volume >= 10 && volume < 100) + return 2; + if (volume >= 0 && volume < 10) + return 1; + return -1; +} + static void paint_top_window(const char *header, mpdclient_t *c, int full_repaint) { @@ -250,6 +262,10 @@ paint_top_window(const char *header, mpdclient_t *c, int full_repaint) full_repaint = 1; } + if (c->status && + volume_length(prev_volume) != volume_length(c->status->volume)) + full_repaint = 1; + if (full_repaint) { wmove(w, 0, 0); wclrtoeol(w);