diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-25 15:36:21 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-25 15:36:21 +0100 |
commit | 03f73b8cdcab5e531e6507bcc29156d9355dff9a (patch) | |
tree | 64a65d7d94ff4c6c3145a6a85b48ef3d92370d0a /src/gui | |
parent | 28df18379fa65e9d6bf8a12908218c150af1f613 (diff) | |
download | weechat-03f73b8cdcab5e531e6507bcc29156d9355dff9a.zip |
core: skip and ignore color attributes before special names like "reset" in gui_color_get_custom
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-color.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index a851b15da..43e43a444 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -219,83 +219,96 @@ gui_color_get_custom (const char *color_name) if (!color_name || !color_name[0]) return color[index_color]; - if (string_strcasecmp (color_name, "reset") == 0) + /* read extra attributes (bold, ..) */ + color_attr = NULL; + ptr_color_name = color_name; + while (gui_color_attr_get_flag (ptr_color_name[0]) > 0) + { + ptr_color_name++; + } + if (ptr_color_name != color_name) + { + color_attr = string_strndup (color_name, + ptr_color_name - color_name); + } + + if (string_strcasecmp (ptr_color_name, "reset") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c", GUI_COLOR_RESET_CHAR); } - else if (string_strcasecmp (color_name, "resetcolor") == 0) + else if (string_strcasecmp (ptr_color_name, "resetcolor") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_COLOR_CHAR, GUI_COLOR_RESET_CHAR); } - else if (string_strcasecmp (color_name, "emphasis") == 0) + else if (string_strcasecmp (ptr_color_name, "emphasis") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_COLOR_CHAR, GUI_COLOR_EMPHASIS_CHAR); } - else if (string_strcasecmp (color_name, "bold") == 0) + else if (string_strcasecmp (ptr_color_name, "bold") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_BOLD_CHAR); } - else if (string_strcasecmp (color_name, "-bold") == 0) + else if (string_strcasecmp (ptr_color_name, "-bold") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_BOLD_CHAR); } - else if (string_strcasecmp (color_name, "reverse") == 0) + else if (string_strcasecmp (ptr_color_name, "reverse") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_REVERSE_CHAR); } - else if (string_strcasecmp (color_name, "-reverse") == 0) + else if (string_strcasecmp (ptr_color_name, "-reverse") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_REVERSE_CHAR); } - else if (string_strcasecmp (color_name, "italic") == 0) + else if (string_strcasecmp (ptr_color_name, "italic") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_ITALIC_CHAR); } - else if (string_strcasecmp (color_name, "-italic") == 0) + else if (string_strcasecmp (ptr_color_name, "-italic") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_ITALIC_CHAR); } - else if (string_strcasecmp (color_name, "underline") == 0) + else if (string_strcasecmp (ptr_color_name, "underline") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_UNDERLINE_CHAR); } - else if (string_strcasecmp (color_name, "-underline") == 0) + else if (string_strcasecmp (ptr_color_name, "-underline") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_UNDERLINE_CHAR); } - else if (string_strcasecmp (color_name, "bar_fg") == 0) + else if (string_strcasecmp (ptr_color_name, "bar_fg") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c%c", @@ -303,7 +316,7 @@ gui_color_get_custom (const char *color_name) GUI_COLOR_BAR_CHAR, GUI_COLOR_BAR_FG_CHAR); } - else if (string_strcasecmp (color_name, "bar_delim") == 0) + else if (string_strcasecmp (ptr_color_name, "bar_delim") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c%c", @@ -311,7 +324,7 @@ gui_color_get_custom (const char *color_name) GUI_COLOR_BAR_CHAR, GUI_COLOR_BAR_DELIM_CHAR); } - else if (string_strcasecmp (color_name, "bar_bg") == 0) + else if (string_strcasecmp (ptr_color_name, "bar_bg") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c%c", @@ -326,22 +339,9 @@ gui_color_get_custom (const char *color_name) bg_term = -1; fg = -1; bg = -1; - color_attr = NULL; color_fg[0] = '\0'; color_bg[0] = '\0'; - /* read extra attributes (bold, ..) */ - ptr_color_name = color_name; - while (gui_color_attr_get_flag (ptr_color_name[0]) > 0) - { - ptr_color_name++; - } - if (ptr_color_name != color_name) - { - color_attr = string_strndup (color_name, - ptr_color_name - color_name); - } - pos_delim = strchr (ptr_color_name, ','); if (!pos_delim) pos_delim = strchr (ptr_color_name, ':'); @@ -451,12 +451,13 @@ gui_color_get_custom (const char *color_name) color_bg); } - if (color_attr) - free (color_attr); if (str_fg) free (str_fg); } + if (color_attr) + free (color_attr); + return color[index_color]; } |