mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
vt: don’t call wcwidth() on all combining characters every time we add
We already have all the widths needed to calculate the new one; it’s the base characters width (base_width), or the previous combining chain’s width (composed->width) plus the new characters’s width (width).
This commit is contained in:
parent
09431dd15c
commit
57e636dd8e
1 changed files with 7 additions and 11 deletions
18
vt.c
18
vt.c
|
|
@ -700,7 +700,7 @@ action_utf8_print(struct terminal *term, wchar_t wc)
|
|||
if (cc->count != wanted_count)
|
||||
continue;
|
||||
|
||||
if (cc->chars[0] != base)
|
||||
if (cc->chars[0] != base)
|
||||
continue;
|
||||
|
||||
bool match = true;
|
||||
|
|
@ -732,16 +732,12 @@ action_utf8_print(struct terminal *term, wchar_t wc)
|
|||
new_cc.chars[wanted_count - 1] = wc;
|
||||
|
||||
if (term->composed_count < CELL_COMB_CHARS_HI) {
|
||||
int grapheme_width = wcwidth(base);
|
||||
int min_grapheme_width = 0;
|
||||
for (size_t i = 0; i < wanted_count; i++) {
|
||||
wchar_t c = new_cc.chars[i];
|
||||
if (c == 0xfe0f)
|
||||
min_grapheme_width = 2;
|
||||
grapheme_width += wcwidth(c);
|
||||
}
|
||||
|
||||
new_cc.width = max(grapheme_width, min_grapheme_width);
|
||||
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;
|
||||
|
||||
term->composed_count++;
|
||||
term->composed = xrealloc(term->composed, term->composed_count * sizeof(term->composed[0]));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue