mirror of https://github.com/tqdm/tqdm.git
Recognize wide characters in description
… by using unicodedata.east_asian_width. Co-authored-by: RedBug312 <redbug312@gmail.com>
This commit is contained in:
parent
825f7dc7ea
commit
124d72a4e3
|
@ -490,7 +490,7 @@ class tqdm(Comparable):
|
|||
return nobar
|
||||
full_bar = Bar(
|
||||
0,
|
||||
max(1, ncols - len(RE_ANSI.sub('', nobar))) if ncols else 10,
|
||||
max(1, ncols - _text_width(RE_ANSI.sub('', nobar))) if ncols else 10,
|
||||
charset=Bar.BLANK)
|
||||
return bar_format.format(bar=full_bar, **format_dict)
|
||||
else:
|
||||
|
|
|
@ -286,6 +286,7 @@ def _term_move_up(): # pragma: no cover
|
|||
|
||||
|
||||
def _text_width(s): # pragma: no cover
|
||||
# TODO consider using wcswidth third-party package for 0-width characters
|
||||
try:
|
||||
from unicodedata import east_asian_width
|
||||
except ImportError:
|
||||
|
|
Loading…
Reference in New Issue