From 88b5a20142f3c7666a78ec86db667635681adc9f Mon Sep 17 00:00:00 2001 From: dbosst Date: Tue, 27 Mar 2018 21:41:12 -0400 Subject: Added: shift tabs right/left shift selected tab right/left with ALT-p or ALT-o --- ranger/config/rc.conf | 2 ++ ranger/core/actions.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index fe00c7c0..8ac83cd3 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -478,6 +478,8 @@ map tab_open 6 map tab_open 7 map tab_open 8 map tab_open 9 +map tab_shift 1 +map tab_shift -1 # Sorting map or set sort_reverse! diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6bbb35aa..68551775 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1191,6 +1191,34 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m return self.tab_open(i, path) 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. -- cgit 1.4.1-2-gfad0