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 __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, 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 __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 __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()
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.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()