diff options
author | hut <hut@lavabit.com> | 2010-04-06 01:54:46 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-06 01:54:46 +0200 |
commit | 1ee34606450cabd86a62ca5992775729e9dd098a (patch) | |
tree | b5990faf7987c5cdabe2b20ac087ec690339c610 /ranger | |
parent | 85a9a41ebf4092e33cb1d176b94d427c01a10e32 (diff) | |
download | ranger-1ee34606450cabd86a62ca5992775729e9dd098a.tar.gz |
Improved tabs
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/actions.py | 25 | ||||
-rw-r--r-- | ranger/defaults/keys.py | 1 | ||||
-rw-r--r-- | ranger/gui/widgets/titlebar.py | 7 | ||||
-rw-r--r-- | ranger/help/movement.py | 1 |
4 files changed, 23 insertions, 11 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index d52dac2b..b40febc8 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -428,12 +428,15 @@ class Actions(EnvironmentAware, SettingsAware): def _get_tab_list(self): return sorted(self.tabs) - def tab_open(self, name): - if name in self.tabs: - self.current_tab = name - self.enter_dir(self.tabs[name], remember=False) + def tab_open(self, name, path=None): + do_emit_signal = name != self.current_tab + self.current_tab = name + if path or (name in self.tabs): + self.enter_dir(path or self.tabs[name]) else: - self.tab_new(name) + self._update_current_tab() + if do_emit_signal: + self.signal_emit('tab.change') def tab_close(self, name=None): if name is None: @@ -454,12 +457,12 @@ class Actions(EnvironmentAware, SettingsAware): if newtab != self.current_tab: self.tab_open(newtab) - def tab_new(self, name, path=None): - self.current_tab = name - if path: - self.enter_dir(path, remember=False) - else: - self._update_current_tab() + def tab_new(self): + for i in range(10): + i = (i + 1) % 10 + if not i in self.tabs: + self.tab_open(i) + break def _update_current_tab(self): self.tabs[self.current_tab] = self.env.cwd.path diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 9be42a78..63e09dfd 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -170,6 +170,7 @@ def initialize_commands(map): map('gc', ctrl('W'), fm.tab_close()) map('gt', TAB, fm.tab_move(1)) map('gT', KEY_BTAB, fm.tab_move(-1)) + map('gn', ctrl('N'), fm.tab_new()) for n in range(10): map('g' + str(n), fm.tab_open(n)) diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index 4bd15e0f..c643b8a8 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -33,6 +33,13 @@ class TitleBar(Widget): need_redraw = False tab_width = 0 + def __init__(self, *args, **keywords): + Widget.__init__(self, *args, **keywords) + self.fm.signal_bind('tab.change', self.request_redraw, weak=True) + + def request_redraw(self): + self.need_redraw = True + def draw(self): if self.need_redraw or \ self.env.cf != self.old_cf or\ diff --git a/ranger/help/movement.py b/ranger/help/movement.py index e9dd6fad..df5021f2 100644 --- a/ranger/help/movement.py +++ b/ranger/help/movement.py @@ -142,6 +142,7 @@ In Ranger, tabs are very simple though and only store the directory path. gt Go to the next tab. (also TAB) gT Go to the previous tab. (also Shift+TAB) + gn Create a new tab g<N> Open a tab. N has to be a number from 0 to 9. If the tab doesn't exist yet, it will be created. gc, ^W Close the current tab. The last tab cannot be closed. |