summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/windows.py b/src/windows.py
index bc697300..b18102bc 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -789,7 +789,10 @@ class TextWin(Win):
nick = truncate_nick(message.nickname)
offset = 0
if nick:
- offset += wcwidth.wcswidth(nick) + 2 # + nick + spaces length
+ # TODO: add the number of corrections.
+ offset += wcwidth.wcswidth(nick) + 2 # + nick + '> ' length
+ if message.me:
+ offset += 1 # '* ' before and ' ' after
if timestamp:
if message.str_time:
offset += 1 + len(message.str_time)
@@ -804,9 +807,8 @@ class TextWin(Win):
start_pos=line[0],
end_pos=line[1]))
else:
-
for line in lines:
- saved_line = Line(msg=message,start_pos=line[0],end_pos=line[1])
+ saved_line = Line(msg=message, start_pos=line[0], end_pos=line[1])
self.built_lines.append(saved_line)
if highlight:
highlight = False
@@ -817,7 +819,7 @@ class TextWin(Win):
return len(lines)
def refresh(self):
- log.debug('Refresh: %s',self.__class__.__name__)
+ log.debug('Refresh: %s', self.__class__.__name__)
if self.height <= 0:
return
if self.pos == 0:
@@ -840,18 +842,14 @@ class TextWin(Win):
color = None
if with_timestamps:
self.write_time(msg.str_time)
- if msg.highlight:
- hl_color = get_theme().COLOR_HIGHLIGHT_NICK
- if hl_color == "reverse":
- self._win.attron(curses.A_REVERSE)
- else:
- color = hl_color
- self.write_nickname(msg.nickname, color)
- if hl_color == "reverse":
- self._win.attroff(curses.A_REVERSE)
+ if msg.me:
+ self._win.attron(to_curses_attr(get_theme().COLOR_ME_MESSAGE))
+ self.addstr('* ')
+ self.write_nickname(msg.nickname, color, msg.highlight)
+ self.addstr(' ')
else:
- self.write_nickname(msg.nickname, color)
- self.addstr("> ")
+ self.write_nickname(msg.nickname, color, msg.highlight)
+ self.addstr('> ')
if y != self.height-1:
self.addstr('\n')
self._win.attrset(0)
@@ -863,7 +861,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))) + 2),
+ (0 if not line.msg.nickname else (len(truncate_nick(line.msg.nickname)) + (3 if line.msg.me else 2))),
line.msg.txt[line.start_pos:line.end_pos])
if y != self.height-1:
self.addstr('\n')
@@ -879,18 +877,26 @@ class TextWin(Win):
"""
self.addstr_colored(txt, y, x)
- def write_nickname(self, nickname, color):
+ def write_nickname(self, nickname, color, highlight=False):
"""
Write the nickname, using the user's color
and return the number of written characters
"""
if not nickname:
return
+ if highlight:
+ hl_color = get_theme().COLOR_HIGHLIGHT_NICK
+ if hl_color == "reverse":
+ self._win.attron(curses.A_REVERSE)
+ else:
+ color = hl_color
if color:
self._win.attron(to_curses_attr(color))
self.addstr(truncate_nick(nickname))
if color:
self._win.attroff(to_curses_attr(color))
+ if highlight and hl_color == "reverse":
+ self._win.attroff(curses.A_REVERSE)
def write_time(self, time):
"""