summaryrefslogtreecommitdiff
path: root/doc/en
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-08-22 08:55:16 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-08-22 08:55:16 +0200
commit268aa631c6b464c0d97dce5dbe76f145a6cc5f68 (patch)
tree00ef2b36db0fc64e2723442f1750934aec030901 /doc/en
parent7dd5abd6252d108858f31a717a127f86d5c206c1 (diff)
downloadweechat-268aa631c6b464c0d97dce5dbe76f145a6cc5f68.zip
api: add function string_color_code_size (issue #1547)
Diffstat (limited to 'doc/en')
-rw-r--r--doc/en/weechat_plugin_api.en.adoc49
-rw-r--r--doc/en/weechat_scripting.en.adoc1
2 files changed, 50 insertions, 0 deletions
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index c7fb69c34..172e9a936 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -1888,6 +1888,55 @@ str = weechat.string_format_size(size)
str = weechat.string_format_size(15200) # == "15.2 KB"
----
+==== string_color_code_size
+
+_WeeChat ≥ 3.0._
+
+Return the size (in bytes) of the WeeChat color code at the beginning of
+the string.
+
+Prototype:
+
+[source,C]
+----
+int weechat_string_color_code_size (const char *string);
+----
+
+Arguments:
+
+* _string_: string
+
+Return value:
+
+* size (in bytes) of the WeeChat color code at the beginning of the string;
+ if the string is NULL, empty or does not start with a color code, 0 is returned;
+ if the string begins with multiple color codes, only the size of the first one
+ is returned
+
+C examples:
+
+[source,C]
+----
+int size;
+
+size = weechat_string_color_code_size ("test"); /* size == 0 */
+size = weechat_string_color_code_size (weechat_color ("bold")); /* size == 2 */
+size = weechat_string_color_code_size (weechat_color ("yellow,red")); /* size == 7 */
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+size = weechat.string_color_code_size(string)
+
+# examples
+size = weechat.string_color_code_size("test") # size == 0
+size = weechat.string_color_code_size(weechat.color("bold")) # size == 2
+size = weechat.string_color_code_size(weechat.color("yellow,red")) # size == 7
+----
+
==== string_remove_color
Remove WeeChat colors from a string.
diff --git a/doc/en/weechat_scripting.en.adoc b/doc/en/weechat_scripting.en.adoc
index 1c57349f2..a14fc1342 100644
--- a/doc/en/weechat_scripting.en.adoc
+++ b/doc/en/weechat_scripting.en.adoc
@@ -546,6 +546,7 @@ List of functions in script API:
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_color_code_size +
string_remove_color +
string_is_command_char +
string_input_for_buffer +