Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 1350:32ccda01a2be frontends_multi_profiles
frontends (primitivus): fixes MUC nicks completion
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 04 Mar 2015 14:04:03 +0100 |
parents | a39d2db03c80 |
children | 361b0fe72961 |
comparison
equal
deleted
inserted
replaced
1349:273b044fde6d | 1350:32ccda01a2be |
---|---|
67 return text | 67 return text |
68 | 68 |
69 def _nick_completion(self, text, completion_data): | 69 def _nick_completion(self, text, completion_data): |
70 """Completion method which complete pseudo in group chat | 70 """Completion method which complete pseudo in group chat |
71 for params, see AdvancedEdit""" | 71 for params, see AdvancedEdit""" |
72 contact = self.host.contact_list.getContact() ###Based on the fact that there is currently only one contact selectable at once | 72 nicks = [] |
73 if contact: | 73 for profile, clist in self.host.contact_lists.iteritems(): |
74 chat = self.host.chat_wins[contact] | 74 for contact in clist.getContacts(): |
75 if chat.type != "group": | 75 chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile) |
76 return text | 76 if chat.type != C.CHAT_GROUP: |
77 space = text.rfind(" ") | 77 continue |
78 start = text[space+1:] | 78 space = text.rfind(" ") |
79 nicks = list(chat.occupants) | 79 start = text[space + 1:] |
80 nicks.extend(list(chat.occupants)) | |
81 if nicks: | |
80 nicks.sort() | 82 nicks.sort() |
81 try: | 83 try: |
82 start_idx=nicks.index(completion_data['last_nick'])+1 | 84 start_idx = nicks.index(completion_data['last_nick']) + 1 |
83 if start_idx == len(nicks): | 85 if start_idx == len(nicks): |
84 start_idx = 0 | 86 start_idx = 0 |
85 except (KeyError,ValueError): | 87 except (KeyError, ValueError): |
86 start_idx = 0 | 88 start_idx = 0 |
87 for idx in range(start_idx,len(nicks)) + range(0,start_idx): | 89 for idx in range(start_idx, len(nicks)) + range(0, start_idx): |
88 if nicks[idx].lower().startswith(start.lower()): | 90 if nicks[idx].lower().startswith(start.lower()): |
89 completion_data['last_nick'] = nicks[idx] | 91 completion_data['last_nick'] = nicks[idx] |
90 return text[:space+1] + nicks[idx] + (': ' if space < 0 else '') | 92 return text[:space + 1] + nicks[idx] + (': ' if space < 0 else '') |
91 return text | 93 return text |
92 | 94 |
93 def onTextEntered(self, editBar): | 95 def onTextEntered(self, editBar): |
94 """Called when text is entered in the main edit bar""" | 96 """Called when text is entered in the main edit bar""" |
95 if self.mode == C.MODE_INSERTION: | 97 if self.mode == C.MODE_INSERTION: |