int escape_vars)
{
SERVER_REC *server;
- WI_ITEM_REC *wiitem;
- char *tmpstr, *tmpstr2;
+ WI_ITEM_REC *wiitem;
+ char *tmpstr, *tmpstr2;
int len;
if (str == NULL)
server = NULL;
wiitem = NULL;
} else {
- server = active_win->active_server;
- wiitem = active_win->active;
+ server = active_win->active_server != NULL ?
+ active_win->active_server : active_win->connect_server;
+ wiitem = active_win->active;
}
/* expand templates */
/* they're forcing us smaller than minimum size.. */
len = format_real_length(tmpstr, item->size);
tmpstr[len] = '\0';
+ } else {
+ /* make sure the str is big enough to fill the
+ requested size, so it won't corrupt screen */
+ len = format_get_length(tmpstr);
+ if (len < item->size) {
+ char *fill;
+
+ len = item->size-len;
+ fill = g_malloc(len + 1);
+ memset(fill, ' ', len); fill[len] = '\0';
+
+ tmpstr2 = g_strconcat(tmpstr, fill, NULL);
+ g_free(fill);
+ g_free(tmpstr);
+ tmpstr = tmpstr2;
+ }
}
tmpstr2 = update_statusbar_bg(tmpstr, item->bar->color);