diff options
author | mathieui <mathieui@mathieui.net> | 2015-12-04 20:33:18 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-12-04 20:33:18 +0100 |
commit | a351473ebfe7ee397aa9f27990fa0144329aa9e5 (patch) | |
tree | 17789f7c87f55a1fb7724c5ab63d1928c370c66d /src/windows | |
parent | 5e2720fafbd4ebffa3585ac048673248bb12d55f (diff) | |
download | poezio-a351473ebfe7ee397aa9f27990fa0144329aa9e5.tar.gz poezio-a351473ebfe7ee397aa9f27990fa0144329aa9e5.tar.bz2 poezio-a351473ebfe7ee397aa9f27990fa0144329aa9e5.tar.xz poezio-a351473ebfe7ee397aa9f27990fa0144329aa9e5.zip |
Fix a wrong text offset
(caused text to align left if the message was multiline and the first
line was out of screen)
Diffstat (limited to 'src/windows')
-rw-r--r-- | src/windows/text_win.py | 27 |
1 files changed, 27 insertions, 0 deletions
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: |