1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-28 03:06:20 -04: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)
#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
static void
put_combined(struct part *part, int x)
@ -596,12 +611,33 @@ good_char:
put_combined(part, x);
document->combi[0] = data;
} else {
if (document->combi_length < (UCS_MAX_LENGTH_COMBINED - 1)) {
document->combi[++document->combi_length] = data;
if (part->cx == x) {
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;
}
#endif
#endif /* CONFIG_COMBINE */
part->spaces[x] = (data == UCS_SPACE);
if (unicode_to_cell(data) == 2) {
@ -615,12 +651,9 @@ good_char:
part->char_width[x] = unicode_to_cell(data);
schar->data = (unicode_val_T)data;
}
#ifdef CONFIG_COMBINE
document->comb_x = X(x);
document->comb_y = Y(y);
assert_comb_x_y_ok(document);
if_assert_failed discard_comb_x_y(document);
#endif
set_comb_x_y(part, x, y);
copy_screen_chars(&POS(x++, y), schar, 1);
} /* while chars < end */