aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-07-02 11:05:19 +0200
committerMattias Andrée <maandree@operamail.com>2014-07-02 11:05:19 +0200
commit5caf2ea4544b3d844310720f456c8022b9886528 (patch)
tree5653ec9f18ae555683dd2108a31976cdc432bfd2 /src
parentreduce flicker (diff)
downloadxpybar-5caf2ea4544b3d844310720f456c8022b9886528.tar.gz
xpybar-5caf2ea4544b3d844310720f456c8022b9886528.tar.bz2
xpybar-5caf2ea4544b3d844310720f456c8022b9886528.tar.xz
do not crash in partial_clear if lines are too long1.3.1
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/__main__.py9
1 files 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