summaryrefslogtreecommitdiff
path: root/poezio/tabs
diff options
context:
space:
mode:
Diffstat (limited to 'poezio/tabs')
-rw-r--r--poezio/tabs/basetabs.py9
-rw-r--r--poezio/tabs/muctab.py31
-rw-r--r--poezio/tabs/rostertab.py31
3 files changed, 38 insertions, 33 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index dbd57aa4..5e753643 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -20,7 +20,7 @@ import string
import time
from xml.etree import cElementTree as ET
-from poezio.core.structs import Command
+from poezio.core.structs import Command, Completion
from poezio import timed_events
from poezio import windows
from poezio import xhtml
@@ -230,7 +230,10 @@ class Tab(object):
if command.comp is None:
return False # There's no completion function
else:
- return command.comp(the_input)
+ comp = command.comp(the_input)
+ if comp:
+ return comp.run()
+ return comp
return False
def execute_command(self, provided_text):
@@ -633,7 +636,7 @@ class ChatTab(Tab):
def completion_correct(self, the_input):
if self.last_sent_message and the_input.get_argument_position() == 1:
- return the_input.auto_completion([self.last_sent_message['body']], '', quotify=False)
+ return Completion(the_input.auto_completion, [self.last_sent_message['body']], '', quotify=False)
@property
def inactive(self):
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index 281237ad..e17ab18b 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -32,6 +32,7 @@ from poezio.logger import logger
from poezio.roster import roster
from poezio.theming import get_theme, dump_tuple
from poezio.user import User
+from poezio.core.structs import Completion
SHOW_NAME = {
@@ -243,7 +244,7 @@ class MucTab(ChatTab):
comp.sort()
userlist.extend(comp)
- return the_input.auto_completion(userlist, quotify=False)
+ return Completion(the_input.auto_completion, userlist, quotify=False)
def completion_info(self, the_input):
"""Completion for /info"""
@@ -251,7 +252,7 @@ class MucTab(ChatTab):
userlist = []
for user in sorted(self.users, key=compare_users, reverse=True):
userlist.append(user.nick)
- return the_input.auto_completion(userlist, quotify=False)
+ return Completion(the_input.auto_completion, userlist, quotify=False)
def completion_nick(self, the_input):
"""Completion for /nick"""
@@ -259,11 +260,11 @@ class MucTab(ChatTab):
config.get('default_nick'),
self.core.get_bookmark_nickname(self.name)]
nicks = [i for i in nicks if i]
- return the_input.auto_completion(nicks, '', quotify=False)
+ return Completion(the_input.auto_completion, nicks, '', quotify=False)
def completion_recolor(self, the_input):
if the_input.get_argument_position() == 1:
- return the_input.new_completion(['random'], 1, '', quotify=False)
+ return Completion(the_input.new_completion, ['random'], 1, '', quotify=False)
return True
def completion_color(self, the_input):
@@ -273,13 +274,13 @@ class MucTab(ChatTab):
userlist = [user.nick for user in self.users]
if self.own_nick in userlist:
userlist.remove(self.own_nick)
- return the_input.new_completion(userlist, 1, '', quotify=True)
+ return Completion(the_input.new_completion, userlist, 1, '', quotify=True)
elif n == 2:
colors = [i for i in xhtml.colors if i]
colors.sort()
colors.append('unset')
colors.append('random')
- return the_input.new_completion(colors, 2, '', quotify=False)
+ return Completion(the_input.new_completion, colors, 2, '', quotify=False)
def completion_ignore(self, the_input):
"""Completion for /ignore"""
@@ -287,7 +288,7 @@ class MucTab(ChatTab):
if self.own_nick in userlist:
userlist.remove(self.own_nick)
userlist.sort()
- return the_input.auto_completion(userlist, quotify=False)
+ return Completion(the_input.auto_completion, userlist, quotify=False)
def completion_role(self, the_input):
"""Completion for /role"""
@@ -296,10 +297,10 @@ class MucTab(ChatTab):
userlist = [user.nick for user in self.users]
if self.own_nick in userlist:
userlist.remove(self.own_nick)
- return the_input.new_completion(userlist, 1, '', quotify=True)
+ return Completion(the_input.new_completion, userlist, 1, '', quotify=True)
elif n == 2:
possible_roles = ['none', 'visitor', 'participant', 'moderator']
- return the_input.new_completion(possible_roles, 2, '',
+ return Completion(the_input.new_completion, possible_roles, 2, '',
quotify=True)
def completion_affiliation(self, the_input):
@@ -313,11 +314,11 @@ class MucTab(ChatTab):
if self.core.xmpp.boundjid.bare in jidlist:
jidlist.remove(self.core.xmpp.boundjid.bare)
userlist.extend(jidlist)
- return the_input.new_completion(userlist, 1, '', quotify=True)
+ return Completion(the_input.new_completion, userlist, 1, '', quotify=True)
elif n == 2:
possible_affiliations = ['none', 'member', 'admin',
'owner', 'outcast']
- return the_input.new_completion(possible_affiliations, 2, '',
+ return Completion(the_input.new_completion, possible_affiliations, 2, '',
quotify=True)
@command_args_parser.quoted(1, 1, [''])
@@ -332,7 +333,7 @@ class MucTab(ChatTab):
"""Completion for /invite"""
n = the_input.get_argument_position(quoted=True)
if n == 1:
- return the_input.new_completion(roster.jids(), 1, quotify=True)
+ return Completion(the_input.new_completion, roster.jids(), 1, quotify=True)
def scroll_user_list_up(self):
self.user_win.scroll_up()
@@ -714,7 +715,7 @@ class MucTab(ChatTab):
def completion_topic(self, the_input):
if the_input.get_argument_position() == 1:
- return the_input.auto_completion([self.topic], '', quotify=False)
+ return Completion(the_input.auto_completion, [self.topic], '', quotify=False)
def completion_quoted(self, the_input):
"""Nick completion, but with quotes"""
@@ -725,7 +726,7 @@ class MucTab(ChatTab):
if user.nick != self.own_nick:
word_list.append(user.nick)
- return the_input.new_completion(word_list, 1, quotify=True)
+ return Completion(the_input.new_completion, word_list, 1, quotify=True)
@command_args_parser.quoted(1, 1)
def command_kick(self, args):
@@ -914,7 +915,7 @@ class MucTab(ChatTab):
def completion_unignore(self, the_input):
if the_input.get_argument_position() == 1:
users = [user.nick for user in self.ignores]
- return the_input.auto_completion(users, quotify=False)
+ return Completion(the_input.auto_completion, users, quotify=False)
def resize(self):
"""
diff --git a/poezio/tabs/rostertab.py b/poezio/tabs/rostertab.py
index f8b3e906..64aae731 100644
--- a/poezio/tabs/rostertab.py
+++ b/poezio/tabs/rostertab.py
@@ -25,6 +25,7 @@ from poezio.decorators import refresh_wrapper
from poezio.roster import RosterGroup, roster
from poezio.theming import get_theme, dump_tuple
from poezio.decorators import command_args_parser
+from poezio.core.structs import Completion
from poezio.tabs import Tab
@@ -277,7 +278,7 @@ class RosterInfoTab(Tab):
elif n == 2:
return self.completion_file(2, the_input)
elif n == 3:
- return the_input.new_completion(['true', 'false'], n)
+ return Completion(the_input.new_completion, ['true', 'false'], n)
@command_args_parser.quoted(1)
def command_cert_disable(self, args):
@@ -399,7 +400,7 @@ class RosterInfoTab(Tab):
"""
if the_input.get_argument_position() == 1:
jids = roster.jids()
- return the_input.new_completion(jids, 1, '', quotify=False)
+ return Completion(the_input.new_completion, jids, 1, '', quotify=False)
@command_args_parser.quoted(0, 1)
def command_unblock(self, args):
@@ -429,7 +430,7 @@ class RosterInfoTab(Tab):
if iq['type'] == 'error':
return
l = sorted(str(item) for item in iq['blocklist']['items'])
- return the_input.new_completion(l, 1, quotify=False)
+ return Completion(the_input.new_completion, l, 1, quotify=False)
if the_input.get_argument_position():
self.core.xmpp.plugin['xep_0191'].get_blocked(callback=on_result)
@@ -544,7 +545,7 @@ class RosterInfoTab(Tab):
if n == complete_number:
if args[n-1] == '' or len(args) < n+1:
home = os.getenv('HOME') or '/'
- return the_input.new_completion([home, '/tmp'], n, quotify=True)
+ return Completion(the_input.new_completion, [home, '/tmp'], n, quotify=True)
path_ = args[n]
if path.isdir(path_):
dir_ = path_
@@ -567,7 +568,7 @@ class RosterInfoTab(Tab):
if not name.startswith('.'):
end_list.append(value)
- return the_input.new_completion(end_list, n, quotify=True)
+ return Completion(the_input.new_completion, end_list, n, quotify=True)
@command_args_parser.ignored
def command_clear(self):
@@ -872,24 +873,24 @@ class RosterInfoTab(Tab):
Completion for /remove
"""
jids = [jid for jid in roster.jids()]
- return the_input.auto_completion(jids, '', quotify=False)
+ return Completion(the_input.auto_completion, jids, '', quotify=False)
def completion_name(self, the_input):
"""Completion for /name"""
n = the_input.get_argument_position()
if n == 1:
jids = [jid for jid in roster.jids()]
- return the_input.new_completion(jids, n, quotify=True)
+ return Completion(the_input.new_completion, jids, n, quotify=True)
return False
def completion_groupadd(self, the_input):
n = the_input.get_argument_position()
if n == 1:
jids = sorted(jid for jid in roster.jids())
- return the_input.new_completion(jids, n, '', quotify=True)
+ return Completion(the_input.new_completion, jids, n, '', quotify=True)
elif n == 2:
groups = sorted(group for group in roster.groups if group != 'none')
- return the_input.new_completion(groups, n, '', quotify=True)
+ return Completion(the_input.new_completion, groups, n, '', quotify=True)
return False
def completion_groupmove(self, the_input):
@@ -897,7 +898,7 @@ class RosterInfoTab(Tab):
n = the_input.get_argument_position()
if n == 1:
jids = sorted(jid for jid in roster.jids())
- return the_input.new_completion(jids, n, '', quotify=True)
+ return Completion(the_input.new_completion, jids, n, '', quotify=True)
elif n == 2:
contact = roster[args[1]]
if not contact:
@@ -905,10 +906,10 @@ class RosterInfoTab(Tab):
groups = list(contact.groups)
if 'none' in groups:
groups.remove('none')
- return the_input.new_completion(groups, n, '', quotify=True)
+ return Completion(the_input.new_completion, groups, n, '', quotify=True)
elif n == 3:
groups = sorted(group for group in roster.groups)
- return the_input.new_completion(groups, n, '', quotify=True)
+ return Completion(the_input.new_completion, groups, n, '', quotify=True)
return False
def completion_groupremove(self, the_input):
@@ -916,7 +917,7 @@ class RosterInfoTab(Tab):
n = the_input.get_argument_position()
if n == 1:
jids = sorted(jid for jid in roster.jids())
- return the_input.new_completion(jids, n, '', quotify=True)
+ return Completion(the_input.new_completion, jids, n, '', quotify=True)
elif n == 2:
contact = roster[args[1]]
if contact is None:
@@ -926,7 +927,7 @@ class RosterInfoTab(Tab):
groups.remove('none')
except ValueError:
pass
- return the_input.new_completion(groups, n, '', quotify=True)
+ return Completion(the_input.new_completion, groups, n, '', quotify=True)
return False
def completion_deny(self, the_input):
@@ -936,7 +937,7 @@ class RosterInfoTab(Tab):
"""
jids = sorted(str(contact.bare_jid) for contact in roster.contacts.values()
if contact.pending_in)
- return the_input.new_completion(jids, 1, '', quotify=False)
+ return Completion(the_input.new_completion, jids, 1, '', quotify=False)
@command_args_parser.quoted(0, 1)
def command_accept(self, args):