diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index c4c7ab446..98b4b4f66 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -250,15 +250,15 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, break; } break; - case GUI_COLOR_SET_WEECHAT_CHAR: + case GUI_COLOR_SET_ATTR_CHAR: string++; - gui_window_string_apply_color_set ((unsigned char **)&string, - GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar); + gui_window_string_apply_color_set_attr ((unsigned char **)&string, + GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar); break; - case GUI_COLOR_REMOVE_WEECHAT_CHAR: + case GUI_COLOR_REMOVE_ATTR_CHAR: string++; - gui_window_string_apply_color_remove ((unsigned char **)&string, - GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar); + gui_window_string_apply_color_remove_attr ((unsigned char **)&string, + GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar); break; case GUI_COLOR_RESET_CHAR: string++; diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index f5632e6e7..a8a21474d 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -219,15 +219,15 @@ gui_chat_string_next_char (struct t_gui_window *window, break; } break; - case GUI_COLOR_SET_WEECHAT_CHAR: + case GUI_COLOR_SET_ATTR_CHAR: string++; - gui_window_string_apply_color_set ((unsigned char **)&string, - (apply_style) ? GUI_WINDOW_OBJECTS(window)->win_chat : NULL); + gui_window_string_apply_color_set_attr ((unsigned char **)&string, + (apply_style) ? GUI_WINDOW_OBJECTS(window)->win_chat : NULL); break; - case GUI_COLOR_REMOVE_WEECHAT_CHAR: + case GUI_COLOR_REMOVE_ATTR_CHAR: string++; - gui_window_string_apply_color_remove ((unsigned char **)&string, - (apply_style) ? GUI_WINDOW_OBJECTS(window)->win_chat : NULL); + gui_window_string_apply_color_remove_attr ((unsigned char **)&string, + (apply_style) ? GUI_WINDOW_OBJECTS(window)->win_chat : NULL); break; case GUI_COLOR_RESET_CHAR: string++; diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index e22db0bfd..7d601cfa8 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -741,15 +741,16 @@ gui_window_string_apply_color_weechat (unsigned char **str, WINDOW *window) } /* - * gui_window_string_apply_color_set: apply "set attribute" color code in - * string and move string pointer after - * color in string - * If window is NULL, no color is applied - * but string pointer is moved anyway + * gui_window_string_apply_color_set_attr: apply "set attribute" color code in + * string and move string pointer after + * color in string + * If window is NULL, no color is + * applied but string pointer is moved + * anyway */ void -gui_window_string_apply_color_set (unsigned char **str, WINDOW *window) +gui_window_string_apply_color_set_attr (unsigned char **str, WINDOW *window) { unsigned char *ptr_string; @@ -782,15 +783,16 @@ gui_window_string_apply_color_set (unsigned char **str, WINDOW *window) } /* - * gui_window_string_apply_color_remove: apply "remove attribute" color code in - * string and move string pointer after - * color in string - * If window is NULL, no color is applied - * but string pointer is moved anyway + * gui_window_string_apply_color_remove_attr: apply "remove attribute" color + * code in string and move string + * pointer after color in string + * If window is NULL, no color is + * applied but string pointer is + * moved anyway */ void -gui_window_string_apply_color_remove (unsigned char **str, WINDOW *window) +gui_window_string_apply_color_remove_attr (unsigned char **str, WINDOW *window) { unsigned char *ptr_string; diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index f3fad901d..0d7e2bf67 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -101,10 +101,10 @@ extern void gui_window_string_apply_color_pair (unsigned char **str, WINDOW *window); extern void gui_window_string_apply_color_weechat (unsigned char **str, WINDOW *window); -extern void gui_window_string_apply_color_set (unsigned char **str, - WINDOW *window); -extern void gui_window_string_apply_color_remove (unsigned char **str, - WINDOW *window); +extern void gui_window_string_apply_color_set_attr (unsigned char **str, + WINDOW *window); +extern void gui_window_string_apply_color_remove_attr (unsigned char **str, + WINDOW *window); extern void gui_window_apply_color (unsigned char **str, WINDOW *window, int apply_bar_colors); extern void gui_window_set_title (const char *title); diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c index f416389dc..ce677f18f 100644 --- a/src/gui/gtk/gui-gtk-chat.c +++ b/src/gui/gtk/gui-gtk-chat.c @@ -177,98 +177,11 @@ char * gui_chat_string_next_char (struct t_gui_window *window, const unsigned char *string, int apply_style) { - char str_fg[3]; - int weechat_color, rc; + /* TODO: write this function for Gtk */ + (void) window; + (void) apply_style; - while (string[0]) - { - switch (string[0]) - { - case GUI_COLOR_RESET_CHAR: - string++; - if (apply_style) - gui_chat_reset_style (window); - break; - case GUI_COLOR_COLOR_CHAR: - string++; - if (isdigit (string[0]) && isdigit (string[1])) - { - str_fg[0] = string[0]; - str_fg[1] = string[1]; - str_fg[2] = '\0'; - string += 2; - if (apply_style) - { - rc = sscanf (str_fg, "%d", &weechat_color); - if ((rc != EOF) && (rc >= 1)) - { - gui_chat_set_weechat_color (window, weechat_color); - } - } - } - break; - case GUI_COLOR_SET_WEECHAT_CHAR: - string++; - switch (string[0]) - { - case GUI_COLOR_ATTR_BOLD_CHAR: - string++; - if (apply_style) - gui_chat_set_color_style (window, A_BOLD); - break; - case GUI_COLOR_ATTR_REVERSE_CHAR: - string++; - if (apply_style) - gui_chat_set_color_style (window, A_REVERSE); - break; - case GUI_COLOR_ATTR_ITALIC_CHAR: - /* not available in Curses GUI */ - string++; - break; - case GUI_COLOR_ATTR_UNDERLINE_CHAR: - string++; - if (apply_style) - gui_chat_set_color_style (window, A_UNDERLINE); - break; - } - break; - case GUI_COLOR_REMOVE_WEECHAT_CHAR: - string++; - switch (string[0]) - { - case GUI_COLOR_ATTR_BOLD_CHAR: - string++; - if (apply_style) - gui_chat_remove_color_style (window, A_BOLD); - break; - case GUI_COLOR_ATTR_REVERSE_CHAR: - string++; - if (apply_style) - gui_chat_remove_color_style (window, A_REVERSE); - break; - case GUI_COLOR_ATTR_ITALIC_CHAR: - /* not available in Curses GUI */ - string++; - break; - case GUI_COLOR_ATTR_UNDERLINE_CHAR: - string++; - if (apply_style) - gui_chat_remove_color_style (window, A_UNDERLINE); - break; - } - break; - default: - if (string[0] < 32) - string++; - else - return (char *)string; - break; - } - - } - - /* nothing found except color/attrib codes, so return NULL */ - return NULL; + return (char *)string; } /* diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index a70a261ae..325ce4cf5 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -114,56 +114,56 @@ gui_color_get_custom (const char *color_name) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_SET_WEECHAT_CHAR, + GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_BOLD_CHAR); } else if (string_strcasecmp (color_name, "-bold") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_REMOVE_WEECHAT_CHAR, + GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_BOLD_CHAR); } else if (string_strcasecmp (color_name, "reverse") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_SET_WEECHAT_CHAR, + GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_REVERSE_CHAR); } else if (string_strcasecmp (color_name, "-reverse") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_REMOVE_WEECHAT_CHAR, + GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_REVERSE_CHAR); } else if (string_strcasecmp (color_name, "italic") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_SET_WEECHAT_CHAR, + GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_ITALIC_CHAR); } else if (string_strcasecmp (color_name, "-italic") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_REMOVE_WEECHAT_CHAR, + GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_ITALIC_CHAR); } else if (string_strcasecmp (color_name, "underline") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_SET_WEECHAT_CHAR, + GUI_COLOR_SET_ATTR_CHAR, GUI_COLOR_ATTR_UNDERLINE_CHAR); } else if (string_strcasecmp (color_name, "-underline") == 0) { snprintf (color[index_color], sizeof (color[index_color]), "%c%c", - GUI_COLOR_REMOVE_WEECHAT_CHAR, + GUI_COLOR_REMOVE_ATTR_CHAR, GUI_COLOR_ATTR_UNDERLINE_CHAR); } else if (string_strcasecmp (color_name, "bar_fg") == 0) @@ -427,8 +427,8 @@ gui_color_decode (const char *string, const char *replacement) out_pos++; } break; - case GUI_COLOR_SET_WEECHAT_CHAR: - case GUI_COLOR_REMOVE_WEECHAT_CHAR: + case GUI_COLOR_SET_ATTR_CHAR: + case GUI_COLOR_REMOVE_ATTR_CHAR: ptr_string++; if (ptr_string[0]) ptr_string++; diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 5ff719d90..48df8cf95 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -69,8 +69,8 @@ enum t_gui_color_enum /* WeeChat internal color attributes (should never be in protocol messages) */ #define GUI_COLOR_COLOR_CHAR '\x19' -#define GUI_COLOR_SET_WEECHAT_CHAR '\x1A' -#define GUI_COLOR_REMOVE_WEECHAT_CHAR '\x1B' +#define GUI_COLOR_SET_ATTR_CHAR '\x1A' +#define GUI_COLOR_REMOVE_ATTR_CHAR '\x1B' #define GUI_COLOR_RESET_CHAR '\x1C' #define GUI_COLOR_ATTR_BOLD_CHAR '\x01'