reimplement stripAnsi

This commit is contained in:
Daylin Morgan 2024-09-30 13:46:43 -05:00
parent efaf252305
commit f8f62e263d
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -16,10 +16,14 @@ func stripAnsi*(s: string): string =
var i: int
while i < s.len:
if s[i] == '\e':
while s[i] != 'm':
inc i
inc i
if i < s.len:
if i < s.len and s[i] == '[':
inc i
while i < s.len and not (s[i] in {'A'..'Z','a'..'z'}):
inc i
else:
result.add s[i-1]
else:
result.add s[i]
inc i