vt: cache grapheme cluster width in composed struct

* Use regular wcswidth() to calculate the width
* Explicitly set to ‘2’ if we see a emoji variant selector
* Cache the result in the composed struct
This commit is contained in:
Daniel Eklöf 2021-05-27 20:07:28 +02:00
parent b9ef703eb1
commit 0a9531ac6c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 11 additions and 12 deletions

8
util.h
View file

@ -35,11 +35,3 @@ sdbm_hash(const char *s)
return hash;
}
#include <wchar.h>
static inline int
my_wcswidth(const wchar_t *s, size_t n)
{
int ret = wcswidth(s, n);
return max(0, ret);
}