diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-04-15 19:35:56 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-04-15 19:35:56 +0100 |
commit | 394d6f5401cd79eb7b1624d23f3d8f4804144c78 (patch) | |
tree | 7861532a671a3c5e629e8242bc607648826aef85 /ttystatus/counter.py | |
parent | 1623d3599bd057677158bfd2167798585d2afc44 (diff) | |
parent | 1a4675e03b42fcf276cf6a160480010cb36ca88c (diff) | |
download | python-ttystatus-394d6f5401cd79eb7b1624d23f3d8f4804144c78.tar.gz |
Fix a lot of rendering bugs by fixing internal abstration
Previously, we told update() how much width there was, but that
meant update() also had to render. That was slow. Then we fixed
that by only updating when it was time to update the display,
but that obviously doesn't work either. And when I say obviously,
I didn't think of it at the time. Now, this should work, since
we always update the values, so counters etc get incremented
correctly, but then only do the actual rendering when it's actually
time to actually write actual text to actual output. Actually.
Diffstat (limited to 'ttystatus/counter.py')
-rw-r--r-- | ttystatus/counter.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ttystatus/counter.py b/ttystatus/counter.py index 5d3e11f..d37ed90 100644 --- a/ttystatus/counter.py +++ b/ttystatus/counter.py @@ -21,16 +21,17 @@ class Counter(ttystatus.Widget): '''Display a count of how many times a value has changed.''' + static_width = False + def __init__(self, name): self.name = name self.prev = None self.count = 0 - self.interesting_keys = [name] - def format(self): + def render(self, width): return str(self.count) - def update(self, master, width): + def update(self, master): if master[self.name] != self.prev: self.prev = master[self.name] self.count += 1 |