summaryrefslogtreecommitdiff
path: root/alot/command.py
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-08-06 13:31:03 +0100
committerpazz <patricktotzke@gmail.com>2011-08-06 13:31:03 +0100
commit55b062c5198b2d9d3eb550932edcebd5318c7e43 (patch)
tree8fdbe503a953e9222607ae73420c7790e8c062b2 /alot/command.py
parentbb0e91ec4709164c8cf7124cbde060de551790ef (diff)
handle keystrokes myself befor urwid does
Diffstat (limited to 'alot/command.py')
-rw-r--r--alot/command.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/alot/command.py b/alot/command.py
index 523d9c74..7161971f 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -31,6 +31,7 @@ from email.header import Header
import buffer
import settings
+import widgets
from db import DatabaseROError
from db import DatabaseLockedError
from completion import ContactsCompleter
@@ -602,13 +603,33 @@ class FoldMessagesCommand(Command):
for widget in lines:
# in case the thread is yet unread, remove this tag
msg = widget.get_message()
- if 'unread' in msg.get_tags():
+ if 'unread' in msg.get_tags() and self.visible:
msg.remove_tags(['unread'])
ui.apply_command(FlushCommand())
widget.rebuild()
widget.fold(self.visible)
+class OpenAttachmentCommand(Command):
+ def __init__(self, attachment, **kwargs):
+ Command.__init__(self, **kwargs)
+ self.attachment = attachment
+
+ def apply(self, ui):
+ lines = []
+#save to tmpfile
+#find out mimehandler
+#eternalcommand
+
+class ThreadSelectCommand(Command):
+ def apply(self, ui):
+ focus = ui.get_deep_focus()
+ if isinstance(focus, widgets.MessageSummaryWidget):
+ ui.apply_command(FoldMessagesCommand())
+ elif isinstance(focus, widgets.AttachmentWidget):
+ ui.apply_command(OpenAttachmentCommand(focus.get_attachment()))
+
+
### ENVELOPE
class EnvelopeOpenCommand(Command):
"""open a new envelope buffer"""
@@ -765,6 +786,7 @@ COMMANDS = {
'forward': (ForwardCommand, {}),
'fold': (FoldMessagesCommand, {'visible': True}),
'unfold': (FoldMessagesCommand, {'visible': False}),
+ 'select': (ThreadSelectCommand, {}),
},
'global': {
'bnext': (BufferFocusCommand, {'offset': 1}),
@@ -811,7 +833,7 @@ def interpret_commandline(cmdline, mode):
if not cmdline:
return None
logging.debug('mode:%s got commandline "%s"' % (mode, cmdline))
- args = cmdline.strip().split(' ', 1)
+ args = cmdline.split(' ', 1)
cmd = args[0]
if args[1:]:
params = args[1]
@@ -862,7 +884,7 @@ def interpret_commandline(cmdline, mode):
elif not params and cmd in ['exit', 'flush', 'pyshell', 'taglist', 'close',
'compose', 'openfocussed', 'closefocussed',
'bnext', 'bprevious', 'retag', 'refresh',
- 'bufferlist', 'refineprompt', 'reply',
+ 'bufferlist', 'refineprompt', 'reply', 'open',
'forward', 'groupreply', 'bounce', 'openthread',
'send', 'reedit', 'select', 'retagprompt']:
return commandfactory(cmd, mode=mode)