Browse Source

Merge pull request #70 from luchr/align_problem

Fix: TTkString alignment (at _hasSpecialWidth)
pull/74/head
Ceccopierangiolieugenio 3 years ago committed by GitHub
parent
commit
59ff68daf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      TermTk/TTkCore/string.py

7
TermTk/TTkCore/string.py

@ -309,9 +309,12 @@ class TTkString():
rt = ""
sz = 0
for ch in self._text:
rt += ch
if unicodedata.category(ch) in ('Me','Mn'):
rt += ch
continue
sz += 2 if unicodedata.east_asian_width(ch) == 'W' else 1
if sz == width:
ret._text = rt
ret._colors = self._colors[:len(rt)]
@ -321,8 +324,6 @@ class TTkString():
ret._colors = self._colors[:len(ret._text)]
ret._colors[-1] = TTkCfg.theme.unicodeWideOverflowColor
break
rt += ch
sz += 2 if unicodedata.east_asian_width(ch) == 'W' else 1
else:
# Legacy, trim the string
ret._text = self._text[:width]

Loading…
Cancel
Save