From a351473ebfe7ee397aa9f27990fa0144329aa9e5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 4 Dec 2015 20:33:18 +0100 Subject: Fix a wrong text offset (caused text to align left if the message was multiline and the first line was out of screen) --- src/windows/text_win.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/windows/text_win.py b/src/windows/text_win.py index 273ee799..fd1fe546 100644 --- a/src/windows/text_win.py +++ b/src/windows/text_win.py @@ -365,6 +365,8 @@ class TextWin(BaseTextWin): msg = line.msg if line.start_pos == 0: offset = self.write_pre_msg(msg, with_timestamps, nick_size) + elif y == 0: + offset = self.compute_offset(msg, with_timestamps, nick_size) self.write_text(y, offset, line.prepend + line.msg.txt[line.start_pos:line.end_pos]) else: @@ -374,6 +376,31 @@ class TextWin(BaseTextWin): self._win.attrset(0) self._refresh() + def compute_offset(self, msg, with_timestamps, nick_size): + offset = 0 + if with_timestamps and msg.str_time: + offset += poopt.wcswidth(msg.str_time) + 1 + + if not msg.nickname: # not a message, nothing to do afterwards + return offset + + nick = truncate_nick(msg.nickname, nick_size) + offset += poopt.wcswidth(nick) + if msg.ack: + if msg.ack > 0: + offset += poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1 + else: + offset += poopt.wcswidth(get_theme().CHAR_NACK) + 1 + if msg.me: + offset += 3 + else: + offset += 2 + if msg.revisions: + offset += ceil(log10(msg.revisions + 1)) + offset += self.write_revisions(msg) + return offset + + def write_pre_msg(self, msg, with_timestamps, nick_size): offset = 0 if with_timestamps: -- cgit v1.2.3