summaryrefslogtreecommitdiff
path: root/doc/en/weechat_plugin_api.en.txt
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-02-21 15:36:14 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-02-21 15:36:14 +0100
commitf907ea17d51d0446987970ab42b225054c99b12c (patch)
tree682e13d516f36522639433b49d481939c1b33c4f /doc/en/weechat_plugin_api.en.txt
parent30191871781575436492eb8ce29c2db660450997 (diff)
parentd6e7c9fda6e6ae4528044c223ab37885adbde90a (diff)
downloadweechat-f907ea17d51d0446987970ab42b225054c99b12c.zip
Merge branch 'trigger'
Diffstat (limited to 'doc/en/weechat_plugin_api.en.txt')
-rw-r--r--doc/en/weechat_plugin_api.en.txt252
1 files changed, 216 insertions, 36 deletions
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 02aa46692..c8a06524c 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -854,41 +854,6 @@ match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
----
-==== weechat_string_replace
-
-Replace all occurrences of a string by another string.
-
-Prototype:
-
-[source,C]
-----
-char *weechat_string_replace (const char *string, const char *search,
- const char *replace);
-----
-
-Arguments:
-
-* 'string': string
-* 'search': string to replace
-* 'replace': replacement for string 'search'
-
-Return value:
-
-* string with 'search' replaced by 'replace' (must be freed by calling "free"
- after use)
-
-C example:
-
-[source,C]
-----
-char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
-/* ... */
-free (str);
-----
-
-[NOTE]
-This function is not available in scripting API.
-
==== weechat_string_expand_home
_WeeChat ≥ 0.3.3._
@@ -995,6 +960,56 @@ free (str);
[NOTE]
This function is not available in scripting API.
+==== weechat_string_convert_escaped_chars
+
+_WeeChat ≥ 0.4.4._
+
+Convert escaped chars to their value:
+
+* `\"`: double quote
+* `\\`: backslash
+* `\a`: alert (BEL)
+* `\b`: backspace
+* `\e`: escape
+* `\f`: form feed
+* `\n`: new line
+* `\r`: carriage return
+* `\t`: horizontal tab
+* `\v`: vertical tab
+* `\0ooo`: char as octal value (ooo is 0 to 3 digits)
+* `\xhh`: char as hexadecimal value (hh is 1 to 2 digits)
+* `\uhhhh`: unicode char as hexadecimal value (hhhh is 1 to 4 digits)
+* `\Uhhhhhhhh`: unicode char as hexadecimal value (hhhhhhhh is 1 to 8 digits)
+
+Prototype:
+
+[source,C]
+----
+char *weechat_string_convert_escaped_chars (const char *string);
+----
+
+Arguments:
+
+* 'string': string
+
+Return value:
+
+* string with escaped chars replaced by their value (must be freed by calling
+ "free" after use)
+
+C example:
+
+[source,C]
+----
+char *str = weechat_string_convert_escaped_chars ("snowman: \\u2603");
+/* str == "snowman: ☃" */
+/* ... */
+free (str);
+----
+
+[NOTE]
+This function is not available in scripting API.
+
==== weechat_string_mask_to_regex
Return a regex, built with a mask, where only special char is "`*`". All other
@@ -1214,6 +1229,95 @@ highlight = weechat.string_has_highlight_regex(string, regex)
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
----
+==== weechat_string_replace
+
+Replace all occurrences of a string by another string.
+
+Prototype:
+
+[source,C]
+----
+char *weechat_string_replace (const char *string, const char *search,
+ const char *replace);
+----
+
+Arguments:
+
+* 'string': string
+* 'search': string to replace
+* 'replace': replacement for string 'search'
+
+Return value:
+
+* string with 'search' replaced by 'replace' (must be freed by calling "free"
+ after use)
+
+C example:
+
+[source,C]
+----
+char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
+/* ... */
+free (str);
+----
+
+[NOTE]
+This function is not available in scripting API.
+
+==== weechat_string_replace_regex
+
+_WeeChat ≥ 0.4.4._
+
+Replace text in a string using a regular expression and replacement text.
+
+Prototype:
+
+[source,C]
+----
+char *weechat_string_replace_regex (const char *string, void *regex,
+ const char *replace, const char reference_char);
+----
+
+Arguments:
+
+* 'string': string
+* 'regex': pointer to a regular expression ('regex_t' structure) compiled with
+ WeeChat function <<_weechat_string_regcomp,weechat_string_regcomp>> or regcomp
+ (see `man regcomp`)
+* 'replace': replacement text, where following references are allowed:
+** `$0` to `$99`: match 0 to 99 in regular expression (0 is the whole match,
+ 1 to 99 are groups captured between parentheses)
+** `$+`: the last match (with highest number)
+** `$.*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 '$')
+
+Return value:
+
+* string with text replaced, NULL if problem (must be freed by calling "free"
+ after use)
+
+C example:
+
+[source,C]
+----
+regex_t my_regex;
+char *string;
+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", '$');
+ /* string == "date: 14/02/2014" */
+ if (string)
+ free (string);
+ regfree (&my_regex);
+}
+----
+
+[NOTE]
+This function is not available in scripting API.
+
==== weechat_string_split
Split a string according to one or more delimiter(s).
@@ -1244,7 +1348,7 @@ Return value:
* array of strings, NULL if problem (must be freed by calling
<<_weechat_string_free_split,weechat_string_free_split>> after use)
-C examples:
+C example:
[source,C]
----
@@ -1272,6 +1376,51 @@ weechat_string_free_split (argv);
[NOTE]
This function is not available in scripting API.
+==== weechat_string_split_shell
+
+_WeeChat ≥ 0.4.4._
+
+Split a string like the shell does for a command with arguments.
+
+This function is a C conversion of Python class "shlex" (file: Lib/shlex.py in
+Python repository), see: http://docs.python.org/3/library/shlex.html.
+
+Prototype:
+
+[source,C]
+----
+char **weechat_string_split_shell (const char *string, int *num_items);
+----
+
+Arguments:
+
+* 'string': string to split
+* 'num_items': pointer to int which will contain number of items created
+
+Return value:
+
+* array of strings, NULL if problem (must be freed by calling
+ <<_weechat_string_free_split,weechat_string_free_split>> after use)
+
+C example:
+
+[source,C]
+----
+char **argv;
+int argc;
+argv = weechat_string_split_shell ("test 'first arg' \"second arg\"", &argc);
+/* result: argv[0] == "test"
+ argv[1] == "first arg"
+ argv[2] == "second arg"
+ argv[3] == NULL
+ argc == 3
+*/
+weechat_string_free_split (argv);
+----
+
+[NOTE]
+This function is not available in scripting API.
+
==== weechat_string_free_split
Free memory used by a split string.
@@ -3480,6 +3629,37 @@ weechat_hashtable_map_string (hashtable, &map_cb, NULL);
[NOTE]
This function is not available in scripting API.
+==== weechat_hashtable_dup
+
+_WeeChat ≥ 0.4.4._
+
+Duplicate a hashtable.
+
+Prototype:
+
+[source,C]
+----
+struct t_hashtable *hashtable_dup (struct t_hashtable *hashtable);
+----
+
+Arguments:
+
+* 'hashtable': hashtable pointer
+
+Return value:
+
+* duplicated hashtable
+
+C example:
+
+[source,C]
+----
+struct t_hashtable *new_hashtable = weechat_hashtable_dup (hashtable);
+----
+
+[NOTE]
+This function is not available in scripting API.
+
==== weechat_hashtable_get_integer
_WeeChat ≥ 0.3.3._