From 031e8f59877f4ad25a5a4116342d66f9aac56c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 29 Jun 2021 18:45:27 +0200 Subject: [PATCH] vt: limit grapheme width to 2 cells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- vt.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vt.c b/vt.c index 900ffd9d..5f2b3c0d 100644 --- a/vt.c +++ b/vt.c @@ -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);