diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-02-15 17:24:35 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-02-15 17:24:35 +0100 |
commit | 690d4495605d8b5820eac3f3c88af1a82c93f248 (patch) | |
tree | 2be3930fad85f6c62c2083fd916eceb3e6281b9d | |
parent | 5a6f9f92cb953b325595cc67ce2cab6fbaffbc4c (diff) | |
download | poezio-690d4495605d8b5820eac3f3c88af1a82c93f248.tar.gz poezio-690d4495605d8b5820eac3f3c88af1a82c93f248.tar.bz2 poezio-690d4495605d8b5820eac3f3c88af1a82c93f248.tar.xz poezio-690d4495605d8b5820eac3f3c88af1a82c93f248.zip |
PgUp and PgDown scroll one page in the roster
M-u, M-y Moves to the next/previous roster group
-rw-r--r-- | src/tabs.py | 26 | ||||
-rw-r--r-- | src/windows.py | 52 |
2 files changed, 71 insertions, 7 deletions
diff --git a/src/tabs.py b/src/tabs.py index 8ac791d0..422bc983 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -810,6 +810,8 @@ class RosterInfoTab(Tab): self.key_func["/"] = self.on_slash self.key_func["KEY_UP"] = self.move_cursor_up self.key_func["KEY_DOWN"] = self.move_cursor_down + self.key_func["M-u"] = self.move_cursor_to_next_group + self.key_func["M-y"] = self.move_cursor_to_prev_group self.key_func["o"] = self.toggle_offline_show self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow @@ -998,13 +1000,29 @@ class RosterInfoTab(Tab): self.roster_win.move_cursor_up() return True + def move_cursor_to_prev_group(self): + self.roster_win.move_cursor_up() + while not isinstance(self.roster_win.get_selected_row(), RosterGroup): + if not self.roster_win.move_cursor_up(): + break + self.core.refresh_window() + + def move_cursor_to_next_group(self): + self.roster_win.move_cursor_down() + while not isinstance(self.roster_win.get_selected_row(), RosterGroup): + if not self.roster_win.move_cursor_down(): + break + self.core.refresh_window() + def on_scroll_down(self): - # Scroll info win - pass + for i in range(self.height-1): + self.roster_win.move_cursor_down() + return True def on_scroll_up(self): - # Scroll info down - pass + for i in range(self.height-1): + self.roster_win.move_cursor_up() + return True def on_info_win_size_changed(self): pass diff --git a/src/windows.py b/src/windows.py index 9ce03fa4..8d2af94c 100644 --- a/src/windows.py +++ b/src/windows.py @@ -452,10 +452,23 @@ class TextWin(Win): if self.pos <= 0: self.pos = 0 + def scroll_to_separator(self): + """ + Scroll until separator is centered. If no separator is + present, scroll at the top of the window + """ + if None in self.built_lines: + self.pos = self.built_lines.index(None) + # Chose a proper position (not too high) + self.scroll_up(0) + else: # Go at the top of the win + self.pos = len(self.built_lines) - self.height + def remove_line_separator(self): """ Remove the line separator """ + log.debug('remove_line_separator') if None in self.built_lines: self.built_lines.remove(None) @@ -978,8 +991,8 @@ class Input(Win): if self.on_input: self.on_input(self.get_text()) return res - if not key or len(key) > 1: - return False # ignore non-handled keyboard shortcuts + # if not key or len(key) > 1: + # return False # ignore non-handled keyboard shortcuts self.reset_completion() self.text = self.text[:self.pos+self.line_pos]+key+self.text[self.pos+self.line_pos:] (y, x) = self._win.getyx() @@ -1187,16 +1200,28 @@ class RosterWin(Win): self._resize(height, width, y, x, stdscr) def move_cursor_down(self): + """ + Return True if we scrolled, False otherwise + """ if self.pos < self.roster_len-1: self.pos += 1 + else: + return False if self.pos == self.start_pos-1 + self.height-1: self.scroll_down() + return True def move_cursor_up(self): + """ + Return True if we scrolled, False otherwise + """ if self.pos > 0: self.pos -= 1 + else: + return False if self.pos == self.start_pos-2: self.scroll_up() + return True def scroll_down(self): self.start_pos += 8 @@ -1329,7 +1354,28 @@ class RosterWin(Win): self.addstr(y, 6, resource.get_jid().full) def get_selected_row(self): - return self.selected_row + y = 1 + for group in roster.get_groups(): + if config.get('roster_show_offline', 'false') == 'false' and group.get_nb_connected_contacts() == 0: + continue # Ignore empty groups + if y-1 == self.pos: + return group + y += 1 + if group.folded: + continue + for contact in group.get_contacts(roster._contact_filter): + if config.get('roster_show_offline', 'false') == 'false' and\ + contact.get_nb_resources() == 0: + continue + if y-1 == self.pos: + return contact + y += 1 + if not contact._folded: + for resource in contact.get_resources(): + if y-1 == self.pos: + return resource + y += 1 + return None class ContactInfoWin(Win): def __init__(self): |