From 9817e44c325f5d44f64bfa768107998134ea7f59 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 30 Jun 2021 18:00:33 +0200 Subject: config: add tweak.grapheme-width-method=wcswidth|at-most-2 --- vt.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'vt.c') diff --git a/vt.c b/vt.c index 5f2b3c0d..6ef2b782 100644 --- a/vt.c +++ b/vt.c @@ -764,17 +764,26 @@ action_utf8_print(struct terminal *term, wchar_t wc) (wanted_count - 2) * sizeof(new_cc->chars[0])); } - int grapheme_width = composed != NULL ? composed->width : base_width; + const int grapheme_width = + composed != NULL ? composed->width : base_width; + + switch (term->conf->tweak.grapheme_width_method) { + case GRAPHEME_WIDTH_MAX_2: + if (unlikely(wc == 0xfe0f)) + width = 2; + new_cc->width = min(grapheme_width + width, 2); + break; - if (wc == 0xfe0f) - width = 2; - new_cc->width = min(max(grapheme_width, width), 2); + case GRAPHEME_WIDTH_WCSWIDTH: + new_cc->width = grapheme_width + width; + break; + } term->composed_count++; composed_insert(&term->composed, new_cc); wc = CELL_COMB_CHARS_LO + key; - width = grapheme_width; + width = new_cc->width; xassert(wc >= CELL_COMB_CHARS_LO); xassert(wc <= CELL_COMB_CHARS_HI); -- cgit v1.3