diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-28 17:29:12 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-28 17:54:08 +0200 |
commit | 9c257361388f5007871a36eea3abc815a8740d66 (patch) | |
tree | 3c9494ecfa6467438043402594bb2d2b7bd262eb /src/utils | |
parent | 1bbad9a452390ebc09d038e25ed0307f3fdcd312 (diff) | |
download | chawan-9c257361388f5007871a36eea3abc815a8740d66.tar.gz |
container: fix control char display
Also, kill twidth and its friends; we haven't been using it for a while now. (In the future, a solution with PUA chars might be worth exploring.)
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/strwidth.nim | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/utils/strwidth.nim b/src/utils/strwidth.nim index 4ce9aa12..df84dbad 100644 --- a/src/utils/strwidth.nim +++ b/src/utils/strwidth.nim @@ -27,17 +27,10 @@ func width*(u: uint32): int = return 2 return 1 -# Width, but also works with tabs. -# Needs the column width of the text so far. -func twidth*(u: uint32; w: int): int = - if u != uint32('\t'): - return u.width() - return ((w div 8) + 1) * 8 - w - func width*(s: openArray[char]): int = var w = 0 for u in s.points: - w += u.twidth(w) + w += u.width() return w func width*(s: string; start, len: int): int = @@ -48,21 +41,9 @@ func width*(s: string; start, len: int): int = m = s.len while i < m: let u = s.nextUTF8(i) - w += u.twidth(w) - return w - -func notwidth*(s: openArray[char]): int = - var w = 0 - for u in s.points: w += u.width() return w -func twidth*(s: string; w: int): int = - var i = w - for u in s.points: - i += u.twidth(w) - return i - w - func padToWidth*(s: string; size: int; schar = '$'): string = result = newStringOfCap(s.len) var w = 0 |