[jhbuild] Fix status line in quiet mode
- From: Craig Keogh <cskeogh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] Fix status line in quiet mode
- Date: Wed, 24 Nov 2010 10:24:11 +0000 (UTC)
commit f94138a12c98b7919413706656ddce3561bb08eb
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Sat Oct 16 01:35:03 2010 +0200
Fix status line in quiet mode
Avoid corruption of the status line by taking into account control
characters when calculating string lengths.
jhbuild/frontends/terminal.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/jhbuild/frontends/terminal.py b/jhbuild/frontends/terminal.py
index 0d8a29f..3ee387d 100644
--- a/jhbuild/frontends/terminal.py
+++ b/jhbuild/frontends/terminal.py
@@ -128,12 +128,13 @@ class TerminalBuildScript(buildscript.BuildScript):
module_pos = '[' + format_str % module_num + '/' + format_str % len(self.modulelist) + ']'
output = '%s %s %s%s%s' % (progress_bar, module_pos, t_bold, message, t_reset)
- if len(output) > columns:
- output = output[:columns]
+ text_width = len(output) - (len(t_bold) + len(t_reset))
+ if text_width > columns:
+ output = output[:columns+len(t_bold)] + t_reset
else:
- output += ' ' * (columns-len(output))
+ output += ' ' * (columns-text_width)
- sys.stdout.write(output + '\r')
+ sys.stdout.write('\r'+output)
if self.is_end_of_build:
sys.stdout.write('\n')
sys.stdout.flush()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]