diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-02 23:53:13 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-03 13:50:19 +0000 |
commit | c841d22dd703978109a6fa855dc22b444a2896a9 (patch) | |
tree | 99d50ea259d70d2bc087759d2f5d76de3336544a /alot | |
parent | 60fc46c2e5d5d7ae8d447a86abea0cde7197408a (diff) |
make thread.move parent message-based
Diffstat (limited to 'alot')
-rw-r--r-- | alot/buffers.py | 14 | ||||
-rw-r--r-- | alot/commands/thread.py | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index 0c5d09a6..ac91f30f 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -342,6 +342,9 @@ class ThreadBuffer(Buffer): self.body = TreeBox(self._nested_tree) self.message_count = self.thread.get_total_messages() + def get_selected_mid(self): + return self.body.get_focus()[1][0] + def get_selected_messagetree(self): """returns currently focussed :class:`MessageTree`""" return self._nested_tree[self.body.get_focus()[1][:1]] @@ -367,9 +370,20 @@ class ThreadBuffer(Buffer): def get_focus(self): return self.body.get_focus() + def get_focus_position(self): + return self._sanitize_position((self.get_selected_mid(),)) + def focus_first(self): self.body.set_focus(self._nested_tree.root) + def _sanitize_position(self, pos): + return self._nested_tree._sanitize_position(pos, self._nested_tree._tree) + + def focus_parent(self): + mid = self.get_selected_mid() + newpos = self._tree.parent_position(mid) + self.body.set_focus(self._sanitize_position((newpos,))) + def expand(self, msgpos): MT = self._tree[msgpos] MT.expand(MT.root) diff --git a/alot/commands/thread.py b/alot/commands/thread.py index ce8189c8..23fcf786 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -834,10 +834,11 @@ class OpenAttachmentCommand(Command): 'help':'up, down, page up, page down, first'})]) class MoveFocusCommand(MoveCommand): def apply(self, ui): + # TODO: use thread here to move in topmost message subtree only logging.debug(self.movement) tbox = ui.current_buffer.body if self.movement == 'parent': - tbox.focus_parent() + ui.current_buffer.focus_parent() elif self.movement == 'first reply': tbox.focus_first_child() elif self.movement == 'last reply': |