Shift+TAB is used to complete recently said words. fixed #1563
This commit is contained in:
parent
640eb2498c
commit
660ddf847f
2 changed files with 21 additions and 5 deletions
18
src/gui.py
18
src/gui.py
|
@ -101,6 +101,7 @@ class Gui(object):
|
|||
"^P": self.rotate_rooms_right,
|
||||
"\t": self.completion,
|
||||
"^I": self.completion,
|
||||
"KEY_BTAB": self.last_words_completion,
|
||||
"KEY_RESIZE": self.resize_window,
|
||||
"KEY_BACKSPACE": self.window.input.key_backspace,
|
||||
'^J': self.execute,
|
||||
|
@ -243,7 +244,7 @@ class Gui(object):
|
|||
return 1
|
||||
if len(self.window.input.text) == 0:
|
||||
self.last_talked_completion()
|
||||
self.window.input.auto_completion(sorted(self.current_room().users, compare_users))
|
||||
self.window.input.auto_completion([user.nick for user in sorted(self.current_room().users, compare_users)])
|
||||
|
||||
def last_talked_completion(self):
|
||||
"""
|
||||
|
@ -255,6 +256,21 @@ class Gui(object):
|
|||
self.window.input.text = msg.nickname+config.get('after_completion', ',')+" "
|
||||
self.window.input.key_end()
|
||||
|
||||
def last_words_completion(self):
|
||||
"""
|
||||
Complete the input with words recently said
|
||||
"""
|
||||
# build the list of the recent words
|
||||
char_we_dont_want = [',', '(', ')', '.']
|
||||
words = list()
|
||||
for msg in self.current_room().messages[:-6:-1]:
|
||||
for word in msg.txt.split():
|
||||
for char in char_we_dont_want: # remove the chars we don't want
|
||||
word = word.replace(char, '')
|
||||
if len(word) > 5:
|
||||
words.append(word)
|
||||
self.window.input.auto_completion(words)
|
||||
|
||||
def go_to_important_room(self):
|
||||
"""
|
||||
Go to the next room with activity, in this order:
|
||||
|
|
|
@ -549,8 +549,8 @@ class Input(Win):
|
|||
begin = self.text.split()[-1].encode('utf-8').lower()
|
||||
hit_list = [] # list of matching nicks
|
||||
for user in user_list:
|
||||
if user.nick.lower().startswith(begin):
|
||||
hit_list.append(user.nick)
|
||||
if user.lower().startswith(begin):
|
||||
hit_list.append(user)
|
||||
if len(hit_list) == 0:
|
||||
return
|
||||
self.last_key_tab = True
|
||||
|
@ -577,8 +577,8 @@ class Input(Win):
|
|||
begin = self.text.split()[-1].encode('utf-8').lower()
|
||||
hit_list = [] # list of matching nicks
|
||||
for user in user_list:
|
||||
if user.nick.lower().startswith(begin):
|
||||
hit_list.append(user.nick)
|
||||
if user.lower().startswith(begin):
|
||||
hit_list.append(user)
|
||||
if len(hit_list) == 0:
|
||||
return
|
||||
end = False
|
||||
|
|
Loading…
Reference in a new issue