From da58aeaf884967d825325a67e839e44778d55ef9 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 10 Nov 2006 20:06:57 +0000 Subject: [PATCH] [Petteri] topic autocompletion. fixes #2654 --- src/groupchat_control.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index d4f77414c..a99629f22 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -1418,11 +1418,22 @@ class GroupchatControl(ChatControlBase): end_iter = message_buffer.get_iter_at_mark(cursor_position) text = message_buffer.get_text(start_iter, end_iter, False).decode( 'utf-8') - if text.endswith(' '): - if not self.last_key_tabs: - return False splitted_text = text.split() + # topic completion + splitted_text2 = text.split(None, 1) + if text.startswith('/topic '): + if len(splitted_text2) == 2 and \ + self.subject.startswith(splitted_text2[1]) and\ + len(self.subject) > len(splitted_text2[1]): + message_buffer.insert_at_cursor( + self.subject[len(splitted_text2[1]):]) + return True + elif len(splitted_text2) == 1 and text.startswith('/topic '): + message_buffer.delete(start_iter, end_iter) + message_buffer.insert_at_cursor('/topic '+self.subject) + return True + # command completion if text.startswith('/') and len(splitted_text) == 1: text = splitted_text[0]