1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

api: add modifier "color_decode" to decode WeeChat colors with a replacement string

This commit is contained in:
Sébastien Helleu
2024-03-10 09:31:32 +01:00
parent 3f49b1b44a
commit 1ab62e37cb
7 changed files with 55 additions and 0 deletions
+21
View File
@@ -450,6 +450,25 @@ plugin_api_command (struct t_weechat_plugin *plugin,
return plugin_api_command_options (plugin, buffer, command, NULL);
}
/*
* Modifier callback: decodes WeeChat colors: converts WeeChat color codes to
* WeeChat a replacement string.
*/
char *
plugin_api_modifier_color_decode_cb (const void *pointer, void *data,
const char *modifier,
const char *modifier_data,
const char *string)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) modifier;
return gui_color_decode (string, modifier_data);
}
/*
* Modifier callback: decodes ANSI colors: converts ANSI color codes to WeeChat
* colors (or removes them).
@@ -681,6 +700,8 @@ void
plugin_api_init ()
{
/* WeeChat core modifiers */
hook_modifier (NULL, "color_decode",
&plugin_api_modifier_color_decode_cb, NULL, NULL);
hook_modifier (NULL, "color_decode_ansi",
&plugin_api_modifier_color_decode_ansi_cb, NULL, NULL);
hook_modifier (NULL, "color_encode_ansi",