diff options
author | bptato <nincsnevem662@gmail.com> | 2022-07-23 16:54:02 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-07-23 17:39:06 +0200 |
commit | e7b53775a3f52cb5d8da865213c5dc38b954e33c (patch) | |
tree | 200741f8ed965f407c1a6af8823705db133bf3d4 /src/utils | |
parent | c7f25b2fe470849e028f9502d3da0851f149f065 (diff) | |
download | chawan-e7b53775a3f52cb5d8da865213c5dc38b954e33c.tar.gz |
Improved incremental search: support unicode
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/twtstr.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 4937d0be..c88c5980 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -867,6 +867,15 @@ func width*(s: string): int = for r in s.runes(): result += width(r) +func width*(s: string, len: int): int = + var i = 0 + var m = len + if m > s.len: m = s.len + while i < m: + var r: Rune + fastRuneAt(s, i, r) + result += width(r) + func width*(s: seq[Rune]): int = for r in s: result += width(r) |