Completion for /bookmark and /bookmark_local
This commit is contained in:
parent
f1a637f24b
commit
fe06d58e74
1 changed files with 36 additions and 0 deletions
36
src/core.py
36
src/core.py
|
@ -1519,6 +1519,36 @@ class Core(object):
|
||||||
the_input.auto_completion(serv_list, '')
|
the_input.auto_completion(serv_list, '')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def completion_bookmark_local(self, the_input):
|
||||||
|
"""Completion for /bookmark_local"""
|
||||||
|
txt = the_input.get_text()
|
||||||
|
args = common.shell_split(txt)
|
||||||
|
n = len(args)
|
||||||
|
if txt.endswith(' '):
|
||||||
|
n += 1
|
||||||
|
|
||||||
|
if len(args) == 1:
|
||||||
|
jid = JID('')
|
||||||
|
else:
|
||||||
|
jid = JID(args[1])
|
||||||
|
if len(args) > 2:
|
||||||
|
return
|
||||||
|
if jid.server and (jid.resource or jid.full.endswith('/')):
|
||||||
|
tab = self.get_tab_by_name(jid.bare, tabs.MucTab)
|
||||||
|
nicks = [tab.own_nick] if tab else []
|
||||||
|
default = os.environ.get('USER') if os.environ.get('USER') else 'poezio'
|
||||||
|
nick = config.get('default_nick', '')
|
||||||
|
if not nick:
|
||||||
|
if not default in nicks:
|
||||||
|
nicks.append(default)
|
||||||
|
else:
|
||||||
|
if not nick in nicks:
|
||||||
|
nicks.append(nick)
|
||||||
|
jids_list = ['%s/%s' % (jid.bare, nick) for nick in nicks]
|
||||||
|
return the_input.auto_completion(jids_list, '')
|
||||||
|
muc_list = [tab.get_name() for tab in self.tabs if isinstance(tab, tabs.MucTab)]
|
||||||
|
return the_input.auto_completion(muc_list, '')
|
||||||
|
|
||||||
def completion_bookmark(self, the_input):
|
def completion_bookmark(self, the_input):
|
||||||
"""Completion for /bookmark"""
|
"""Completion for /bookmark"""
|
||||||
txt = the_input.get_text()
|
txt = the_input.get_text()
|
||||||
|
@ -1531,6 +1561,12 @@ class Core(object):
|
||||||
jid = JID('')
|
jid = JID('')
|
||||||
else:
|
else:
|
||||||
jid = JID(args[1])
|
jid = JID(args[1])
|
||||||
|
|
||||||
|
if len(args) == 2:
|
||||||
|
return the_input.auto_completion(['true', 'false'], '')
|
||||||
|
if len(args) == 3:
|
||||||
|
return
|
||||||
|
|
||||||
if jid.server and (jid.resource or jid.full.endswith('/')):
|
if jid.server and (jid.resource or jid.full.endswith('/')):
|
||||||
tab = self.get_tab_by_name(jid.bare, tabs.MucTab)
|
tab = self.get_tab_by_name(jid.bare, tabs.MucTab)
|
||||||
nicks = [tab.own_nick] if tab else []
|
nicks = [tab.own_nick] if tab else []
|
||||||
|
|
Loading…
Reference in a new issue