summaryrefslogtreecommitdiff
path: root/src/windows/info_bar.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/info_bar.py')
-rw-r--r--src/windows/info_bar.py133
1 files changed, 65 insertions, 68 deletions
diff --git a/src/windows/info_bar.py b/src/windows/info_bar.py
index 9917fa6a..390b7aea 100644
--- a/src/windows/info_bar.py
+++ b/src/windows/info_bar.py
@@ -12,7 +12,7 @@ import curses
from config import config
-from . import Win, g_lock
+from . import Win
from theming import get_theme, to_curses_attr
class GlobalInfoBar(Win):
@@ -21,39 +21,38 @@ class GlobalInfoBar(Win):
def refresh(self):
log.debug('Refresh: %s', self.__class__.__name__)
- with g_lock:
- self._win.erase()
- self.addstr(0, 0, "[", to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self._win.erase()
+ self.addstr(0, 0, "[", to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- create_gaps = config.get('create_gaps', False)
- show_names = config.get('show_tab_names', False)
- show_nums = config.get('show_tab_numbers', True)
- use_nicks = config.get('use_tab_nicks', True)
- # ignore any remaining gap tabs if the feature is not enabled
- if create_gaps:
- sorted_tabs = self.core.tabs[:]
- else:
- sorted_tabs = [tab for tab in self.core.tabs if tab]
+ create_gaps = config.get('create_gaps', False)
+ show_names = config.get('show_tab_names', False)
+ show_nums = config.get('show_tab_numbers', True)
+ use_nicks = config.get('use_tab_nicks', True)
+ # ignore any remaining gap tabs if the feature is not enabled
+ if create_gaps:
+ sorted_tabs = self.core.tabs[:]
+ else:
+ sorted_tabs = [tab for tab in self.core.tabs if tab]
- for nb, tab in enumerate(sorted_tabs):
- if not tab: continue
- color = tab.color
- if not config.get('show_inactive_tabs', True) and\
- color is get_theme().COLOR_TAB_NORMAL:
- continue
- try:
- if show_nums or not show_names:
- self.addstr("%s" % str(nb), to_curses_attr(color))
- if show_names:
- self.addstr(' ', to_curses_attr(color))
+ for nb, tab in enumerate(sorted_tabs):
+ if not tab: continue
+ color = tab.color
+ if not config.get('show_inactive_tabs', True) and\
+ color is get_theme().COLOR_TAB_NORMAL:
+ continue
+ try:
+ if show_nums or not show_names:
+ self.addstr("%s" % str(nb), to_curses_attr(color))
if show_names:
- if use_nicks:
- self.addstr("%s" % str(tab.get_nick()), to_curses_attr(color))
- else:
- self.addstr("%s" % tab.name, to_curses_attr(color))
- self.addstr("|", to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- except: # end of line
- break
+ self.addstr(' ', to_curses_attr(color))
+ if show_names:
+ if use_nicks:
+ self.addstr("%s" % str(tab.get_nick()), to_curses_attr(color))
+ else:
+ self.addstr("%s" % tab.name, to_curses_attr(color))
+ self.addstr("|", to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ except: # end of line
+ break
(y, x) = self._win.getyx()
self.addstr(y, x-1, '] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
(y, x) = self._win.getyx()
@@ -68,42 +67,40 @@ class VerticalGlobalInfoBar(Win):
self._win = scr
def refresh(self):
- with g_lock:
- height, width = self._win.getmaxyx()
- self._win.erase()
- sorted_tabs = [tab for tab in self.core.tabs if tab]
- if not config.get('show_inactive_tabs', True):
- sorted_tabs = [tab for tab in sorted_tabs if\
- tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL]
- nb_tabs = len(sorted_tabs)
- use_nicks = config.get('use_tab_nicks', True)
- 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]
+ height, width = self._win.getmaxyx()
+ self._win.erase()
+ sorted_tabs = [tab for tab in self.core.tabs if tab]
+ if not config.get('show_inactive_tabs', True):
+ sorted_tabs = [tab for tab in sorted_tabs if\
+ tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL]
+ nb_tabs = len(sorted_tabs)
+ use_nicks = config.get('use_tab_nicks', True)
+ if nb_tabs >= height:
for y, tab in enumerate(sorted_tabs):
- color = tab.vertical_color
-
- if not config.get('vertical_tab_list_sort', 'desc') != 'asc':
- y = height - y - 1
- self.addstr(y, 0, "%2d" % tab.nb,
- to_curses_attr(get_theme().COLOR_VERTICAL_TAB_NUMBER))
- self.addstr('.')
- if use_nicks:
- self.addnstr("%s" % tab.get_nick(), width - 4, to_curses_attr(color))
- else:
- self.addnstr("%s" % tab.name, width - 4, to_curses_attr(color))
- separator = to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)
- self._win.attron(separator)
- self._win.vline(0, width-1, curses.ACS_VLINE, height)
- self._win.attroff(separator)
- self._refresh()
+ 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
+ if not config.get('vertical_tab_list_sort', 'desc') != 'asc':
+ y = height - y - 1
+ self.addstr(y, 0, "%2d" % tab.nb,
+ to_curses_attr(get_theme().COLOR_VERTICAL_TAB_NUMBER))
+ self.addstr('.')
+ if use_nicks:
+ self.addnstr("%s" % tab.get_nick(), width - 4, to_curses_attr(color))
+ else:
+ self.addnstr("%s" % tab.name, width - 4, to_curses_attr(color))
+ separator = to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)
+ self._win.attron(separator)
+ self._win.vline(0, width-1, curses.ACS_VLINE, height)
+ self._win.attroff(separator)
+ self._refresh()