diff options
-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': |