summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-27 16:32:03 +0200
committermathieui <mathieui@mathieui.net>2014-04-27 16:32:03 +0200
commit5999b71c416f02dc11803bf52a406b9109ddc3c1 (patch)
treee132ffeb929d23b94ee4ed2261be5bc8498815c1 /src/windows.py
parent60224bb76a08d5332e1d0bca810cf9682d45aa89 (diff)
downloadpoezio-5999b71c416f02dc11803bf52a406b9109ddc3c1.tar.gz
poezio-5999b71c416f02dc11803bf52a406b9109ddc3c1.tar.bz2
poezio-5999b71c416f02dc11803bf52a406b9109ddc3c1.tar.xz
poezio-5999b71c416f02dc11803bf52a406b9109ddc3c1.zip
Fix #2106 (implement message delivery receipts)
- two options request/ack_message_receipts - two new theme parameters : CHAR_ACK_RECEIVED and COLOR_CHAR_ACK - if a message has a receipt, the character is displayed between the timestamp and the nick, using the color
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/windows.py b/src/windows.py
index 4dd0c242..fb901f19 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -914,6 +914,8 @@ class TextWin(Win):
ret = []
nick = truncate_nick(message.nickname)
offset = 0
+ if message.ack:
+ offset += poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1
if nick:
offset += poopt.wcswidth(nick) + 2 # + nick + '> ' length
if message.revisions > 0:
@@ -967,6 +969,8 @@ class TextWin(Win):
color = None
if with_timestamps:
self.write_time(msg.str_time)
+ if msg.ack:
+ self.write_ack()
if msg.me:
self._win.attron(to_curses_attr(get_theme().COLOR_ME_MESSAGE))
self.addstr('* ')
@@ -990,11 +994,29 @@ class TextWin(Win):
if not line:
self.write_line_separator(y)
else:
- self.write_text(y,
- # Offset for the timestamp (if any) plus a space after it
- (0 if not with_timestamps else (len(line.msg.str_time) + (1 if line.msg.str_time else 0) )) +
- # Offset for the nickname (if any) plus a space and a > after it
- (0 if not line.msg.nickname else (poopt.wcswidth(truncate_nick(line.msg.nickname)) + (3 if line.msg.me else 2) + ceil(log10(line.msg.revisions + 1)))),
+ offset = 0
+ # Offset for the timestamp (if any) plus a space after it
+ if with_timestamps:
+ offset += len(line.msg.str_time)
+ if offset:
+ offset += 1
+
+ # Offset for the nickname (if any)
+ # plus a space and a > after it
+ if line.msg.nickname:
+ offset += poopt.wcswidth(
+ truncate_nick(line.msg.nickname))
+ if line.msg.me:
+ offset += 3
+ else:
+ offset += 2
+ offset += ceil(log10(line.msg.revisions + 1))
+
+ if line.msg.ack:
+ offset += 1 + poopt.wcswidth(
+ get_theme().CHAR_ACK_RECEIVED)
+
+ self.write_text(y, offset,
line.prepend+line.msg.txt[line.start_pos:line.end_pos])
if y != self.height-1:
self.addstr('\n')
@@ -1014,6 +1036,13 @@ class TextWin(Win):
"""
self.addstr_colored(txt, y, x)
+ def write_ack(self):
+ color = get_theme().COLOR_CHAR_ACK
+ self._win.attron(to_curses_attr(color))
+ self.addstr(get_theme().CHAR_ACK_RECEIVED)
+ 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