summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugin-api.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index f7405d647..9001716ab 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -352,7 +352,8 @@ plugin_api_command (struct t_weechat_plugin *plugin,
}
/*
- * Modifier to decode ANSI colors.
+ * Modifier to decode ANSI colors: convert ANSI color codes to WeeChat colors
+ * (or removes them)
*/
char *
@@ -373,6 +374,25 @@ plugin_api_modifier_color_decode_ansi_cb (const void *pointer, void *data,
}
/*
+ * Modifier to encode ANSI colors: convert WeeChat colors to ANSI color codes
+ */
+
+char *
+plugin_api_modifier_color_encode_ansi_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;
+ (void) modifier_data;
+
+ return gui_color_encode_ansi (string);
+}
+
+/*
* Moves item pointer to next item in an infolist.
*
* Returns:
@@ -521,6 +541,8 @@ plugin_api_init ()
/* WeeChat core modifiers */
hook_modifier (NULL, "color_decode_ansi",
&plugin_api_modifier_color_decode_ansi_cb, NULL, NULL);
+ hook_modifier (NULL, "color_encode_ansi",
+ &plugin_api_modifier_color_encode_ansi_cb, NULL, NULL);
/* WeeChat core info/infolist hooks */
plugin_api_info_init ();