[louizatakk] shell-like completion

This commit is contained in:
Yann Leboulanger 2009-10-16 15:20:12 +02:00
parent da955fd4da
commit 43f87899f8
2 changed files with 18 additions and 1 deletions

View File

@ -270,6 +270,7 @@ class Config:
'latex_png_dpi': [opt_str, '108',_('Change the value to change the size of latex formulas displayed. The higher is larger.') ],
'uri_schemes': [opt_str, 'aaa aaas acap cap cid crid data dav dict dns fax file ftp go gopher h323 http https icap im imap info ipp iris iris.beep iris.xpc iris.xpcs iris.lwz ldap mid modem msrp msrps mtqp mupdate news nfs nntp opaquelocktoken pop pres rtsp service shttp sip sips snmp soap.beep soap.beeps tag tel telnet tftp thismessage tip tv urn vemmi xmlrpc.beep xmlrpc.beeps z39.50r z39.50s about cvs daap ed2k feed fish git iax2 irc ircs ldaps magnet mms rsync ssh svn sftp smb webcal', _('Valid uri schemes. Only schemes in this list will be accepted as "real" uri. (mailto and xmpp are handled separately)'), True],
'ask_offline_status_on_connection': [ opt_bool, False, _('Ask offline status message to all offline contacts when connection to an accoutn is established. WARNING: This causes a lot of requests to be sent!') ],
'shell_like_completion': [ opt_bool, False, _('If True, completion in groupchats will be like a shell auto-completion')],
}
__options_per_key = {

View File

@ -1856,7 +1856,23 @@ class GroupchatControl(ChatControlBase):
start_iter.backward_chars(len(begin))
message_buffer.delete(start_iter, end_iter)
message_buffer.insert_at_cursor(self.nick_hits[0] + add)
completion = self.nick_hits[0]
# get a shell-like completion
# if there's more than one nick for this completion, complete only
# the part that all these nicks have in common
if gajim.config.get('shell_like_completion') and \
len(self.nick_hits) > 1:
end = False
cur = ''
while not end:
cur = self.nick_hits[0][:len(cur)+1]
for nick in self.nick_hits:
if cur.lower() not in nick.lower():
end = True
cur = cur[:-1]
completion = cur
add = "" # if nick is not complete, don't but any comma or so
message_buffer.insert_at_cursor(completion + add)
self.last_key_tabs = True
return True
self.last_key_tabs = False