summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2018-09-08 20:21:39 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-09-25 12:47:09 +0200
commit4b8c63d25bd76d9dfc69bfb778b2f500e0613c17 (patch)
tree12e141879a13cb9133c9b455e9b8515745de8d04
parent791d44f1b906b873a741ec1973e6a3738e33064d (diff)
downloadpoezio-4b8c63d25bd76d9dfc69bfb778b2f500e0613c17.tar.gz
poezio-4b8c63d25bd76d9dfc69bfb778b2f500e0613c17.tar.bz2
poezio-4b8c63d25bd76d9dfc69bfb778b2f500e0613c17.tar.xz
poezio-4b8c63d25bd76d9dfc69bfb778b2f500e0613c17.zip
Split highlight logic and UI changes
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/tabs/muctab.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index 6c3ed34f..55275337 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -1251,34 +1251,37 @@ class MucTab(ChatTab):
1, self.width, self.height - 2 - self.core.information_win_size -
Tab.tab_win_height(), 0)
- def do_highlight(self, txt, time, nickname, corrected=False):
- """
- Set the tab color and returns the nick color
- """
+ def is_highlight(self, txt, time, nickname, own_nick, highlight_on,
+ corrected=False):
highlighted = False
- if (not time or corrected
- ) and nickname and nickname != self.own_nick and self.joined:
-
- if re.search(r'\b' + self.own_nick.lower() + r'\b', txt.lower()):
- if self.state != 'current':
- self.state = 'highlight'
+ if (not time or corrected) and nickname and nickname != own_nick:
+ if re.search(r'\b' + own_nick.lower() + r'\b', txt.lower()):
highlighted = True
else:
- highlight_words = config.get_by_tabname(
- 'highlight_on', self.general_jid)
- highlight_words = highlight_words.split(':')
+ highlight_words = highlight_on.split(':')
for word in highlight_words:
if word and word.lower() in txt.lower():
- if self.state != 'current':
- self.state = 'highlight'
highlighted = True
break
- if highlighted:
+ return highlighted
+
+ def do_highlight(self, txt, time, nickname, corrected=False):
+ """
+ Set the tab color and returns the nick color
+ """
+ own_nick = self.own_nick
+ highlight_on = config.get_by_tabname('highlight_on', self.general_jid)
+ highlighted = self.is_highlight(txt, time, nickname, own_nick,
+ highlight_on, corrected)
+ if highlighted and self.joined:
+ if self.state != 'current':
+ self.state = 'highlight'
beep_on = config.get('beep_on').split()
if 'highlight' in beep_on and 'message' not in beep_on:
if not config.get_by_tabname('disable_beep', self.name):
curses.beep()
- return highlighted
+ return True
+ return False
########################## COMMANDS ####################################