diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2010-05-25 16:24:44 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2010-05-25 16:24:44 +0200 |
commit | 5be7570ee85e2961a7a25fec6f30fff3c0437da2 (patch) | |
tree | 6ca8eda4d06da84d683ce306a2db7db5448e2cff /sphinx/util/console.py | |
parent | 9b9d188ded7631ae2f206046f5bd78773068c963 (diff) | |
download | sphinx-git-5be7570ee85e2961a7a25fec6f30fff3c0437da2.tar.gz |
Fixed console.py function term_width_line() issue. #423
Diffstat (limited to 'sphinx/util/console.py')
-rw-r--r-- | sphinx/util/console.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sphinx/util/console.py b/sphinx/util/console.py index bd2851fa4..381803bce 100644 --- a/sphinx/util/console.py +++ b/sphinx/util/console.py @@ -11,7 +11,9 @@ import os import sys +import re +_strip_core_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm') codes = {} def get_terminal_width(): @@ -29,14 +31,15 @@ def get_terminal_width(): terminal_width = int(os.environ.get('COLUMNS', 80)) - 1 return terminal_width -_tw = get_terminal_width() +_tw = get_terminal_width() def term_width_line(text): if not codes: # if no coloring, don't output fancy backspaces return text + '\n' else: - return text.ljust(_tw) + '\r' + # codes are not displayed and must be taken into account by introducing the correction factor + return text.ljust(_tw + len(text) - len(_strip_core_re.sub('', text))) + '\r' def color_terminal(): if not hasattr(sys.stdout, 'isatty'): |