From 5caf2ea4544b3d844310720f456c8022b9886528 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 2 Jul 2014 11:05:19 +0200 Subject: do not crash in partial_clear if lines are too long MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/__main__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/__main__.py b/src/__main__.py index c502d7c..352851a 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -394,7 +394,8 @@ class Bar: for line in text.split('\n'): if '\0' not in line: x_ = Bar.coloured_length(line) - areas.append((x + x_, y, width - x_, line_height)) + if width > x_: + areas.append((x + x_, y, width - x_, line_height)) else: areas_ = [] parts = line.split('\0') @@ -402,11 +403,13 @@ class Bar: for part in parts: w = Bar.coloured_length(part) * self.font_width x_ = int((width - w) * i / n) - areas_.append((x_, x_ + w)) + if w > 0: + areas_.append((x_, x_ + w)) i += 1 x1 = areas_[0][1] for x2, x3 in areas_[1:]: - areas.append((x + x1, y, x2 - x1, line_height)) + if x2 > x1: + areas.append((x + x1, y, x2 - x1, line_height)) x1 = x3 y += line_height -- cgit v1.2.3-70-g09d2