1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 17:23:15 +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
+1
View File
@@ -21,6 +21,7 @@ New features::
* core: add option `-s` in command `/command` to execute multiple commands separated by semicolons
* core: allow case insensitive search of partial buffer name with `(?i)name` in command `/buffer`
* core: use function util_strftimeval in evaluation of expression `date:xxx`
* api: add modifier "color_decode" to decode WeeChat colors with a replacement string
* api: use whole replacement string instead of first char in function string_remove_color
* api: add functions config_option_get_{string|pointer} and config_{boolean|integer|string|color|enum}_inherited in scripting API
* api: add info "plugin_loaded"
+6
View File
@@ -13286,6 +13286,12 @@ List of modifiers defined by WeeChat and plugins that can be used:
| String with IRC tag value unescaped,
see https://ircv3.net/specs/extensions/message-tags#escaping-values[this page ^↗^^].
| [[hook_modifier_color_decode]] color_decode | 4.3.0
| Replacement string for colors removed
| Any string.
| String with WeeChat colors converted to a replacement string
(colors stripped if the replacement string is empty).
| [[hook_modifier_color_decode_ansi]] color_decode_ansi | 1.0
| "1" to keep colors, "0" to remove colors
| Any string.
+6
View File
@@ -13574,6 +13574,12 @@ utilisés :
| Chaîne avec la valeur de l'étiquette IRC sans échappements,
voir https://ircv3.net/specs/extensions/message-tags#escaping-values[cette page ^↗^^].
| [[hook_modifier_color_decode]] color_decode | 4.3.0
| Chaîne de remplacement pour les couleurs supprimées
| Toute chaîne.
| Chaîne avec les couleurs WeeChat converties vers la chaîne de remplacement
(couleurs supprimées si la chaîne de remplacement est vide).
| [[hook_modifier_color_decode_ansi]] color_decode_ansi | 1.0
| "1" pour garder les couleurs, "0" pour les supprimer
| Toute chaîne.
+7
View File
@@ -13883,6 +13883,13 @@ List of modifiers defined by WeeChat and plugins that can be used:
| String with IRC tag value unescaped,
see https://ircv3.net/specs/extensions/message-tags#escaping-values[this page ^↗^^].
// TRANSLATION MISSING
| [[hook_modifier_color_decode]] color_decode | 4.3.0
| Replacement string for colors removed
| Any string.
| String with WeeChat colors converted to a replacement string
(colors stripped if the replacement string is empty).
// TRANSLATION MISSING
| [[hook_modifier_color_decode_ansi]] color_decode_ansi | 1.0
| "1" per mantenere i colori, "0" per rimuovere i colori
+7
View File
@@ -13471,6 +13471,13 @@ WeeChat とプラグインが定義する修飾子のリスト:
| String with IRC tag value unescaped,
see https://ircv3.net/specs/extensions/message-tags#escaping-values[this page ^↗^^].
// TRANSLATION MISSING
| [[hook_modifier_color_decode]] color_decode | 4.3.0
| Replacement string for colors removed
| Any string.
| String with WeeChat colors converted to a replacement string
(colors stripped if the replacement string is empty).
| [[hook_modifier_color_decode_ansi]] color_decode_ansi | 1.0
| 色を保持する場合は "1"、削除する場合は "0"
| 任意の文字列
+7
View File
@@ -12930,6 +12930,13 @@ char *weechat_hook_modifier_exec (const char *modifier,
| Стринг са неозначеном вредности IRC ознаке,
погледајте https://ircv3.net/specs/extensions/message-tags#escaping-values[ову страницу ^↗^^].
// TRANSLATION MISSING
| [[hook_modifier_color_decode]] color_decode | 4.3.0
| Replacement string for colors removed
| Any string.
| String with WeeChat colors converted to a replacement string
(colors stripped if the replacement string is empty).
| [[hook_modifier_color_decode_ansi]] color_decode_ansi | 1.0
| "1" да се боје задрже, "0" да се боје уклоне
| Било који стринг.
+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",