summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-08 20:57:07 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-07-08 20:57:07 +0000
commit660ddf847fbb8b693223ba96e9f8f4e79d17fadc (patch)
tree0f84b26ab28851f8d3b0e8354ab1861762aa1c7e
parent640eb2498c5427119d9ab9dac1235881666b41ca (diff)
downloadpoezio-660ddf847fbb8b693223ba96e9f8f4e79d17fadc.tar.gz
poezio-660ddf847fbb8b693223ba96e9f8f4e79d17fadc.tar.bz2
poezio-660ddf847fbb8b693223ba96e9f8f4e79d17fadc.tar.xz
poezio-660ddf847fbb8b693223ba96e9f8f4e79d17fadc.zip
Shift+TAB is used to complete recently said words. fixed #1563
-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