mirror of
https://github.com/rkd77/elinks.git
synced 2025-04-18 00:47:36 -04:00
Corrected support for double-width UTF-8 chars in titles of dialogs.
This commit is contained in:
parent
33c0943ce4
commit
f3a063f1ed
@ -97,25 +97,33 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
|
|||||||
title_color = get_bfu_color(term, "dialog.title");
|
title_color = get_bfu_color(term, "dialog.title");
|
||||||
if (title_color && box.width > 2) {
|
if (title_color && box.width > 2) {
|
||||||
unsigned char *title = dlg_data->dlg->title;
|
unsigned char *title = dlg_data->dlg->title;
|
||||||
#ifdef CONFIG_UTF_8
|
|
||||||
unsigned char *t2 = title;
|
|
||||||
int titlelen = strlen(title);
|
int titlelen = strlen(title);
|
||||||
int len = term->utf8 ? strlen_utf8(&t2) : titlelen;
|
int titlecells = titlelen;
|
||||||
len = int_min(box.width - 2, len);
|
int x, y;
|
||||||
int x = (box.width - len) / 2 + box.x;
|
#ifdef CONFIG_UTF_8
|
||||||
#else
|
if (term->utf8)
|
||||||
int titlelen = int_min(box.width - 2, strlen(title));
|
titlecells = utf8_ptr2cells(title,
|
||||||
int x = (box.width - titlelen) / 2 + box.x;
|
&title[titlelen]);
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
int y = box.y - 1;
|
|
||||||
|
titlecells = int_min(box.width - 2, titlecells);
|
||||||
|
|
||||||
|
#ifdef CONFIG_UTF_8
|
||||||
|
if (term->utf8) {
|
||||||
|
titlelen = utf8_cells2bytes(title,
|
||||||
|
titlecells,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_UTF_8 */
|
||||||
|
|
||||||
|
x = (box.width - titlecells) / 2 + box.x;
|
||||||
|
y = box.y - 1;
|
||||||
|
|
||||||
|
|
||||||
draw_text(term, x - 1, y, " ", 1, 0, title_color);
|
draw_text(term, x - 1, y, " ", 1, 0, title_color);
|
||||||
draw_text(term, x, y, title, titlelen, 0, title_color);
|
draw_text(term, x, y, title, titlelen, 0, title_color);
|
||||||
#ifdef CONFIG_UTF_8
|
draw_text(term, x + titlecells, y, " ", 1, 0,
|
||||||
draw_text(term, x + len, y, " ", 1, 0, title_color);
|
title_color);
|
||||||
#else
|
|
||||||
draw_text(term, x + titlelen, y, " ", 1, 0, title_color);
|
|
||||||
#endif /* CONFIG_UTF_8 */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,7 +587,13 @@ generic_dialog_layouter(struct dialog_data *dlg_data)
|
|||||||
struct terminal *term = dlg_data->win->term;
|
struct terminal *term = dlg_data->win->term;
|
||||||
int w = dialog_max_width(term);
|
int w = dialog_max_width(term);
|
||||||
int height = dialog_max_height(term);
|
int height = dialog_max_height(term);
|
||||||
int rw = int_min(w, strlen(dlg_data->dlg->title));
|
int rw;
|
||||||
|
#ifdef CONFIG_UTF_8
|
||||||
|
if (term->utf8)
|
||||||
|
rw = int_min(w, utf8_ptr2cells(dlg_data->dlg->title, NULL));
|
||||||
|
else
|
||||||
|
#endif /* CONFIG_UTF_8 */
|
||||||
|
rw = int_min(w, strlen(dlg_data->dlg->title));
|
||||||
int y = dlg_data->dlg->layout.padding_top ? 0 : -1;
|
int y = dlg_data->dlg->layout.padding_top ? 0 : -1;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user