From 435bdd6e85da9a3d075ca3dd6f9d60c249359469 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Thu, 25 Nov 2010 03:04:03 +0000 Subject: command completion. Also completion for command's arguments. (try it to complete the server of the muc with /join test@kiko[TAB] for example --- src/core.py | 84 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 34 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index fdb77343..cd9cb32a 100644 --- a/src/core.py +++ b/src/core.py @@ -34,6 +34,8 @@ import common import theme import logging +from sleekxmpp.xmlstream.stanzabase import JID + log = logging.getLogger(__name__) import multiuserchat as muc @@ -93,28 +95,33 @@ class Core(object): self.resize_timer = None self.previous_tab_nb = 0 self.own_nick = config.get('own_nick', self.xmpp.boundjid.bare) - # global commands, available from all tabs (having an input, of course) + # global commands, available from all tabs + # a command is tuple of the form: + # (the function executing the command. Takes a string as argument, + # a string representing the help message, + # a completion function, taking a Input as argument. Can be None) + # The completion function should return True if a completion was + # made ; False otherwise self.commands = { - 'help': (self.command_help, '\_o< KOIN KOIN KOIN'), - 'join': (self.command_join, _("Usage: /join [room_name][@server][/nick] [password]\nJoin: Join the specified room. You can specify a nickname after a slash (/). If no nickname is specified, you will use the default_nick in the configuration file. You can omit the room name: you will then join the room you\'re looking at (useful if you were kicked). You can also provide a room_name without specifying a server, the server of the room you're currently in will be used. You can also provide a password to join the room.\nExamples:\n/join room@server.tld\n/join room@server.tld/John\n/join room2\n/join /me_again\n/join\n/join room@server.tld/my_nick password\n/join / password")), - 'quit': (self.command_quit, _("Usage: /quit\nQuit: Just disconnect from the server and exit poezio.")), - 'exit': (self.command_quit, _("Usage: /exit\nExit: Just disconnect from the server and exit poezio.")), - 'next': (self.rotate_rooms_right, _("Usage: /next\nNext: Go to the next room.")), - 'n': (self.rotate_rooms_right, _("Usage: /n\nN: Go to the next room.")), - 'prev': (self.rotate_rooms_left, _("Usage: /prev\nPrev: Go to the previous room.")), - 'p': (self.rotate_rooms_left, _("Usage: /p\nP: Go to the previous room.")), - 'win': (self.command_win, _("Usage: /win \nWin: Go to the specified room.")), - 'w': (self.command_win, _("Usage: /w \nW: Go to the specified room.")), - 'show': (self.command_show, _("Usage: /show [status]\nShow: Change your availability and (optionaly) your status. The argument is one of \"avail, available, ok, here, chat, away, afk, dnd, busy, xa\" and the optional [status] argument will be your status message")), - 'away': (self.command_away, _("Usage: /away [message]\nAway: Sets your availability to away and (optional) sets your status message. This is equivalent to '/show away [message]'")), - 'busy': (self.command_busy, _("Usage: /busy [message]\nBusy: Sets your availability to busy and (optional) sets your status message. This is equivalent to '/show busy [message]'")), - 'avail': (self.command_avail, _("Usage: /avail [message]\nAvail: Sets your availability to available and (optional) sets your status message. This is equivalent to '/show available [message]'")), - 'available': (self.command_avail, _("Usage: /available [message]\nAvailable: Sets your availability to available and (optional) sets your status message. This is equivalent to '/show available [message]'")), - 'bookmark': (self.command_bookmark, _("Usage: /bookmark [roomname][/nick]\nBookmark: Bookmark the specified room (you will then auto-join it on each poezio start). This commands uses the same syntaxe as /join. Type /help join for syntaxe examples. Note that when typing \"/bookmark\" on its own, the room will be bookmarked with the nickname you\'re currently using in this room (instead of default_nick)")), - 'set': (self.command_set, _("Usage: /set