summaryrefslogtreecommitdiff
path: root/ttystatus/pathname.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-07-07 09:41:19 +1200
committerLars Wirzenius <liw@liw.fi>2010-07-07 09:41:19 +1200
commit139e35b55938060d80e04750fc36229635fde587 (patch)
treefdd8b7ce20622f8df2d52274659895b8c7937410 /ttystatus/pathname.py
parent56f628bb3d49a52c6e5ee1360b520c6381ebd510 (diff)
parente6618ad0ed66ed459a55ecd903a5627dacf97915 (diff)
downloadpython-ttystatus-139e35b55938060d80e04750fc36229635fde587.tar.gz
Merge optimizations.
Diffstat (limited to 'ttystatus/pathname.py')
-rw-r--r--ttystatus/pathname.py24
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
+