From c3595b0abe321e59b74ab29103cc57e8ba5e16a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=99=A8?= <ailin@xli51.site>
Date: Tue, 8 May 2012 02:19:22 +0200
Subject: [PATCH 4/4] color inactive(offline) nicks

---
 src/core/wee-config.c             |   13 +++++++++++
 src/core/wee-config.h             |    2 +
 src/gui/curses/gui-curses-chat.c  |   42 +++++++++++++++++++++++++++++++-----
 src/gui/curses/gui-curses-color.c |    1 +
 src/gui/gui-color.h               |    1 +
 5 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index ed64060..c9d9d06 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -93,6 +93,7 @@ struct t_config_option *config_look_color_inactive_time;
 struct t_config_option *config_look_color_inactive_prefix_buffer;
 struct t_config_option *config_look_color_inactive_prefix;
 struct t_config_option *config_look_color_inactive_message;
+struct t_config_option *config_look_color_inactive_nicks;
 struct t_config_option *config_look_color_pairs_auto_reset;
 struct t_config_option *config_look_color_real_white;
 struct t_config_option *config_look_command_chars;
@@ -161,6 +162,7 @@ struct t_config_option *config_color_chat;
 struct t_config_option *config_color_chat_bg;
 struct t_config_option *config_color_chat_inactive_window;
 struct t_config_option *config_color_chat_inactive_buffer;
+struct t_config_option *config_color_chat_inactive_nicks;
 struct t_config_option *config_color_chat_time;
 struct t_config_option *config_color_chat_time_delimiters;
 struct t_config_option *config_color_chat_prefix_buffer;
@@ -1827,6 +1829,11 @@ config_weechat_init_options ()
         N_("use a different color for inactive message (when window is not "
            "current window, or if line is from a merged buffer not selected)"),
         NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+    config_look_color_inactive_nicks = config_file_new_option (
+        weechat_config_file, ptr_section,
+        "color_inactive_nicks", "boolean",
+        N_("use a different color for inactive nicks"),
+        NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
     config_look_color_pairs_auto_reset = config_file_new_option (
         weechat_config_file, ptr_section,
         "color_pairs_auto_reset", "integer",
@@ -2285,6 +2292,12 @@ config_weechat_init_options ()
            "other buffers and is not selected)"),
         NULL, GUI_COLOR_CHAT_INACTIVE_BUFFER, 0, "darkgray", NULL, 0,
         NULL, NULL, &config_change_color, NULL, NULL, NULL);
+    config_color_chat_inactive_nicks = config_file_new_option (
+        weechat_config_file, ptr_section,
+        "chat_inactive_nicks", "color",
+        N_("text color for chat when nick is inactive"),
+        NULL, GUI_COLOR_CHAT_INACTIVE_NICKS, 0, "yellow", NULL, 0,
+        NULL, NULL, &config_change_color, NULL, NULL, NULL);
     config_color_chat_time = config_file_new_option (
         weechat_config_file, ptr_section,
         "chat_time", "color",
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index a38b192..e0002c1 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -119,6 +119,7 @@ extern struct t_config_option *config_look_color_inactive_time;
 extern struct t_config_option *config_look_color_inactive_prefix_buffer;
 extern struct t_config_option *config_look_color_inactive_prefix;
 extern struct t_config_option *config_look_color_inactive_message;
+extern struct t_config_option *config_look_color_inactive_nicks;
 extern struct t_config_option *config_look_color_pairs_auto_reset;
 extern struct t_config_option *config_look_color_real_white;
 extern struct t_config_option *config_look_day_change;
@@ -182,6 +183,7 @@ extern struct t_config_option *config_color_chat;
 extern struct t_config_option *config_color_chat_bg;
 extern struct t_config_option *config_color_chat_inactive_window;
 extern struct t_config_option *config_color_chat_inactive_buffer;
+extern struct t_config_option *config_color_chat_inactive_nicks;
 extern struct t_config_option *config_color_chat_time;
 extern struct t_config_option *config_color_chat_time_delimiters;
 extern struct t_config_option *config_color_chat_prefix_buffer;
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index b730811..4860e74 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -43,6 +43,7 @@
 #include "../gui-line.h"
 #include "../gui-main.h"
 #include "../gui-window.h"
+#include "../gui-nicklist.h"
 #include "gui-curses.h"
 
 
@@ -126,6 +127,16 @@ gui_chat_reset_style (struct t_gui_window *window, struct t_gui_line *line,
     {
         color = color_inactive_buffer;
     }
+    else if (line &&
+			 gui_line_get_nick_tag(line) &&
+			 (line->data->buffer->nicklist_root->nicks || line->data->buffer->nicklist_root->children) &&
+			 !gui_nicklist_search_nick(line->data->buffer, NULL, gui_line_get_nick_tag(line))
+			 && CONFIG_BOOLEAN(config_look_color_inactive_nicks))
+    {
+	  if (color_inactive_buffer == GUI_COLOR_CHAT_INACTIVE_BUFFER)
+        color = GUI_COLOR_CHAT_INACTIVE_NICKS;
+    }
+
 
     if (reset_attributes)
         gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, color);
@@ -219,6 +230,13 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
             if (CONFIG_BOOLEAN(config_look_color_inactive_buffer))
                 apply_style = 0;
         }
