summaryrefslogtreecommitdiff
path: root/alot/widgets.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-08-27 22:04:59 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-08-27 22:04:59 +0100
commita32214f88f41c4919272780412976c8994838d09 (patch)
tree7105d9af07ed985bf46ae6597f2983f2b3b0e46b /alot/widgets.py
parent744e86bbaa5f521908100f4fd3c8b8fc43a894f4 (diff)
parent4ea9ef9dab9202149e851ef1bfff2b3cb29a34d2 (diff)
Merge branch 'develop' into addressbook
Diffstat (limited to 'alot/widgets.py')
-rw-r--r--alot/widgets.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/alot/widgets.py b/alot/widgets.py
index 690c6260..2b811146 100644
--- a/alot/widgets.py
+++ b/alot/widgets.py
@@ -59,7 +59,7 @@ class ThreadlineWidget(urwid.AttrMap):
for tag in tags:
tw = TagWidget(tag)
self.tag_widgets.append(tw)
- cols.append(('fixed', tw.len(), tw))
+ cols.append(('fixed', tw.width(), tw))
authors = self.thread.get_authors() or '(None)'
maxlength = config.getint('general', 'authors_maxlength')
@@ -138,16 +138,17 @@ class BufferlineWidget(urwid.Text):
class TagWidget(urwid.AttrMap):
def __init__(self, tag):
self.tag = tag
- self.translated = config.get('tag translate', tag, fallback=tag)
- # encode to utf-8 before passing to urwid (issue #4)
+ self.translated = config.get('tag-translate', tag, fallback=tag)
self.translated = self.translated.encode('utf-8')
- txt = urwid.Text(self.translated, wrap='clip')
+ self.txt = urwid.Text(self.translated, wrap='clip')
normal = config.get_tagattr(tag)
focus = config.get_tagattr(tag, focus=True)
- urwid.AttrMap.__init__(self, txt, normal, focus)
+ urwid.AttrMap.__init__(self, self.txt, normal, focus)
- def len(self):
- return len(self.translated)
+ def width(self):
+ # evil voodoo hotfix for double width chars that may
+ # lead e.g. to strings with length 1 that need width 2
+ return self.txt.pack()[0]
def selectable(self):
return True
@@ -442,8 +443,8 @@ class MessageHeaderWidget(urwid.AttrMap):
else:
value = value + v
#sanitize it a bit:
- value = value.replace('\t', '')
- value = value.replace('\r', '')
+ value = value.replace('\t', ' ')
+ value = ' '.join([line.strip() for line in value.splitlines()])
keyw = ('fixed', max_key_len + 1,
urwid.Text(('message_header_key', key)))
valuew = urwid.Text(('message_header_value', value))