diff options
author | pazz <patricktotzke@gmail.com> | 2011-08-04 22:45:49 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-08-04 22:45:49 +0100 |
commit | 41de892d94d1e53ef4226ad2b96e2f361c62db60 (patch) | |
tree | e4868e27adff0cd30516726a87d5b6c38adf3d78 | |
parent | 0b6a640eabf107777c68a5689af44b744b387335 (diff) |
fold command
-rw-r--r-- | alot/buffer.py | 9 | ||||
-rw-r--r-- | alot/command.py | 23 | ||||
-rw-r--r-- | alot/widgets.py | 5 |
3 files changed, 36 insertions, 1 deletions
diff --git a/alot/buffer.py b/alot/buffer.py index 4ffb449d..03e13387 100644 --- a/alot/buffer.py +++ b/alot/buffer.py @@ -217,10 +217,17 @@ class ThreadBuffer(Buffer): msglines.append(mwidget) self.body = urwid.ListBox(msglines) - def get_selected_message(self): + def get_selection(self): (messagewidget, size) = self.body.get_focus() + return messagewidget + + def get_selected_message(self): + messagewidget = self.get_selection() return messagewidget.get_message() + def get_message_widgets(self): + return self.body.body.contents + class TagListBuffer(Buffer): def __init__(self, ui, alltags=[], filtfun=None): diff --git a/alot/command.py b/alot/command.py index 804604b4..469ed062 100644 --- a/alot/command.py +++ b/alot/command.py @@ -597,6 +597,23 @@ class BounceMailCommand(Command): ui.apply_command(ComposeCommand(mail=mail)) +class FoldMessagesCommand(Command): + def __init__(self, all=False, visible=True, **kwargs): + self.all = all + self.visible = visible + Command.__init__(self, **kwargs) + + def apply(self, ui): + if not self.all: + msg_wg = ui.current_buffer.get_selection() + msg_wg.fold(self.visible) + else: + for widget in ui.current_buffer.get_message_widgets(): + widget.fold(self.visible) + + + + ### ENVELOPE class EnvelopeOpenCommand(Command): def __init__(self, mail=None, **kwargs): @@ -751,6 +768,8 @@ COMMANDS = { 'groupreply': (ReplyCommand, {'groupreply': True}), 'forward': (ForwardCommand, {}), 'bounce': (BounceMailCommand, {}), + 'fold': (FoldMessagesCommand, {'visible': True}), + 'unfold': (FoldMessagesCommand, {'visible': False}), }, 'global': { 'bnext': (BufferFocusCommand, {'offset': 1}), @@ -849,6 +868,10 @@ def interpret_commandline(cmdline, mode): return commandfactory(cmd, mode=mode, key='To', value=params) elif cmd == 'toggletag': return commandfactory(cmd, mode=mode, tag=params) + elif cmd == 'fold': + return commandfactory(cmd, mode=mode, all=(params=='all')) + elif cmd == 'unfold': + return commandfactory(cmd, mode=mode, all=(params=='all')) elif cmd == 'edit': filepath = os.path.expanduser(params) if os.path.isfile(filepath): diff --git a/alot/widgets.py b/alot/widgets.py index 9854e44d..8f8a5bbe 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -336,6 +336,11 @@ class MessageWidget(urwid.WidgetWrap): self.sumw.toggle_folded() self.rebuild() + #TODO: toggle header/body should call this.. + def fold(self, visible=True): + self.toggle_body() + self.toggle_header() + def selectable(self): return True |