mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
vt: presentation selectors may be anywhere in the cluster
This commit is contained in:
parent
96ff29bbd3
commit
09431dd15c
1 changed files with 10 additions and 8 deletions
18
vt.c
18
vt.c
|
|
@ -726,20 +726,22 @@ action_utf8_print(struct terminal *term, wchar_t wc)
|
||||||
struct composed new_cc;
|
struct composed new_cc;
|
||||||
new_cc.count = wanted_count;
|
new_cc.count = wanted_count;
|
||||||
new_cc.chars[0] = base;
|
new_cc.chars[0] = base;
|
||||||
|
|
||||||
for (size_t i = 1; i < wanted_count - 1; i++)
|
for (size_t i = 1; i < wanted_count - 1; i++)
|
||||||
new_cc.chars[i] = composed->chars[i];
|
new_cc.chars[i] = composed->chars[i];
|
||||||
new_cc.chars[wanted_count - 1] = wc;
|
new_cc.chars[wanted_count - 1] = wc;
|
||||||
|
|
||||||
if (term->composed_count < CELL_COMB_CHARS_HI) {
|
if (term->composed_count < CELL_COMB_CHARS_HI) {
|
||||||
/* TODO: grapheme cluster width */
|
int grapheme_width = wcwidth(base);
|
||||||
int grapheme_width = wcswidth(new_cc.chars, new_cc.count);
|
int min_grapheme_width = 0;
|
||||||
#if 0 /* Fish expects this, but nothing else */
|
for (size_t i = 0; i < wanted_count; i++) {
|
||||||
if (new_cc.chars[new_cc.count - 1] == 0xfe0f) {
|
wchar_t c = new_cc.chars[i];
|
||||||
/* Emoji selector */
|
if (c == 0xfe0f)
|
||||||
grapheme_width = max(2, grapheme_width);
|
min_grapheme_width = 2;
|
||||||
|
grapheme_width += wcwidth(c);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
new_cc.width = grapheme_width;
|
new_cc.width = max(grapheme_width, min_grapheme_width);
|
||||||
|
|
||||||
term->composed_count++;
|
term->composed_count++;
|
||||||
term->composed = xrealloc(term->composed, term->composed_count * sizeof(term->composed[0]));
|
term->composed = xrealloc(term->composed, term->composed_count * sizeof(term->composed[0]));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue