Commit 4c0a3fb5 authored by mathieui's avatar mathieui

Resolves separator persistence problems - Fixes #2073

Now we have to pass the textbuffer object when we want to add a line
separator.
parent 0f7bda20
......@@ -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')
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment