diff options
author | dbosst <dbosst@gmail.com> | 2018-03-27 21:41:12 -0400 |
---|---|---|
committer | dbosst <dbosst@gmail.com> | 2018-03-27 21:41:12 -0400 |
commit | 88b5a20142f3c7666a78ec86db667635681adc9f (patch) | |
tree | 5e1b8bbfbdfcb2fd818dcefbebabd62ef960f6e9 | |
parent | f855979587bd918f0d32c0caba79ab4b4aa531cf (diff) | |
download | ranger-88b5a20142f3c7666a78ec86db667635681adc9f.tar.gz |
Added: shift tabs right/left
shift selected tab right/left with ALT-p or ALT-o
-rw-r--r-- | ranger/config/rc.conf | 2 | ||||
-rw-r--r-- | ranger/core/actions.py | 28 |
2 files changed, 30 insertions, 0 deletions
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 <a-6> tab_open 6 map <a-7> tab_open 7 map <a-8> tab_open 8 map <a-9> tab_open 9 +map <a-p> tab_shift 1 +map <a-o> 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. |