summaryrefslogtreecommitdiff
path: root/poezio/ui
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2019-09-29 12:20:00 +0200
committermathieui <mathieui@mathieui.net>2020-05-09 19:46:17 +0200
commit5bc510eafa5d3e9c735687f0b8c9d446159fffca (patch)
treee00c4b890c0c7e09c32a227b14ae90c0869c6a38 /poezio/ui
parent32beeca48018422499b9c0af55a5c5b1eaa67d75 (diff)
downloadpoezio-5bc510eafa5d3e9c735687f0b8c9d446159fffca.tar.gz
poezio-5bc510eafa5d3e9c735687f0b8c9d446159fffca.tar.bz2
poezio-5bc510eafa5d3e9c735687f0b8c9d446159fffca.tar.xz
poezio-5bc510eafa5d3e9c735687f0b8c9d446159fffca.zip
Fix an issue in xmllog rendering due to wrong offset
and improve tests to catch that
Diffstat (limited to 'poezio/ui')
-rw-r--r--poezio/ui/render.py4
-rw-r--r--poezio/ui/types.py5
2 files changed, 4 insertions, 5 deletions
diff --git a/poezio/ui/render.py b/poezio/ui/render.py
index 64b480a9..b695e8f3 100644
--- a/poezio/ui/render.py
+++ b/poezio/ui/render.py
@@ -100,7 +100,7 @@ def build_xmllog(msg: XMLLog, width: int, timestamp: bool, nick_size: int = 10)
def write_pre(msg: BaseMessage, win, with_timestamps: bool, nick_size: int) -> int:
"""Write the part before text (only the timestamp)"""
if with_timestamps:
- return 1 + PreMessageHelpers.write_time(win, False, msg.time)
+ return PreMessageHelpers.write_time(win, False, msg.time)
return 0
@@ -153,7 +153,7 @@ def write_pre_xmllog(msg: XMLLog, win, with_timestamps: bool, nick_size: int) ->
"""Write the part before the stanza (timestamp + IN/OUT)"""
offset = 0
if with_timestamps:
- offset += PreMessageHelpers.write_time(win, False, msg.time)
+ offset += 1 + PreMessageHelpers.write_time(win, False, msg.time)
theme = get_theme()
if msg.incoming:
char = theme.CHAR_XML_IN
diff --git a/poezio/ui/types.py b/poezio/ui/types.py
index 18e51427..6c744ac3 100644
--- a/poezio/ui/types.py
+++ b/poezio/ui/types.py
@@ -48,13 +48,12 @@ class XMLLog(BaseMessage):
def compute_offset(self, with_timestamps: bool, nick_size: int) -> int:
offset = 0
theme = get_theme()
- IN, OUT = theme.CHAR_XML_IN, theme.CHAR_XML_OUT
if with_timestamps:
offset += 1 + SHORT_FORMAT_LENGTH
if self.incoming:
- nick = IN
+ nick = theme.CHAR_XML_IN
else:
- nick = OUT
+ nick = theme.CHAR_XML_OUT
nick = truncate_nick(nick, nick_size) or ''
offset += 1 + len(nick)
return offset