about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-17 21:10:08 +0000
committerJames Booth <boothj5@gmail.com>2014-11-17 21:10:08 +0000
commit1d5ac1b4742bbd782a43da02a01f7e50476022b4 (patch)
treecd179cf541601d7b83dc8237968ecf32513caa16
parent74d99375730f3be30ed8070c84148c6c1902ad7c (diff)
downloadprofani-tty-1d5ac1b4742bbd782a43da02a01f7e50476022b4.tar.gz
Added /theme colours command
-rw-r--r--src/command/command.c11
-rw-r--r--src/command/commands.c8
-rw-r--r--src/config/theme.c124
-rw-r--r--src/config/theme.h18
-rw-r--r--src/ui/console.c37
-rw-r--r--src/ui/ui.h1
6 files changed, 146 insertions, 53 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 3dcca100..c69e66d5 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -941,14 +941,14 @@ static struct cmd_t command_defs[] =
 
     { "/theme",
         cmd_theme, parse_args, 1, 2, &cons_theme_setting,
-        { "/theme command [theme-name]", "Change colour theme.",
-        { "/theme command [theme-name]",
+        { "/theme list|set [theme-name]", "Change colour theme.",
+        { "/theme list|set [theme-name]",
           "---------------------------",
           "Change the colour settings used.",
           "",
-          "command : One of the following,",
-          "list             : List all available themes.",
-          "set [theme-name] : Load the named theme.\"default\" will reset to the default colours.",
+          "list           : List all available themes.",
+          "set theme-name : Load the named theme.\"default\" will reset to the default colours.",
+          "colours        : Show the colour values as rendered by the terminal.",
           "",
           "Example : /theme list",
           "Example : /theme set mycooltheme",
@@ -1201,6 +1201,7 @@ cmd_init(void)
     theme_ac = autocomplete_new();
     autocomplete_add(theme_ac, "list");
     autocomplete_add(theme_ac, "set");
+    autocomplete_add(theme_ac, "colours");
 
     disco_ac = autocomplete_new();
     autocomplete_add(disco_ac, "info");
diff --git a/src/command/commands.c b/src/command/commands.c
index 68d70779..ecb3b30c 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -703,13 +703,13 @@ gboolean
 cmd_theme(gchar **args, struct cmd_help_t help)
 {
     // list themes
-    if (strcmp(args[0], "list") == 0) {
+    if (g_strcmp0(args[0], "list") == 0) {
         GSList *themes = theme_list();
         cons_show_themes(themes);
         g_slist_free_full(themes, g_free);
 
     // load a theme
-    } else if (strcmp(args[0], "set") == 0) {
+    } else if (g_strcmp0(args[0], "set") == 0) {
         if (args[1] == NULL) {
             cons_show("Usage: %s", help.usage);
         } else if (theme_load(args[1])) {
@@ -720,6 +720,10 @@ cmd_theme(gchar **args, struct cmd_help_t help)
         } else {
             cons_show("Couldn't find theme: %s", args[1]);
         }
+
+    // show colours
+    } else if (g_strcmp0(args[0], "colours") == 0) {
+        cons_theme_colours();
     } else {
         cons_show("Usage: %s", help.usage);
     }
diff --git a/src/config/theme.c b/src/config/theme.c
index ffdff732..d648847a 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -264,6 +264,16 @@ theme_init_colours(void)
     // subwin headers
     init_pair(44, colour_prefs.rosterheader, colour_prefs.bkgnd);
     init_pair(45, colour_prefs.occupantsheader, colour_prefs.bkgnd);
+
+    // raw
+    init_pair(46, COLOR_WHITE, colour_prefs.bkgnd);
+    init_pair(47, COLOR_GREEN, colour_prefs.bkgnd);
+    init_pair(48, COLOR_RED, colour_prefs.bkgnd);
+    init_pair(49, COLOR_YELLOW, colour_prefs.bkgnd);
+    init_pair(50, COLOR_BLUE, colour_prefs.bkgnd);
+    init_pair(51, COLOR_CYAN, colour_prefs.bkgnd);
+    init_pair(52, COLOR_BLACK, colour_prefs.bkgnd);
+    init_pair(53, COLOR_MAGENTA, colour_prefs.bkgnd);
 }
 
 static NCURSES_COLOR_T
@@ -308,6 +318,14 @@ _load_colours(void)
         g_hash_table_destroy(bold_items);
     }
     bold_items = g_hash_table_new(g_direct_hash, g_direct_equal);
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_WHITE_BOLD), GINT_TO_POINTER(THEME_WHITE_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_GREEN_BOLD), GINT_TO_POINTER(THEME_GREEN_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_RED_BOLD), GINT_TO_POINTER(THEME_RED_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_YELLOW_BOLD), GINT_TO_POINTER(THEME_YELLOW_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_BLUE_BOLD), GINT_TO_POINTER(THEME_BLUE_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_CYAN_BOLD), GINT_TO_POINTER(THEME_CYAN_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_BLACK_BOLD), GINT_TO_POINTER(THEME_BLACK_BOLD));
+    g_hash_table_insert(bold_items, GINT_TO_POINTER(THEME_MAGENTA_BOLD), GINT_TO_POINTER(THEME_MAGENTA_BOLD));
 
     gchar *bkgnd_val = g_key_file_get_string(theme, "colours", "bkgnd", NULL);
     _set_colour(bkgnd_val, &colour_prefs.bkgnd, -1, THEME_NONE);
@@ -582,51 +600,67 @@ theme_attrs(theme_item_t attrs)
     int result = 0;
 
     switch (attrs) {
-    case THEME_TEXT:                   result = COLOR_PAIR(1); break;
-    case THEME_TEXT_ME:                result = COLOR_PAIR(2); break;
-    case THEME_TEXT_THEM:              result = COLOR_PAIR(3); break;
-    case THEME_SPLASH:                 result = COLOR_PAIR(4); break;
-    case THEME_ERROR:                  result = COLOR_PAIR(5); break;
-    case THEME_INCOMING:               result = COLOR_PAIR(6); break;
-    case THEME_INPUT_TEXT:             result = COLOR_PAIR(7); break;
-    case THEME_TIME:                   result = COLOR_PAIR(8); break;
-    case THEME_TITLE_TEXT:             result = COLOR_PAIR(9); break;
-    case THEME_TITLE_BRACKET:          result = COLOR_PAIR(10); break;
-    case THEME_TITLE_UNENCRYPTED:      result = COLOR_PAIR(11); break;
-    case THEME_TITLE_ENCRYPTED:        result = COLOR_PAIR(12); break;
-    case THEME_TITLE_UNTRUSTED:        result = COLOR_PAIR(13); break;
-    case THEME_TITLE_TRUSTED:          result = COLOR_PAIR(14); break;
-    case THEME_TITLE_ONLINE:           result = COLOR_PAIR(15); break;
-    case THEME_TITLE_OFFLINE:          result = COLOR_PAIR(16); break;
-    case THEME_TITLE_AWAY:             result = COLOR_PAIR(17); break;
-    case THEME_TITLE_CHAT:             result = COLOR_PAIR(18); break;
-    case THEME_TITLE_DND:              result = COLOR_PAIR(19); break;
-    case THEME_TITLE_XA:               result = COLOR_PAIR(20); break;
-    case THEME_STATUS_TEXT:            result = COLOR_PAIR(21); break;
-    case THEME_STATUS_BRACKET:         result = COLOR_PAIR(22); break;
-    case THEME_STATUS_ACTIVE:          result = COLOR_PAIR(23); break;
-    case THEME_STATUS_NEW:             result = COLOR_PAIR(24); break;
-    case THEME_ME:                     result = COLOR_PAIR(25); break;
-    case THEME_THEM:                   result = COLOR_PAIR(26); break;
-    case THEME_ROOMINFO:               result = COLOR_PAIR(27); break;
-    case THEME_ROOMMENTION:            result = COLOR_PAIR(28); break;
-    case THEME_ONLINE:                 result = COLOR_PAIR(29); break;
-    case THEME_OFFLINE:                result = COLOR_PAIR(30); break;
-    case THEME_AWAY:                   result = COLOR_PAIR(31); break;
-    case THEME_CHAT:                   result = COLOR_PAIR(32); break;
-    case THEME_DND:                    result = COLOR_PAIR(33); break;
-    case THEME_XA:                     result = COLOR_PAIR(34); break;
-    case THEME_TYPING:                 result = COLOR_PAIR(35); break;
-    case THEME_GONE:                   result = COLOR_PAIR(36); break;
-    case THEME_SUBSCRIBED:             result = COLOR_PAIR(37); break;
-    case THEME_UNSUBSCRIBED:           result = COLOR_PAIR(38); break;
-    case THEME_OTR_STARTED_TRUSTED:    result = COLOR_PAIR(39); break;
-    case THEME_OTR_STARTED_UNTRUSTED:  result = COLOR_PAIR(40); break;
-    case THEME_OTR_ENDED:              result = COLOR_PAIR(41); break;
-    case THEME_OTR_TRUSTED:            result = COLOR_PAIR(42); break;
-    case THEME_OTR_UNTRUSTED:          result = COLOR_PAIR(43); break;
-    case THEME_ROSTER_HEADER:          result = COLOR_PAIR(44); break;
-    case THEME_OCCUPANTS_HEADER:       result = COLOR_PAIR(45); break;
+    case THEME_TEXT:                    result = COLOR_PAIR(1); break;
+    case THEME_TEXT_ME:                 result = COLOR_PAIR(2); break;
+    case THEME_TEXT_THEM:               result = COLOR_PAIR(3); break;
+    case THEME_SPLASH:                  result = COLOR_PAIR(4); break;
+    case THEME_ERROR:                   result = COLOR_PAIR(5); break;
+    case THEME_INCOMING:                result = COLOR_PAIR(6); break;
+    case THEME_INPUT_TEXT:              result = COLOR_PAIR(7); break;
+    case THEME_TIME:                    result = COLOR_PAIR(8); break;
+    case THEME_TITLE_TEXT:              result = COLOR_PAIR(9); break;
+    case THEME_TITLE_BRACKET:           result = COLOR_PAIR(10); break;
+    case THEME_TITLE_UNENCRYPTED:       result = COLOR_PAIR(11); break;
+    case THEME_TITLE_ENCRYPTED:         result = COLOR_PAIR(12); break;
+    case THEME_TITLE_UNTRUSTED:         result = COLOR_PAIR(13); break;
+    case THEME_TITLE_TRUSTED:           result = COLOR_PAIR(14); break;
+    case THEME_TITLE_ONLINE:            result = COLOR_PAIR(15); break;
+    case THEME_TITLE_OFFLINE:           result = COLOR_PAIR(16); break;
+    case THEME_TITLE_AWAY:              result = COLOR_PAIR(17); break;
+    case THEME_TITLE_CHAT:              result = COLOR_PAIR(18); break;
+    case THEME_TITLE_DND:               result = COLOR_PAIR(19); break;
+    case THEME_TITLE_XA:                result = COLOR_PAIR(20); break;
+    case THEME_STATUS_TEXT:             result = COLOR_PAIR(21); break;
+    case THEME_STATUS_BRACKET:          result = COLOR_PAIR(22); break;
+    case THEME_STATUS_ACTIVE:           result = COLOR_PAIR(23); break;
+    case THEME_STATUS_NEW:              result = COLOR_PAIR(24); break;
+    case THEME_ME:                      result = COLOR_PAIR(25); break;
+    case THEME_THEM:                    result = COLOR_PAIR(26); break;
+    case THEME_ROOMINFO:                result = COLOR_PAIR(27); break;
+    case THEME_ROOMMENTION:             result = COLOR_PAIR(28); break;
+    case THEME_ONLINE:                  result = COLOR_PAIR(29); break;
+    case THEME_OFFLINE:                 result = COLOR_PAIR(30); break;
+    case THEME_AWAY:                    result = COLOR_PAIR(31); break;
+    case THEME_CHAT:                    result = COLOR_PAIR(32); break;
+    case THEME_DND:                     result = COLOR_PAIR(33); break;
+    case THEME_XA:                      result = COLOR_PAIR(34); break;
+    case THEME_TYPING:                  result = COLOR_PAIR(35); break;
+    case THEME_GONE:                    result = COLOR_PAIR(36); break;
+    case THEME_SUBSCRIBED:              result = COLOR_PAIR(37); break;
+    case THEME_UNSUBSCRIBED:            result = COLOR_PAIR(38); break;
+    case THEME_OTR_STARTED_TRUSTED:     result = COLOR_PAIR(39); break;
+    case THEME_OTR_STARTED_UNTRUSTED:   result = COLOR_PAIR(40); break;
+    case THEME_OTR_ENDED:               result = COLOR_PAIR(41); break;
+    case THEME_OTR_TRUSTED:             result = COLOR_PAIR(42); break;
+    case THEME_OTR_UNTRUSTED:           result = COLOR_PAIR(43); break;
+    case THEME_ROSTER_HEADER:           result = COLOR_PAIR(44); break;
+    case THEME_OCCUPANTS_HEADER:        result = COLOR_PAIR(45); break;
+    case THEME_WHITE:                   result = COLOR_PAIR(46); break;
+    case THEME_WHITE_BOLD:              result = COLOR_PAIR(46); break;
+    case THEME_GREEN:                   result = COLOR_PAIR(47); break;
+    case THEME_GREEN_BOLD:              result = COLOR_PAIR(47); break;
+    case THEME_RED:                     result = COLOR_PAIR(48); break;
+    case THEME_RED_BOLD:                result = COLOR_PAIR(48); break;
+    case THEME_YELLOW:                  result = COLOR_PAIR(49); break;
+    case THEME_YELLOW_BOLD:             result = COLOR_PAIR(49); break;
+    case THEME_BLUE:                    result = COLOR_PAIR(50); break;
+    case THEME_BLUE_BOLD:               result = COLOR_PAIR(50); break;
+    case THEME_CYAN:                    result = COLOR_PAIR(51); break;
+    case THEME_CYAN_BOLD:               result = COLOR_PAIR(51); break;
+    case THEME_BLACK:                   result = COLOR_PAIR(52); break;
+    case THEME_BLACK_BOLD:              result = COLOR_PAIR(52); break;
+    case THEME_MAGENTA:                 result = COLOR_PAIR(53); break;
+    case THEME_MAGENTA_BOLD:            result = COLOR_PAIR(53); break;
     default:                           break;
     }
 
diff --git a/src/config/theme.h b/src/config/theme.h
index 23abab63..a6a580f8 100644
--- a/src/config/theme.h
+++ b/src/config/theme.h
@@ -90,7 +90,23 @@ typedef enum {
     THEME_OTR_UNTRUSTED,
     THEME_OCCUPANTS_HEADER,
     THEME_ROSTER_HEADER,
-    THEME_NONE
+    THEME_NONE,
+    THEME_WHITE,
+    THEME_WHITE_BOLD,
+    THEME_GREEN,
+    THEME_GREEN_BOLD,
+    THEME_RED,
+    THEME_RED_BOLD,
+    THEME_YELLOW,
+    THEME_YELLOW_BOLD,
+    THEME_BLUE,
+    THEME_BLUE_BOLD,
+    THEME_CYAN,
+    THEME_CYAN_BOLD,
+    THEME_BLACK,
+    THEME_BLACK_BOLD,
+    THEME_MAGENTA,
+    THEME_MAGENTA_BOLD
 } theme_item_t;
 
 void theme_init(const char * const theme_name);
diff --git a/src/ui/console.c b/src/ui/console.c
index 32f040e0..9d397268 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1480,6 +1480,42 @@ _cons_alert(void)
 }
 
 static void
+_cons_theme_colours(void)
+{
+    /*
+     *     { "default", -1 },
+    { "white", COLOR_WHITE },
+    { "green", COLOR_GREEN },
+    { "red", COLOR_RED },
+    { "yellow", COLOR_YELLOW },
+    { "blue", COLOR_BLUE },
+    { "cyan", COLOR_CYAN },
+    { "black", COLOR_BLACK },
+    { "magenta", COLOR_MAGENTA },
+
+     */
+
+    ProfWin *console = wins_get_console();
+    cons_show("Theme colours:");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_WHITE, "",         " white   ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_WHITE_BOLD, "",   " bold_white");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_GREEN, "",         " green   ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_GREEN_BOLD, "",   " bold_green");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_RED, "",           " red     ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_RED_BOLD, "",     " bold_red");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_YELLOW, "",        " yellow  ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_YELLOW_BOLD, "",  " bold_yellow");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_BLUE, "",          " blue    ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_BLUE_BOLD, "",    " bold_blue");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_CYAN, "",          " cyan    ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_CYAN_BOLD, "",    " bold_cyan");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_MAGENTA, "",       " magenta ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta");
+    win_save_print(console, '-', NULL, NO_EOL, THEME_BLACK, "",         " black   ");
+    win_save_print(console, '-', NULL, NO_DATE, THEME_BLACK_BOLD, "",   " bold_black");
+}
+
+static void
 _cons_splash_logo(void)
 {
     ProfWin *console = wins_get_console();
@@ -1651,4 +1687,5 @@ console_init_module(void)
     cons_show_contact_online = _cons_show_contact_online;
     cons_show_contact_offline = _cons_show_contact_offline;
     cons_show_aliases = _cons_show_aliases;
+    cons_theme_colours = _cons_theme_colours;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 3f8ed7ca..2b74f38c 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -325,6 +325,7 @@ void (*cons_priority_setting)(void);
 void (*cons_autoconnect_setting)(void);
 void (*cons_show_contact_online)(PContact contact, Resource *resource, GDateTime *last_activity);
 void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
+void (*cons_theme_colours)(void);
 
 // desktop notifier actions
 void (*notifier_uninit)(void);