mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 08:13:14 +02:00
Rename some color constants and functions for attributes
This commit is contained in:
@@ -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++;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+10
-10
@@ -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++;
|
||||
|
||||
+2
-2
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user