From 91fde24388c97d5f74b1b68d5ada7f69725ab964 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 13 Apr 2015 17:32:35 +0200 Subject: Display error messages inside a conversation if the error has the same id as a sent message, it will be displayed with a cross where there is usually a checkmark (ack), and the received error will be appended to the message, in red. if it does not have a know id, it will be added as another message to the conversation, without a nick, and in red. --- src/windows/text_win.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/windows') diff --git a/src/windows/text_win.py b/src/windows/text_win.py index 380142bb..bdda721c 100644 --- a/src/windows/text_win.py +++ b/src/windows/text_win.py @@ -307,7 +307,10 @@ class TextWin(BaseTextWin): nick = truncate_nick(message.nickname) offset = 0 if message.ack: - offset += poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1 + if message.ack > 0: + offset += poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1 + else: + offset += poopt.wcswidth(get_theme().CHAR_NACK) + 1 if nick: offset += poopt.wcswidth(nick) + 2 # + nick + '> ' length if message.revisions > 0: @@ -361,7 +364,10 @@ class TextWin(BaseTextWin): if with_timestamps: self.write_time(msg.str_time) if msg.ack: - self.write_ack() + if msg.ack > 0: + self.write_ack() + else: + self.write_nack() if msg.me: self._win.attron(to_curses_attr(get_theme().COLOR_ME_MESSAGE)) self.addstr('* ') @@ -404,8 +410,11 @@ class TextWin(BaseTextWin): offset += ceil(log10(line.msg.revisions + 1)) if line.msg.ack: - offset += 1 + poopt.wcswidth( - get_theme().CHAR_ACK_RECEIVED) + if msg.ack > 0: + offset += 1 + poopt.wcswidth( + get_theme().CHAR_ACK_RECEIVED) + else: + offset += 1 + poopt.wcswidth(get_theme().CHAR_NACK) self.write_text(y, offset, line.prepend+line.msg.txt[line.start_pos:line.end_pos]) @@ -428,6 +437,13 @@ class TextWin(BaseTextWin): self._win.attroff(to_curses_attr(color)) self.addstr(' ') + def write_nack(self): + color = get_theme().COLOR_CHAR_NACK + self._win.attron(to_curses_attr(color)) + self.addstr(get_theme().CHAR_NACK) + self._win.attroff(to_curses_attr(color)) + self.addstr(' ') + def write_nickname(self, nickname, color, highlight=False): """ Write the nickname, using the user's color -- cgit v1.2.3