diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-07-08 20:42:01 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-07-08 20:42:01 +0000 |
commit | 640eb2498c5427119d9ab9dac1235881666b41ca (patch) | |
tree | 923db9bafc22033d5e0467969f6baf0feacd25b7 | |
parent | 49e62b940f769d9794f34c3f902637e82079d5bb (diff) | |
download | poezio-640eb2498c5427119d9ab9dac1235881666b41ca.tar.gz poezio-640eb2498c5427119d9ab9dac1235881666b41ca.tar.bz2 poezio-640eb2498c5427119d9ab9dac1235881666b41ca.tar.xz poezio-640eb2498c5427119d9ab9dac1235881666b41ca.zip |
when tab is pressed when nothing is in the input, complete to the last nickname who spole. fixed #1566
-rw-r--r-- | src/gui.py | 18 | ||||
-rw-r--r-- | src/window.py | 2 |
2 files changed, 16 insertions, 4 deletions
@@ -99,8 +99,8 @@ class Gui(object): "^N": self.rotate_rooms_left, "KEY_F(6)": self.rotate_rooms_right, "^P": self.rotate_rooms_right, - "\t": self.auto_completion, - "^I": self.auto_completion, + "\t": self.completion, + "^I": self.completion, "KEY_RESIZE": self.resize_window, "KEY_BACKSPACE": self.window.input.key_backspace, '^J': self.execute, @@ -228,7 +228,7 @@ class Gui(object): self.rooms.insert(0, self.rooms.pop()) self.window.refresh(self.rooms) - def auto_completion(self): + def completion(self): """ Called when Tab is pressed, complete the nickname in the input """ @@ -241,8 +241,20 @@ class Gui(object): if a.show is None: return -1 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)) + def last_talked_completion(self): + """ + If tab is used while the input is empty, insert the nickname + of the last person who spoke + """ + for msg in self.current_room().messages[::-1]: + if msg.nickname is not None and msg.nickname != self.current_room().own_nick: + self.window.input.text = msg.nickname+config.get('after_completion', ',')+" " + self.window.input.key_end() + 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 1461b247..7d8a5e60 100644 --- a/src/window.py +++ b/src/window.py @@ -248,7 +248,7 @@ class TextWin(Win): if txt.startswith('\n'): txt = txt[1:] first = False - return lines[-len(messages):]# return only the needed number of lines + return lines[-len(messages):] # return only the needed number of lines def refresh(self, room): """ |