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

Improve isolated combining characters handling

If there are isolated combining characters, e.g. at the beginning of a paragraph
or table cell:
– if it’s not the first screen column, combine them with whatever character is
printed to their left;
– otherwise, add a no-break space as the base character.

Previously, such combining characters were combined with the last letter
displayed, i.e. the last letter of the previous paragraph or cell.

Signed-off-by: Fabienne Ducroquet <fabiduc@gmail.com>
This commit is contained in:
Fabienne Ducroquet 2016-04-12 21:02:38 +02:00 committed by Witold Filipczyk
parent a43ec1075c
commit 13f3da8416

View File

@ -425,6 +425,21 @@ move_comb_x_y(struct part *part, int xf, int yf, int xt, int yt)
# define move_comb_x_y(part, xf, yf, xt, yt) ((void) 0) # define move_comb_x_y(part, xf, yf, xt, yt) ((void) 0)
#endif #endif
#ifdef CONFIG_COMBINE
static void
set_comb_x_y(struct part *part, int x, int y)
{
struct document *document = part->document;
document->comb_x = X(x);
document->comb_y = Y(y);
assert_comb_x_y_ok(document);
if_assert_failed discard_comb_x_y(document);
}
#else
# define set_comb_x_y(part, x, y) ((void) 0)
#endif
#ifdef CONFIG_COMBINE #ifdef CONFIG_COMBINE
static void static void
put_combined(struct part *part, int x) put_combined(struct part *part, int x)
@ -596,12 +611,33 @@ good_char:
put_combined(part, x); put_combined(part, x);
document->combi[0] = data; document->combi[0] = data;
} else { } else {
if (document->combi_length < (UCS_MAX_LENGTH_COMBINED - 1)) { if (part->cx == x) {
document->combi[++document->combi_length] = data; if (X(x)) {
/* Isolated combining
* character not on the
* first column: combine
* it with whatever is
* printed at its left. */
document->combi[0] = POS(x - 1, y).data;
set_comb_x_y(part, x - 1, y);
} else {
/* Isolated combining
* character on the
* first column: use
* UCS_NO_BREAK_SPACE as
* the base character.
* */
document->combi[0] = UCS_NO_BREAK_SPACE;
set_comb_x_y(part, x, y);
schar->data = UCS_SPACE;
copy_screen_chars(&POS(x++, y), schar, 1);
}
} }
if (document->combi_length < (UCS_MAX_LENGTH_COMBINED - 1))
document->combi[++document->combi_length] = data;
continue; continue;
} }
#endif #endif /* CONFIG_COMBINE */
part->spaces[x] = (data == UCS_SPACE); part->spaces[x] = (data == UCS_SPACE);
if (unicode_to_cell(data) == 2) { if (unicode_to_cell(data) == 2) {
@ -615,12 +651,9 @@ good_char:
part->char_width[x] = unicode_to_cell(data); part->char_width[x] = unicode_to_cell(data);
schar->data = (unicode_val_T)data; schar->data = (unicode_val_T)data;
} }
#ifdef CONFIG_COMBINE
document->comb_x = X(x); set_comb_x_y(part, x, y);
document->comb_y = Y(y);
assert_comb_x_y_ok(document);
if_assert_failed discard_comb_x_y(document);
#endif
copy_screen_chars(&POS(x++, y), schar, 1); copy_screen_chars(&POS(x++, y), schar, 1);
} /* while chars < end */ } /* while chars < end */