diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-08-09 14:51:40 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-08-09 14:51:40 +0100 |
commit | 5628dc0fbfff945f55229c6bc5845e4e456eda8e (patch) | |
tree | cbff7313e3eaa523be2ef83856f9eaa73edf94de /alot/walker.py | |
parent | 4183ba5acf8b3d292dbe53a52a98e50ee3324b3a (diff) |
explicit direction in PipeWalker
This allows to instanciate the walker as "reversed", i.e.,
makes the list grow from bottom up instead of top down.
Diffstat (limited to 'alot/walker.py')
-rw-r--r-- | alot/walker.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/alot/walker.py b/alot/walker.py index d1d0a898..beaf255e 100644 --- a/alot/walker.py +++ b/alot/walker.py @@ -9,13 +9,14 @@ class PipeWalker(urwid.ListWalker): """urwid.ListWalker that reads next items from a pipe and wraps them in `containerclass` widgets for displaying """ - def __init__(self, pipe, containerclass, **kwargs): + def __init__(self, pipe, containerclass, reverse=False, **kwargs): self.pipe = pipe self.kwargs = kwargs self.containerclass = containerclass self.lines = [] self.focus = 0 self.empty = False + self.direction = -1 if reverse else 1 def __contains__(self, name): return self.lines.__contains__(name) @@ -28,10 +29,10 @@ class PipeWalker(urwid.ListWalker): self._modified() def get_next(self, start_from): - return self._get_at_pos(start_from + 1) + return self._get_at_pos(start_from + self.direction) def get_prev(self, start_from): - return self._get_at_pos(start_from - 1) + return self._get_at_pos(start_from - self.direction) def remove(self, obj): next_focus = self.focus % len(self.lines) |