summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2012-12-26 18:39:31 +0100
committerFlorent Le Coz <louiz@louiz.org>2012-12-29 13:14:50 +0100
commit65e097f4107e0c095a9818f5d7f0851b292c9a84 (patch)
treefef23bb1da4d4d7ebd4b2837bab927351fb8be08 /src/windows.py
parent590afbd4bcc8c9e3f04dd46d7747959290e71f51 (diff)
downloadpoezio-65e097f4107e0c095a9818f5d7f0851b292c9a84.tar.gz
poezio-65e097f4107e0c095a9818f5d7f0851b292c9a84.tar.bz2
poezio-65e097f4107e0c095a9818f5d7f0851b292c9a84.tar.xz
poezio-65e097f4107e0c095a9818f5d7f0851b292c9a84.zip
Display the number of revisions of a corrected message.
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/windows.py b/src/windows.py
index b18102bc..d5239a09 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -20,6 +20,7 @@ log = logging.getLogger(__name__)
import curses
import string
+from math import ceil, log10
from config import config
from threading import RLock
@@ -789,8 +790,9 @@ class TextWin(Win):
nick = truncate_nick(message.nickname)
offset = 0
if nick:
- # TODO: add the number of corrections.
offset += wcwidth.wcswidth(nick) + 2 # + nick + '> ' length
+ if message.revisions > 0:
+ offset += ceil(log10(message.revisions + 1))
if message.me:
offset += 1 # '* ' before and ' ' after
if timestamp:
@@ -846,9 +848,17 @@ class TextWin(Win):
self._win.attron(to_curses_attr(get_theme().COLOR_ME_MESSAGE))
self.addstr('* ')
self.write_nickname(msg.nickname, color, msg.highlight)
+ if msg.revisions:
+ self._win.attron(to_curses_attr(get_theme().COLOR_REVISIONS_MESSAGE))
+ self.addstr('%d' % msg.revisions)
+ self._win.attrset(0)
self.addstr(' ')
else:
self.write_nickname(msg.nickname, color, msg.highlight)
+ if msg.revisions:
+ self._win.attron(to_curses_attr(get_theme().COLOR_REVISIONS_MESSAGE))
+ self.addstr('%d' % msg.revisions)
+ self._win.attrset(0)
self.addstr('> ')
if y != self.height-1:
self.addstr('\n')
@@ -861,7 +871,7 @@ class TextWin(Win):
# Offset for the timestamp (if any) plus a space after it
(0 if not with_timestamps else (len(line.msg.str_time) + 1)) +
# Offset for the nickname (if any) plus a space and a > after it
- (0 if not line.msg.nickname else (len(truncate_nick(line.msg.nickname)) + (3 if line.msg.me else 2))),
+ (0 if not line.msg.nickname else (len(truncate_nick(line.msg.nickname)) + (3 if line.msg.me else 2) + ceil(log10(line.msg.revisions + 1)))),
line.msg.txt[line.start_pos:line.end_pos])
if y != self.height-1:
self.addstr('\n')