# HG changeset patch # User Mikael Berthe # Date 1165616417 -3600 # Node ID 6ca9a65df21fa00e3553f0452ead1b0fdc45251e # Parent 1ef7572c3096ad5d0eff8562189f275201cc26d1 Do not rewrap buffer lines when the chat window width doesn't change diff -r 1ef7572c3096 -r 6ca9a65df21f mcabber/src/screen.c --- a/mcabber/src/screen.c Fri Dec 08 22:32:26 2006 +0100 +++ b/mcabber/src/screen.c Fri Dec 08 23:20:17 2006 +0100 @@ -74,6 +74,7 @@ static PANEL *mainstatusPanel, *chatstatusPanel; static PANEL *logPanel; static int maxY, maxX; +static int prev_chatwidth; static winbuf *statusWindow; static winbuf *currentWindow; static GList *statushbuf; @@ -431,9 +432,11 @@ y = Log_Win_Height-1; else y = 0; + lines = CHAT_WIN_HEIGHT; cols = maxX - Roster_Width; - if (cols < 1) cols = 1; + if (cols < 1) + cols = 1; tmp->win = newwin(lines, cols, y, x); while (!tmp->win) { @@ -905,8 +908,12 @@ // Build the buddylist at least once, to make sure the special buffer // is added buddylist_build(); + + // Init prev_chatwidth; this variable will be used to prevent us + // from rewrapping buffers when the width doesn't change. + prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; // Wrap existing status buffer lines - hbuf_rebuild(&statushbuf, maxX - Roster_Width - PREFIX_WIDTH); + hbuf_rebuild(&statushbuf, prev_chatwidth); #ifndef UNICODE if (utf8_mode) @@ -933,6 +940,7 @@ winbuf *wbp = value; struct dimensions *dim = data; int chat_x_pos, chat_y_pos; + int new_chatwidth; if (!(wbp && wbp->win)) return; @@ -956,7 +964,10 @@ replace_panel(wbp->panel, wbp->win); // Redo line wrapping wbp->top = hbuf_previous_persistent(wbp->top); - hbuf_rebuild(&wbp->hbuf, maxX - Roster_Width - PREFIX_WIDTH); + + new_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; + if (new_chatwidth != prev_chatwidth) + hbuf_rebuild(&wbp->hbuf, new_chatwidth); } // scr_Resize() @@ -990,6 +1001,9 @@ if (statusWindow) resize_win_buffer(NULL, statusWindow, &dim); + // Update prev_chatwidth, now that all buffers have been resized + prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; + // Refresh current buddy window if (chatmode) scr_ShowBuddyWindow();