From 97a56f2c791383a50a00bb9442fc3e6c64f71a52 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 5 Mar 2011 12:42:04 +0100 Subject: [PATCH] gui: Fix window redrawing on SIGWINCH. It is incorrect to check the condition (offset < 0 || len < offset). This caused messed up contents of the bottom window after a resize. --- gui.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gui.c b/gui.c index eba1e2a5..38addd98 100644 --- a/gui.c +++ b/gui.c @@ -400,11 +400,13 @@ static int draw_top_rbe(unsigned *lines) rbe = ringbuffer_get(bot_win_rb, fvr); if (!rbe) return -1; - /* first rbe might be only partially visible */ - offset = (*lines - bot.lines) * bot.cols; len = strlen(rbe->msg); - if (offset < 0 || len < offset) - return -1; + if (*lines > bot.lines) { + /* first rbe is only partially visible */ + offset = (*lines - bot.lines) * bot.cols; + assert(offset <= len); + } else + offset = 0; wattron(bot.win, COLOR_PAIR(rbe->color)); waddstr(bot.win, rbe->msg + offset); *lines = NUM_LINES(len - offset); -- 2.39.2