summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py68
1 files changed, 43 insertions, 25 deletions
diff --git a/src/windows.py b/src/windows.py
index 68518086..b8d276f0 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -199,6 +199,10 @@ class UserList(Win):
'none': lambda: get_theme().COLOR_USER_NONE,
'': lambda: get_theme().COLOR_USER_NONE
}
+ self.symbol_affiliation = {'owner': lambda: get_theme().CHAR_AFFILIATION_OWNER,
+ 'admin': lambda: get_theme().CHAR_AFFILIATION_ADMIN,
+ 'member': lambda: get_theme().CHAR_AFFILIATION_MEMBER,
+ 'none': lambda: get_theme().CHAR_AFFILIATION_NONE, }
self.color_show = {'xa': lambda: get_theme().COLOR_STATUS_XA,
'none': lambda: get_theme().COLOR_STATUS_NONE,
'': lambda: get_theme().COLOR_STATUS_NONE,
@@ -206,7 +210,6 @@ class UserList(Win):
'away': lambda: get_theme().COLOR_STATUS_AWAY,
'chat': lambda: get_theme().COLOR_STATUS_CHAT
}
-
def scroll_up(self):
self.pos += self.height-1
@@ -222,30 +225,24 @@ class UserList(Win):
log.debug('Refresh: %s',self.__class__.__name__)
with g_lock:
self._win.erase()
- y = 0
- users = sorted(users)
+ if config.get('user_list_sort', 'desc').lower() == 'asc':
+ y, x = self._win.getmaxyx()
+ y -= 1
+ users = sorted(users, reverse=True)
+ else:
+ y = 0
+ users = sorted(users)
+
if self.pos >= len(users) and self.pos != 0:
self.pos = len(users)-1
for user in users[self.pos:]:
- if not user.role in self.color_role:
- role_col = get_theme().COLOR_USER_NONE
- else:
- role_col = self.color_role[user.role]()
- if not user.show in self.color_show:
- show_col = get_theme().COLOR_STATUS_NONE
+ self.draw_role_affiliation(y, user)
+ self.draw_status_chatstate(y, user)
+ self.addstr(y, 2, user.nick[:self.width-2], to_curses_attr(user.color))
+ if config.get('user_list_sort', 'desc').lower() == 'asc':
+ y -= 1
else:
- show_col = self.color_show[user.show]()
- if user.chatstate == 'composing':
- char = get_theme().CHAR_CHATSTATE_COMPOSING
- elif user.chatstate == 'active':
- char = get_theme().CHAR_CHATSTATE_ACTIVE
- elif user.chatstate == 'paused':
- char = get_theme().CHAR_CHATSTATE_PAUSED
- else:
- char = get_theme().CHAR_STATUS
- self.addstr(y, 0, char, to_curses_attr(show_col))
- self.addstr(y, 1, user.nick[:self.width-2], to_curses_attr(role_col))
- y += 1
+ y += 1
if y == self.height:
break
# draw indicators of position in the list
@@ -255,6 +252,29 @@ class UserList(Win):
self.draw_plus(self.height-1)
self._refresh()
+ def draw_role_affiliation(self, y, user):
+ if not user.role in self.color_role:
+ color = get_theme().COLOR_USER_NONE
+ else:
+ color = self.color_role[user.role]()
+ symbol = self.symbol_affiliation.get(user.affiliation, lambda: '-')()
+ self.addstr(y, 1, symbol, to_curses_attr(color))
+
+ def draw_status_chatstate(self, y, user):
+ if not user.show in self.color_show:
+ show_col = get_theme().COLOR_STATUS_NONE
+ else:
+ show_col = self.color_show[user.show]()
+ if user.chatstate == 'composing':
+ char = get_theme().CHAR_CHATSTATE_COMPOSING
+ elif user.chatstate == 'active':
+ char = get_theme().CHAR_CHATSTATE_ACTIVE
+ elif user.chatstate == 'paused':
+ char = get_theme().CHAR_CHATSTATE_PAUSED
+ else:
+ char = get_theme().CHAR_STATUS
+ self.addstr(y, 0, char, to_curses_attr(show_col))
+
def resize(self, height, width, y, x):
with g_lock:
self._resize(height, width, y, x)
@@ -302,7 +322,7 @@ class GlobalInfoBar(Win):
for tab in sorted_tabs:
color = tab.color
if config.get('show_inactive_tabs', 'true') == 'false' and\
- color == get_theme().COLOR_TAB_NORMAL:
+ color is get_theme().COLOR_TAB_NORMAL:
continue
try:
self.addstr("%s" % str(tab.nb), to_curses_attr(color))
@@ -334,7 +354,7 @@ class VerticalGlobalInfoBar(Win):
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]
+ tab.vertical_color is not get_theme().COLOR_VERTICAL_TAB_NORMAL]
nb_tabs = len(sorted_tabs)
if nb_tabs >= height:
for y, tab in enumerate(sorted_tabs):
@@ -1659,8 +1679,6 @@ class ListWin(Win):
if not lines:
return
self.lines += lines
- self.refresh()
- curses.doupdate()
def get_selected_row(self):
"""