Added plugin API function to get IRC color number by name
This commit is contained in:
parent
4e434e4fb3
commit
62059cb614
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 *,
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 *,
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user