From 640eb2498c5427119d9ab9dac1235881666b41ca Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Thu, 8 Jul 2010 20:42:01 +0000 Subject: when tab is pressed when nothing is in the input, complete to the last nickname who spole. fixed #1566 --- src/gui.py | 18 +++++++++++++++--- src/window.py | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui.py b/src/gui.py index 23af902e..2914de11 100644 --- a/src/gui.py +++ b/src/gui.py @@ -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): """ -- cgit v1.2.3