aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-07-01 17:55:50 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-07-01 17:55:50 +0000
commitd9fc1e0d8aaf580649aef2f900948e2e053fb9df (patch)
treef3aebec4807e101387eb07451451d13d2a925357 /vt.c
parentconfig: add unit test for config_clone() (diff)
parentconfig: rename at-most-2 (value for grapheme-width-method) to double-width (diff)
Merge branch 'max-grapheme-width-is-2'
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/vt.c b/vt.c
index 900ffd9d..b9a4f4b0 100644
--- a/vt.c
+++ b/vt.c
@@ -764,19 +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;
- if (wc == 0xfe0f && grapheme_width < 2)
- grapheme_width = 2;
- else
- grapheme_width += width;
- new_cc->width = grapheme_width;
+ switch (term->conf->tweak.grapheme_width_method) {
+ case GRAPHEME_WIDTH_DOUBLE:
+ if (unlikely(wc == 0xfe0f))
+ width = 2;
+ new_cc->width = min(grapheme_width + width, 2);
+ break;
+
+ 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);