diff options
Diffstat (limited to 'ttystatus/pathname.py')
-rw-r--r-- | ttystatus/pathname.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/ttystatus/pathname.py b/ttystatus/pathname.py index ac51a31..0f5fb43 100644 --- a/ttystatus/pathname.py +++ b/ttystatus/pathname.py @@ -27,13 +27,21 @@ class Pathname(ttystatus.Widget): def __init__(self, key): self._key = key - - def update(self, master, width): - v = master.get(self._key, '') - if len(v) > width: + self.interesting_keys = [key] + self.pathname = '' + self.width = 0 + + def format(self): + v = self.pathname + if len(v) > self.width: ellipsis = '...' - if len(ellipsis) < width: - v = ellipsis + v[-(width - len(ellipsis)):] + if len(ellipsis) < self.width: + v = ellipsis + v[-(self.width - len(ellipsis)):] else: - v = v[-width:] - self.value = v + v = v[-self.width:] + return v + + def update(self, master, width): + self.pathname = master.get(self._key, '') + self.width = width + |