summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-03-13 10:59:58 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-03-13 10:59:58 +0100
commitcd65198c713577e3fee2232a10984fedfc274aa9 (patch)
tree667d54587a06bcf897e71a5b36ef4f176245bd35 /doc
parentc8f574d7305b5a064b084e82d93cd90950ea2306 (diff)
downloadweechat-cd65198c713577e3fee2232a10984fedfc274aa9.zip
api: add callback in function string_replace_regex
Diffstat (limited to 'doc')
-rw-r--r--doc/en/weechat_plugin_api.en.txt16
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt18
-rw-r--r--doc/it/weechat_plugin_api.it.txt16
-rw-r--r--doc/ja/weechat_plugin_api.ja.txt16
4 files changed, 53 insertions, 13 deletions
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 91631663d..a57636d20 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -1268,14 +1268,17 @@ This function is not available in scripting API.
_WeeChat ≥ 0.4.4._
-Replace text in a string using a regular expression and replacement text.
+Replace text in a string using a regular expression, replacement text and
+optional callback.
Prototype:
[source,C]
----
char *weechat_string_replace_regex (const char *string, void *regex,
- const char *replace, const char reference_char);
+ const char *replace, const char reference_char,
+ char *(*callback)(void *data, const char *text),
+ void *callback_data);
----
Arguments:
@@ -1291,6 +1294,13 @@ Arguments:
** `$.*N`: match `N` (can be `+` or `0` to `99`), with all chars replaced by `*`
(the `*` char can be any char between space (32) and `~` (126))
* 'reference_char': the char used for reference to match (commonly '$')
+* 'callback': an optional callback called for each reference in 'replace'
+ (except for matches replaced by a char); the callback must return:
+** newly allocated string: it is used as replacement text (it is freed after
+ use)
+** NULL: the text received in callback is used as replacement text (without
+ changes)
+* 'callback_data': pointer given to callback when it is called
Return value:
@@ -1307,7 +1317,7 @@ if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
REG_EXTENDED) == 0)
{
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
- "$3/$2/$1", '$');
+ "$3/$2/$1", '$', NULL, NULL);
/* string == "date: 14/02/2014" */
if (string)
free (string);
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index 60cca1461..20ecc200a 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -1286,15 +1286,17 @@ Cette fonction n'est pas disponible dans l'API script.
_WeeChat ≥ 0.4.4._
-Remplacer du texte dans une chaîne en utilisant une expression régulière et du
-texte de remplacement.
+Remplacer du texte dans une chaîne en utilisant une expression régulière, du
+texte de remplacement et un "callback" optionnel.
Prototype :
[source,C]
----
char *weechat_string_replace_regex (const char *string, void *regex,
- const char *replace, const char reference_char);
+ const char *replace, const char reference_char,
+ char *(*callback)(void *data, const char *text),
+ void *callback_data);
----
Paramètres :
@@ -1314,6 +1316,14 @@ Paramètres :
caractère entre l'espace (32) et `~` (126))
* 'reference_char' : le caractère utilisé pour les références aux
correspondances (en général '$')
+* 'callback' : un "callback" optionnel appelé pour chaque référence dans
+ 'replace' (sauf pour les correspondances remplacées par un caractère); le
+ "callback" doit retourner :
+** une chaîne nouvellement allouée : elle est utilisée en texte de remplacement
+ (elle est libérée après utilisation)
+** NULL : le texte reçu dans le "callback" est utilisé comme texte de
+ remplacement (sans changement)
+* 'callback_data' : pointeur donné au "callback" lorsqu'il est appelé
Valeur de retour :
@@ -1330,7 +1340,7 @@ if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
REG_EXTENDED) == 0)
{
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
- "$3/$2/$1", '$');
+ "$3/$2/$1", '$', NULL, NULL);
/* string == "date: 14/02/2014" */
if (string)
free (string);
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index 62ae887e6..eaccf8cc0 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -1302,14 +1302,17 @@ Questa funzione non è disponibile nelle API per lo scripting.
_WeeChat ≥ 0.4.4._
// TRANSLATION MISSING
-Replace text in a string using a regular expression and replacement text.
+Replace text in a string using a regular expression, replacement text and
+optional callback.
Prototipo:
[source,C]
----
char *weechat_string_replace_regex (const char *string, void *regex,
- const char *replace, const char reference_char);
+ const char *replace, const char reference_char,
+ char *(*callback)(void *data, const char *text),
+ void *callback_data);
----
Argomenti:
@@ -1326,6 +1329,13 @@ Argomenti:
** `$.*N`: match `N` (can be `+` or `0` to `99`), with all chars replaced by `*`
(the `*` char can be any char between space (32) and `~` (126))
* 'reference_char': the char used for reference to match (commonly '$')
+* 'callback': an optional callback called for each reference in 'replace'
+ (except for matches replaced by a char); the callback must return:
+** newly allocated string: it is used as replacement text (it is freed after
+ use)
+** NULL: the text received in callback is used as replacement text (without
+ changes)
+* 'callback_data': pointer given to callback when it is called
Valore restituito:
@@ -1343,7 +1353,7 @@ if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
REG_EXTENDED) == 0)
{
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
- "$3/$2/$1", '$');
+ "$3/$2/$1", '$', NULL, NULL);
/* string == "date: 14/02/2014" */
if (string)
free (string);
diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt
index 42032beef..136950763 100644
--- a/doc/ja/weechat_plugin_api.ja.txt
+++ b/doc/ja/weechat_plugin_api.ja.txt
@@ -1269,14 +1269,17 @@ free (str);
_WeeChat バージョン 0.4.4 以上で利用可。_
// TRANSLATION MISSING
-Replace text in a string using a regular expression and replacement text.
+Replace text in a string using a regular expression, replacement text and
+optional callback.
プロトタイプ:
[source,C]
----
char *weechat_string_replace_regex (const char *string, void *regex,
- const char *replace, const char reference_char);
+ const char *replace, const char reference_char,
+ char *(*callback)(void *data, const char *text),
+ void *callback_data);
----
引数:
@@ -1293,6 +1296,13 @@ char *weechat_string_replace_regex (const char *string, void *regex,
** `$.*N`: match `N` (can be `+` or `0` to `99`), with all chars replaced by `*`
(the `*` char can be any char between space (32) and `~` (126))
* 'reference_char': the char used for reference to match (commonly '$')
+* 'callback': an optional callback called for each reference in 'replace'
+ (except for matches replaced by a char); the callback must return:
+** newly allocated string: it is used as replacement text (it is freed after
+ use)
+** NULL: the text received in callback is used as replacement text (without
+ changes)
+* 'callback_data': pointer given to callback when it is called
戻り値:
@@ -1310,7 +1320,7 @@ if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
REG_EXTENDED) == 0)
{
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
- "$3/$2/$1", '$');
+ "$3/$2/$1", '$', NULL, NULL);
/* string == "date: 14/02/2014" */
if (string)
free (string);