summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-16 02:01:38 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-16 02:09:30 +0100
commitd67ec3278ae5a56373597c6f2a259d9dba9cc809 (patch)
tree1b1804fdfbd8126080df80cbda2d2332f6c6c20b /src/windows.py
parent241369c3309f43cc710fd66dc8b0348c66f92293 (diff)
downloadpoezio-d67ec3278ae5a56373597c6f2a259d9dba9cc809.tar.gz
poezio-d67ec3278ae5a56373597c6f2a259d9dba9cc809.tar.bz2
poezio-d67ec3278ae5a56373597c6f2a259d9dba9cc809.tar.xz
poezio-d67ec3278ae5a56373597c6f2a259d9dba9cc809.zip
Add an optional vertical tab list.
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py51
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