1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-12 00:34:47 -04:00

Modified titlebar for correctly displaying UTF-8 page titles.

This commit is contained in:
Pavol Babincak 2006-03-05 01:54:17 +01:00 committed by Pavol Babincak
parent e0886dd842
commit 33c0943ce4

View File

@ -412,11 +412,25 @@ display_title_bar(struct session *ses, struct terminal *term)
if (document->title) {
int maxlen = int_max(term->width - 4 - buflen, 0);
int titlelen = int_min(strlen(document->title), maxlen);
int titlelen, titlewidth;
#ifdef CONFIG_UTF_8
if (term->utf8) {
titlewidth = utf8_ptr2cells(document->title, NULL);
titlewidth = int_min(titlewidth, maxlen);
titlelen = utf8_cells2bytes(document->title,
titlewidth, NULL);
} else
#endif /* CONFIG_UTF_8 */
{
titlewidth = int_min(strlen(document->title), maxlen);
titlelen = titlewidth;
}
add_bytes_to_string(&title, document->title, titlelen);
if (titlelen == maxlen)
if (titlewidth == maxlen)
add_bytes_to_string(&title, "...", 3);
}
@ -424,7 +438,16 @@ display_title_bar(struct session *ses, struct terminal *term)
add_bytes_to_string(&title, buf, buflen);
if (title.length) {
int x = int_max(term->width - 1 - title.length, 0);
int x;
#ifdef CONFIG_UTF_8
if (term->utf8) {
x = int_max(term->width - 1
- utf8_ptr2cells(title.source,
title.source
+ title.length), 0);
} else
#endif /* CONFIG_UTF_8 */
x = int_max(term->width - 1 - title.length, 0);
draw_text(term, x, 0, title.source, title.length, 0,
get_bfu_color(term, "title.title-text"));