From e5722ad0d95e53b7d486475b6ec7c58e4d8a2105 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Thu, 1 Jan 2009 20:01:50 +0000 Subject: [PATCH] Bug 1061: Correctly truncate UTF-8 titles in the tab bar. --- NEWS | 1 + src/dialogs/status.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d52363b2..1a38a4bf 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,7 @@ includes the changes listed under ``ELinks 0.11.5.GIT'' below. option to disable this. When removing control characters from a title, note the charset. Don't truncate titles to the width of the terminal. +* bug 1061: Correctly truncate UTF-8 titles in the tab bar. * enhancement: Updated ISO 8859-7, ISO 8859-16, KOI8-R, and MacRoman. ELinks 0.12pre2: diff --git a/src/dialogs/status.c b/src/dialogs/status.c index b41b0955..53ac42ca 100644 --- a/src/dialogs/status.c +++ b/src/dialogs/status.c @@ -359,7 +359,16 @@ display_tab_bar(struct session *ses, struct terminal *term, int tabs_count) box.x, box.y, actual_tab_width, msg, NULL); } else { - int msglen = int_min(strlen(msg), actual_tab_width); + int msglen; +#ifdef CONFIG_UTF8 + if (term->utf8_cp) { + msglen = utf8_step_forward(msg, NULL, + actual_tab_width, + UTF8_STEP_CELLS_FEWER, + NULL) - msg; + } else +#endif /* CONFIG_UTF8 */ + msglen = int_min(strlen(msg), actual_tab_width); draw_text(term, box.x, box.y, msg, msglen, 0, color); }