summaryrefslogtreecommitdiff
path: root/src/windows/muc.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/muc.py')
-rw-r--r--src/windows/muc.py107
1 files changed, 52 insertions, 55 deletions
diff --git a/src/windows/muc.py b/src/windows/muc.py
index ce296e26..02bc58ef 100644
--- a/src/windows/muc.py
+++ b/src/windows/muc.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
import curses
-from . import Win, g_lock
+from . import Win
import poopt
from config import config
@@ -36,44 +36,43 @@ class UserList(Win):
log.debug('Refresh: %s', self.__class__.__name__)
if config.get("hide_user_list", False):
return # do not refresh if this win is hidden.
- with g_lock:
- self._win.erase()
+ self._win.erase()
+ if config.get('user_list_sort', 'desc').lower() == 'asc':
+ y, x = self._win.getmaxyx()
+ y -= 1
+ users = sorted(users)
+ else:
+ y = 0
+ users = sorted(users)
+
+ if len(users) < self.height:
+ self.pos = 0
+ elif self.pos >= len(users) - self.height and self.pos != 0:
+ self.pos = len(users) - self.height
+ for user in users[self.pos:]:
+ self.draw_role_affiliation(y, user)
+ self.draw_status_chatstate(y, user)
+ self.addstr(y, 2,
+ poopt.cut_by_columns(user.nick, self.width - 2),
+ to_curses_attr(user.color))
if config.get('user_list_sort', 'desc').lower() == 'asc':
- y, x = self._win.getmaxyx()
y -= 1
- users = sorted(users)
else:
- y = 0
- users = sorted(users)
-
- if len(users) < self.height:
- self.pos = 0
- elif self.pos >= len(users) - self.height and self.pos != 0:
- self.pos = len(users) - self.height
- for user in users[self.pos:]:
- self.draw_role_affiliation(y, user)
- self.draw_status_chatstate(y, user)
- self.addstr(y, 2,
- poopt.cut_by_columns(user.nick, self.width - 2),
- to_curses_attr(user.color))
- if config.get('user_list_sort', 'desc').lower() == 'asc':
- y -= 1
- else:
- y += 1
- if y == self.height:
- break
- # draw indicators of position in the list
- if self.pos > 0:
- if config.get('user_list_sort', 'desc').lower() == 'asc':
- self.draw_plus(self.height-1)
- else:
- self.draw_plus(0)
- if self.pos + self.height < len(users):
- if config.get('user_list_sort', 'desc').lower() == 'asc':
- self.draw_plus(0)
- else:
- self.draw_plus(self.height-1)
- self._refresh()
+ y += 1
+ if y == self.height:
+ break
+ # draw indicators of position in the list
+ if self.pos > 0:
+ if config.get('user_list_sort', 'desc').lower() == 'asc':
+ self.draw_plus(self.height-1)
+ else:
+ self.draw_plus(0)
+ if self.pos + self.height < len(users):
+ if config.get('user_list_sort', 'desc').lower() == 'asc':
+ self.draw_plus(0)
+ else:
+ self.draw_plus(self.height-1)
+ self._refresh()
def draw_role_affiliation(self, y, user):
theme = get_theme()
@@ -94,12 +93,11 @@ class UserList(Win):
self.addstr(y, 0, char, to_curses_attr(show_col))
def resize(self, height, width, y, x):
- with g_lock:
- separator = to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)
- self._resize(height, width, y, x)
- self._win.attron(separator)
- self._win.vline(0, 0, curses.ACS_VLINE, self.height)
- self._win.attroff(separator)
+ separator = to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)
+ self._resize(height, width, y, x)
+ self._win.attron(separator)
+ self._win.vline(0, 0, curses.ACS_VLINE, self.height)
+ self._win.attroff(separator)
class Topic(Win):
def __init__(self):
@@ -108,19 +106,18 @@ class Topic(Win):
def refresh(self, topic=None):
log.debug('Refresh: %s', self.__class__.__name__)
- with g_lock:
- self._win.erase()
- if topic:
- msg = topic[:self.width-1]
- else:
- msg = self._message[:self.width-1]
- self.addstr(0, 0, msg, to_curses_attr(get_theme().COLOR_TOPIC_BAR))
- (y, x) = self._win.getyx()
- remaining_size = self.width - x
- if remaining_size:
- self.addnstr(' '*remaining_size, remaining_size,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- self._refresh()
+ self._win.erase()
+ if topic:
+ msg = topic[:self.width-1]
+ else:
+ msg = self._message[:self.width-1]
+ self.addstr(0, 0, msg, to_curses_attr(get_theme().COLOR_TOPIC_BAR))
+ (y, x) = self._win.getyx()
+ remaining_size = self.width - x
+ if remaining_size:
+ self.addnstr(' '*remaining_size, remaining_size,
+ to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self._refresh()
def set_message(self, message):
self._message = message