diff options
Diffstat (limited to 'src/windows.py')
-rw-r--r-- | src/windows.py | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/src/windows.py b/src/windows.py index 3e283320..c31954d9 100644 --- a/src/windows.py +++ b/src/windows.py @@ -55,6 +55,7 @@ def truncate_nick(nick, size=25): class Win(object): _win_core = None + _tab_win = None def __init__(self): self._win = None @@ -63,14 +64,12 @@ class Win(object): self.height, self.width = height, width return self.height, self.width, self.x, self.y = height, width, x, y - if not self._win: - self._win = curses.newwin(height, width, y, x) - else: - try: - self._win.resize(height, width) - self._win.mvwin(y, x) - except: - log.debug('DEBUG: mvwin returned ERR. Please investigate') + # try: + self._win = Win._tab_win.derwin(height, width, y, x) + # except: + # log.debug('DEBUG: mvwin returned ERR. Please investigate') + + # If this ever fail, uncomment that ^ def resize(self, height, width, y, x): """ @@ -315,6 +314,42 @@ class GlobalInfoBar(Win): to_curses_attr(get_theme().COLOR_INFORMATION_BAR)) self._refresh() +class VerticalGlobalInfoBar(Win): + def __init__(self, scr): + Win.__init__(self) + 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) + if config.get('show_inactive_tabs', 'true') == 'false': + sorted_tabs = [tab for tab in sorted_tabs if\ + tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL] + nb_tabs = len(sorted_tabs) + if nb_tabs >= height: + for y, tab in enumerate(sorted_tabs): + if tab.vertical_color == get_theme().COLOR_VERTICAL_TAB_CURRENT: + pos = y + break + # center the current tab as much as possible + if pos < height//2: + sorted_tabs = sorted_tabs[:height] + elif nb_tabs - pos <= height//2: + sorted_tabs = sorted_tabs[-height:] + else: + sorted_tabs = sorted_tabs[pos-height//2 : pos+height//2] + for y, tab in enumerate(sorted_tabs): + color = tab.vertical_color + self.addstr(y, 0, "%2d" % tab.nb, to_curses_attr(get_theme().COLOR_VERTICAL_TAB_NUMBER)) + self.addstr('.') + self._win.addnstr("%s" % tab.get_name(), width - 4, to_curses_attr(color)) + self._refresh() + class InfoWin(Win): """ Base class for all the *InfoWin, used in various tabs. For example |