summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui.py18
-rw-r--r--src/window.py8
2 files changed, 21 insertions, 5 deletions
diff --git a/src/gui.py b/src/gui.py
index 2914de11..26fd2506 100644
--- a/src/gui.py
+++ b/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:
diff --git a/src/window.py b/src/window.py
index 7d8a5e60..8931ccac 100644
--- a/src/window.py
+++ b/src/window.py
@@ -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