diff options
Diffstat (limited to 'src/wcwidth.py')
-rw-r--r-- | src/wcwidth.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wcwidth.py b/src/wcwidth.py index b72c3ca3..bb0c456e 100644 --- a/src/wcwidth.py +++ b/src/wcwidth.py @@ -233,6 +233,22 @@ def wcswidth(s): width += w return width +def wcsislonger(s, l): + """ + Returns the same result than "wcswidth(s) > l" but + is faster. + """ + width = 0 + for c in s: + w = wcwidth(c) + if w < 0: + return -1 + else: + width += w + if width > l: + return True + return False + def widthcut(s, m): """ Return the first characters of s that can be contained in |