mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
Fix bug with text attribute in IRC messages: toggle attribute instead of always forcing it to on (bug #25770)
This commit is contained in:
@@ -4674,8 +4674,10 @@ const char *weechat_color (const char *color_name);
|
||||
<listitem>
|
||||
<para>
|
||||
<option>color_name</option>: name of color: may be a WeeChat
|
||||
color name (from weechat.color.xxx), or a color with optional
|
||||
background (separated by comma).
|
||||
color name (from weechat.color.xxx), a color with optional
|
||||
background (separated by comma), attribute ("bold", "-bold",
|
||||
"reverse", "-reverse", "italic", "-italic", "underline",
|
||||
"-underline", ) or a bar color ("bar_fg", "bar_delim", "bar_bg").
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
@@ -104,6 +104,13 @@ gui_color_get_custom (const char *color_name)
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_BOLD_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-bold") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_BOLD_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "reverse") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
@@ -111,6 +118,13 @@ gui_color_get_custom (const char *color_name)
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_REVERSE_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-reverse") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_REVERSE_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "italic") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
@@ -118,6 +132,13 @@ gui_color_get_custom (const char *color_name)
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_ITALIC_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-italic") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_ITALIC_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "underline") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
@@ -125,6 +146,13 @@ gui_color_get_custom (const char *color_name)
|
||||
GUI_COLOR_SET_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_UNDERLINE_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "-underline") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s%s",
|
||||
GUI_COLOR_REMOVE_WEECHAT_STR,
|
||||
GUI_COLOR_ATTR_UNDERLINE_STR);
|
||||
}
|
||||
else if (string_strcasecmp (color_name, "bar_fg") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
|
||||
@@ -54,7 +54,7 @@ char *irc_color_to_weechat[IRC_NUM_COLORS] =
|
||||
* irc_color_decode: replace IRC colors by WeeChat colors
|
||||
* if keep_colors == 0: remove any color/style in message
|
||||
* otherwise: keep colors
|
||||
* Note: after use, string returned has to be free()
|
||||
x * Note: after use, string returned has to be free()
|
||||
*/
|
||||
|
||||
char *
|
||||
@@ -63,13 +63,18 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
unsigned char *out, *ptr_string;
|
||||
int out_length, length, out_pos;
|
||||
char str_fg[3], str_bg[3], str_color[128];
|
||||
int fg, bg;
|
||||
int fg, bg, bold, reverse, italic, underline;
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
bold = 0;
|
||||
reverse = 0;
|
||||
italic = 0;
|
||||
underline = 0;
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out[0] = '\0';
|
||||
while (ptr_string && ptr_string[0])
|
||||
@@ -78,12 +83,18 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
{
|
||||
case IRC_COLOR_BOLD_CHAR:
|
||||
if (keep_colors)
|
||||
strcat ((char *)out, weechat_color("bold"));
|
||||
strcat ((char *)out,
|
||||
weechat_color((bold) ? "-bold" : "bold"));
|
||||
bold ^= 1;
|
||||
ptr_string++;
|
||||
break;
|
||||
case IRC_COLOR_RESET_CHAR:
|
||||
if (keep_colors)
|
||||
strcat ((char *)out, weechat_color("reset"));
|
||||
bold = 0;
|
||||
reverse = 0;
|
||||
italic = 0;
|
||||
underline = 0;
|
||||
ptr_string++;
|
||||
break;
|
||||
case IRC_COLOR_FIXED_CHAR:
|
||||
@@ -92,17 +103,23 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
case IRC_COLOR_REVERSE_CHAR:
|
||||
case IRC_COLOR_REVERSE2_CHAR:
|
||||
if (keep_colors)
|
||||
strcat ((char *)out, weechat_color("reverse"));
|
||||
strcat ((char *)out,
|
||||
weechat_color((reverse) ? "-reverse" : "reverse"));
|
||||
reverse ^= 1;
|
||||
ptr_string++;
|
||||
break;
|
||||
case IRC_COLOR_ITALIC_CHAR:
|
||||
if (keep_colors)
|
||||
strcat ((char *)out, weechat_color("italic"));
|
||||
strcat ((char *)out,
|
||||
weechat_color((italic) ? "-italic" : "italic"));
|
||||
italic ^= 1;
|
||||
ptr_string++;
|
||||
break;
|
||||
case IRC_COLOR_UNDERLINE_CHAR:
|
||||
if (keep_colors)
|
||||
strcat ((char *)out, weechat_color("underline"));
|
||||
strcat ((char *)out,
|
||||
weechat_color((underline) ? "-underline" : "underline"));
|
||||
underline ^= 1;
|
||||
ptr_string++;
|
||||
break;
|
||||
case IRC_COLOR_COLOR_CHAR:
|
||||
|
||||
Reference in New Issue
Block a user