frontends (primitivus): fixes MUC nicks completion
This commit is contained in:
parent
b160e3d92c
commit
3a35a5590d
1 changed files with 14 additions and 12 deletions
|
|
@ -69,25 +69,27 @@ class EditBar(sat_widgets.ModalEdit):
|
||||||
def _nick_completion(self, text, completion_data):
|
def _nick_completion(self, text, completion_data):
|
||||||
"""Completion method which complete pseudo in group chat
|
"""Completion method which complete pseudo in group chat
|
||||||
for params, see AdvancedEdit"""
|
for params, see AdvancedEdit"""
|
||||||
contact = self.host.contact_list.getContact() ###Based on the fact that there is currently only one contact selectable at once
|
nicks = []
|
||||||
if contact:
|
for profile, clist in self.host.contact_lists.iteritems():
|
||||||
chat = self.host.chat_wins[contact]
|
for contact in clist.getContacts():
|
||||||
if chat.type != "group":
|
chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile)
|
||||||
return text
|
if chat.type != C.CHAT_GROUP:
|
||||||
space = text.rfind(" ")
|
continue
|
||||||
start = text[space+1:]
|
space = text.rfind(" ")
|
||||||
nicks = list(chat.occupants)
|
start = text[space + 1:]
|
||||||
|
nicks.extend(list(chat.occupants))
|
||||||
|
if nicks:
|
||||||
nicks.sort()
|
nicks.sort()
|
||||||
try:
|
try:
|
||||||
start_idx=nicks.index(completion_data['last_nick'])+1
|
start_idx = nicks.index(completion_data['last_nick']) + 1
|
||||||
if start_idx == len(nicks):
|
if start_idx == len(nicks):
|
||||||
start_idx = 0
|
start_idx = 0
|
||||||
except (KeyError,ValueError):
|
except (KeyError, ValueError):
|
||||||
start_idx = 0
|
start_idx = 0
|
||||||
for idx in range(start_idx,len(nicks)) + range(0,start_idx):
|
for idx in range(start_idx, len(nicks)) + range(0, start_idx):
|
||||||
if nicks[idx].lower().startswith(start.lower()):
|
if nicks[idx].lower().startswith(start.lower()):
|
||||||
completion_data['last_nick'] = nicks[idx]
|
completion_data['last_nick'] = nicks[idx]
|
||||||
return text[:space+1] + nicks[idx] + (': ' if space < 0 else '')
|
return text[:space + 1] + nicks[idx] + (': ' if space < 0 else '')
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def onTextEntered(self, editBar):
|
def onTextEntered(self, editBar):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue