summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-04-30 18:18:14 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-04-30 18:18:14 +0200
commitbbde23dec66de5ddf00b75fedb0abf6a93e6a079 (patch)
treef73196dc26f9a187e2535f9e0a67d1c7dc654eed /src
parent339be5544f8364920750921d2e4ef07c45370769 (diff)
downloadweechat-bbde23dec66de5ddf00b75fedb0abf6a93e6a079.zip
IRC colors reintroduced
Diffstat (limited to 'src')
-rw-r--r--src/gui/curses/gui-curses-keyboard.c1
-rw-r--r--src/plugins/irc/irc-color.c325
-rw-r--r--src/plugins/irc/irc-color.h10
-rw-r--r--src/plugins/irc/irc-command.c54
-rw-r--r--src/plugins/irc/irc-completion.c10
-rw-r--r--src/plugins/irc/irc-input.c17
-rw-r--r--src/plugins/irc/irc-protocol.c260
-rw-r--r--src/plugins/irc/irc-protocol.h1
-rw-r--r--src/plugins/irc/irc-server.c3
-rw-r--r--src/plugins/plugin-api.c101
10 files changed, 420 insertions, 362 deletions
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index d0278786d..3f8b98712 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -100,6 +100,7 @@ gui_keyboard_default_bindings ()
gui_keyboard_bind (NULL, /* ^S^U */ "ctrl-Sctrl-U", "/input set_unread");
gui_keyboard_bind (NULL, /* ^Cb */ "ctrl-Cb", "/input insert \\x02");
gui_keyboard_bind (NULL, /* ^Cc */ "ctrl-Cc", "/input insert \\x03");
+ gui_keyboard_bind (NULL, /* ^Cc */ "ctrl-Ci", "/input insert \\x1D");
gui_keyboard_bind (NULL, /* ^Co */ "ctrl-Co", "/input insert \\x0F");
gui_keyboard_bind (NULL, /* ^Cr */ "ctrl-Cr", "/input insert \\x12");
gui_keyboard_bind (NULL, /* ^Cu */ "ctrl-Cu", "/input insert \\x15");
diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
index 4ec0aded8..bda5f8f3f 100644
--- a/src/plugins/irc/irc-color.c
+++ b/src/plugins/irc/irc-color.c
@@ -20,242 +20,227 @@
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-color.h"
+#include "irc-config.h"
+
+
+char *irc_color_to_weechat[IRC_NUM_COLORS] =
+{ /* 0 */ "white",
+ /* 1 */ "black",
+ /* 2 */ "blue",
+ /* 3 */ "green",
+ /* 4 */ "lightred",
+ /* 5 */ "red",
+ /* 6 */ "magenta",
+ /* 7 */ "brown",
+ /* 8 */ "yellow",
+ /* 9 */ "lightgreen",
+ /* 10 */ "cyan",
+ /* 11 */ "lightcyan",
+ /* 12 */ "lightblue",
+ /* 13 */ "lightmagenta",
+ /* 14 */ "default",
+ /* 15 */ "white"
+};
/*
- * irc_color_decode: parses a message (coming from IRC server),
+ * irc_color_decode: replace IRC colors by WeeChat colors
* if keep_colors == 0: remove any color/style in message
- * otherwise change colors by internal WeeChat color codes
- * if keep_eechat_attr == 0: remove any weechat color/style attribute
- * After use, string returned has to be free()
+ * otherwise: keep colors
+ * Note: after use, string returned has to be free()
*/
-unsigned char *
-irc_color_decode (unsigned char *string, int keep_irc_colors,
- int keep_weechat_attr)
+char *
+irc_color_decode (char *string, int keep_colors)
{
- /*unsigned char *out;
- int out_length, out_pos, length;
- char str_fg[3], str_bg[3];
- int fg, bg, attr;*/
-
- (void) string;
- (void) keep_irc_colors;
- (void) keep_weechat_attr;
-
- return (unsigned char *)strdup ((char *)string);
+ unsigned char *out, *ptr_string;
+ int out_length, length, out_pos;
+ char str_fg[3], str_bg[3], str_color[128];
+ int fg, bg;
- /*out_length = (strlen ((char *)string) * 2) + 1;
+ out_length = (strlen (string) * 2) + 1;
out = malloc (out_length);
if (!out)
return NULL;
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
+ ptr_string = (unsigned char *)string;
+ out[0] = '\0';
+ while (ptr_string && ptr_string[0])
{
- switch (string[0])
+ switch (ptr_string[0])
{
case IRC_COLOR_BOLD_CHAR:
+ if (keep_colors)
+ strcat ((char *)out, weechat_color("bold"));
+ ptr_string++;
+ break;
case IRC_COLOR_RESET_CHAR:
+ if (keep_colors)
+ strcat ((char *)out, weechat_color("reset"));
+ ptr_string++;
+ break;
case IRC_COLOR_FIXED_CHAR:
+ ptr_string++;
+ break;
case IRC_COLOR_REVERSE_CHAR:
case IRC_COLOR_REVERSE2_CHAR:
+ if (keep_colors)
+ strcat ((char *)out, weechat_color("reverse"));
+ ptr_string++;
+ break;
case IRC_COLOR_ITALIC_CHAR:
+ if (keep_colors)
+ strcat ((char *)out, weechat_color("italic"));
+ ptr_string++;
+ break;
case IRC_COLOR_UNDERLINE_CHAR:
- if (keep_irc_colors)
- out[out_pos++] = string[0];
- string++;
+ if (keep_colors)
+ strcat ((char *)out, weechat_color("underline"));
+ ptr_string++;
break;
case IRC_COLOR_COLOR_CHAR:
- string++;
+ ptr_string++;
str_fg[0] = '\0';
str_bg[0] = '\0';
- if (isdigit (string[0]))
+ if (isdigit (ptr_string[0]))
{
- str_fg[0] = string[0];
+ str_fg[0] = ptr_string[0];
str_fg[1] = '\0';
- string++;
- if (isdigit (string[0]))
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
- str_fg[1] = string[0];
+ str_fg[1] = ptr_string[0];
str_fg[2] = '\0';
- string++;
+ ptr_string++;
}
}
- if (string[0] == ',')
+ if (ptr_string[0] == ',')
{
- string++;
- if (isdigit (string[0]))
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
- str_bg[0] = string[0];
+ str_bg[0] = ptr_string[0];
str_bg[1] = '\0';
- string++;
- if (isdigit (string[0]))
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
- str_bg[1] = string[0];
+ str_bg[1] = ptr_string[0];
str_bg[2] = '\0';
- string++;
+ ptr_string++;
}
}
}
- if (keep_irc_colors)
+ if (keep_colors)
{
- if (!str_fg[0] && !str_bg[0])
- out[out_pos++] = IRC_COLOR_COLOR_CHAR;
- else
+ if (str_fg[0] || str_bg[0])
{
- attr = 0;
+ fg = -1;
+ bg = -1;
if (str_fg[0])
{
sscanf (str_fg, "%d", &fg);
- fg %= GUI_NUM_IRC_COLORS;
- attr |= gui_irc_colors[fg][1];
+ fg %= IRC_NUM_COLORS;
}
if (str_bg[0])
{
sscanf (str_bg, "%d", &bg);
- bg %= GUI_NUM_IRC_COLORS;
- attr |= gui_irc_colors[bg][1];
- }
- if (attr & A_BOLD)
- {
- out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR;
- out[out_pos++] = IRC_COLOR_BOLD_CHAR;
+ bg %= IRC_NUM_COLORS;
}
- else
- {
- out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR;
- out[out_pos++] = IRC_COLOR_BOLD_CHAR;
- }
- out[out_pos++] = IRC_COLOR_COLOR_CHAR;
- if (str_fg[0])
- {
- out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0';
- out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0';
- }
- if (str_bg[0])
- {
- out[out_pos++] = ',';
- out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0';
- out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0';
- }
- }
- }
- break;
- case GUI_ATTR_WEECHAT_COLOR_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]) && isdigit (string[1]))
- {
- if (keep_weechat_attr)
- {
- out[out_pos++] = string[0];
- out[out_pos++] = string[1];
+ snprintf (str_color, sizeof (str_color),
+ "%s%s%s",
+ (fg >= 0) ? irc_color_to_weechat[fg] : "",
+ (bg >= 0) ? "," : "",
+ (bg >= 0) ? irc_color_to_weechat[bg] : "");
+ strcat ((char *)out, weechat_color(str_color));
}
- string += 2;
}
break;
- case GUI_ATTR_WEECHAT_SET_CHAR:
- case GUI_ATTR_WEECHAT_REMOVE_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- if (string[0])
- {
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- }
- break;
- case GUI_ATTR_WEECHAT_RESET_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- break;
default:
- length = utf8_char_size ((char *)string);
+ length = weechat_utf8_char_size ((char *)ptr_string);
if (length == 0)
length = 1;
- memcpy (out + out_pos, string, length);
- out_pos += length;
- string += length;
+ out_pos = strlen ((char *)out);
+ memcpy (out + out_pos, ptr_string, length);
+ out[out_pos + length] = '\0';
+ ptr_string += length;
+ break;
}
}
- out[out_pos] = '\0';
- return out;*/
+
+ return (char *)out;
}
/*
* irc_color_decode_for_user_entry: parses a message (coming from IRC server),
* and replaces colors/bold/.. by ^C, ^B, ..
- * After use, string returned has to be free()
+ * Note: after use, string returned has to be free()
*/
-unsigned char *
-irc_color_decode_for_user_entry (unsigned char *string)
+char *
+irc_color_decode_for_user_entry (char *string)
{
- /*unsigned char *out;
- int out_length, out_pos, length;*/
-
- (void) string;
-
- return (unsigned char *)strdup ((char *)string);
+ unsigned char *out, *ptr_string;
+ int out_length, out_pos, length;
- /*out_length = (strlen ((char *)string) * 2) + 1;
+ out_length = (strlen (string) * 2) + 1;
out = malloc (out_length);
if (!out)
return NULL;
+ ptr_string = (unsigned char *)string;
out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
+ while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
{
- switch (string[0])
+ switch (ptr_string[0])
{
case IRC_COLOR_BOLD_CHAR:
- out[out_pos++] = 0x02; // ^B
- string++;
+ out[out_pos++] = 0x02;
+ ptr_string++;
break;
case IRC_COLOR_FIXED_CHAR:
- string++;
+ ptr_string++;
break;
case IRC_COLOR_RESET_CHAR:
- out[out_pos++] = 0x0F; // ^O
- string++;
+ out[out_pos++] = 0x0F;
+ ptr_string++;
break;
case IRC_COLOR_REVERSE_CHAR:
case IRC_COLOR_REVERSE2_CHAR:
- out[out_pos++] = 0x12; // ^R
- string++;
+ out[out_pos++] = 0x12;
+ ptr_string++;
break;
case IRC_COLOR_ITALIC_CHAR:
- string++;
+ out[out_pos++] = 0x1D;
+ ptr_string++;
break;
case IRC_COLOR_UNDERLINE_CHAR:
- out[out_pos++] = 0x15; // ^U
- string++;
+ out[out_pos++] = 0x15;
+ ptr_string++;
break;
case IRC_COLOR_COLOR_CHAR:
- out[out_pos++] = 0x03; // ^C
- string++;
+ out[out_pos++] = 0x03;
+ ptr_string++;
break;
default:
- length = utf8_char_size ((char *)string);
+ length = weechat_utf8_char_size ((char *)ptr_string);
if (length == 0)
length = 1;
- memcpy (out + out_pos, string, length);
+ memcpy (out + out_pos, ptr_string, length);
out_pos += length;
- string += length;
+ ptr_string += length;
}
}
+
out[out_pos] = '\0';
- return out;*/
+
+ return (char *)out;
}
/*
@@ -263,66 +248,62 @@ irc_color_decode_for_user_entry (unsigned char *string)
* encode special chars (^Cb, ^Cc, ..) in IRC colors
* if keep_colors == 0: remove any color/style in message
* otherwise: keep colors
- * After use, string returned has to be free()
+ * Note: after use, string returned has to be free()
*/
-unsigned char *
-irc_color_encode (unsigned char *string, int keep_colors)
+char *
+irc_color_encode (char *string, int keep_colors)
{
- /*unsigned char *out;
- int out_length, out_pos, length;*/
-
- (void) string;
- (void) keep_colors;
-
- return NULL;
+ unsigned char *out, *ptr_string;
+ int out_length, out_pos, length;
- /*out_length = (strlen ((char *)string) * 2) + 1;
+ out_length = (strlen (string) * 2) + 1;
out = malloc (out_length);
if (!out)
return NULL;
+ ptr_string = (unsigned char *)string;
out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
+ while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
{
- switch (string[0])
+ switch (ptr_string[0])
{
case 0x02: // ^B
if (keep_colors)
out[out_pos++] = IRC_COLOR_BOLD_CHAR;
- string++;
+ ptr_string++;
break;
case 0x03: // ^C
if (keep_colors)
out[out_pos++] = IRC_COLOR_COLOR_CHAR;
- string++;
- if (isdigit (string[0]))
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
+ out[out_pos++] = ptr_string[0];
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
if (keep_colors)
- out[out_pos++] = string[0];
- string++;
+ out[out_pos++] = ptr_string[0];
+ ptr_string++;
}
}
- if (string[0] == ',')
+ if (ptr_string[0] == ',')
{
if (keep_colors)
out[out_pos++] = ',';
- string++;
- if (isdigit (string[0]))
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
+ out[out_pos++] = ptr_string[0];
+ ptr_string++;
+ if (isdigit (ptr_string[0]))
{
if (keep_colors)
- out[out_pos++] = string[0];
- string++;
+ out[out_pos++] = ptr_string[0];
+ ptr_string++;
}
}
}
@@ -330,27 +311,29 @@ irc_color_encode (unsigned char *string, int keep_colors)
case 0x0F: // ^O
if (keep_colors)
out[out_pos++] = IRC_COLOR_RESET_CHAR;
- string++;
+ ptr_string++;
break;
case 0x12: // ^R
if (keep_colors)
out[out_pos++] = IRC_COLOR_REVERSE_CHAR;
- string++;
+ ptr_string++;
break;
case 0x15: // ^U
if (keep_colors)
out[out_pos++] = IRC_COLOR_UNDERLINE_CHAR;
- string++;
+ ptr_string++;
break;
default:
- length = utf8_char_size ((char *)string);
+ length = weechat_utf8_char_size ((char *)ptr_string);
if (length == 0)
length = 1;
- memcpy (out + out_pos, string, length);
+ memcpy (out + out_pos, ptr_string, length);
out_pos += length;
- string += length;
+ ptr_string += length;
}
}
+
out[out_pos] = '\0';
- return out;*/
+
+ return (char *)out;
}
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index 9a6de84d9..7b4ff08b9 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_IRC_COLOR_H
#define __WEECHAT_IRC_COLOR_H 1
+#define IRC_NUM_COLORS 16
+
/* shift ncurses colors for compatibility with colors
in IRC messages (same as other IRC clients) */
@@ -51,10 +53,8 @@
#define IRC_COLOR_UNDERLINE_CHAR '\x1F'
#define IRC_COLOR_UNDERLINE_STR "\x1F"
-extern unsigned char *irc_color_decode (unsigned char *string,
- int keep_irc_colors,
- int keep_weechat_attr);
-extern unsigned char *irc_color_decode_for_user_entry (unsigned char *string);
-extern unsigned char *irc_color_encode (unsigned char *string, int keep_colors);
+extern char *irc_color_decode (char *string, int keep_colors);
+extern char *irc_color_decode_for_user_entry (char *string);
+extern char *irc_color_encode (char *string, int keep_colors);
#endif /* irc-color.h */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 701550929..fbde8a9ce 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -76,7 +76,8 @@ irc_command_me_channel (struct t_irc_server *server,
channel->name,
(arguments && arguments[0]) ? arguments : "");
string = (arguments && arguments[0]) ?
- (char *)irc_color_decode ((unsigned char *)arguments, 1, 0) : NULL;
+ irc_color_decode (arguments,
+ weechat_config_boolean (irc_config_network_colors_receive)) : NULL;
weechat_printf (channel->buffer,
"%s%s%s %s%s",
weechat_prefix ("action"),
@@ -211,8 +212,8 @@ irc_command_amsg (void *data, struct t_gui_buffer *buffer, int argc,
ptr_server->nick);
if (ptr_nick)
{
- string = (char *)irc_color_decode (
- (unsigned char *)argv_eol[1], 1, 0);
+ string = irc_color_decode (argv_eol[1],
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_channel->buffer, "%s%s",
irc_nick_as_prefix (ptr_nick,
NULL, NULL),
@@ -268,8 +269,8 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
irc_server_sendf (server, "AWAY :%s", arguments);
if (weechat_config_integer (irc_config_look_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
{
- string = (char *)irc_color_decode ((unsigned char *)arguments,
- 1, 0);
+ string = irc_color_decode (arguments,
+ weechat_config_boolean (irc_config_network_colors_receive));
if (weechat_config_integer (irc_config_look_display_away) == IRC_CONFIG_DISPLAY_AWAY_LOCAL)
irc_display_away (server, "away",
(string) ? string : arguments);
@@ -296,8 +297,8 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
{
/* server not connected, store away for future usage
(when connecting to server) */
- string = (char *)irc_color_decode ((unsigned char *)arguments,
- 1, 0);
+ string = irc_color_decode (arguments,
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (server->buffer,
_("%s: future away on %s%s%s: %s"),
"irc",
@@ -1761,8 +1762,8 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
else
ptr_nick = NULL;
- string = (char *)irc_color_decode ((unsigned char *)argv_eol[2],
- 1, 0);
+ string = irc_color_decode (argv_eol[2],
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_channel->buffer,
"%s",
(string) ? string : argv_eol[2]);
@@ -1784,8 +1785,8 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
ptr_server->nick);
if (ptr_nick)
{
- string = (char *)irc_color_decode (
- (unsigned char *)argv_eol[2], 1, 0);
+ string = irc_color_decode (argv_eol[2],
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_channel->buffer,
"%s",
(string) ?
@@ -1815,10 +1816,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (msg_pwd_hidden
&& (weechat_config_boolean (irc_config_log_hide_nickserv_pwd)))
irc_display_hide_password (msg_pwd_hidden, 0);
- string = (char *)irc_color_decode (
- (unsigned char *)((msg_pwd_hidden) ?
- msg_pwd_hidden : argv_eol[2]),
- 1, 0);
+ string = irc_color_decode (
+ (msg_pwd_hidden) ? msg_pwd_hidden : argv_eol[2],
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_server->buffer,
"%s%s-%s%s%s- %s%s",
weechat_prefix ("network"),
@@ -1837,8 +1837,8 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
}
else
{
- string = (char *)irc_color_decode (
- (unsigned char *)argv_eol[2], 1, 0);
+ string = irc_color_decode (argv_eol[2],
+ weechat_config_boolean (irc_config_network_colors_receive));
ptr_channel = irc_channel_search (ptr_server,
targets[i]);
if (ptr_channel)
@@ -1995,7 +1995,8 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
if (argc > 2)
{
- string = (char *)irc_color_decode ((unsigned char *)argv_eol[2], 1, 0);
+ string = irc_color_decode (argv_eol[2],
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_server->buffer,
"notice%s(%s%s%s)%s: %s",
IRC_COLOR_CHAT_DELIMITERS,
@@ -2268,8 +2269,8 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
/* display text if given */
if (argv_eol[2])
{
- string = (char *)irc_color_decode ((unsigned char *)argv_eol[2],
- 1, 0);
+ string = irc_color_decode (argv_eol[2],
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_channel->buffer,
"%s%s",
irc_nick_as_prefix (NULL,
@@ -3121,7 +3122,7 @@ int
irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
- char *channel_name, *new_topic;
+ char *channel_name, *new_topic, *new_topic_color;
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3166,8 +3167,15 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
irc_server_sendf (ptr_server, "TOPIC %s :",
channel_name);
else
+ {
+ new_topic_color = irc_color_encode (new_topic,
+ weechat_config_boolean (irc_config_network_colors_send));
irc_server_sendf (ptr_server, "TOPIC %s :%s",
- channel_name, new_topic);
+ channel_name,
+ (new_topic_color) ? new_topic_color : new_topic);
+ if (new_topic_color)
+ free (new_topic_color);
+ }
}
else
irc_server_sendf (ptr_server, "TOPIC %s",
@@ -3892,7 +3900,7 @@ irc_command_init ()
"topic: new topic for "
"channel (if topic is \"-delete\" then topic "
"is deleted)"),
- "%(irc_topic)|-delete %-", &irc_command_topic, NULL);
+ "%(irc_channel_topic)|-delete %-", &irc_command_topic, NULL);
weechat_hook_command ("trace",
N_("find the route to specific server"),
N_("[target]"),
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 62a85723d..81fe87aae 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -25,6 +25,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
+#include "irc-color.h"
#include "irc-completion.h"
#include "irc-config.h"
#include "irc-server.h"
@@ -264,6 +265,8 @@ irc_completion_channel_topic_cb (void *data, char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list)
{
+ char *topic_color;
+
IRC_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
@@ -272,7 +275,12 @@ irc_completion_channel_topic_cb (void *data, char *completion,
if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0])
{
- weechat_list_add (list, ptr_channel->topic, WEECHAT_LIST_POS_SORT);
+ topic_color = irc_color_decode_for_user_entry (ptr_channel->topic);
+ weechat_list_add (list,
+ (topic_color) ? topic_color : ptr_channel->topic,
+ WEECHAT_LIST_POS_SORT);
+ if (topic_color)
+ free (topic_color);
}
return WEECHAT_RC_OK;
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 586168e7a..1a6c86598 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -40,9 +40,13 @@ void
irc_input_user_message_display (struct t_gui_buffer *buffer, char *text)
{
struct t_irc_nick *ptr_nick;
+ char *text_decoded;
+
+ text_decoded = irc_color_decode (text,
+ weechat_config_boolean (irc_config_network_colors_send));
IRC_GET_SERVER_CHANNEL(buffer);
-
+
if (ptr_channel)
{
if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
@@ -52,7 +56,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, char *text)
"%s%s",
irc_nick_as_prefix (NULL, ptr_server->nick,
IRC_COLOR_CHAT_NICK_SELF),
- text);
+ (text_decoded) ? text_decoded : text);
}
else
{
@@ -63,7 +67,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, char *text)
"%s%s",
irc_nick_as_prefix (ptr_nick, NULL,
IRC_COLOR_CHAT_NICK_SELF),
- text);
+ (text_decoded) ? text_decoded : text);
}
else
{
@@ -74,6 +78,9 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, char *text)
}
}
}
+
+ if (text_decoded)
+ free (text_decoded);
}
/*
@@ -157,8 +164,8 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, char *input_data)
if (ptr_channel)
{
- data_with_colors = (char *)irc_color_encode ((unsigned char *)input_data,
- weechat_config_boolean (irc_config_network_colors_send));
+ data_with_colors = irc_color_encode (input_data,
+ weechat_config_boolean (irc_config_network_colors_send));
if (ptr_channel->dcc_chat)
{
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index d4ac892d9..e051e67b8 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -41,6 +41,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-protocol.h"
+#include "irc-color.h"
#include "irc-command.h"
#include "irc-config.h"
#include "irc-server.h"
@@ -2386,7 +2387,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command,
int argc, char **argv, char **argv_eol,
int highlight)
{
- char *pos_topic;
+ char *pos_topic, *topic_color;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *buffer;
@@ -2415,6 +2416,8 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command,
if (pos_topic && pos_topic[0])
{
+ topic_color = irc_color_decode (pos_topic,
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf_tags (buffer,
"irc_topic",
_("%s%s%s%s has changed topic for %s%s%s to: "
@@ -2426,8 +2429,10 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command,
IRC_COLOR_CHAT_CHANNEL,
argv[2],
IRC_COLOR_CHAT,
- pos_topic,
+ (topic_color) ? topic_color : pos_topic,
IRC_COLOR_CHAT);
+ if (topic_color)
+ free (topic_color);
}
else
{
@@ -4432,129 +4437,129 @@ void
irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
char *host, char *command, char *arguments)
{
- int i, cmd_found, return_code, highlight, argc;
+ int i, cmd_found, return_code, highlight, argc, decode_color;
char *pos, *nick;
char *dup_entire_line, *dup_host, *dup_arguments, *irc_message;
t_irc_recv_func *cmd_recv_func;
char *cmd_name, **argv, **argv_eol;
struct t_irc_protocol_msg irc_protocol_messages[] =
- { { "error", N_("error received from IRC server"), &irc_protocol_cmd_error },
- { "invite", N_("invite a nick on a channel"), &irc_protocol_cmd_invite },
- { "join", N_("join a channel"), &irc_protocol_cmd_join },
- { "kick", N_("forcibly remove a user from a channel"), &irc_protocol_cmd_kick },
- { "kill", N_("close client-server connection"), &irc_protocol_cmd_kill },
- { "mode", N_("change channel or user mode"), &irc_protocol_cmd_mode },
- { "nick", N_("change current nickname"), &irc_protocol_cmd_nick },
- { "notice", N_("send notice message to user"), &irc_protocol_cmd_notice },
- { "part", N_("leave a channel"), &irc_protocol_cmd_part },
- { "ping", N_("ping server"), &irc_protocol_cmd_ping },
- { "pong", N_("answer to a ping message"), &irc_protocol_cmd_pong },
- { "privmsg", N_("message received"), &irc_protocol_cmd_privmsg },
- { "quit", N_("close all connections and quit"), &irc_protocol_cmd_quit },
- { "topic", N_("get/set channel topic"), &irc_protocol_cmd_topic },
+ { { "error", N_("error received from IRC server"), 1, &irc_protocol_cmd_error },
+ { "invite", N_("invite a nick on a channel"), 1, &irc_protocol_cmd_invite },
+ { "join", N_("join a channel"), 1, &irc_protocol_cmd_join },
+ { "kick", N_("forcibly remove a user from a channel"), 1, &irc_protocol_cmd_kick },
+ { "kill", N_("close client-server connection"), 1, &irc_protocol_cmd_kill },
+ { "mode", N_("change channel or user mode"), 1, &irc_protocol_cmd_mode },
+ { "nick", N_("change current nickname"), 1, &irc_protocol_cmd_nick },
+ { "notice", N_("send notice message to user"), 1, &irc_protocol_cmd_notice },
+ { "part", N_("leave a channel"), 1, &irc_protocol_cmd_part },
+ { "ping", N_("ping server"), 1, &irc_protocol_cmd_ping },
+ { "pong", N_("answer to a ping message"), 1, &irc_protocol_cmd_pong },
+ { "privmsg", N_("message received"), 1, &irc_protocol_cmd_privmsg },
+ { "quit", N_("close all connections and quit"), 1, &irc_protocol_cmd_quit },
+ { "topic", N_("get/set channel topic"), 0, &irc_protocol_cmd_topic },
{ "wallops", N_("send a message to all currently connected users who have "
"set the 'w' user mode "
- "for themselves"), &irc_protocol_cmd_wallops },
- { "001", N_("a server message"), &irc_protocol_cmd_001 },
- { "005", N_("a server message"), &irc_protocol_cmd_005 },
- { "221", N_("user mode string"), &irc_protocol_cmd_221 },
- { "301", N_("away message"), &irc_protocol_cmd_301 },
- { "303", N_("ison"), &irc_protocol_cmd_303 },
- { "305", N_("unaway"), &irc_protocol_cmd_305 },
- { "306", N_("now away"), &irc_protocol_cmd_306 },
- { "307", N_("whois (registered nick)"), &irc_protocol_cmd_whois_nick_msg },
- { "310", N_("whois (help mode)"), &irc_protocol_cmd_whois_nick_msg },
- { "311", N_("whois (user)"), &irc_protocol_cmd_311 },
- { "312", N_("whois (server)"), &irc_protocol_cmd_312 },
- { "313", N_("whois (operator)"), &irc_protocol_cmd_whois_nick_msg },
- { "314", N_("whowas"), &irc_protocol_cmd_314 },
- { "315", N_("end of /who list"), &irc_protocol_cmd_315 },
- { "317", N_("whois (idle)"), &irc_protocol_cmd_317 },
- { "318", N_("whois (end)"), &irc_protocol_cmd_whois_nick_msg },
- { "319", N_("whois (channels)"), &irc_protocol_cmd_whois_nick_msg },
- { "320", N_("whois (identified user)"), &irc_protocol_cmd_whois_nick_msg },
- { "321", N_("/list start"), &irc_protocol_cmd_321 },
- { "322", N_("channel (for /list)"), &irc_protocol_cmd_322 },
- { "323", N_("end of /list"), &irc_protocol_cmd_323 },
- { "324", N_("channel mode"), &irc_protocol_cmd_324 },
- { "326", N_("whois (has oper privs)"), &irc_protocol_cmd_whois_nick_msg },
- { "327", N_("whois (host)"), &irc_protocol_cmd_327 },
- { "329", N_("channel creation date"), &irc_protocol_cmd_329 },
- { "331", N_("no topic for channel"), &irc_protocol_cmd_331 },
- { "332", N_("topic of channel"), &irc_protocol_cmd_332 },
- { "333", N_("infos about topic (nick and date changed)"), &irc_protocol_cmd_333 },
- { "338", N_("whois (host)"), &irc_protocol_cmd_338 },
- { "341", N_("inviting"), &irc_protocol_cmd_341 },
- { "344", N_("channel reop"), &irc_protocol_cmd_344 },
- { "345", N_("end of channel reop list"), &irc_protocol_cmd_345 },
- { "348", N_("channel exception list"), &irc_protocol_cmd_348 },
- { "349", N_("end of channel exception list"), &irc_protocol_cmd_349 },
- { "351", N_("server version"), &irc_protocol_cmd_351 },
- { "352", N_("who"), &irc_protocol_cmd_352 },
- { "353", N_("list of nicks on channel"), &irc_protocol_cmd_353 },
- { "366", N_("end of /names list"), &irc_protocol_cmd_366 },
- { "367", N_("banlist"), &irc_protocol_cmd_367 },
- { "368", N_("end of banlist"), &irc_protocol_cmd_368 },
- { "378", N_("whois (connecting from)"), &irc_protocol_cmd_whois_nick_msg },
- { "379", N_("whois (using modes)"), &irc_protocol_cmd_whois_nick_msg },
- { "401", N_("no such nick/channel"), &irc_protocol_cmd_error },
- { "402", N_("no such server"), &irc_protocol_cmd_error },
- { "403", N_("no such channel"), &irc_protocol_cmd_error },
- { "404", N_("cannot send to channel"), &irc_protocol_cmd_error },
- { "405", N_("too many channels"), &irc_protocol_cmd_error },
- { "406", N_("was no such nick"), &irc_protocol_cmd_error },
- { "407", N_("was no such nick"), &irc_protocol_cmd_error },
- { "409", N_("no origin"), &irc_protocol_cmd_error },
- { "410", N_("no services"), &irc_protocol_cmd_error },
- { "411", N_("no recipient"), &irc_protocol_cmd_error },
- { "412", N_("no text to send"), &irc_protocol_cmd_error },
- { "413", N_("no toplevel"), &irc_protocol_cmd_error },
- { "414", N_("wilcard in toplevel domain"), &irc_protocol_cmd_error },
- { "421", N_("unknown command"), &irc_protocol_cmd_error },
- { "422", N_("MOTD is missing"), &irc_protocol_cmd_error },
- { "423", N_("no administrative info"), &irc_protocol_cmd_error },
- { "424", N_("file error"), &irc_protocol_cmd_error },
- { "431", N_("no nickname given"), &irc_protocol_cmd_error },
- { "432", N_("erroneous nickname"), &irc_protocol_cmd_432 },
- { "433", N_("nickname already in use"), &irc_protocol_cmd_433 },
- { "436", N_("nickname collision"), &irc_protocol_cmd_error },
- { "437", N_("resource unavailable"), &irc_protocol_cmd_error },
- { "438", N_("not authorized to change nickname"), &irc_protocol_cmd_438 },
- { "441", N_("user not in channel"), &irc_protocol_cmd_error },
- { "442", N_("not on channel"), &irc_protocol_cmd_error },
- { "443", N_("user already on channel"), &irc_protocol_cmd_error },
- { "444", N_("user not logged in"), &irc_protocol_cmd_error },
- { "445", N_("summon has been disabled"), &irc_protocol_cmd_error },
- { "446", N_("users has been disabled"), &irc_protocol_cmd_error },
- { "451", N_("you are not registered"), &irc_protocol_cmd_error },
- { "461", N_("not enough parameters"), &irc_protocol_cmd_error },
- { "462", N_("you may not register"), &irc_protocol_cmd_error },
- { "463", N_("your host isn't among the privileged"), &irc_protocol_cmd_error },
- { "464", N_("password incorrect"), &irc_protocol_cmd_error },
- { "465", N_("you are banned from this server"), &irc_protocol_cmd_error },
- { "467", N_("channel key already set"), &irc_protocol_cmd_error },
- { "470", N_("forwarding to another channel"), &irc_protocol_cmd_error },
- { "471", N_("channel is already full"), &irc_protocol_cmd_error },
- { "472", N_("unknown mode char to me"), &irc_protocol_cmd_error },
- { "473", N_("cannot join channel (invite only)"), &irc_protocol_cmd_error },
- { "474", N_("cannot join channel (banned from channel)"), &irc_protocol_cmd_error },
- { "475", N_("cannot join channel (bad channel key)"), &irc_protocol_cmd_error },
- { "476", N_("bad channel mask"), &irc_protocol_cmd_error },
- { "477", N_("channel doesn't support modes"), &irc_protocol_cmd_error },
- { "481", N_("you're not an IRC operator"), &irc_protocol_cmd_error },
- { "482", N_("you're not channel operator"), &irc_protocol_cmd_error },
- { "483", N_("you can't kill a server!"), &irc_protocol_cmd_error },
- { "484", N_("your connection is restricted!"), &irc_protocol_cmd_error },
- { "485", N_("user is immune from kick/deop"), &irc_protocol_cmd_error },
- { "487", N_("network split"), &irc_protocol_cmd_error },
- { "491", N_("no O-lines for your host"), &irc_protocol_cmd_error },
- { "501", N_("unknown mode flag"), &irc_protocol_cmd_error },
- { "502", N_("can't change mode for other users"), &irc_protocol_cmd_error },
- { "671", N_("whois (secure connection)"), &irc_protocol_cmd_whois_nick_msg },
- { "973", N_("whois (secure connection)"), &irc_protocol_cmd_server_mode_reason },
- { "974", N_("whois (secure connection)"), &irc_protocol_cmd_server_mode_reason },
- { "975", N_("whois (secure connection)"), &irc_protocol_cmd_server_mode_reason },
- { NULL, NULL, NULL }
+ "for themselves"), 1, &irc_protocol_cmd_wallops },
+ { "001", N_("a server message"), 1, &irc_protocol_cmd_001 },
+ { "005", N_("a server message"), 1, &irc_protocol_cmd_005 },
+ { "221", N_("user mode string"), 1, &irc_protocol_cmd_221 },
+ { "301", N_("away message"), 1, &irc_protocol_cmd_301 },
+ { "303", N_("ison"), 1, &irc_protocol_cmd_303 },
+ { "305", N_("unaway"), 1, &irc_protocol_cmd_305 },
+ { "306", N_("now away"), 1, &irc_protocol_cmd_306 },
+ { "307", N_("whois (registered nick)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "310", N_("whois (help mode)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "311", N_("whois (user)"), 1, &irc_protocol_cmd_311 },
+ { "312", N_("whois (server)"), 1, &irc_protocol_cmd_312 },
+ { "313", N_("whois (operator)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "314", N_("whowas"), 1, &irc_protocol_cmd_314 },
+ { "315", N_("end of /who list"), 1, &irc_protocol_cmd_315 },
+ { "317", N_("whois (idle)"), 1, &irc_protocol_cmd_317 },
+ { "318", N_("whois (end)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "319", N_("whois (channels)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "320", N_("whois (identified user)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "321", N_("/list start"), 1, &irc_protocol_cmd_321 },
+ { "322", N_("channel (for /list)"), 1, &irc_protocol_cmd_322 },
+ { "323", N_("end of /list"), 1, &irc_protocol_cmd_323 },
+ { "324", N_("channel mode"), 1, &irc_protocol_cmd_324 },
+ { "326", N_("whois (has oper privs)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "327", N_("whois (host)"), 1, &irc_protocol_cmd_327 },
+ { "329", N_("channel creation date"), 1, &irc_protocol_cmd_329 },
+ { "331", N_("no topic for channel"), 1, &irc_protocol_cmd_331 },
+ { "332", N_("topic of channel"), 1, &irc_protocol_cmd_332 },
+ { "333", N_("infos about topic (nick and date changed)"), 1, &irc_protocol_cmd_333 },
+ { "338", N_("whois (host)"), 1, &irc_protocol_cmd_338 },
+ { "341", N_("inviting"), 1, &irc_protocol_cmd_341 },
+ { "344", N_("channel reop"), 1, &irc_protocol_cmd_344 },
+ { "345", N_("end of channel reop list"), 1, &irc_protocol_cmd_345 },
+ { "348", N_("channel exception list"), 1, &irc_protocol_cmd_348 },
+ { "349", N_("end of channel exception list"), 1, &irc_protocol_cmd_349 },
+ { "351", N_("server version"), 1, &irc_protocol_cmd_351 },
+ { "352", N_("who"), 1, &irc_protocol_cmd_352 },
+ { "353", N_("list of nicks on channel"), 1, &irc_protocol_cmd_353 },
+ { "366", N_("end of /names list"), 1, &irc_protocol_cmd_366 },
+ { "367", N_("banlist"), 1, &irc_protocol_cmd_367 },
+ { "368", N_("end of banlist"), 1, &irc_protocol_cmd_368 },
+ { "378", N_("whois (connecting from)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "379", N_("whois (using modes)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "401", N_("no such nick/channel"), 1, &irc_protocol_cmd_error },
+ { "402", N_("no such server"), 1, &irc_protocol_cmd_error },
+ { "403", N_("no such channel"), 1, &irc_protocol_cmd_error },
+ { "404", N_("cannot send to channel"), 1, &irc_protocol_cmd_error },
+ { "405", N_("too many channels"), 1, &irc_protocol_cmd_error },
+ { "406", N_("was no such nick"), 1, &irc_protocol_cmd_error },
+ { "407", N_("was no such nick"), 1, &irc_protocol_cmd_error },
+ { "409", N_("no origin"), 1, &irc_protocol_cmd_error },
+ { "410", N_("no services"), 1, &irc_protocol_cmd_error },
+ { "411", N_("no recipient"), 1, &irc_protocol_cmd_error },
+ { "412", N_("no text to send"), 1, &irc_protocol_cmd_error },
+ { "413", N_("no toplevel"), 1, &irc_protocol_cmd_error },
+ { "414", N_("wilcard in toplevel domain"), 1, &irc_protocol_cmd_error },
+ { "421", N_("unknown command"), 1, &irc_protocol_cmd_error },
+ { "422", N_("MOTD is missing"), 1, &irc_protocol_cmd_error },
+ { "423", N_("no administrative info"), 1, &irc_protocol_cmd_error },
+ { "424", N_("file error"), 1, &irc_protocol_cmd_error },
+ { "431", N_("no nickname given"), 1, &irc_protocol_cmd_error },
+ { "432", N_("erroneous nickname"), 1, &irc_protocol_cmd_432 },
+ { "433", N_("nickname already in use"), 1, &irc_protocol_cmd_433 },
+ { "436", N_("nickname collision"), 1, &irc_protocol_cmd_error },
+ { "437", N_("resource unavailable"), 1, &irc_protocol_cmd_error },
+ { "438", N_("not authorized to change nickname"), 1, &irc_protocol_cmd_438 },
+ { "441", N_("user not in channel"), 1, &irc_protocol_cmd_error },
+ { "442", N_("not on channel"), 1, &irc_protocol_cmd_error },
+ { "443", N_("user already on channel"), 1, &irc_protocol_cmd_error },
+ { "444", N_("user not logged in"), 1, &irc_protocol_cmd_error },
+ { "445", N_("summon has been disabled"), 1, &irc_protocol_cmd_error },
+ { "446", N_("users has been disabled"), 1, &irc_protocol_cmd_error },
+ { "451", N_("you are not registered"), 1, &irc_protocol_cmd_error },
+ { "461", N_("not enough parameters"), 1, &irc_protocol_cmd_error },
+ { "462", N_("you may not register"), 1, &irc_protocol_cmd_error },
+ { "463", N_("your host isn't among the privileged"), 1, &irc_protocol_cmd_error },
+ { "464", N_("password incorrect"), 1, &irc_protocol_cmd_error },
+ { "465", N_("you are banned from this server"), 1, &irc_protocol_cmd_error },
+ { "467", N_("channel key already set"), 1, &irc_protocol_cmd_error },
+ { "470", N_("forwarding to another channel"), 1, &irc_protocol_cmd_error },
+ { "471", N_("channel is already full"), 1, &irc_protocol_cmd_error },
+ { "472", N_("unknown mode char to me"), 1, &irc_protocol_cmd_error },
+ { "473", N_("cannot join channel (invite only)"), 1, &irc_protocol_cmd_error },
+ { "474", N_("cannot join channel (banned from channel)"), 1, &irc_protocol_cmd_error },
+ { "475", N_("cannot join channel (bad channel key)"), 1, &irc_protocol_cmd_error },
+ { "476", N_("bad channel mask"), 1, &irc_protocol_cmd_error },
+ { "477", N_("channel doesn't support modes"), 1, &irc_protocol_cmd_error },
+ { "481", N_("you're not an IRC operator"), 1, &irc_protocol_cmd_error },
+ { "482", N_("you're not channel operator"), 1, &irc_protocol_cmd_error },
+ { "483", N_("you can't kill a server!"), 1, &irc_protocol_cmd_error },
+ { "484", N_("your connection is restricted!"), 1, &irc_protocol_cmd_error },
+ { "485", N_("user is immune from kick/deop"), 1, &irc_protocol_cmd_error },
+ { "487", N_("network split"), 1, &irc_protocol_cmd_error },
+ { "491", N_("no O-lines for your host"), 1, &irc_protocol_cmd_error },
+ { "501", N_("unknown mode flag"), 1, &irc_protocol_cmd_error },
+ { "502", N_("can't change mode for other users"), 1, &irc_protocol_cmd_error },
+ { "671", N_("whois (secure connection)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "973", N_("whois (secure connection)"), 1, &irc_protocol_cmd_server_mode_reason },
+ { "974", N_("whois (secure connection)"), 1, &irc_protocol_cmd_server_mode_reason },
+ { "975", N_("whois (secure connection)"), 1, &irc_protocol_cmd_server_mode_reason },
+ { NULL, NULL, 0, NULL }
};
if (!command)
@@ -4578,6 +4583,7 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
if (irc_protocol_is_numeric_command (command))
{
cmd_name = command;
+ decode_color = 1;
cmd_recv_func = irc_protocol_cmd_numeric;
}
else
@@ -4594,21 +4600,29 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
else
{
cmd_name = irc_protocol_messages[cmd_found].name;
+ decode_color = irc_protocol_messages[cmd_found].decode_color;
cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;
}
if (cmd_recv_func != NULL)
{
- argv = weechat_string_explode (entire_line, " ", 0, 0, &argc);
- argv_eol = weechat_string_explode (entire_line, " ", 1, 0, NULL);
- dup_entire_line = (entire_line) ? strdup (entire_line) : NULL;
+ if (entire_line)
+ {
+ if (decode_color)
+ dup_entire_line = irc_color_decode (entire_line,
+ weechat_config_boolean (irc_config_network_colors_receive));
+ else
+ dup_entire_line = strdup (entire_line);
+ }
+ else
+ dup_entire_line = NULL;
+ argv = weechat_string_explode (dup_entire_line, " ", 0, 0, &argc);
+ argv_eol = weechat_string_explode (dup_entire_line, " ", 1, 0, NULL);
dup_host = (host) ? strdup (host) : NULL;
dup_arguments = (arguments) ? strdup (arguments) : NULL;
highlight = 0;
-
-
//return_code = plugin_msg_handler_exec (server->name,
// cmd_name,
// dup_entire_line);
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 07cd438d3..93b1ae35b 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -52,6 +52,7 @@ struct t_irc_protocol_msg
{
char *name; /* IRC message name */
char *description; /* message description */
+ int decode_color; /* decode color before calling function */
t_irc_recv_func *recv_function; /* function called when msg is received */
};
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index eb12f0abe..fe6834771 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1632,8 +1632,7 @@ irc_server_msgq_flush ()
/* parse and execute command */
irc_protocol_recv_command (irc_recv_msgq->server,
- (msg_decoded) ?
- msg_decoded : ptr_msg,
+ (msg_decoded) ? msg_decoded : ptr_msg,
host,
command,
arguments);
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index facda3a10..0dc2d96e1 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -236,51 +236,88 @@ plugin_api_color (char *color_name)
if (num_color >= 0)
return GUI_COLOR(num_color);
- /* custom color name (GUI dependent) */
- pos_comma = strchr (color_name, ',');
- if (pos_comma)
+ /* attribute or other color name (GUI dependent) */
+ index_color = (index_color + 1) % 20;
+ color[index_color][0] = '\0';
+
+ if (string_strcasecmp (color_name, "reset") == 0)
{
- if (pos_comma == color_name)
- str_fg = NULL;
- else
- str_fg = string_strndup (color_name, pos_comma - color_name);
- pos_bg = pos_comma + 1;
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s",
+ GUI_COLOR_RESET_STR);
}
- else
+ else if (string_strcasecmp (color_name, "bold") == 0)
{
- str_fg = strdup (color_name);
- pos_bg = NULL;
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_BOLD_STR);
}
-
- index_color = (index_color + 1) % 20;
-
- color[index_color][0] = '\0';
-
- if (str_fg && pos_bg)
+ else if (string_strcasecmp (color_name, "reverse") == 0)
{
- fg = gui_color_search (str_fg);
- bg = gui_color_search (pos_bg);
snprintf (color[index_color], sizeof (color[index_color]),
- "%s*%02d,%02d",
- GUI_COLOR_COLOR_STR, fg, bg);
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_REVERSE_STR);
}
- else if (str_fg && !pos_bg)
+ else if (string_strcasecmp (color_name, "italic") == 0)
{
- fg = gui_color_search (str_fg);
snprintf (color[index_color], sizeof (color[index_color]),
- "%sF%02d",
- GUI_COLOR_COLOR_STR, fg);
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_ITALIC_STR);
}
- else if (!str_fg && pos_bg)
+ else if (string_strcasecmp (color_name, "underline") == 0)
{
- bg = gui_color_search (pos_bg);
snprintf (color[index_color], sizeof (color[index_color]),
- "%sB%02d",
- GUI_COLOR_COLOR_STR, bg);
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_UNDERLINE_STR);
+ }
+ else
+ {
+ /* custom color name (GUI dependent) */
+ pos_comma = strchr (color_name, ',');
+ if (pos_comma)
+ {
+ if (pos_comma == color_name)
+ str_fg = NULL;
+ else
+ str_fg = string_strndup (color_name, pos_comma - color_name);
+ pos_bg = pos_comma + 1;
+ }
+ else
+ {
+ str_fg = strdup (color_name);
+ pos_bg = NULL;
+ }
+
+ if (str_fg && pos_bg)
+ {
+ fg = gui_color_search (str_fg);
+ bg = gui_color_search (pos_bg);
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s*%02d,%02d",
+ GUI_COLOR_COLOR_STR, fg, bg);
+ }
+ else if (str_fg && !pos_bg)
+ {
+ fg = gui_color_search (str_fg);
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%sF%02d",
+ GUI_COLOR_COLOR_STR, fg);
+ }
+ else if (!str_fg && pos_bg)
+ {
+ bg = gui_color_search (pos_bg);
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%sB%02d",
+ GUI_COLOR_COLOR_STR, bg);
+ }
+
+ if (str_fg)
+ free (str_fg);
}
-
- if (str_fg)
- free (str_fg);
return color[index_color];
}