summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/themes/dark.py2
-rw-r--r--src/tabs.py12
-rw-r--r--src/text_buffer.py10
-rw-r--r--src/theming.py5
-rw-r--r--src/windows.py14
5 files changed, 26 insertions, 17 deletions
diff --git a/data/themes/dark.py b/data/themes/dark.py
index c7942290..9d856b8f 100644
--- a/data/themes/dark.py
+++ b/data/themes/dark.py
@@ -14,8 +14,6 @@ class DarkTheme(theming.Theme):
COLOR_NEW_TEXT_SEPARATOR = (213, -1)
COLOR_MORE_INDICATOR = (6, 4)
- COLOR_HIGHLIGHT_NICK = (236, 202, 'b')
-
COLOR_TAB_NORMAL = (-1, 236)
COLOR_TAB_CURRENT = (-1, 16)
COLOR_TAB_NEW_MESSAGE = (3, 236)
diff --git a/src/tabs.py b/src/tabs.py
index f8a6ecac..f604eca2 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1574,26 +1574,26 @@ class MucTab(ChatTab):
"""
Set the tab color and returns the nick color
"""
- color = None
+ highlighted = False
if not time and nickname and nickname != self.own_nick and self.joined:
if self.own_nick.lower() in txt.lower():
if self.state != 'current':
self.state = 'highlight'
- color = get_theme().COLOR_HIGHLIGHT_NICK
+ highlighted = True
else:
highlight_words = config.get_by_tabname('highlight_on', '', self.general_jid, True).split(':')
for word in highlight_words:
if word and word.lower() in txt.lower():
if self.state != 'current':
self.state = 'highlight'
- color = get_theme().COLOR_HIGHLIGHT_NICK
+ highlighted = True
break
- if color:
+ if highlighted:
beep_on = config.get('beep_on', 'highlight private').split()
if 'highlight' in beep_on and 'message' not in beep_on:
if config.get_by_tabname('disable_beep', 'false', self.name, False).lower() != 'true':
curses.beep()
- return color
+ return highlighted
def get_user_by_name(self, nick):
"""
@@ -1628,8 +1628,6 @@ class MucTab(ChatTab):
txt = '\x19%(info_col)s}%(txt)s' % {'txt':txt, 'info_col': get_theme().COLOR_INFORMATION_TEXT[0]}
else: # TODO
highlight = self.do_highlight(txt, time, nickname)
- if highlight:
- nick_color = highlight
time = time or datetime.now()
self._text_buffer.add_message(txt, time, nickname, nick_color, history, user, highlight=highlight, identifier=identifier)
return highlight
diff --git a/src/text_buffer.py b/src/text_buffer.py
index 33942537..2d3cb87a 100644
--- a/src/text_buffer.py
+++ b/src/text_buffer.py
@@ -18,7 +18,7 @@ from datetime import datetime
from config import config
from theming import get_theme
-Message = collections.namedtuple('Message', 'txt nick_color time str_time nickname user identifier')
+Message = collections.namedtuple('Message', 'txt nick_color time str_time nickname user identifier highlight')
class TextBuffer(object):
"""
@@ -40,7 +40,7 @@ class TextBuffer(object):
return self.messages[-1] if self.messages else None
- def make_message(self, txt, time, nickname, nick_color, history, user, identifier, str_time=None):
+ def make_message(self, txt, time, nickname, nick_color, history, user, identifier, str_time=None, highlight=False):
time = time or datetime.now()
if txt.startswith('/me '):
if nick_color:
@@ -57,12 +57,12 @@ class TextBuffer(object):
nick_color=nick_color,
time=time,
str_time=(time.strftime("%Y-%m-%d %H:%M:%S") if history else time.strftime("%H:%M:%S")) if str_time is None else '',
- nickname=nickname, user=user, identifier=identifier)
+ nickname=nickname, user=user, identifier=identifier, highlight=highlight)
log.debug('Set message %s with %s.' % (identifier, msg))
return msg
def add_message(self, txt, time=None, nickname=None, nick_color=None, history=None, user=None, highlight=False, identifier=None, str_time=None):
- msg = self.make_message(txt, time, nickname, nick_color, history, user, identifier, str_time)
+ msg = self.make_message(txt, time, nickname, nick_color, history, user, identifier, str_time, highlight)
self.messages.append(msg)
while len(self.messages) > self.messages_nb_limit:
self.messages.pop(0)
@@ -79,7 +79,7 @@ class TextBuffer(object):
def modify_message(self, txt, old_id, new_id):
for i, msg in enumerate(self.messages):
if msg.identifier == old_id:
- message = self.make_message(txt, msg.time, msg.nickname, msg.nick_color, None, msg.user, new_id)
+ message = self.make_message(txt, msg.time, msg.nickname, msg.nick_color, None, msg.user, new_id, msg.highlight)
self.messages[i] = message
log.debug('Replacing message %s with %s.' % (old_id, new_id))
return
diff --git a/src/theming.py b/src/theming.py
index 2068c83a..910e62d9 100644
--- a/src/theming.py
+++ b/src/theming.py
@@ -80,7 +80,10 @@ class Theme(object):
# Message text color
COLOR_NORMAL_TEXT = (-1, -1)
COLOR_INFORMATION_TEXT = (5, -1) # TODO
- COLOR_HIGHLIGHT_NICK = (3, 5, 'b')
+ # "reverse" is a special value, available only for this option. It just
+ # takes the nick colors and reverses it. A theme can still specify a
+ # fixed color if need be.
+ COLOR_HIGHLIGHT_NICK = "reverse"
# User list color
COLOR_USER_VISITOR = (239, -1)
diff --git a/src/windows.py b/src/windows.py
index e139e87d..9b12bbb6 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -831,7 +831,18 @@ class TextWin(Win):
color = None
if with_timestamps:
self.write_time(msg.str_time)
- self.write_nickname(msg.nickname, color)
+ 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)
+ else:
+ self.write_nickname(msg.nickname, color)
+ self.addstr("> ")
if y != self.height-1:
self.addstr('\n')
self._win.attrset(0)
@@ -871,7 +882,6 @@ class TextWin(Win):
self.addstr(truncate_nick(nickname))
if color:
self._win.attroff(to_curses_attr(color))
- self.addstr("> ")
def write_time(self, time):
"""