From 4c0a3fb5a2eca27133e558fa8394b3d07d0203ba Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 17 May 2012 03:34:04 +0200 Subject: [PATCH] Resolves separator persistence problems - Fixes #2073 Now we have to pass the textbuffer object when we want to add a line separator. --- src/tabs.py | 8 ++++---- src/windows.py | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/tabs.py b/src/tabs.py index f97c7f03..be2a886d 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -535,7 +535,7 @@ class ChatTab(Tab): def move_separator(self): self.text_win.remove_line_separator() - self.text_win.add_line_separator() + self.text_win.add_line_separator(self._text_buffer) self.text_win.refresh() self.input.refresh() @@ -1150,7 +1150,7 @@ class MucTab(ChatTab): else: self.state = 'disconnected' self.text_win.remove_line_separator() - self.text_win.add_line_separator() + self.text_win.add_line_separator(self._text_buffer) if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and not self.input.get_text(): self.send_chat_state('inactive') @@ -1686,7 +1686,7 @@ class PrivateTab(ChatTab): def on_lose_focus(self): self.state = 'normal' self.text_win.remove_line_separator() - self.text_win.add_line_separator() + self.text_win.add_line_separator(self._text_buffer) tab = self.core.get_tab_by_name(JID(self.name).bare, MucTab) if tab and tab.joined and config.get_by_tabname( 'send_chat_states', 'true', self.general_jid, True) == 'true'\ @@ -2604,7 +2604,7 @@ class ConversationTab(ChatTab): resource = None self.state = 'normal' self.text_win.remove_line_separator() - self.text_win.add_line_separator() + self.text_win.add_line_separator(self._text_buffer) if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and (not self.input.get_text() or not self.input.get_text().startswith('//')): if resource: self.send_chat_state('inactive') diff --git a/src/windows.py b/src/windows.py index ae79fb74..ea2cb3f7 100644 --- a/src/windows.py +++ b/src/windows.py @@ -620,11 +620,17 @@ class TextWin(Win): self.pos = 0 self.built_lines = [] # Each new message is built and kept here. # on resize, we rebuild all the messages + self.lock = False self.lock_buffer = [] + + # the Lines of the highlights in that buffer self.highlights = [] + # the current HL position in that list self.hl_pos = -1 + self.separator_after = None + def toggle_lock(self): if self.lock: self.release_lock() @@ -738,13 +744,18 @@ class TextWin(Win): log.debug('remove_line_separator') if None in self.built_lines: self.built_lines.remove(None) + self.separator_after = None - def add_line_separator(self): + def add_line_separator(self, room=None): """ add a line separator at the end of messages list + room is a textbuffer that is needed to get the previous message + (in case of resize) """ if None not in self.built_lines: self.built_lines.append(None) + if room: + self.separator_after = room.messages[-1] def build_new_message(self, message, history=None, clean=True, highlight=False): """ @@ -862,6 +873,8 @@ class TextWin(Win): self.built_lines = [] for message in room.messages: self.build_new_message(message, clean=False) + if self.separator_after is message: + self.build_new_message(None) while len(self.built_lines) > self.lines_nb_limit: self.built_lines.pop(0)