fixed #1901 Alt-U and Alt-Y scrolls the participant-list in MUCs

parent ea3e606d
...@@ -353,6 +353,8 @@ class MucTab(ChatTab): ...@@ -353,6 +353,8 @@ class MucTab(ChatTab):
# keys # keys
self.key_func['^I'] = self.completion self.key_func['^I'] = self.completion
self.key_func['M-i'] = self.completion self.key_func['M-i'] = self.completion
self.key_func['M-u'] = self.scroll_user_list_down
self.key_func['M-y'] = self.scroll_user_list_up
# commands # commands
self.commands['ignore'] = (self.command_ignore, _("Usage: /ignore <nickname> \nIgnore: Ignore a specified nickname."), None) self.commands['ignore'] = (self.command_ignore, _("Usage: /ignore <nickname> \nIgnore: Ignore a specified nickname."), None)
self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore <nickname>\nUnignore: Remove the specified nickname from the ignore list."), None) self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore <nickname>\nUnignore: Remove the specified nickname from the ignore list."), None)
...@@ -364,6 +366,14 @@ class MucTab(ChatTab): ...@@ -364,6 +366,14 @@ class MucTab(ChatTab):
self.commands['recolor'] = (self.command_recolor, _('Usage: /recolor\nRecolor: Re-assign a color to all participants of the current room, based on the last time they talked. Use this if the participants currently talking have too many identical colors.'), None) self.commands['recolor'] = (self.command_recolor, _('Usage: /recolor\nRecolor: Re-assign a color to all participants of the current room, based on the last time they talked. Use this if the participants currently talking have too many identical colors.'), None)
self.resize() self.resize()
def scroll_user_list_up(self):
self.user_win.scroll_up()
self.core.refresh_window()
def scroll_user_list_down(self):
self.user_win.scroll_down()
self.core.refresh_window()
def command_recolor(self, arg): def command_recolor(self, arg):
""" """
Re-assign color to the participants of the room Re-assign color to the participants of the room
......
...@@ -91,6 +91,7 @@ class Win(object): ...@@ -91,6 +91,7 @@ class Win(object):
class UserList(Win): class UserList(Win):
def __init__(self): def __init__(self):
Win.__init__(self) Win.__init__(self)
self.pos = 0
self.color_role = {'moderator': theme.COLOR_USER_MODERATOR, self.color_role = {'moderator': theme.COLOR_USER_MODERATOR,
'participant':theme.COLOR_USER_PARTICIPANT, 'participant':theme.COLOR_USER_PARTICIPANT,
'visitor':theme.COLOR_USER_VISITOR, 'visitor':theme.COLOR_USER_VISITOR,
...@@ -105,11 +106,25 @@ class UserList(Win): ...@@ -105,11 +106,25 @@ class UserList(Win):
'chat':theme.COLOR_STATUS_CHAT 'chat':theme.COLOR_STATUS_CHAT
} }
def scroll_up(self):
self.pos += 4
def scroll_down(self):
self.pos -= 4
if self.pos < 0:
self.pos = 0
def draw_plus(self, y):
self.addstr(y, self.width-2, '++', curses.color_pair(42))
def refresh(self, users): def refresh(self, users):
with g_lock: with g_lock:
self._win.erase() self._win.erase()
y = 0 y = 0
for user in sorted(users): 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: if not user.role in self.color_role:
role_col = theme.COLOR_USER_NONE role_col = theme.COLOR_USER_NONE
else: else:
...@@ -119,10 +134,15 @@ class UserList(Win): ...@@ -119,10 +134,15 @@ class UserList(Win):
else: else:
show_col = self.color_show[user.show] show_col = self.color_show[user.show]
self.addstr(y, 0, theme.CHAR_STATUS, curses.color_pair(show_col)) self.addstr(y, 0, theme.CHAR_STATUS, curses.color_pair(show_col))
self.addnstr(y, 1, user.nick, self.width-1, curses.color_pair(role_col)) self.addstr(y, 1, user.nick, curses.color_pair(role_col))
y += 1 y += 1
if y == self.height: if y == self.height:
break break
# draw indicators of position in the list
if self.pos > 0:
self.draw_plus(0)
if self.pos + self.height < len(users):
self.draw_plus(self.height-1)
self._refresh() self._refresh()
def resize(self, height, width, y, x, stdscr): def resize(self, height, width, y, x, stdscr):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment