diff options
author | mathieui <mathieui@mathieui.net> | 2012-09-26 01:54:20 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-09-26 01:54:20 +0200 |
commit | 09ff076bc44eed93a570af29e04bdd720ce9569a (patch) | |
tree | 72343022025dca4af60c3ad61286a5b154820c71 /src/windows.py | |
parent | 0bd55a27f2f14dd434c828f4a061f366b39dda92 (diff) | |
download | poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.tar.gz poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.tar.bz2 poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.tar.xz poezio-09ff076bc44eed93a570af29e04bdd720ce9569a.zip |
Rewrite the tab number handling
- Now the tab number is computed instead of assigned and fixed
- Added tabs.GapTab to keep the old behaviour
- Added a create_gaps option, defaults to true (may change in the
future)
- If there are gaps before using /set to change the option to false,
they will be removed.
(this is a preparation for the move_tab command)
Diffstat (limited to 'src/windows.py')
-rw-r--r-- | src/windows.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/windows.py b/src/windows.py index 6e1fd9ec..a8af3b7f 100644 --- a/src/windows.py +++ b/src/windows.py @@ -316,24 +316,25 @@ class GlobalInfoBar(Win): def refresh(self): log.debug('Refresh: %s',self.__class__.__name__) - def compare_room(a): - return a.nb - comp = lambda x: x.nb with g_lock: self._win.erase() self.addstr(0, 0, "[", to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) - sorted_tabs = sorted(self.core.tabs, key=comp) + + create_gaps = config.getl('create_gaps', 'false') == 'true' show_names = config.getl('show_tab_names', 'false') == 'true' show_nums = config.getl('show_tab_numbers', 'true') != 'false' use_nicks = config.getl('use_tab_nicks', 'true') != 'false' - for tab in sorted_tabs: + # ignore any remaining gap tabs if the feature is not enabled + sorted_tabs = [tab for tab in self.core.tabs if tab] if not create_gaps else self.core.tabs[:] + for nb, tab in enumerate(sorted_tabs): + if not tab: continue color = tab.color if config.get('show_inactive_tabs', 'true') == 'false' and\ color is get_theme().COLOR_TAB_NORMAL: continue try: if show_nums or not show_names: - self.addstr("%s" % str(tab.nb), to_curses_attr(color)) + self.addstr("%s" % str(nb), to_curses_attr(color)) if show_names: self.addstr(' ', to_curses_attr(color)) if show_names: @@ -358,16 +359,13 @@ class VerticalGlobalInfoBar(Win): self._win = scr def refresh(self): - def compare_room(a): - return a.nb - comp = lambda x: x.nb with g_lock: height, width = self._win.getmaxyx() self._win.erase() - sorted_tabs = sorted(self.core.tabs, key=comp) + sorted_tabs = [tab for tab in self.core.tabs if tab] if config.get('show_inactive_tabs', 'true') == 'false': sorted_tabs = [tab for tab in sorted_tabs if\ - tab.vertical_color is not get_theme().COLOR_VERTICAL_TAB_NORMAL] + tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL] nb_tabs = len(sorted_tabs) use_nicks = config.getl('use_tab_nicks', 'true') != 'false' if nb_tabs >= height: |