summary refs log tree commit diff stats
diff options
context:
space:
mode:
authordbosst <dbosst@gmail.com>2018-03-27 21:41:12 -0400
committertoonn <toonn@toonn.io>2018-08-22 19:42:46 +0200
commitfe999acb75d2e5bf8bee401afb98589e530b57da (patch)
treeb359900b825a6e55b4130aa5ca803d9602fa5198
parent1d8c5e6e4d5090bc5c45b5ad0eecbe0113772614 (diff)
downloadranger-fe999acb75d2e5bf8bee401afb98589e530b57da.tar.gz
Added: shift tabs right/left
shift selected tab right/left with ALT-p or ALT-o
-rw-r--r--ranger/core/actions.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 55226434..5a1ea258 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1244,6 +1244,34 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             self.signal_emit('tab.layoutchange')
         return None
 
+    def tab_shift(self, offset):
+        """Shift the tab left/right
+
+        Shift the current tab to the left or right
+        """
+        assert isinstance(offset, int)
+        tablist = self.get_tab_list()
+        oldtab_index = self.current_tab
+        old_index = tablist.index(oldtab_index)
+        new_index = (old_index + offset)
+        if new_index < 0:
+            return None
+        if new_index > (len(tablist)-1):
+            return None
+        newtab_index = tablist[new_index]
+        if newtab_index != oldtab_index:
+            oldtab = self.tabs[oldtab_index]
+            newtab = self.tabs[newtab_index]
+            self.tabs[oldtab_index] = newtab
+            self.tabs[newtab_index] = oldtab
+            self.current_tab = newtab_index
+            self.thistab = oldtab
+            self.change_mode('normal')
+            self.signal_emit('tab.change', old=oldtab, new=newtab)
+            self.signal_emit('tab.change', old=newtab, new=oldtab)
+            self.signal_emit('tab.layoutchange')
+        return None
+
     def tab_switch(self, path, create_directory=False):
         """Switches to tab of given path, opening a new tab as necessary.