vt: limit grapheme width to 2 cells

All emoji graphemes are double-width. Foot doesn’t support non-latin
scripts. Ergo, this should result in the Right Thing, even though
we’re not doing it the Right Way.

Note that we’re now breaking cursor synchronization with nearly all
applications.

But the way I see it, the applications need to be
updated.
This commit is contained in:
Daniel Eklöf 2021-06-29 18:45:27 +02:00
parent 55bd3cfd62
commit 031e8f5987
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

8
vt.c
View file

@ -766,11 +766,9 @@ action_utf8_print(struct terminal *term, wchar_t wc)
int grapheme_width = composed != NULL ? composed->width : base_width;
if (wc == 0xfe0f && grapheme_width < 2)
grapheme_width = 2;
else
grapheme_width += width;
new_cc->width = grapheme_width;
if (wc == 0xfe0f)
width = 2;
new_cc->width = min(max(grapheme_width, width), 2);
term->composed_count++;
composed_insert(&term->composed, new_cc);