def __init__(self, core, bookmarks: BookmarkList): Tab.__init__(self, core) self.name = "Bookmarks" self.bookmarks = bookmarks self.new_bookmarks = [] # type: List[Bookmark] self.removed_bookmarks = [] # type: List[Bookmark] self.header_win = windows.ColumnHeaderWin( ('name', 'room@server/nickname', 'password', 'autojoin', 'storage')) self.bookmarks_win = windows.BookmarksWin( self.bookmarks, self.height - 4, self.width, 1, 0) self.help_win = windows.HelpText('Ctrl+Y: save, Ctrl+G: cancel, ' '↑↓: change lines, tab: change ' 'column, M-a: add bookmark, C-k' ': delete bookmark') self.info_header = windows.BookmarksInfoWin() self.key_func['KEY_UP'] = self.bookmarks_win.go_to_previous_line_input self.key_func['KEY_DOWN'] = self.bookmarks_win.go_to_next_line_input self.key_func['^I'] = self.bookmarks_win.go_to_next_horizontal_input self.key_func['^G'] = self.on_cancel self.key_func['^Y'] = self.on_save self.key_func['M-a'] = self.add_bookmark self.key_func['^K'] = self.del_bookmark self.resize() self.update_commands()
def __init__(self, core, bookmarks: BookmarkList): Tab.__init__(self, core) self.name = "Bookmarks" self.bookmarks = bookmarks self.new_bookmarks = [] # type: List[Bookmark] self.removed_bookmarks = [] # type: List[Bookmark] self.header_win = windows.ColumnHeaderWin( ('name', 'room@server/nickname', 'password', 'autojoin', 'storage')) self.bookmarks_win = windows.BookmarksWin(self.bookmarks, self.height - 4, self.width, 1, 0) self.help_win = windows.HelpText('Ctrl+Y: save, Ctrl+G: cancel, ' '↑↓: change lines, tab: change ' 'column, M-a: add bookmark, C-k' ': delete bookmark') self.info_header = windows.BookmarksInfoWin() self.key_func['KEY_UP'] = self.bookmarks_win.go_to_previous_line_input self.key_func['KEY_DOWN'] = self.bookmarks_win.go_to_next_line_input self.key_func['^I'] = self.bookmarks_win.go_to_next_horizontal_input self.key_func['^G'] = self.on_cancel self.key_func['^Y'] = self.on_save self.key_func['M-a'] = self.add_bookmark self.key_func['^K'] = self.del_bookmark self.resize() self.update_commands()
def __init__(self, core): Tab.__init__(self, core) self.state = 'normal' self.name = 'XMLTab' self.filters = [] self.core_buffer = self.core.xml_buffer self.filtered_buffer = text_buffer.TextBuffer() self.info_header = windows.XMLInfoWin() self.text_win = windows.XMLTextWin() self.core_buffer.add_window(self.text_win) self.default_help_message = windows.HelpText("/ to enter a command") self.register_command('close', self.close, shortdesc="Close this tab.") self.register_command('clear', self.command_clear, shortdesc='Clear the current buffer.') self.register_command('filter_reset', self.command_filter_reset, shortdesc='Reset the stanza filter.') self.register_command('filter_id', self.command_filter_id, usage='<id>', desc='Show only the stanzas with the id <id>.', shortdesc='Filter by id.') self.register_command('filter_xpath', self.command_filter_xpath, usage='<xpath>', desc='Show only the stanzas matching the xpath <xpath>.' ' Any occurrences of %n will be replaced by jabber:client.', shortdesc='Filter by XPath.') self.register_command('filter_jid', self.command_filter_jid, usage='<jid>', desc='Show only the stanzas matching the jid <jid> in from= or to=.', shortdesc='Filter by JID.') self.register_command('filter_from', self.command_filter_from, usage='<jid>', desc='Show only the stanzas matching the jid <jid> in from=.', shortdesc='Filter by JID from.') self.register_command('filter_to', self.command_filter_to, usage='<jid>', desc='Show only the stanzas matching the jid <jid> in to=.', shortdesc='Filter by JID to.') self.register_command('filter_xmlmask', self.command_filter_xmlmask, usage='<xml mask>', desc='Show only the stanzas matching the given xml mask.', shortdesc='Filter by xml mask.') self.register_command('dump', self.command_dump, usage='<filename>', desc='Writes the content of the XML buffer into a file.', shortdesc='Write in a file.') self.input = self.default_help_message self.key_func['^T'] = self.close self.key_func['^I'] = self.completion self.key_func["KEY_DOWN"] = self.on_scroll_down self.key_func["KEY_UP"] = self.on_scroll_up self.key_func["^K"] = self.on_freeze self.key_func["/"] = self.on_slash self.resize() # Used to display the infobar self.filter_type = '' self.filter = ''
def __init__(self, core, name, help_message, header_text, cols): """Parameters: name: The name of the tab help_message: The default help message displayed instead of the input header_text: The text displayed on the header line, at the top of the tab cols: a tuple of 2-tuples. e.g. (('column1_name', number), ('column2_name', number)) """ Tab.__init__(self, core) self.state = 'normal' self._error_message = '' self.name = name columns = collections.OrderedDict() for col, num in cols: columns[col] = num self.list_header = windows.ColumnHeaderWin(list(columns)) self.listview = windows.ListWin(columns) self.info_header = windows.MucListInfoWin(header_text) self.default_help_message = windows.HelpText(help_message) self.input = self.default_help_message self.key_func["KEY_DOWN"] = self.move_cursor_down self.key_func["KEY_UP"] = self.move_cursor_up self.key_func['^I'] = self.completion self.key_func["/"] = self.on_slash self.key_func['KEY_LEFT'] = self.list_header.sel_column_left self.key_func['KEY_RIGHT'] = self.list_header.sel_column_right self.key_func[' '] = self.sort_by self.register_command('close', self.close, shortdesc='Close this tab.') self.resize() self.update_keys() self.update_commands()
def __init__(self, core, name, text, short_message, callback, critical=False): """Parameters: name: The name of the tab text: the text shown in the tab short_message: what will be displayed at the top and bottom of the tab callback: the function(bool) that will be called when the user makes a choice critical: if the message needs to be displayed in a flashy color """ Tab.__init__(self, core) self.state = 'highlight' self.name = name self.default_help_message = windows.HelpText( "Choose with arrow keys and press enter") self.input = self.default_help_message self.infowin_top = windows.ConfirmStatusWin(short_message, critical) self.infowin_bottom = windows.ConfirmStatusWin(short_message, critical) self.dialog = windows.Dialog(text, critical) self.key_func['^I'] = self.toggle_choice self.key_func[' '] = self.toggle_choice self.key_func['KEY_LEFT'] = self.toggle_choice self.key_func['KEY_RIGHT'] = self.toggle_choice self.key_func['^M'] = self.validate self.resize() self.update_keys() self.update_commands() self.completion_callback = callback self.done = False
def on_info_win_size_changed(self): if self.core.information_win_size >= self.height - 3: return self.info_header.resize( 1, self.width, self.height - 2 - self.core.information_win_size - Tab.tab_win_height(), 0) self.listview.resize(self.height - 3 - self.core.information_win_size - Tab.tab_win_height(), self.width, 1, 0)
def on_info_win_size_changed(self): if self.core.information_win_size >= self.height - 3: return self.info_header.resize( 1, self.width, self.height - 2 - self.core.information_win_size - Tab.tab_win_height(), 0) self.listview.resize( self.height - 3 - self.core.information_win_size - Tab.tab_win_height(), self.width, 1, 0)
def resize(self): self.need_resize = False self.topic_win.resize(1, self.width, 0, 0) self.form_win.resize(self.height - 3 - Tab.tab_win_height(), self.width, 1, 0) self.help_win.resize(1, self.width, self.height - 1, 0) self.help_win_dyn.resize(1, self.width, self.height - 2 - Tab.tab_win_height(), 0) self.lines = []
def on_info_win_size_changed(self): if self.core.information_win_size >= self.height - 3: return self.dialog.resize( self.height - 3 - self.core.information_win_size - Tab.tab_win_height(), self.width, 1, 0) self.infowin_bottom.resize( 1, self.width, self.height - 2 - self.core.information_win_size - Tab.tab_win_height(), 0)
def append(self, tab: tabs.Tab): """ Add a tab to the list """ if not self._tabs: tab.nb = 0 self._current_tab = tab else: tab.nb = self._tabs[-1].nb + 1 self._tabs.append(tab) for cls in _get_tab_types(tab): self._tab_types[cls].append(tab) self._tab_names[tab.name] = tab
def append(self, tab: tabs.Tab): """ Add a tab to the list """ if not self._tabs: tab.nb = 0 self._current_tab = tab else: tab.nb = self._tabs[-1].nb + 1 self._tabs.append(tab) for cls in _get_tab_types(tab): self._tab_types[cls].append(tab) self._tab_names[tab.name] = tab
def __init__(self, core, qr): Tab.__init__(self, core) self.state = 'highlight' self.text = qr self.name = qr self.topic_win = windows.Topic() self.topic_win.set_message(qr) self.qr_win = QrWindow(qr) self.help_win = windows.HelpText( "Choose with arrow keys and press enter") self.key_func['^I'] = self.toggle_choice self.key_func[' '] = self.toggle_choice self.key_func['KEY_LEFT'] = self.toggle_choice self.key_func['KEY_RIGHT'] = self.toggle_choice self.key_func['^M'] = self.engage self.resize() self.update_commands() self.update_keys()
def on_info_win_size_changed(self): if self.core.information_win_size >= self.height - 3: return info_height = self.core.information_win_size tab_height = Tab.tab_win_height() self.bookmarks_win.resize(self.height - 3 - tab_height - info_height, self.width, 1, 0) self.info_header.resize(1, self.width, self.height - 2 - tab_height - info_height, 0)
def on_info_win_size_changed(self): if self.core.information_win_size >= self.height - 3: return info_height = self.core.information_win_size tab_height = Tab.tab_win_height() self.bookmarks_win.resize(self.height - 3 - tab_height - info_height, self.width, 1, 0) self.info_header.resize(1, self.width, self.height - 2 - tab_height - info_height, 0)
def __init__(self, core, form, on_cancel, on_send, kwargs): Tab.__init__(self, core) self._form = form self._on_cancel = on_cancel self._on_send = on_send self._kwargs = kwargs self.fields = [] for field in self._form: self.fields.append(field) self.topic_win = windows.Topic() self.form_win = windows.FormWin(form, self.height-4, self.width, 1, 0) self.help_win = windows.HelpText("Ctrl+Y: send form, Ctrl+G: cancel") self.help_win_dyn = windows.HelpText() self.key_func['KEY_UP'] = self.form_win.go_to_previous_input self.key_func['KEY_DOWN'] = self.form_win.go_to_next_input self.key_func['^G'] = self.on_cancel self.key_func['^Y'] = self.on_send self.resize() self.update_commands()
def __init__(self, core, form, on_cancel, on_send, kwargs): Tab.__init__(self, core) self._form = form self._on_cancel = on_cancel self._on_send = on_send self._kwargs = kwargs self.fields = [] for field in self._form: self.fields.append(field) self.topic_win = windows.Topic() self.form_win = windows.FormWin(form, self.height - 4, self.width, 1, 0) self.help_win = windows.HelpText("Ctrl+Y: send form, Ctrl+G: cancel") self.help_win_dyn = windows.HelpText() self.key_func['KEY_UP'] = self.form_win.go_to_previous_input self.key_func['KEY_DOWN'] = self.form_win.go_to_next_input self.key_func['^G'] = self.on_cancel self.key_func['^Y'] = self.on_send self.resize() self.update_commands()
def resize(self): if self.size.tab_degrade_y: info_win_height = 0 tab_win_height = 0 else: info_win_height = self.core.information_win_size tab_win_height = Tab.tab_win_height() self.infowin_top.resize(1, self.width, 0, 0) self.infowin_bottom.resize(1, self.width, self.height - 2 - info_win_height - tab_win_height, 0) self.dialog.resize(self.height - 3 - info_win_height - tab_win_height, self.width, 1, 0) self.input.resize(1, self.width, self.height-1, 0)
def resize(self): self.need_resize = False if self.size.tab_degrade_x: display_info = False roster_width = self.width else: display_info = True roster_width = self.width // 2 if self.size.tab_degrade_y: display_contact_win = False contact_win_h = 0 else: display_contact_win = True contact_win_h = 8 if self.size.tab_degrade_y: tab_win_height = 0 else: tab_win_height = Tab.tab_win_height() info_width = self.width - roster_width - 1 if display_info: self.v_separator.resize(self.height - 1 - tab_win_height, 1, 0, roster_width) self.information_win.resize( self.height - 1 - tab_win_height - contact_win_h, info_width, 0, roster_width + 1, self.core.information_buffer) if display_contact_win: y = self.height - tab_win_height - contact_win_h - 1 avatar_width = contact_win_h * 2 self.contact_info_win.resize(contact_win_h, info_width - avatar_width, y, roster_width + 1) self.avatar_win.resize(contact_win_h, avatar_width, y, self.width - avatar_width) self.roster_win.resize(self.height - 1 - Tab.tab_win_height(), roster_width, 0, 0) self.input.resize(1, self.width, self.height - 1, 0) self.default_help_message.resize(1, self.width, self.height - 1, 0)
def resize(self): self.need_resize = False if self.size.tab_degrade_x: display_info = False roster_width = self.width else: display_info = True roster_width = self.width // 2 if self.size.tab_degrade_y: display_contact_win = False contact_win_h = 0 else: display_contact_win = True contact_win_h = 8 if self.size.tab_degrade_y: tab_win_height = 0 else: tab_win_height = Tab.tab_win_height() info_width = self.width - roster_width - 1 if display_info: self.v_separator.resize(self.height - 1 - tab_win_height, 1, 0, roster_width) self.information_win.resize( self.height - 1 - tab_win_height - contact_win_h, info_width, 0, roster_width + 1, self.core.information_buffer) if display_contact_win: y = self.height - tab_win_height - contact_win_h - 1 avatar_width = contact_win_h * 2 self.contact_info_win.resize(contact_win_h, info_width - avatar_width, y, roster_width + 1) self.avatar_win.resize(contact_win_h, avatar_width, y, self.width - avatar_width) self.roster_win.resize(self.height - 1 - Tab.tab_win_height(), roster_width, 0, 0) self.input.resize(1, self.width, self.height - 1, 0) self.default_help_message.resize(1, self.width, self.height - 1, 0)
def resize(self): if self.size.tab_degrade_y: info_win_height = 0 tab_win_height = 0 else: info_win_height = self.core.information_win_size tab_win_height = Tab.tab_win_height() self.infowin_top.resize(1, self.width, 0, 0) self.infowin_bottom.resize( 1, self.width, self.height - 2 - info_win_height - tab_win_height, 0) self.dialog.resize(self.height - 3 - info_win_height - tab_win_height, self.width, 1, 0) self.input.resize(1, self.width, self.height - 1, 0)
def resize(self): self.need_resize = False if self.size.tab_degrade_y: info_win_size = 0 tab_win_height = 0 else: info_win_size = self.core.information_win_size tab_win_height = Tab.tab_win_height() self.text_win.resize(self.height - info_win_size - tab_win_height - 2, self.width, 0, 0) self.text_win.rebuild_everything(self.core_buffer) self.info_header.resize( 1, self.width, self.height - 2 - info_win_size - tab_win_height, 0) self.input.resize(1, self.width, self.height - 1, 0)
def resize(self): self.need_resize = False self.header_win.resize_columns({ 'room@server/nickname': self.width // 3, 'password': self.width // 3, 'autojoin': self.width // 6, 'storage': self.width // 6 }) info_height = self.core.information_win_size tab_height = Tab.tab_win_height() self.header_win.resize(1, self.width, 0, 0) self.bookmarks_win.resize(self.height - 3 - tab_height - info_height, self.width, 1, 0) self.help_win.resize(1, self.width, self.height - 1, 0) self.info_header.resize(1, self.width, self.height - 2 - tab_height - info_height, 0)
def resize(self): self.need_resize = False if self.size.tab_degrade_y: info_win_height = 0 tab_win_height = 0 else: info_win_height = self.core.information_win_size tab_win_height = Tab.tab_win_height() self.text_win.resize( self.height - 2 - info_win_height - tab_win_height, self.width, 0, 0) self.text_win.rebuild_everything(self._text_buffer) self.info_header.resize( 1, self.width, self.height - 2 - info_win_height - tab_win_height, 0) self.input.resize(1, self.width, self.height - 1, 0)
def resize(self): if self.size.tab_degrade_y: info_win_height = 0 tab_win_height = 0 else: info_win_height = self.core.information_win_size tab_win_height = Tab.tab_win_height() self.info_header.resize( 1, self.width, self.height - 2 - info_win_height - tab_win_height, 0) column_size = self.get_columns_sizes() self.list_header.resize_columns(column_size) self.list_header.resize(1, self.width, 0, 0) self.listview.resize_columns(column_size) self.listview.resize( self.height - 3 - info_win_height - tab_win_height, self.width, 1, 0) self.input.resize(1, self.width, self.height - 1, 0)
def resize(self): self.need_resize = False self.header_win.resize_columns({ 'name': self.width // 4, 'room@server/nickname': self.width // 4, 'password': self.width // 6, 'autojoin': self.width // 6, 'storage': self.width // 6 }) info_height = self.core.information_win_size tab_height = Tab.tab_win_height() self.header_win.resize(1, self.width, 0, 0) self.bookmarks_win.resize(self.height - 3 - tab_height - info_height, self.width, 1, 0) self.help_win.resize(1, self.width, self.height - 1, 0) self.info_header.resize(1, self.width, self.height - 2 - tab_height - info_height, 0)
def __init__(self, core): Tab.__init__(self, core) self.name = "Roster" self.v_separator = windows.VerticalSeparator() self.information_win = windows.TextWin() self.core.information_buffer.add_window(self.information_win) self.roster_win = windows.RosterWin() self.contact_info_win = windows.ContactInfoWin() self.avatar_win = windows.ImageWin() self.default_help_message = windows.HelpText( "Enter commands with “/”. “o”: toggle offline show") self.input = self.default_help_message self.state = 'normal' self.key_func['^I'] = self.completion self.key_func["/"] = self.on_slash # disable most of the roster features when in anonymous mode if not self.core.xmpp.anon: self.key_func[' '] = self.on_space 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_contact self.key_func["M-y"] = self.move_cursor_to_prev_contact 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["M-[1;5B"] = self.move_cursor_to_next_group self.key_func["M-[1;5A"] = self.move_cursor_to_prev_group self.key_func["l"] = self.command_last_activity self.key_func["o"] = self.toggle_offline_show self.key_func["v"] = self.get_contact_version self.key_func["i"] = self.show_contact_info self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.key_func["n"] = self.change_contact_name self.register_command( 'name', self.command_name, usage='<jid> [name]', shortdesc='Set the given JID\'s name.', completion=self.completion_name) self.register_command( 'groupadd', self.command_groupadd, usage='[<jid> <group>]|<group>', desc='Add the given JID or selected line to the given group.', shortdesc='Add a user to a group', completion=self.completion_groupadd) self.register_command( 'groupmove', self.command_groupmove, usage='<jid> <old group> <new group>', desc='Move the given JID from the old group to the new group.', shortdesc='Move a user to another group.', completion=self.completion_groupmove) self.register_command( 'groupremove', self.command_groupremove, usage='<jid> <group>', desc='Remove the given JID from the given group.', shortdesc='Remove a user from a group.', completion=self.completion_groupremove) self.register_command( 'export', self.command_export, usage='[/path/to/file]', desc='Export your contacts into /path/to/file if ' 'specified, or $HOME/poezio_contacts if not.', shortdesc='Export your roster to a file.', completion=partial(self.completion_file, 1)) self.register_command( 'import', self.command_import, usage='[/path/to/file]', desc='Import your contacts from /path/to/file if ' 'specified, or $HOME/poezio_contacts if not.', shortdesc='Import your roster from a file.', completion=partial(self.completion_file, 1)) self.register_command( 'password', self.command_password, usage='<password>', shortdesc='Change your password') self.register_command( 'disconnect', self.command_disconnect, desc='Disconnect from the remote server.', shortdesc='Disconnect from the server.') self.register_command( 'clear', self.command_clear, shortdesc='Clear the info buffer.') self.register_command( 'last_activity', self.command_last_activity, usage='<jid>', desc='Informs you of the last activity of a JID.', shortdesc='Get the activity of someone.', completion=self.core.completion.last_activity) self.resize() self.update_commands() self.update_keys()
def __init__(self, core): Tab.__init__(self, core) self.name = "Roster" self.v_separator = windows.VerticalSeparator() self.information_win = windows.TextWin() self.core.information_buffer.add_window(self.information_win) self.roster_win = windows.RosterWin() self.contact_info_win = windows.ContactInfoWin() self.avatar_win = windows.ImageWin() self.default_help_message = windows.HelpText( "Enter commands with “/”. “o”: toggle offline show") self.input = self.default_help_message self.state = 'normal' self.key_func['^I'] = self.completion self.key_func["/"] = self.on_slash # disable most of the roster features when in anonymous mode if not self.core.xmpp.anon: self.key_func[' '] = self.on_space 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_contact self.key_func["M-y"] = self.move_cursor_to_prev_contact 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["M-[1;5B"] = self.move_cursor_to_next_group self.key_func["M-[1;5A"] = self.move_cursor_to_prev_group self.key_func["l"] = self.command_last_activity self.key_func["o"] = self.toggle_offline_show self.key_func["v"] = self.get_contact_version self.key_func["i"] = self.show_contact_info self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.key_func["n"] = self.change_contact_name self.register_command( 'deny', self.command_deny, usage='[jid]', desc='Deny your presence to the provided JID (or the ' 'selected contact in your roster), who is asking' 'you to be in his/here roster.', shortdesc='Deny a user your presence.', completion=self.completion_deny) self.register_command( 'accept', self.command_accept, usage='[jid]', desc='Allow the provided JID (or the selected contact ' 'in your roster), to see your presence.', shortdesc='Allow a user your presence.', completion=self.completion_deny) self.register_command( 'add', self.command_add, usage='<jid>', desc='Add the specified JID to your roster, ask them to' ' allow you to see his presence, and allow them to' ' see your presence.', shortdesc='Add a user to your roster.') self.register_command( 'name', self.command_name, usage='<jid> [name]', shortdesc='Set the given JID\'s name.', completion=self.completion_name) self.register_command( 'groupadd', self.command_groupadd, usage='[<jid> <group>]|<group>', desc='Add the given JID or selected line to the given group.', shortdesc='Add a user to a group', completion=self.completion_groupadd) self.register_command( 'groupmove', self.command_groupmove, usage='<jid> <old group> <new group>', desc='Move the given JID from the old group to the new group.', shortdesc='Move a user to another group.', completion=self.completion_groupmove) self.register_command( 'groupremove', self.command_groupremove, usage='<jid> <group>', desc='Remove the given JID from the given group.', shortdesc='Remove a user from a group.', completion=self.completion_groupremove) self.register_command( 'remove', self.command_remove, usage='[jid]', desc='Remove the specified JID from your roster. This ' 'will unsubscribe you from its presence, cancel ' 'its subscription to yours, and remove the item ' 'from your roster.', shortdesc='Remove a user from your roster.', completion=self.completion_remove) self.register_command( 'export', self.command_export, usage='[/path/to/file]', desc='Export your contacts into /path/to/file if ' 'specified, or $HOME/poezio_contacts if not.', shortdesc='Export your roster to a file.', completion=partial(self.completion_file, 1)) self.register_command( 'import', self.command_import, usage='[/path/to/file]', desc='Import your contacts from /path/to/file if ' 'specified, or $HOME/poezio_contacts if not.', shortdesc='Import your roster from a file.', completion=partial(self.completion_file, 1)) self.register_command( 'password', self.command_password, usage='<password>', shortdesc='Change your password') self.register_command( 'reconnect', self.command_reconnect, desc='Disconnect from the remote server if you are ' 'currently connected and then connect to it again.', shortdesc='Disconnect and reconnect to the server.') self.register_command( 'disconnect', self.command_disconnect, desc='Disconnect from the remote server.', shortdesc='Disconnect from the server.') self.register_command( 'clear', self.command_clear, shortdesc='Clear the info buffer.') self.register_command( 'last_activity', self.command_last_activity, usage='<jid>', desc='Informs you of the last activity of a JID.', shortdesc='Get the activity of someone.', completion=self.core.completion.last_activity) self.resize() self.update_commands() self.update_keys()
def __init__(self, core): Tab.__init__(self, core) self.name = "Roster" self.v_separator = windows.VerticalSeparator() self.information_win = windows.TextWin() self.core.information_buffer.add_window(self.information_win) self.roster_win = windows.RosterWin() self.contact_info_win = windows.ContactInfoWin() self.default_help_message = windows.HelpText("Enter commands with “/”. “o”: toggle offline show") self.input = self.default_help_message self.state = 'normal' self.key_func['^I'] = self.completion self.key_func["/"] = self.on_slash # disable most of the roster features when in anonymous mode if not self.core.xmpp.anon: self.key_func[' '] = self.on_space 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_contact self.key_func["M-y"] = self.move_cursor_to_prev_contact 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["M-[1;5B"] = self.move_cursor_to_next_group self.key_func["M-[1;5A"] = self.move_cursor_to_prev_group self.key_func["l"] = self.command_last_activity self.key_func["o"] = self.toggle_offline_show self.key_func["v"] = self.get_contact_version self.key_func["i"] = self.show_contact_info self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.key_func["n"] = self.change_contact_name self.register_command('deny', self.command_deny, usage='[jid]', desc='Deny your presence to the provided JID (or the ' 'selected contact in your roster), who is asking' 'you to be in his/here roster.', shortdesc='Deny a user your presence.', completion=self.completion_deny) self.register_command('accept', self.command_accept, usage='[jid]', desc='Allow the provided JID (or the selected contact ' 'in your roster), to see your presence.', shortdesc='Allow a user your presence.', completion=self.completion_deny) self.register_command('add', self.command_add, usage='<jid>', desc='Add the specified JID to your roster, ask him to' ' allow you to see his presence, and allow him to' ' see your presence.', shortdesc='Add a user to your roster.') self.register_command('name', self.command_name, usage='<jid> [name]', shortdesc='Set the given JID\'s name.', completion=self.completion_name) self.register_command('groupadd', self.command_groupadd, usage='[<jid> <group>]|<group>', desc='Add the given JID or selected line to the given group.', shortdesc='Add a user to a group', completion=self.completion_groupadd) self.register_command('groupmove', self.command_groupmove, usage='<jid> <old group> <new group>', desc='Move the given JID from the old group to the new group.', shortdesc='Move a user to another group.', completion=self.completion_groupmove) self.register_command('groupremove', self.command_groupremove, usage='<jid> <group>', desc='Remove the given JID from the given group.', shortdesc='Remove a user from a group.', completion=self.completion_groupremove) self.register_command('remove', self.command_remove, usage='[jid]', desc='Remove the specified JID from your roster. This ' 'will unsubscribe you from its presence, cancel ' 'its subscription to yours, and remove the item ' 'from your roster.', shortdesc='Remove a user from your roster.', completion=self.completion_remove) self.register_command('export', self.command_export, usage='[/path/to/file]', desc='Export your contacts into /path/to/file if ' 'specified, or $HOME/poezio_contacts if not.', shortdesc='Export your roster to a file.', completion=partial(self.completion_file, 1)) self.register_command('import', self.command_import, usage='[/path/to/file]', desc='Import your contacts from /path/to/file if ' 'specified, or $HOME/poezio_contacts if not.', shortdesc='Import your roster from a file.', completion=partial(self.completion_file, 1)) self.register_command('password', self.command_password, usage='<password>', shortdesc='Change your password') self.register_command('reconnect', self.command_reconnect, desc='Disconnect from the remote server if you are ' 'currently connected and then connect to it again.', shortdesc='Disconnect and reconnect to the server.') self.register_command('disconnect', self.command_disconnect, desc='Disconnect from the remote server.', shortdesc='Disconnect from the server.') self.register_command('clear', self.command_clear, shortdesc='Clear the info buffer.') self.register_command('last_activity', self.command_last_activity, usage='<jid>', desc='Informs you of the last activity of a JID.', shortdesc='Get the activity of someone.', completion=self.core.completion.last_activity) self.resize() self.update_commands() self.update_keys()