summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorEmanuel Guevel <guevel.emanuel@gmail.com>2014-12-15 22:15:10 +0100
committerEmanuel Guevel <guevel.emanuel@gmail.com>2014-12-15 22:15:10 +0100
commit2e8a1516f3c9295cafe50f748078ace5685d8342 (patch)
tree078e15aa811a0209bf5f632e48b5bc9a43577d4e /ranger
parent20ea71805beafe299b707be7a570dfa94117b6cc (diff)
downloadranger-2e8a1516f3c9295cafe50f748078ace5685d8342.tar.gz
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.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/ext/direction.py5
1 files changed, 5 insertions, 0 deletions
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):