diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tabs.py | 10 | ||||
-rw-r--r-- | src/windows.py | 24 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/tabs.py b/src/tabs.py index de2d3996..b106592b 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -353,6 +353,8 @@ class MucTab(ChatTab): # keys self.key_func['^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 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) @@ -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.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): """ Re-assign color to the participants of the room diff --git a/src/windows.py b/src/windows.py index df3d40e2..315ef84d 100644 --- a/src/windows.py +++ b/src/windows.py @@ -91,6 +91,7 @@ class Win(object): class UserList(Win): def __init__(self): Win.__init__(self) + self.pos = 0 self.color_role = {'moderator': theme.COLOR_USER_MODERATOR, 'participant':theme.COLOR_USER_PARTICIPANT, 'visitor':theme.COLOR_USER_VISITOR, @@ -105,11 +106,25 @@ class UserList(Win): '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): with g_lock: self._win.erase() 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: role_col = theme.COLOR_USER_NONE else: @@ -119,10 +134,15 @@ class UserList(Win): else: show_col = self.color_show[user.show] 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 if y == self.height: 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() def resize(self, height, width, y, x, stdscr): |