From 4b02b1a8123505607de90db7a82b485d302f0267 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 00:25:30 +0100 Subject: Fix add_tab_command (and remove) --- src/tabs.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 472a15fa..28bb90d2 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -222,17 +222,10 @@ class Tab(object): def on_input(self, key): pass - def add_plugin_command(self, name, handler, help, completion=None): - if name in self.plugin_commands or name in self.commands: - return - self.plugin_commands[name] = (handler, help, completion) - self.commands[name] = (handler, help, completion) - self.update_commands() - def update_commands(self): for c in self.plugin_commands: if not c in self.commands: - self.commands[name] = self.plugin_commands[c] + self.commands[c] = self.plugin_commands[c] def on_lose_focus(self): """ -- cgit v1.2.3 From 30b9827a2766725f146a04bf00735748cde91fec Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 14:31:11 +0100 Subject: Move /clear to the chattab instead of the muctab --- src/tabs.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 28bb90d2..5987007b 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -303,6 +303,8 @@ class ChatTab(Tab): _("""Usage: /say \nSay: Just send the message. Useful if you want your message to begin with a '/'."""), None) self.commands['xhtml'] = (self.command_xhtml, _("Usage: /xhtml \nXHTML: Send custom XHTML."), None) + self.commands['clear'] = (self.command_clear, + _('Usage: /clear\nClear: Clear the current buffer.'), None) self.chat_state = None self.update_commands() @@ -357,6 +359,15 @@ class ChatTab(Tab): self.refresh() msg.send() + def command_clear(self, args): + """ + /clear + """ + self._text_buffer.messages = [] + self.text_win.rebuild_everything(self._text_buffer) + self.refresh() + self.core.doupdate() + def send_chat_state(self, state, always_send=False): """ Send an empty chatstate message @@ -476,8 +487,6 @@ class MucTab(ChatTab): self.commands['configure'] = (self.command_configure, _('Usage: /configure\nConfigure: Configure the current room, through a form.'), None) self.commands['version'] = (self.command_version, _('Usage: /version \nVersion: Get the software version of the given JID or nick in room (usually its XMPP client and Operating System).'), None) self.commands['names'] = (self.command_names, _('Usage: /names\nNames: Get the list of the users in the room, and the list of the people assuming the different roles.'), None) - self.commands['clear'] = (self.command_clear, - _('Usage: /clear\nClear: Clear the current buffer.'), None) self.resize() self.update_commands() @@ -526,15 +535,6 @@ class MucTab(ChatTab): self.core.xmpp.plugin['xep_0045'].configureRoom(self.get_name(), form) self.core.close_tab() - def command_clear(self, args): - """ - /clear - """ - self._text_buffer.messages = [] - self.text_win.rebuild_everything(self._text_buffer) - self.refresh() - self.core.doupdate() - def command_cycle(self, arg): if self.joined: muc.leave_groupchat(self.core.xmpp, self.get_name(), self.own_nick, arg) -- cgit v1.2.3 From 8f826388f0b34b5230c2569ffd3e16a713c4c071 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:11:39 +0100 Subject: Completion for /export and /import --- src/tabs.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 5987007b..a49917c5 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -31,6 +31,7 @@ import singleton import xhtml import weakref import timed_events +import os import multiuserchat as muc @@ -1450,8 +1451,8 @@ class RosterInfoTab(Tab): self.commands['groupadd'] = (self.command_groupadd, _("Usage: /groupadd \nAdd the given JID to the given group."), self.completion_groupadd) self.commands['groupremove'] = (self.command_groupremove, _("Usage: /groupremove \nRemove the given JID from the given group."), self.completion_groupremove) self.commands['remove'] = (self.command_remove, _("Usage: /remove [jid]\nRemove: Remove the specified JID from your roster. This wil unsubscribe you from its presence, cancel its subscription to yours, and remove the item from your roster."), self.completion_remove) - self.commands['export'] = (self.command_export, _("Usage: /export [/path/to/file]\nExport: Export your contacts into /path/to/file if specified, or $HOME/poezio_contacts if not."), None) - self.commands['import'] = (self.command_import, _("Usage: /import [/path/to/file]\nImport: Import your contacts from /path/to/file if specified, or $HOME/poezio_contacts if not."), None) + self.commands['export'] = (self.command_export, _("Usage: /export [/path/to/file]\nExport: Export your contacts into /path/to/file if specified, or $HOME/poezio_contacts if not."), self.completion_file) + self.commands['import'] = (self.command_import, _("Usage: /import [/path/to/file]\nImport: Import your contacts from /path/to/file if specified, or $HOME/poezio_contacts if not."), self.completion_file) self.commands['clear_infos'] = (self.command_clear_infos, _("Usage: /clear_infos\nClear Infos: Use this command to clear the info buffer."), None) self.resize() self.update_commands() @@ -1474,6 +1475,30 @@ class RosterInfoTab(Tab): not self.input.help_message: self.complete_commands(self.input) + def completion_file(self, the_input): + """ + Completion for /import and /export + """ + text = the_input.get_text() + args = text.split() + n = len(args) + if n == 1: + home = os.getenv('HOME') or '/' + return the_input.auto_completion([home, '/tmp'], '') + else: + the_path = text[text.index(' ')+1:] + try: + names = os.listdir(the_path) + except: + names = [] + end_list = [] + for name in names: + value = os.path.join(the_path, name) + if not name.startswith('.'): + end_list.append(value) + + return the_input.auto_completion(end_list, '') + def command_clear_infos(self, arg): """ /clear_infos -- cgit v1.2.3 From 283b258d4e7d2131620eca22e9effc9cb0ede036 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:15:34 +0100 Subject: Completion for /ignore --- src/tabs.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index a49917c5..a1facb6f 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -472,7 +472,7 @@ class MucTab(ChatTab): 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 \nIgnore: Ignore a specified nickname."), None) + self.commands['ignore'] = (self.command_ignore, _("Usage: /ignore \nIgnore: Ignore a specified nickname."), self.completion_ignore) self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore \nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore) self.commands['kick'] = (self.command_kick, _("Usage: /kick [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), None) self.commands['role'] = (self.command_role, _("Usage: /role [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), None) @@ -491,6 +491,11 @@ class MucTab(ChatTab): self.resize() self.update_commands() + def completion_ignore(self, the_input): + userlist = [user.nick for user in self.users] + userlist.remove(self.own_nick) + return the_input.auto_completion(userlist, '') + def scroll_user_list_up(self): self.user_win.scroll_up() self.user_win.refresh(self.users) -- cgit v1.2.3 From 33f8efd77263368b7f83a27b7645196215700272 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:21:15 +0100 Subject: Completion for /kick --- src/tabs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index a1facb6f..15731b73 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -474,7 +474,7 @@ class MucTab(ChatTab): # commands self.commands['ignore'] = (self.command_ignore, _("Usage: /ignore \nIgnore: Ignore a specified nickname."), self.completion_ignore) self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore \nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore) - self.commands['kick'] = (self.command_kick, _("Usage: /kick [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), None) + self.commands['kick'] = (self.command_kick, _("Usage: /kick [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), self.completion_ignore) self.commands['role'] = (self.command_role, _("Usage: /role [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), None) self.commands['affiliation'] = (self.command_affiliation, _("Usage: /affiliation [reason]\nAffiliation: Set the affiliation of an user. Affiliations can be: none, member, admin, owner. You also can give an optional reason."), None) self.commands['topic'] = (self.command_topic, _("Usage: /topic \nTopic: Change the subject of the room."), self.completion_topic) @@ -492,10 +492,12 @@ class MucTab(ChatTab): self.update_commands() def completion_ignore(self, the_input): + """Completion for /ignore""" userlist = [user.nick for user in self.users] userlist.remove(self.own_nick) return the_input.auto_completion(userlist, '') + def scroll_user_list_up(self): self.user_win.scroll_up() self.user_win.refresh(self.users) -- cgit v1.2.3 From 23f5ee5e1152f3d568d351532ea967107e149758 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:21:27 +0100 Subject: Fix /kick with nicks with spaces in it --- src/tabs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 15731b73..ec057459 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -706,10 +706,9 @@ class MucTab(ChatTab): else: if len(args) > 1: msg = ' '+args[1] - self.core.information("-%s-" % msg) else: msg = '' - self.command_role(args[0]+ ' none'+msg) + self.command_role('"'+args[0]+ '" none'+msg) def command_role(self, arg): """ -- cgit v1.2.3 From 3ddbac5e47c166fc28cd285e0e299e6e7b9bc09a Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:25:11 +0100 Subject: Completion for /role --- src/tabs.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index ec057459..ebb2a0e6 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -475,7 +475,7 @@ class MucTab(ChatTab): self.commands['ignore'] = (self.command_ignore, _("Usage: /ignore \nIgnore: Ignore a specified nickname."), self.completion_ignore) self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore \nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore) self.commands['kick'] = (self.command_kick, _("Usage: /kick [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), self.completion_ignore) - self.commands['role'] = (self.command_role, _("Usage: /role [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), None) + self.commands['role'] = (self.command_role, _("Usage: /role [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), self.completion_role) self.commands['affiliation'] = (self.command_affiliation, _("Usage: /affiliation [reason]\nAffiliation: Set the affiliation of an user. Affiliations can be: none, member, admin, owner. You also can give an optional reason."), None) self.commands['topic'] = (self.command_topic, _("Usage: /topic \nTopic: Change the subject of the room."), self.completion_topic) self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . This nick has to be present in the room you\'re currently in. If you specified a message after the nickname, it will immediately be sent to this user.'), None) @@ -497,6 +497,20 @@ class MucTab(ChatTab): userlist.remove(self.own_nick) return the_input.auto_completion(userlist, '') + def completion_role(self, the_input): + """Completion for /role""" + text = the_input.get_text() + args = common.shell_split(text) + n = len(args) + if text.endswith(' '): + n += 1 + if n == 2: + userlist = [user.nick for user in self.users] + userlist.remove(self.own_nick) + return the_input.auto_completion(userlist, '') + elif n == 3: + possible_roles = ['none', 'visitor', 'participant', 'moderator'] + return the_input.auto_completion(possible_roles, '') def scroll_user_list_up(self): self.user_win.scroll_up() -- cgit v1.2.3 From 552c504559eef91a525f1794d4954f311314d075 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:28:11 +0100 Subject: Completion for /affiliation --- src/tabs.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index ebb2a0e6..38737890 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -476,7 +476,7 @@ class MucTab(ChatTab): self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore \nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore) self.commands['kick'] = (self.command_kick, _("Usage: /kick [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), self.completion_ignore) self.commands['role'] = (self.command_role, _("Usage: /role [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), self.completion_role) - self.commands['affiliation'] = (self.command_affiliation, _("Usage: /affiliation [reason]\nAffiliation: Set the affiliation of an user. Affiliations can be: none, member, admin, owner. You also can give an optional reason."), None) + self.commands['affiliation'] = (self.command_affiliation, _("Usage: /affiliation [reason]\nAffiliation: Set the affiliation of an user. Affiliations can be: none, member, admin, owner. You also can give an optional reason."), self.completion_affiliation) self.commands['topic'] = (self.command_topic, _("Usage: /topic \nTopic: Change the subject of the room."), self.completion_topic) self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . This nick has to be present in the room you\'re currently in. If you specified a message after the nickname, it will immediately be sent to this user.'), None) self.commands['part'] = (self.command_part, _("Usage: /part [message]\nPart: Disconnect from a room. You can specify an optional message."), None) @@ -512,6 +512,20 @@ class MucTab(ChatTab): possible_roles = ['none', 'visitor', 'participant', 'moderator'] return the_input.auto_completion(possible_roles, '') + def completion_affiliation(self, the_input): + """Completion for /affiliation""" + text = the_input.get_text() + args = common.shell_split(text) + n = len(args) + if text.endswith(' '): + n += 1 + if n == 2: + userlist = [user.nick for user in self.users] + return the_input.auto_completion(userlist, '') + elif n == 3: + possible_affiliations = ['none', 'member', 'admin', 'owner'] + return the_input.auto_completion(possible_affiliations, '') + def scroll_user_list_up(self): self.user_win.scroll_up() self.user_win.refresh(self.users) -- cgit v1.2.3 From ed53ab4edf1b99fb6b48b3e23848d234ef612044 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:29:36 +0100 Subject: Completion for /query (re-uses /ignore) --- src/tabs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 38737890..03f47744 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -478,7 +478,7 @@ class MucTab(ChatTab): self.commands['role'] = (self.command_role, _("Usage: /role [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), self.completion_role) self.commands['affiliation'] = (self.command_affiliation, _("Usage: /affiliation [reason]\nAffiliation: Set the affiliation of an user. Affiliations can be: none, member, admin, owner. You also can give an optional reason."), self.completion_affiliation) self.commands['topic'] = (self.command_topic, _("Usage: /topic \nTopic: Change the subject of the room."), self.completion_topic) - self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . This nick has to be present in the room you\'re currently in. If you specified a message after the nickname, it will immediately be sent to this user.'), None) + self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . This nick has to be present in the room you\'re currently in. If you specified a message after the nickname, it will immediately be sent to this user.'), self.completion_ignore) self.commands['part'] = (self.command_part, _("Usage: /part [message]\nPart: Disconnect from a room. You can specify an optional message."), None) self.commands['close'] = (self.command_close, _("Usage: /close [message]\nClose: Disconnect from a room and close the tab. You can specify an optional message if you are still connected."), None) self.commands['nick'] = (self.command_nick, _("Usage: /nick \nNick: Change your nickname in the current room."), None) -- cgit v1.2.3 From 6af593f44b2f9326fa18f4c09f8580941b8acc00 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 16:31:03 +0100 Subject: Completion for /info --- src/tabs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 03f47744..54207ba9 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -484,7 +484,7 @@ class MucTab(ChatTab): self.commands['nick'] = (self.command_nick, _("Usage: /nick \nNick: Change your nickname in the current room."), 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.commands['cycle'] = (self.command_cycle, _('Usage: /cycle [message]\nCycle: Leave the current room and rejoin it immediately.'), None) - self.commands['info'] = (self.command_info, _('Usage: /info \nInfo: Display some information about the user in the MUC: its/his/her role, affiliation, status and status message.'), None) + self.commands['info'] = (self.command_info, _('Usage: /info \nInfo: Display some information about the user in the MUC: its/his/her role, affiliation, status and status message.'), self.completion_ignore) self.commands['configure'] = (self.command_configure, _('Usage: /configure\nConfigure: Configure the current room, through a form.'), None) self.commands['version'] = (self.command_version, _('Usage: /version \nVersion: Get the software version of the given JID or nick in room (usually its XMPP client and Operating System).'), None) self.commands['names'] = (self.command_names, _('Usage: /names\nNames: Get the list of the users in the room, and the list of the people assuming the different roles.'), None) -- cgit v1.2.3 From 34511797a93497409d828b9fa87621ad5ff63672 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 13 Nov 2011 17:36:16 +0100 Subject: Completion for /nick --- src/tabs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 54207ba9..feb4be37 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -481,7 +481,7 @@ class MucTab(ChatTab): self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . This nick has to be present in the room you\'re currently in. If you specified a message after the nickname, it will immediately be sent to this user.'), self.completion_ignore) self.commands['part'] = (self.command_part, _("Usage: /part [message]\nPart: Disconnect from a room. You can specify an optional message."), None) self.commands['close'] = (self.command_close, _("Usage: /close [message]\nClose: Disconnect from a room and close the tab. You can specify an optional message if you are still connected."), None) - self.commands['nick'] = (self.command_nick, _("Usage: /nick \nNick: Change your nickname in the current room."), None) + self.commands['nick'] = (self.command_nick, _("Usage: /nick \nNick: Change your nickname in the current room."), self.completion_nick) 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['cycle'] = (self.command_cycle, _('Usage: /cycle [message]\nCycle: Leave the current room and rejoin it immediately.'), None) self.commands['info'] = (self.command_info, _('Usage: /info \nInfo: Display some information about the user in the MUC: its/his/her role, affiliation, status and status message.'), self.completion_ignore) @@ -491,6 +491,13 @@ class MucTab(ChatTab): self.resize() self.update_commands() + def completion_nick(self, the_input): + """Completion for /nick""" + nicks = [os.environ.get('USER'), config.get('default_nick', ''), self.core.get_bookmark_nickname(self.get_name())] + while nicks.count(''): + nicks.remove('') + return the_input.auto_completion(nicks, '') + def completion_ignore(self, the_input): """Completion for /ignore""" userlist = [user.nick for user in self.users] -- cgit v1.2.3