summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Schäfer <j.wielicki@sotecware.net>2020-05-10 12:07:37 +0200
committerLink Mauve <linkmauve@linkmauve.fr>2022-04-06 20:30:33 +0200
commit7b99fcfb2f367c51faf3f2fd2b6a583be87a9e45 (patch)
tree151e4a69c00cd5ea97be651b540b43141cf095cd
parentbe7542b8c822877da31b14177cbec1435a097ca0 (diff)
downloadpoezio-7b99fcfb2f367c51faf3f2fd2b6a583be87a9e45.tar.gz
poezio-7b99fcfb2f367c51faf3f2fd2b6a583be87a9e45.tar.bz2
poezio-7b99fcfb2f367c51faf3f2fd2b6a583be87a9e45.tar.xz
poezio-7b99fcfb2f367c51faf3f2fd2b6a583be87a9e45.zip
Add option to use XEP-0392 for tab names/numbers in the infobar
This will autocolour the tabs based on their name (typically the JID) if a new message or highlight occured. If it was a normal new message, the colouring will be subtle (foreground instead of background), otherwise (on a highlight or 1:1 message), the colouring will affect the background and thus stand out much more.
-rw-r--r--poezio/config.py1
-rwxr-xr-xpoezio/theming.py5
-rw-r--r--poezio/windows/info_bar.py20
3 files changed, 26 insertions, 0 deletions
diff --git a/poezio/config.py b/poezio/config.py
index 7bbc9268..01455173 100644
--- a/poezio/config.py
+++ b/poezio/config.py
@@ -48,6 +48,7 @@ DEFAULT_CONFIG: ConfigDict = {
'after_completion': ',',
'alternative_nickname': '',
'auto_reconnect': True,
+ 'autocolor_tab_names': False,
'autorejoin_delay': '5',
'autorejoin': False,
'beep_on': 'highlight private invite disconnect',
diff --git a/poezio/theming.py b/poezio/theming.py
index f0309f65..cc4ea34a 100755
--- a/poezio/theming.py
+++ b/poezio/theming.py
@@ -233,6 +233,11 @@ class Theme:
COLOR_TAB_ATTENTION = (7, 1)
COLOR_TAB_DISCONNECTED = (7, 8)
+ # If autocolor_tab_names is set to true, the following modes are used to
+ # distinguish tabs with normal and important messages.
+ MODE_TAB_NORMAL = ''
+ MODE_TAB_IMPORTANT = 'r' # reverse video mode
+
COLOR_VERTICAL_TAB_NORMAL = (4, -1)
COLOR_VERTICAL_TAB_NONEMPTY = (4, -1)
COLOR_VERTICAL_TAB_JOINED = (82, -1)
diff --git a/poezio/windows/info_bar.py b/poezio/windows/info_bar.py
index 67b68888..6e6c3bbd 100644
--- a/poezio/windows/info_bar.py
+++ b/poezio/windows/info_bar.py
@@ -15,6 +15,7 @@ from poezio.config import config
from poezio.windows.base_wins import Win
from poezio.theming import get_theme, to_curses_attr
from poezio.common import unique_prefix_of
+from poezio.colors import ccg_text_to_color
log = logging.getLogger(__name__)
@@ -38,6 +39,7 @@ class GlobalInfoBar(Win):
use_nicks = config.getbool('use_tab_nicks')
show_inactive = config.getbool('show_inactive_tabs')
unique_prefix_tab_names = config.getbool('unique_prefix_tab_names')
+ autocolor_tab_names = config.getbool('autocolor_tab_names')
if unique_prefix_tab_names:
unique_prefixes: List[Optional[str]] = [None] * len(self.core.tabs)
@@ -73,6 +75,24 @@ class GlobalInfoBar(Win):
if not show_inactive and color is theme.COLOR_TAB_NORMAL and (
tab.priority < 0):
continue
+ if autocolor_tab_names:
+ # TODO: in case of private MUC conversations, we should try to
+ # get hold of more information to make the colour the same as
+ # the nickname colour in the MUC.
+ fgcolor, bgcolor, *flags = color
+ # this is fugly, but I’m not sure how to improve it... since
+ # apparently the state is only kept in the color -.-
+ if (color == theme.COLOR_TAB_HIGHLIGHT or
+ color == theme.COLOR_TAB_PRIVATE):
+ fgcolor = ccg_text_to_color(theme.ccg_palette, tab.name)
+ bgcolor = -1
+ flags = theme.MODE_TAB_IMPORTANT
+ elif color == theme.COLOR_TAB_NEW_MESSAGE:
+ fgcolor = ccg_text_to_color(theme.ccg_palette, tab.name)
+ bgcolor = -1
+ flags = theme.MODE_TAB_NORMAL
+
+ color = (fgcolor, bgcolor) + tuple(flags)
try:
if show_nums or not show_names:
self.addstr("%s" % str(nb), to_curses_attr(color))