+        else if (line && gui_line_get_nick_tag(line) &&
+				 (line->data->buffer->nicklist_root->nicks || line->data->buffer->nicklist_root->children) &&
+				 !gui_nicklist_search_nick(line->data->buffer, NULL, gui_line_get_nick_tag(line)))
+        {
+            if (CONFIG_BOOLEAN(config_look_color_inactive_nicks))
+                apply_style = 0;
+        }
     }
 
     while (string[0])
@@ -685,9 +703,13 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
         {
             gui_chat_reset_style (window, line, 1,
                                   GUI_COLOR_CHAT_INACTIVE_WINDOW,
-                                  (CONFIG_BOOLEAN(config_look_color_inactive_buffer)
+                                  ((CONFIG_BOOLEAN(config_look_color_inactive_buffer)
                                    && CONFIG_BOOLEAN(config_look_color_inactive_prefix_buffer)
-                                   && (!line->data->buffer->active)) ?
+									&& !(line->data->buffer->active)) ||
+										(CONFIG_BOOLEAN(config_look_color_inactive_nicks) &&
+										 gui_line_get_nick_tag(line) &&
+										 (line->data->buffer->nicklist_root->nicks || line->data->buffer->nicklist_root->children) &&
+										 !gui_nicklist_search_nick(line->data->buffer, NULL, gui_line_get_nick_tag(line)))) ?
                                   GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER :
                                   GUI_COLOR_CHAT_PREFIX_BUFFER,
                                   GUI_COLOR_CHAT_PREFIX_BUFFER);
@@ -849,9 +871,13 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
             {
                 gui_chat_reset_style (window, line, 1,
                                       GUI_COLOR_CHAT_INACTIVE_WINDOW,
-                                      (CONFIG_BOOLEAN(config_look_color_inactive_buffer)
+                                      ((CONFIG_BOOLEAN(config_look_color_inactive_buffer)
                                        && CONFIG_BOOLEAN(config_look_color_inactive_prefix)
-                                       && (!line->data->buffer->active)) ?
+										&& !(line->data->buffer->active)) ||
+									   (CONFIG_BOOLEAN(config_look_color_inactive_nicks) &&
+										gui_line_get_nick_tag(line) &&
+										(line->data->buffer->nicklist_root->nicks || line->data->buffer->nicklist_root->children) &&
+										!gui_nicklist_search_nick(line->data->buffer, NULL, gui_line_get_nick_tag(line)))) ?
                                       GUI_COLOR_CHAT_INACTIVE_BUFFER :
                                       GUI_COLOR_CHAT_HIGHLIGHT,
                                       GUI_COLOR_CHAT_HIGHLIGHT);
@@ -863,9 +889,13 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
             {
                 gui_chat_reset_style (window, line, 1,
                                       GUI_COLOR_CHAT_INACTIVE_WINDOW,
-                                      (CONFIG_BOOLEAN(config_look_color_inactive_buffer)
+                                      ((CONFIG_BOOLEAN(config_look_color_inactive_buffer)
                                        && CONFIG_BOOLEAN(config_look_color_inactive_prefix)
-                                       && (!line->data->buffer->active)) ?
+                                       && !(line->data->buffer->active)) ||
+									  (CONFIG_BOOLEAN(config_look_color_inactive_nicks) &&
+									   gui_line_get_nick_tag(line) &&
+									   (line->data->buffer->nicklist_root->nicks || line->data->buffer->nicklist_root->children) &&
+									   !gui_nicklist_search_nick(line->data->buffer, NULL, gui_line_get_nick_tag(line)))) ?
                                       GUI_COLOR_CHAT_INACTIVE_BUFFER :
                                       GUI_COLOR_CHAT,
                                       GUI_COLOR_CHAT);
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index 607d3c2..62bbbcd 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -1420,6 +1420,7 @@ gui_color_init_weechat ()
     gui_color_build (GUI_COLOR_CHAT_TAGS, CONFIG_COLOR(config_color_chat_tags), CONFIG_COLOR(config_color_chat_bg));
     gui_color_build (GUI_COLOR_CHAT_INACTIVE_WINDOW, CONFIG_COLOR(config_color_chat_inactive_window), CONFIG_COLOR(config_color_chat_bg));
     gui_color_build (GUI_COLOR_CHAT_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_inactive_buffer), CONFIG_COLOR(config_color_chat_bg));
+    gui_color_build (GUI_COLOR_CHAT_INACTIVE_NICKS, CONFIG_COLOR(config_color_chat_inactive_nicks), CONFIG_COLOR(config_color_chat_bg));
     gui_color_build (GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_prefix_buffer_inactive_buffer), CONFIG_COLOR(config_color_chat_bg));
 
     /*
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 963f6e4..db92d35 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -69,6 +69,7 @@ enum t_gui_color_enum
     GUI_COLOR_CHAT_TAGS,
     GUI_COLOR_CHAT_INACTIVE_WINDOW,
     GUI_COLOR_CHAT_INACTIVE_BUFFER,
+    GUI_COLOR_CHAT_INACTIVE_NICKS,
     GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER,
 
     /* number of colors */
-- 
1.7.3.4

