summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.py9
-rw-r--r--src/tabs.py46
-rw-r--r--src/windows.py6
3 files changed, 44 insertions, 17 deletions
diff --git a/src/core.py b/src/core.py
index 5f535f48..d147e7ce 100644
--- a/src/core.py
+++ b/src/core.py
@@ -2403,7 +2403,11 @@ class Core(object):
if replaced_id is not '':
conversation.modify_message(body, replaced_id, message['id'])
else:
- conversation._text_buffer.add_message(body, date, nickname=remote_nick, nick_color=get_theme().COLOR_REMOTE_USER, history=delayed)
+ conversation._text_buffer.add_message(body, date,
+ nickname=remote_nick,
+ nick_color=get_theme().COLOR_REMOTE_USER,
+ history=delayed,
+ identifier=message['id'])
if conversation.remote_wants_chatstates is None and not delayed:
if message['chat_state']:
conversation.remote_wants_chatstates = True
@@ -2502,7 +2506,8 @@ class Core(object):
tab.modify_message(body, replaced_id, message['id'])
else:
tab.add_message(body, time=None, nickname=nick_from,
- forced_user=self.get_tab_by_name(room_from, tabs.MucTab).get_user_by_name(nick_from))
+ forced_user=self.get_tab_by_name(room_from, tabs.MucTab).get_user_by_name(nick_from),
+ identifier=message['id'])
conversation = self.get_tab_by_name(jid.full, tabs.PrivateTab)
if conversation and conversation.remote_wants_chatstates is None:
if message['chat_state']:
diff --git a/src/tabs.py b/src/tabs.py
index f4e224f7..954f3b25 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -451,6 +451,13 @@ class ChatTab(Tab):
user='',
str_time=''
)
+ def log_message(self, txt, time, nickname):
+ """
+ Log the messages in the archives, if it needs
+ to be
+ """
+ if time is None and self.joined: # don't log the history messages
+ logger.log_message(self.name, nickname, txt)
def last_words_completion(self):
"""
@@ -605,7 +612,7 @@ class ChatTab(Tab):
def get_conversation_messages(self):
return self._text_buffer.messages
- def command_say(self, line):
+ def command_say(self, line, correct=False):
pass
def on_line_up(self):
@@ -1717,7 +1724,14 @@ class PrivateTab(ChatTab):
# This lets a plugin insert \x19xxx} colors, that will
# be converted in xhtml.
self.core.events.trigger('private_say', msg, self)
- self.add_message(msg['body'], nickname=self.core.own_nick or self.own_nick, nick_color=get_theme().COLOR_OWN_NICK)
+ if correct:
+ msg['replace']['id'] = self.last_sent_message['id']
+ self.modify_message(line, self.last_sent_message['id'], msg['id'])
+ else:
+ self.add_message(msg['body'],
+ nickname=self.core.own_nick or self.own_nick,
+ nick_color=get_theme().COLOR_OWN_NICK,
+ identifier=msg['id'])
if msg['body'].find('\x19') != -1:
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
msg['body'] = xhtml.clean_text(msg['body'])
@@ -1726,8 +1740,6 @@ class PrivateTab(ChatTab):
msg['chat_state'] = needed
if attention and self.remote_supports_attention:
msg['attention'] = True
- if correct:
- msg['replace']['id'] = self.last_sent_message['id']
self.core.events.trigger('private_say_after', msg, self)
self.last_sent_message = msg
msg.send()
@@ -1905,8 +1917,11 @@ class PrivateTab(ChatTab):
self.add_message(txt=reason)
def modify_message(self, txt, old_id, new_id):
- self._text_buffer.modify_message(txt, old_id, new_id)
- self.core.refresh_window()
+ self.log_message(txt, time, self.name)
+ message = self._text_buffer.modify_message(txt, old_id, new_id, time=time)
+ if message:
+ self.text_win.modify_message(old_id, message)
+ self.core.refresh_window()
def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None):
self._text_buffer.add_message(txt, time=time,
@@ -2774,8 +2789,14 @@ class ConversationTab(ChatTab):
# This lets a plugin insert \x19xxx} colors, that will
# be converted in xhtml.
self.core.events.trigger('conversation_say', msg, self)
- self.add_message(msg['body'], nickname=self.core.own_nick,
- nick_color=get_theme().COLOR_OWN_NICK)
+ if correct:
+ msg['replace']['id'] = self.last_sent_message['id']
+ self.modify_message(line, self.last_sent_message['id'], msg['id'])
+ else:
+ self.add_message(msg['body'],
+ nickname=self.core.own_nick,
+ nick_color=get_theme().COLOR_OWN_NICK,
+ identifier=msg['id'])
if msg['body'].find('\x19') != -1:
msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
msg['body'] = xhtml.clean_text(msg['body'])
@@ -2784,8 +2805,6 @@ class ConversationTab(ChatTab):
msg['chat_state'] = needed
if attention and self.remote_supports_attention:
msg['attention'] = True
- if correct:
- msg['replace']['id'] = self.last_sent_message['id']
self.core.events.trigger('conversation_say_after', msg, self)
self.last_sent_message = msg
msg.send()
@@ -2980,8 +2999,11 @@ class ConversationTab(ChatTab):
self.send_chat_state('gone')
def modify_message(self, txt, old_id, new_id):
- self._text_buffer.modify_message(txt, old_id, new_id)
- self.core.refresh_window()
+ self.log_message(txt, time, self.name)
+ message = self._text_buffer.modify_message(txt, old_id, new_id, time=time)
+ if message:
+ self.text_win.modify_message(old_id, message)
+ self.core.refresh_window()
def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None):
self._text_buffer.add_message(txt, time=time,
diff --git a/src/windows.py b/src/windows.py
index 1bab7777..c9ba0f61 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -945,10 +945,10 @@ class TextWin(Win):
(instead of rebuilding everything in order to correct a message)
"""
with_timestamps = config.get("show_timestamps", 'true') != 'false'
- for i in range(len(self.built_lines)-1, 0, -1):
- if self.built_lines[i].msg.identifier == old_id:
+ for i in range(len(self.built_lines)-1, -1, -1):
+ if self.build_lines[i] and self.built_lines[i].msg.identifier == old_id:
index = i
- while index > 0 and self.built_lines[index].msg.identifier == old_id:
+ while index >= 0 and self.built_lines[index].msg.identifier == old_id:
self.built_lines.pop(index)
index -= 1
index += 1