mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 13:56:37 +02:00
irc: add infolist "irc_color_weechat"
This commit is contained in:
@@ -805,6 +805,40 @@ irc_color_for_tags (const char *color)
|
||||
return weechat_string_replace (color, ",", ":");
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds mapping between IRC color codes and WeeChat color names in an infolist.
|
||||
*
|
||||
* Returns:
|
||||
* 1: OK
|
||||
* 0: error
|
||||
*/
|
||||
|
||||
int
|
||||
irc_color_weechat_add_to_infolist (struct t_infolist *infolist)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
char str_color_irc[32];
|
||||
int i;
|
||||
|
||||
if (!infolist)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < IRC_NUM_COLORS; i++)
|
||||
{
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
snprintf (str_color_irc, sizeof (str_color_irc), "%02d", i);
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "color_irc", str_color_irc))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "color_weechat", irc_color_to_weechat[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ends IRC colors.
|
||||
*/
|
||||
|
||||
@@ -109,6 +109,7 @@ extern char *irc_color_modifier_cb (void *data, const char *modifier,
|
||||
const char *modifier_data,
|
||||
const char *string);
|
||||
extern char *irc_color_for_tags (const char *color);
|
||||
extern int irc_color_weechat_add_to_infolist (struct t_infolist *infolist);
|
||||
extern void irc_color_end ();
|
||||
|
||||
#endif /* WEECHAT_IRC_COLOR_H */
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "../weechat-plugin.h"
|
||||
#include "irc.h"
|
||||
#include "irc-channel.h"
|
||||
#include "irc-color.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-message.h"
|
||||
@@ -563,6 +564,20 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (weechat_strcasecmp (infolist_name, "irc_color_weechat") == 0)
|
||||
{
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
/* build list with all IRC colors */
|
||||
if (!irc_color_weechat_add_to_infolist (ptr_infolist))
|
||||
{
|
||||
weechat_infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -658,6 +673,11 @@ irc_info_init ()
|
||||
N_("notify pointer (optional)"),
|
||||
N_("server name (wildcard \"*\" is allowed) (optional)"),
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_color_weechat",
|
||||
N_("mapping between IRC color codes and WeeChat color names"),
|
||||
NULL,
|
||||
NULL,
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
|
||||
/* hdata hooks */
|
||||
weechat_hook_hdata ("irc_nick", N_("irc nick"),
|
||||
|
||||
Reference in New Issue
Block a user