aboutsummaryrefslogtreecommitdiff
path: root/csi.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-05-16 08:46:25 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-05-16 16:46:26 +0000
commitebd1614316ea541cd1ac0cc0029f771be333176e (patch)
tree70b17e4a16f4d7488376c5c60bf800be9f14a7a9 /csi.c
parentterm: unittest: auto-scroll timer FD is created on-demand nowadays (diff)
csi: when REP:ing a "combining" character, use correct width
Before this patch, we just called c32width(), which only works on actual codepoints. If the last printed character is a "combining" character, i.e. a key into our lookup table for multi-codepoint graphemes, we need to lookup the grapheme and pick the width from there. See https://gitlab.com/AutumnMeowMeow/jexer/-/issues/119#note_2499712901
Diffstat (limited to 'csi.c')
-rw-r--r--csi.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/csi.c b/csi.c
index e8b2c492..6d4845be 100644
--- a/csi.c
+++ b/csi.c
@@ -799,7 +799,17 @@ csi_dispatch(struct terminal *term, uint8_t final)
int count = vt_param_get(term, 0, 1);
LOG_DBG("REP: '%lc' %d times", (wint_t)term->vt.last_printed, count);
- const int width = c32width(term->vt.last_printed);
+ int width;
+
+ if (term->vt.last_printed >= CELL_COMB_CHARS_LO) {
+ const struct composed *comp = composed_lookup(
+ term->composed, term->vt.last_printed - CELL_COMB_CHARS_LO);
+
+ xassert(comp != NULL);
+ width = comp->forced_width > 0 ? comp->forced_width : comp->width;
+ } else
+ width = c32width(term->vt.last_printed);
+
if (width > 0) {
for (int i = 0; i < count; i++)
term_print(term, term->vt.last_printed, width, false);