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):
|
||||
"""Completion method which complete pseudo in group chat
|
||||
for params, see AdvancedEdit"""
|
||||
contact = self.host.contact_list.getContact() ###Based on the fact that there is currently only one contact selectable at once
|
||||
if contact:
|
||||
chat = self.host.chat_wins[contact]
|
||||
if chat.type != "group":
|
||||
return text
|
||||
space = text.rfind(" ")
|
||||
start = text[space+1:]
|
||||
nicks = list(chat.occupants)
|
||||
nicks = []
|
||||
for profile, clist in self.host.contact_lists.iteritems():
|
||||
for contact in clist.getContacts():
|
||||
chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile)
|
||||
if chat.type != C.CHAT_GROUP:
|
||||
continue
|
||||
space = text.rfind(" ")
|
||||
start = text[space + 1:]
|
||||
nicks.extend(list(chat.occupants))
|
||||
if nicks:
|
||||
nicks.sort()
|
||||
try:
|
||||
start_idx=nicks.index(completion_data['last_nick'])+1
|
||||
start_idx = nicks.index(completion_data['last_nick']) + 1
|
||||
if start_idx == len(nicks):
|
||||
start_idx = 0
|
||||
except (KeyError,ValueError):
|
||||
except (KeyError, ValueError):
|
||||
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()):
|
||||
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
|
||||
|
||||
def onTextEntered(self, editBar):
|
||||
|
|
|
|||
Loading…
Reference in a new issue