about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-01-22 10:01:04 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-01-22 10:01:04 +0100
commit802df37926903eb01e64e2f0ad0b7d6d04a7358c (patch)
treef0c7b1a8a8be3267e87b803008bbee75eee8fcbc /src
parentdac6d088d01e6359aa3c788cac924f062f1ab077 (diff)
downloadprofani-tty-802df37926903eb01e64e2f0ad0b7d6d04a7358c.tar.gz
XEP-0392: get background color from theme
So far we just used -1 (default color). Now we actually check whether
`bkgnd` is set in the theme file and use this if available.

Fix https://github.com/profanity-im/profanity/issues/1255
Diffstat (limited to 'src')
-rw-r--r--src/config/color.c9
-rw-r--r--src/config/theme.c8
-rw-r--r--src/config/theme.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/src/config/color.c b/src/config/color.c
index 9a646132..cb857792 100644
--- a/src/config/color.c
+++ b/src/config/color.c
@@ -49,6 +49,7 @@
 #endif
 
 #include "config/color.h"
+#include "config/theme.h"
 #include "log.h"
 
 static
@@ -494,13 +495,19 @@ static int _color_pair_cache_get(int fg, int bg)
  * possible given a 256 colors terminal.
  *
  * hash a string into a color that will be used as fg
- * use default color as bg
+ * check for 'bkgnd' in theme file or use default color as bg
  */
 int color_pair_cache_hash_str(const char *str, color_profile profile)
 {
     int fg = color_hash(str, profile);
     int bg = -1;
 
+    char *bkgnd = theme_get_bkgnd();
+    if (bkgnd) {
+        bg = find_col(bkgnd, strlen(bkgnd));
+        free(bkgnd);
+    }
+
     return _color_pair_cache_get(fg, bg);
 }
 
diff --git a/src/config/theme.c b/src/config/theme.c
index 50c0ffb0..1342f551 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -618,6 +618,14 @@ _theme_prep_bgnd(char *setting, char *def, GString *lookup_str)
     g_free(val);
 }
 
+/* return value needs to be freed */
+char*
+theme_get_bkgnd(void)
+{
+    char *val = g_key_file_get_string(theme, "colours", "bkgnd", NULL);
+    return val;
+}
+
 static void
 _theme_prep_fgnd(char *setting, GString *lookup_str, gboolean *bold)
 {
diff --git a/src/config/theme.h b/src/config/theme.h
index bdca6cf6..65d91257 100644
--- a/src/config/theme.h
+++ b/src/config/theme.h
@@ -155,5 +155,6 @@ theme_item_t theme_main_presence_attrs(const char *const presence);
 theme_item_t theme_roster_unread_presence_attrs(const char *const presence);
 theme_item_t theme_roster_active_presence_attrs(const char *const presence);
 theme_item_t theme_roster_presence_attrs(const char *const presence);
+char* theme_get_bkgnd(void);
 
 #endif