diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-08-07 19:18:36 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-08-07 19:18:36 +0000 |
commit | 05928d592f76c7948a19981454d763feee51b2fb (patch) | |
tree | 8cd049bbc0d987fee219f51aa258be924274baab | |
parent | eb36e08e11e8acac2db6a0422b5c9bd5ec9ab395 (diff) | |
download | poezio-05928d592f76c7948a19981454d763feee51b2fb.tar.gz poezio-05928d592f76c7948a19981454d763feee51b2fb.tar.bz2 poezio-05928d592f76c7948a19981454d763feee51b2fb.tar.xz poezio-05928d592f76c7948a19981454d763feee51b2fb.zip |
completion is now sorted by last_talked. fixed #1712
-rw-r--r-- | src/gui.py | 27 | ||||
-rw-r--r-- | src/keyboard.py | 5 | ||||
-rw-r--r-- | src/user.py | 5 | ||||
-rw-r--r-- | src/window.py | 14 |
4 files changed, 21 insertions, 30 deletions
@@ -264,28 +264,17 @@ class Gui(object): """ def compare_users(a, b): """ - Used to sort users by their availability + Used to sort users by their last_talked """ - if a.show == b.show: + if not a.last_talked and b.last_talked: return 0 - if a.show is None: + elif not b.last_talked and a.last_talked: + return 1 + if a.last_talked < b.last_talked: + return 1 + else: return -1 - return 1 - if len(self.window.input.text) == 0: - self.last_talked_completion() - else: - self.window.input.auto_completion([user.nick for user in 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() - return + self.window.input.auto_completion([user.nick for user in sorted(self.current_room().users, compare_users)]) def last_words_completion(self): """ diff --git a/src/keyboard.py b/src/keyboard.py index 90bd79ef..9fdef730 100644 --- a/src/keyboard.py +++ b/src/keyboard.py @@ -23,8 +23,6 @@ of the time ONE char, but may be longer if it's a keyboard shortcut, like ^A, M-a or KEY_RESIZE) """ -from common import debug - def get_next_byte(s): """ Read the next byte of the utf-8 char @@ -54,15 +52,12 @@ def read_char(s): (first, c) = get_next_byte(s) char = "M-"+c if 194 <= first: - debug('1\n') (code, c) = get_next_byte(s) # 2 bytes char char += c if 224 <= first: - debug('2\n') (code, c) = get_next_byte(s) # 3 bytes char char += c if 240 <= first: - debug('3\n') (code, c) = get_next_byte(s) # 4 bytes char char += c return char diff --git a/src/user.py b/src/user.py index c0a55d7b..5dbe77ce 100644 --- a/src/user.py +++ b/src/user.py @@ -59,5 +59,6 @@ class User(object): return True def __repr__(self): - return "<user.User object nick:%s show:%s(%s) status:%s affiliation:%s>"\ - % (self.nick, self.show, type(self.show), self.status, self.affiliation) + return ">%s<" % (self.nick.decode('utf-8')) + # return "<user.User object nick:%s show:%s(%s) status:%s affiliation:%s>"\ + # % (self.nick.decode('utf-8'), self.show, type(self.show), self.status, self.affiliation) diff --git a/src/window.py b/src/window.py index a0b58cfd..2c030afe 100644 --- a/src/window.py +++ b/src/window.py @@ -541,10 +541,10 @@ class Input(Win): """ Complete the nickname """ - if self.pos+self.line_pos != len(self.text) or len(self.text) == 0: + if self.pos+self.line_pos != len(self.text): # or len(self.text) == 0 return # we don't complete if cursor is not at the end of line completion_type = config.get('completion', 'normal') - if completion_type == 'shell': + if completion_type == 'shell' and self.text != '': self.shell_completion(user_list) else: self.normal_completion(user_list) @@ -567,7 +567,10 @@ class Input(Win): (y, x) = self.win.getyx() if not self.last_key_tab: # begin is the begining of the nick we want to complete - begin = self.text.split()[-1].encode('utf-8').lower() + if self.text != '': + begin = self.text.split()[-1].encode('utf-8').lower() + else: + begin = '' hit_list = [] # list of matching nicks for user in user_list: if user.lower().startswith(begin): @@ -595,7 +598,10 @@ class Input(Win): else: after = config.get('after_completion', ',')+" " (y, x) = self.win.getyx() - begin = self.text.split()[-1].encode('utf-8').lower() + if self.text != '': + begin = self.text.split()[-1].encode('utf-8').lower() + else: + begin = '' hit_list = [] # list of matching nicks for user in user_list: if user.lower().startswith(begin): |