mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Fix format_real_length to return the correct length when the input string
includes a trailing wide char. Change statusbar_item_default_handler to compute padding also when item->size < item->min_size, needed after the fix to format_real_length. Patch by Yi-Hsuan Hsin, bug #452. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4416 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
6d11f6f897
commit
c536d1f19c
@ -366,6 +366,7 @@ int format_real_length(const char *str, int len)
|
|||||||
GString *tmp;
|
GString *tmp;
|
||||||
const char *start;
|
const char *start;
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
|
const char *oldstr;
|
||||||
gboolean utf8;
|
gboolean utf8;
|
||||||
#endif
|
#endif
|
||||||
g_return_val_if_fail(str != NULL, 0);
|
g_return_val_if_fail(str != NULL, 0);
|
||||||
@ -394,7 +395,10 @@ int format_real_length(const char *str, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
|
oldstr = str;
|
||||||
len -= advance(&str, utf8);
|
len -= advance(&str, utf8);
|
||||||
|
if (len < 0)
|
||||||
|
str = oldstr;
|
||||||
#else
|
#else
|
||||||
len--;
|
len--;
|
||||||
str++;
|
str++;
|
||||||
|
@ -732,7 +732,7 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
|
|||||||
/* they're forcing us smaller than minimum size.. */
|
/* they're forcing us smaller than minimum size.. */
|
||||||
len = format_real_length(tmpstr, item->size);
|
len = format_real_length(tmpstr, item->size);
|
||||||
tmpstr[len] = '\0';
|
tmpstr[len] = '\0';
|
||||||
} else {
|
}
|
||||||
/* make sure the str is big enough to fill the
|
/* make sure the str is big enough to fill the
|
||||||
requested size, so it won't corrupt screen */
|
requested size, so it won't corrupt screen */
|
||||||
len = format_get_length(tmpstr);
|
len = format_get_length(tmpstr);
|
||||||
@ -748,7 +748,6 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
|
|||||||
g_free(tmpstr);
|
g_free(tmpstr);
|
||||||
tmpstr = tmpstr2;
|
tmpstr = tmpstr2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tmpstr2 = update_statusbar_bg(tmpstr, item->bar->color);
|
tmpstr2 = update_statusbar_bg(tmpstr, item->bar->color);
|
||||||
gui_printtext(item->xpos, item->bar->real_ypos, tmpstr2);
|
gui_printtext(item->xpos, item->bar->real_ypos, tmpstr2);
|
||||||
|
Loading…
Reference in New Issue
Block a user