Primitivus: added nick completion
This commit is contained in:
parent
1fddd7dea3
commit
03e9f23b01
1 changed files with 27 additions and 0 deletions
|
|
@ -227,11 +227,38 @@ class PrimitivusApp(QuickApp):
|
|||
#self.center_part = urwid.Columns([('weight',2,self.contactList),('weight',8,Chat('',self))])
|
||||
self.center_part = urwid.Columns([('weight',2,self.contactList), ('weight',8,urwid.Filler(urwid.Text('')))])
|
||||
self.editBar = custom_widgets.AdvancedEdit('> ')
|
||||
self.editBar.setCompletionMethod(self._nick_completion)
|
||||
urwid.connect_signal(self.editBar,'click',self.onTextEntered)
|
||||
self.menu_roller = self.__buildMenuRoller()
|
||||
self.main_widget = custom_widgets.FocusFrame(self.center_part, header=self.menu_roller, footer=self.editBar, focus_part='footer')
|
||||
return self.main_widget
|
||||
|
||||
def _nick_completion(self, text, completion_data):
|
||||
"""Completion method which complete pseudo in group chat
|
||||
for params, see AdvancedEdit"""
|
||||
contact = self.contactList.get_contact() ###Based on the fact that there is currently only one contact selectableat once
|
||||
if contact:
|
||||
chat = self.chat_wins[contact]
|
||||
if chat.type != "group":
|
||||
return text
|
||||
space = text.rfind(" ")
|
||||
start = text[space+1:]
|
||||
nicks = list(chat.occupants)
|
||||
nicks.sort()
|
||||
try:
|
||||
start_idx=nicks.index(completion_data['last_nick'])+1
|
||||
if start_idx == len(nicks):
|
||||
start_idx = 0
|
||||
except (KeyError,ValueError):
|
||||
start_idx = 0
|
||||
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
|
||||
|
||||
|
||||
|
||||
def plug_profile(self, profile_key='@DEFAULT@'):
|
||||
self.loop.widget = self.__buildMainWidget()
|
||||
QuickApp.plug_profile(self, profile_key)
|
||||
|
|
|
|||
Loading…
Reference in a new issue