Mercurial > dillo_port1.3
changeset 1126:958903cf2733
properly truncate utf8 window titles
author | corvid <corvid@lavabit.com> |
---|---|
date | Sun, 24 May 2009 20:48:50 +0200 |
parents | 6b59ccaaaf92 |
children | 65c7e33e4466 |
files | src/uicmd.cc |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/uicmd.cc Sun May 24 17:48:31 2009 +0200 +++ b/src/uicmd.cc Sun May 24 20:48:50 2009 +0200 @@ -26,6 +26,7 @@ #include "ui.hh" #include "uicmd.hh" #include "timeout.hh" +#include "utf8.hh" #include "menu.hh" #include "dialog.hh" #include "xembed.hh" @@ -1137,11 +1138,15 @@ */ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label) { - char title[128]; + const int size = 128; + char title[size]; if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->selected_child()) == bw) { // This is the focused bw, set window title - snprintf(title, 128, "Dillo: %s", label); + if (snprintf(title, size, "Dillo: %s", label) >= size) { + uint_t i = MIN(size - 4, 1 + a_Utf8_end_of_char(title, size - 8)); + snprintf(title + i, 4, "..."); + } BW2UI(bw)->window()->copy_label(title); BW2UI(bw)->window()->redraw_label(); }