fix(ui): fix tabs not being spaced properly after virtual text with no wrap

also fixes incorrect skipping of multibyte characters
This commit is contained in:
Ibby
2023-04-12 18:21:46 +10:00
committed by bfredl
parent 7423d3479d
commit 5d7afb2e9f
3 changed files with 63 additions and 6 deletions

View File

@@ -2024,6 +2024,24 @@ int mb_charlen(const char *str)
return count;
}
int mb_charlen2bytelen(const char *str, int charlen)
{
const char *p = str;
int count = 0;
if (p == NULL) {
return 0;
}
for (int i = 0; *p != NUL && i < charlen; i++) {
int b = utfc_ptr2len(p);
p += b;
count += b;
}
return count;
}
/// Like mb_charlen() but for a string with specified length.
int mb_charlen_len(const char *str, int len)
{