diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-07-12 19:18:03 +1200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-07-12 19:18:03 +1200 |
commit | d1d4231a36d620031a247bac7e4f768c78120e41 (patch) | |
tree | 5de1fc3312036cc6eb3c01118413eec5af7b522e | |
parent | e4f843d0ab595a97f30ed6d480814b86891e0c3d (diff) | |
download | python-ttystatus-d1d4231a36d620031a247bac7e4f768c78120e41.tar.gz |
Re-draw all widgets if terminal width changes.
-rw-r--r-- | ttystatus/status.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ttystatus/status.py b/ttystatus/status.py index 138b615..e96666b 100644 --- a/ttystatus/status.py +++ b/ttystatus/status.py @@ -49,6 +49,7 @@ class TerminalStatus(object): self._values = dict() self._interests = dict() self._wildcards = list() + self._latest_width = None self._m.clear() def __getitem__(self, key): @@ -63,7 +64,12 @@ class TerminalStatus(object): '''Set value for key.''' self._values[key] = value width = self._m.width - for w in self._interests.get(key, []) + self._wildcards: + if width != self._latest_width: + widgets = self._widgets + self._latest_width = width + else: + widgets = self._interests.get(key, []) + self._wildcards + for w in widgets: w.update(self, width) width -= len(str(w)) if self._m.time_to_write(): |