Commit a351473e authored by mathieui's avatar mathieui

Fix a wrong text offset

(caused text to align left if the message was multiline and the first
line was out of screen)
parent 5e2720fa
......@@ -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:
......
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