summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-05-24 20:48:50 +0200
committercorvid <corvid@lavabit.com>2009-05-24 20:48:50 +0200
commit3712ecc11ee723fedee09627f097bf66a0e7e984 (patch)
treea6e196074076f6242528d83e1a781264abc4a879 /src
parent88ad29908349549c880f74a9572c1cd032a8479b (diff)
properly truncate utf8 window titles
Diffstat (limited to 'src')
-rw-r--r--src/uicmd.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 362f0a9b..22827d7a 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -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_bug_prog(BrowserWindow *bw, int n_bug)
*/
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();
}