about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--preferences.c76
-rw-r--r--preferences.h8
-rw-r--r--windows.c21
3 files changed, 94 insertions, 11 deletions
diff --git a/preferences.c b/preferences.c
index 46e511eb..65cc3dc1 100644
--- a/preferences.c
+++ b/preferences.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <ncurses.h>
 #include <glib.h>
 
 #include "preferences.h"
@@ -34,6 +35,33 @@ static GKeyFile *prefs;
 // search logins list
 static PAutocomplete ac;
 
+struct colour_string_t {
+    char *str;
+    NCURSES_COLOR_T colour;
+};
+/*
+static struct colour_string_t colours[] = {
+    { "bkgnd", -1 },
+    { "white", COLOR_WHITE },
+    { "green", COLOR_GREEN },
+    { "red", COLOR_RED },
+    { "yellow", COLOR_YELLOW },
+    { "blue", COLOR_BLUE },
+    { "cyan", COLOR_CYAN },
+};
+*/
+// colour preferences
+static struct colours_t {
+        NCURSES_COLOR_T bkgnd;
+        NCURSES_COLOR_T text;
+        NCURSES_COLOR_T online;
+        NCURSES_COLOR_T err;
+        NCURSES_COLOR_T inc;
+        NCURSES_COLOR_T bar;
+        NCURSES_COLOR_T bar_text;
+} colour_prefs;
+
+static void _load_colours(void);
 static void _save_prefs(void);
 
 void prefs_load(void)
@@ -54,6 +82,19 @@ void prefs_load(void)
     for (i = 0; i < njids; i++) {
         p_autocomplete_add(ac, jids[i]);
     }
+
+    _load_colours();
+}
+
+static void _load_colours(void)
+{
+    colour_prefs.bkgnd = -1;
+    colour_prefs.text = COLOR_WHITE;
+    colour_prefs.online = COLOR_GREEN;
+    colour_prefs.err = COLOR_RED;
+    colour_prefs.inc = COLOR_YELLOW;
+    colour_prefs.bar = COLOR_BLUE;
+    colour_prefs.bar_text = COLOR_CYAN;
 }
 
 char * find_login(char *prefix)
@@ -146,3 +187,38 @@ static void _save_prefs(void)
     char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
     g_file_set_contents(prefs_loc->str, g_prefs_data, g_data_size, NULL);
 }
+
+NCURSES_COLOR_T prefs_get_bkgnd() 
+{
+    return colour_prefs.bkgnd;
+}
+
+NCURSES_COLOR_T prefs_get_text() 
+{
+    return colour_prefs.text;
+}
+
+NCURSES_COLOR_T prefs_get_online() 
+{
+    return colour_prefs.online;
+}
+
+NCURSES_COLOR_T prefs_get_err() 
+{
+    return colour_prefs.err;
+}
+
+NCURSES_COLOR_T prefs_get_inc() 
+{
+    return colour_prefs.inc;
+}
+
+NCURSES_COLOR_T prefs_get_bar() 
+{
+    return colour_prefs.bar;
+}
+
+NCURSES_COLOR_T prefs_get_bar_text() 
+{
+    return colour_prefs.bar_text;
+}
diff --git a/preferences.h b/preferences.h
index 2785a32e..78cfea5c 100644
--- a/preferences.h
+++ b/preferences.h
@@ -38,4 +38,12 @@ void prefs_add_login(const char *jid);
 gboolean prefs_get_showsplash(void);
 void prefs_set_showsplash(gboolean value);
 
+NCURSES_COLOR_T prefs_get_bkgnd();
+NCURSES_COLOR_T prefs_get_text();
+NCURSES_COLOR_T prefs_get_online();
+NCURSES_COLOR_T prefs_get_err();
+NCURSES_COLOR_T prefs_get_inc();
+NCURSES_COLOR_T prefs_get_bar();
+NCURSES_COLOR_T prefs_get_bar_text();
+
 #endif
diff --git a/windows.c b/windows.c
index 935d66b4..bf82766b 100644
--- a/windows.c
+++ b/windows.c
@@ -77,15 +77,14 @@ void gui_init(void)
     if (has_colors()) {    
         use_default_colors();
         start_color();
-        
-        init_pair(1, COLOR_WHITE, -1);
-        init_pair(2, COLOR_GREEN, -1);
-        init_pair(3, COLOR_WHITE, COLOR_BLUE);
-        init_pair(4, COLOR_CYAN, COLOR_BLUE);
-        init_pair(5, COLOR_CYAN, -1);
-        init_pair(6, COLOR_RED, -1);
-        init_pair(7, COLOR_MAGENTA, -1);
-        init_pair(8, COLOR_YELLOW, -1);
+
+        init_pair(1, prefs_get_text(), prefs_get_bkgnd());
+        init_pair(2, prefs_get_online(), prefs_get_bkgnd());
+        init_pair(3, prefs_get_text(), prefs_get_bar());
+        init_pair(4, prefs_get_bar_text(), prefs_get_bar());
+        init_pair(5, prefs_get_bar_text(), prefs_get_bkgnd());
+        init_pair(6, prefs_get_err(), prefs_get_bkgnd());
+        init_pair(7, prefs_get_inc(), prefs_get_bkgnd());
     }
 
     refresh();
@@ -564,9 +563,9 @@ static void _show_status_string(WINDOW *win, const char * const from,
 static void _cons_show_incoming_message(const char * const short_from, const int win_index)
 {
     _win_show_time(_cons_win);
-    wattron(_cons_win, COLOR_PAIR(8));
+    wattron(_cons_win, COLOR_PAIR(7));
     wprintw(_cons_win, "<< incoming from %s (%d)\n", short_from, win_index + 1);
-    wattroff(_cons_win, COLOR_PAIR(8));
+    wattroff(_cons_win, COLOR_PAIR(7));
 }
 
 static void _win_handle_switch(const int * const ch)