summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/en/weechat_plugin_api.en.adoc6
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc6
-rw-r--r--doc/it/weechat_plugin_api.it.adoc7
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc7
-rw-r--r--src/plugins/plugin-api.c24
6 files changed, 50 insertions, 1 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 7f96ef05a..0489448b3 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -22,6 +22,7 @@ New features::
* core: add length of string (number of chars and on screen) in evaluation of expressions with "length:xxx" and "lengthscr:xxx"
* core: add calculation of expression in evaluation of expressions with "calc:xxx" (issue #997)
+ * api: add modifier "color_encode_ansi" (issue #528)
* irc: add "user" in output of irc_message_parse (issue #136)
* irc: add options irc.color.message_kick and irc.color.reason_kick (issue #683, issue #684)
* script: add options "-ol" and "-il" in command /script to send translated string with list of scripts loaded, display "No scripts loaded" if no scripts are loaded
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 6d385a461..679638b3e 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -11375,6 +11375,12 @@ List of modifiers defined by WeeChat and plugins that can be used:
"1" to keep colors, "0" to remove colors |
Any string. |
String with ANSI colors converted to WeeChat colors (or ANSI colors removed).
+
+| [[hook_modifier_color_encode_ansi]] color_encode_ansi +
+ _(WeeChat ≥ 2.7)_ |
+ - |
+ Any string. |
+ String with WeeChat colors converted to ANSI colors.
|===
C example:
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 4aec140e3..b92aa678f 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -11619,6 +11619,12 @@ utilisés :
Toute chaîne. |
Chaîne avec les couleurs ANSI converties en couleurs WeeChat (ou avec les
couleurs ANSI supprimées).
+
+| [[hook_modifier_color_encode_ansi]] color_encode_ansi +
+ _(WeeChat ≥ 2.7)_ |
+ - |
+ Toute chaîne. |
+ Chaîne avec les couleurs WeeChat converties en couleurs ANSI.
|===
Exemple en C :
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index 24a351725..450a3b44e 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -11835,6 +11835,13 @@ List of modifiers defined by WeeChat and plugins that can be used:
"1" per mantenere i colori, "0" per rimuovere i colori |
Qualsiasi stringa. |
String with ANSI colors converted to WeeChat colors (or ANSI colors removed).
+
+// TRANSLATION MISSING
+| [[hook_modifier_color_encode_ansi]] color_encode_ansi +
+ _(WeeChat ≥ 2.7)_ |
+ - |
+ Any string. |
+ String with WeeChat colors converted to ANSI colors.
|===
Esempio in C:
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index 358569d01..f46da312d 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -11347,6 +11347,13 @@ WeeChat とプラグインが定義する修飾子のリスト:
色を保持する場合は "1"、削除する場合は "0" |
任意の文字列 |
WeeChat 色コードに変換された ANSI 色コードを含む (または ANSI 色コードを削除された) 文字列
+
+// TRANSLATION MISSING
+| [[hook_modifier_color_encode_ansi]] color_encode_ansi +
+ _(WeeChat バージョン 2.7 以上で利用可)_ |
+ - |
+ 任意の文字列 |
+ String with WeeChat colors converted to ANSI colors.
|===
C 言語での使用例:
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 ();