1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

Replace double-width chars in html renderer with ' ' if there isn't space.

Instead of double-width chars use ' ' in html renderer if there isn't
enought room for it.
This commit is contained in:
Pavol Babincak 2006-04-09 16:58:00 +02:00 committed by Pavol Babincak
parent 20331ffd74
commit 69a1c40fbd

View File

@ -116,22 +116,15 @@ draw_char_data(struct terminal *term, int x, int y, unsigned char data)
screen_char->data = data; screen_char->data = data;
#ifdef CONFIG_UTF_8 #ifdef CONFIG_UTF_8
if (unicode_to_cell(data) == 2) {
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
/* Detect attempt to draw double-width char on the last /* Detect attempt to draw double-width char on the last
* collumn of terminal. */ * collumn of terminal. */
if (x+1 > term->width) if (unicode_to_cell(data) == 2 && x + 1 > term->width)
INTERNAL("Attempt to draw double-width glyph on " INTERNAL("Attempt to draw double-width glyph on last collumn!");
"last collumn!!");
#endif /* CONFIG_DEBUG */ #endif /* CONFIG_DEBUG */
screen_char = get_char(term, x+1, y); if (data == UCS_NO_CHAR)
screen_char->attr = 0;
if (!screen_char) return;
screen_char->data = UCS_NO_CHAR;
}
#endif /* CONFIG_UTF_8 */ #endif /* CONFIG_UTF_8 */
set_screen_dirty(term->screen, y, y); set_screen_dirty(term->screen, y, y);
@ -152,7 +145,37 @@ draw_line(struct terminal *term, int x, int y, int l, struct screen_char *line)
size = int_min(l, term->width - x); size = int_min(l, term->width - x);
if (size == 0) return; if (size == 0) return;
copy_screen_chars(screen_char, line, size); #ifdef CONFIG_UTF_8
if (term->utf8) {
struct screen_char *sc;
if (line->data == UCS_NO_CHAR && x == 0) {
sc = line;
unicode_val_T data_save = sc->data;
sc->data = ' ';
copy_screen_chars(screen_char, line, 1);
sc->data = data_save;
size--;
line++;
screen_char++;
}
/* Instead of displaying double-width character at last collumn
* display only space. */
if (size - 1 > 0 && unicode_to_cell(line[size - 1].data) == 2) {
sc = &line[size - 1];
unicode_val_T data_save = sc->data;
sc->data = ' ';
copy_screen_chars(screen_char, line, size);
sc->data = data_save;
} else {
copy_screen_chars(screen_char, line, size);
}
} else
#endif
copy_screen_chars(screen_char, line, size);
set_screen_dirty(term->screen, y, y); set_screen_dirty(term->screen, y, y);
} }
@ -334,6 +357,9 @@ draw_text_utf8(struct terminal *term, int x, int y,
get_opt_int_tree(term->spec, "colors")); get_opt_int_tree(term->spec, "colors"));
} }
if (start->data == UCS_NO_CHAR && x - 1 > 0)
draw_char_data(term, x - 1, y, ' ');
pos = start; pos = start;
if (unicode_to_cell(data) == 2) { if (unicode_to_cell(data) == 2) {