summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-06-10 18:59:43 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-06-10 18:59:43 +0000
commit62059cb614d69f340655560cffb10f56b17b3a9a (patch)
tree332155ae5e623e936bff7dda4798a579f89f9c53 /src/plugins
parent4e434e4fb375ef3bce29b8ab51b3264ece399654 (diff)
downloadweechat-62059cb614d69f340655560cffb10f56b17b3a9a.zip
Added plugin API function to get IRC color number by name
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugins-interface.c22
-rw-r--r--src/plugins/plugins.c19
-rw-r--r--src/plugins/plugins.h10
-rw-r--r--src/plugins/weechat-plugin.h3
4 files changed, 54 insertions, 0 deletions
diff --git a/src/plugins/plugins-interface.c b/src/plugins/plugins-interface.c
index e80a1d870..15bd6d2fd 100644
--- a/src/plugins/plugins-interface.c
+++ b/src/plugins/plugins-interface.c
@@ -1090,3 +1090,25 @@ weechat_plugin_input_color (t_weechat_plugin *plugin, int color, int start, int
}
}
}
+
+/*
+ * weechat_plugin_get_irc_color: get number of IRC color name
+ */
+
+int
+weechat_plugin_get_irc_color (t_weechat_plugin *plugin, char *color_name)
+{
+ int i;
+
+ if (!plugin)
+ return -1;
+
+ for (i = 0; i < GUI_NUM_IRC_COLORS; i++)
+ {
+ if (strcasecmp (plugins_irc_colors[i].name, color_name) == 0)
+ return i;
+ }
+
+ /* color not found */
+ return -1;
+}
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index 9242cffb3..e73a82e86 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -46,6 +46,24 @@
t_weechat_plugin *weechat_plugins = NULL;
t_weechat_plugin *last_weechat_plugin = NULL;
+t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS] =
+{ { /* 0 */ WEECHAT_IRC_COLOR_WHITE, "white" },
+ { /* 1 */ WEECHAT_IRC_COLOR_BLACK, "black" },
+ { /* 2 */ WEECHAT_IRC_COLOR_BLUE, "blue" },
+ { /* 3 */ WEECHAT_IRC_COLOR_GREEN, "green" },
+ { /* 4 */ WEECHAT_IRC_COLOR_LIGHTRED, "lightred" },
+ { /* 5 */ WEECHAT_IRC_COLOR_RED, "red" },
+ { /* 6 */ WEECHAT_IRC_COLOR_MAGENTA, "magenta" },
+ { /* 7 */ WEECHAT_IRC_COLOR_BROWN, "brown" },
+ { /* 8 */ WEECHAT_IRC_COLOR_YELLOW, "yellow" },
+ { /* 9 */ WEECHAT_IRC_COLOR_LIGHTGREEN, "lightgreen" },
+ { /* 10 */ WEECHAT_IRC_COLOR_CYAN, "cyan" },
+ { /* 11 */ WEECHAT_IRC_COLOR_LIGHTCYAN, "lightcyan" },
+ { /* 12 */ WEECHAT_IRC_COLOR_LIGHTBLUE, "lightblue" },
+ { /* 13 */ WEECHAT_IRC_COLOR_LIGHTMAGENTA, "lightmagenta" },
+ { /* 14 */ WEECHAT_IRC_COLOR_GRAY, "gray" },
+ { /* 15 */ WEECHAT_IRC_COLOR_LIGHTGRAY, "lightgray" }};
+
/*
* plugin_find_server_channel: find server/channel for command execution
@@ -861,6 +879,7 @@ plugin_load (char *filename)
new_plugin->get_nick_info = &weechat_plugin_get_nick_info;
new_plugin->free_nick_info = &weechat_plugin_free_nick_info;
new_plugin->input_color = &weechat_plugin_input_color;
+ new_plugin->get_irc_color = &weechat_plugin_get_irc_color;
/* handlers */
new_plugin->handlers = NULL;
diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h
index 48eb16944..1ea028129 100644
--- a/src/plugins/plugins.h
+++ b/src/plugins/plugins.h
@@ -26,12 +26,22 @@
#include "../irc/irc.h"
#include "../gui/gui.h"
+typedef struct t_plugin_irc_color t_plugin_irc_color;
+
+struct t_plugin_irc_color
+{
+ int number;
+ char *name;
+};
+
typedef int (t_weechat_init_func) (t_weechat_plugin *);
typedef void (t_weechat_end_func) (t_weechat_plugin *);
extern t_weechat_plugin *weechat_plugins;
extern t_weechat_plugin *last_weechat_plugin;
+extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
+
extern int plugin_find_server_channel (char *, char *,
t_irc_server **, t_irc_channel **);
extern void plugin_exec_on_files (t_weechat_plugin *, char *,
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index b308636bd..241356207 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -262,6 +262,8 @@ struct t_weechat_plugin
void (*log) (t_weechat_plugin *, char *, char *, char *, ...);
void (*input_color) (t_weechat_plugin *, int, int, int);
+
+ int (*get_irc_color) (t_weechat_plugin *, char *);
/* WeeChat developers: ALWAYS add new functions at the end */
};
@@ -318,5 +320,6 @@ extern void weechat_plugin_free_channel_info (t_weechat_plugin *, t_plugin_chann
extern t_plugin_nick_info *weechat_plugin_get_nick_info (t_weechat_plugin *, char *, char *);
extern void weechat_plugin_free_nick_info (t_weechat_plugin *, t_plugin_nick_info *);
extern void weechat_plugin_input_color (t_weechat_plugin *, int, int, int);
+extern int weechat_plugin_get_irc_color (t_weechat_plugin *, char *);
#endif /* weechat-plugin.h */