From 2e8a1516f3c9295cafe50f748078ace5685d8342 Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Mon, 15 Dec 2014 22:15:10 +0100 Subject: Add a 'cycle' option to direction This allows to loop on a file list, going at the other side of the list when trying to go beyond the boundaries. --- ranger/ext/direction.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 4b20ea0d..bd00fa6b 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -81,6 +81,9 @@ class Direction(dict): def percentage(self): return 'percentage' in self and self['percentage'] + def cycle(self): + return self.get('cycle') + def multiply(self, n): for key in ('up', 'right', 'down', 'left'): try: @@ -126,6 +129,8 @@ class Direction(dict): pos += maximum else: pos += current + if self.cycle(): + return minimum + pos % (maximum + offset - minimum) return int(max(min(pos, maximum + offset - 1), minimum)) def select(self, lst, current, pagesize, override=None, offset=1): -- cgit 1.4.1-2-gfad0