From 347733804f8d61a01bc0a286f6f872f8dd14527d Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 1 Oct 2011 20:46:20 +0200 Subject: Do not try to cycle completion on commands if there was only one possibily. You can now see by the space appended at the end if it was the only one. It lets you complete arguments without having to add a stupid space after the command name --- src/tabs.py | 10 ++++++++-- src/windows.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tabs.py b/src/tabs.py index 1b6aeb7c..fbcfc597 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -125,7 +125,13 @@ class Tab(object): # complete the command's name words = ['/%s'% (name) for name in self.core.commands] +\ ['/%s' % (name) for name in self.commands] - the_input.auto_completion(words, ' ') + the_input.auto_completion(words, '') + # Do not try to cycle command completion if there was only + # one possibily. The next tab will complete the argument. + # Otherwise we would need to add a useless space before being + # able to complete the arguments. + if len(the_input.hit_list) == 1: + the_input.do_command(' ') return True return False @@ -600,7 +606,7 @@ class MucTab(ChatTab): def completion_topic(self, the_input): current_topic = self.get_room().topic - return the_input.auto_completion([current_topic], ' ') + return the_input.auto_completion([current_topic], '') def command_kick(self, arg): """ diff --git a/src/windows.py b/src/windows.py index 03066857..fb99416c 100644 --- a/src/windows.py +++ b/src/windows.py @@ -122,7 +122,6 @@ class Win(object): self.move(y, x) next_attr_char = text.find('\x19') while next_attr_char != -1 and text: - log.debug('Addstr_Colored: [%s]' % text.replace('\x19', '\\x19')) if next_attr_char + 1 < len(text): attr_char = text[next_attr_char+1].lower() else: @@ -961,7 +960,7 @@ class Input(Win): if pos < len(self.text) and after.endswith(' ') and self.text[pos] == ' ': after = after[:-1] # remove the last space if we are already on a space if not self.last_completion: - space_before_cursor = self.text.rfind(' ', 0, pos-1) + space_before_cursor = self.text.rfind(' ', 0, pos) if space_before_cursor != -1: begin = self.text[space_before_cursor+1:pos] else: @@ -1043,7 +1042,8 @@ class Input(Win): return res if not key or len(key) > 1: return False # ignore non-handled keyboard shortcuts - self.reset_completion() + if reset: + self.reset_completion() self.text = self.text[:self.pos+self.line_pos]+key+self.text[self.pos+self.line_pos:] (y, x) = self._win.getyx() if x == self.width-1: -- cgit v1.2.3