summaryrefslogtreecommitdiff
path: root/doc/sr
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-09-25 10:53:37 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-09-27 15:50:43 +0200
commit4d74a89cfcdce4d9207f51c786a2a1fc278c5a11 (patch)
tree57dad8d63de8a0bf1b5f5e6e13d57982da431601 /doc/sr
parentbe6a29a596b5da3be4c00943cd5bdceabd5159c5 (diff)
downloadweechat-4d74a89cfcdce4d9207f51c786a2a1fc278c5a11.zip
api: add function string_parse_size
Diffstat (limited to 'doc/sr')
-rw-r--r--doc/sr/weechat_plugin_api.sr.adoc46
-rw-r--r--doc/sr/weechat_scripting.sr.adoc1
2 files changed, 47 insertions, 0 deletions
diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc
index d12126d84..36b189a3a 100644
--- a/doc/sr/weechat_plugin_api.sr.adoc
+++ b/doc/sr/weechat_plugin_api.sr.adoc
@@ -1875,6 +1875,52 @@ def string_format_size(size: int) -> str: ...
str = weechat.string_format_size(15200) # == "15.2 KB"
----
+// TRANSLATION MISSING
+==== string_parse_size
+
+_WeeChat ≥ 3.7._
+
+Parse a string with a size and optional unit and return the size in bytes.
+
+Прототип:
+
+[source,c]
+----
+unsigned long long weechat_string_parse_size (const char *size);
+----
+
+Аргументи:
+
+* _size_: the size as string: float number followed optional spaces and optional
+ unit (lower or upper case), which is one of:
+** _b_: bytes
+** _k_: kilobytes (1k = 1000 bytes)
+** _m_: megabytes (1m = 1000k = 1,000,000 bytes)
+** _g_: gigabytes (1g = 1000m = 1,000,000,000 bytes)
+** _t_: terabytes (1t = 1000g = 1,000,000,000,000 bytes)
+
+Повратна вредност:
+
+* size in bytes, 0 if error
+
+C пример:
+
+[source,c]
+----
+unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */
+----
+
+Script (Python):
+
+[source,python]
+----
+# прототип
+def string_parse_size(size: str) -> int: ...
+
+# пример
+size = weechat.string_parse_size("1.34m") # 1340000
+----
+
==== string_color_code_size
_WeeChat ≥ 3.0._
diff --git a/doc/sr/weechat_scripting.sr.adoc b/doc/sr/weechat_scripting.sr.adoc
index 80264ad31..0f880dba3 100644
--- a/doc/sr/weechat_scripting.sr.adoc
+++ b/doc/sr/weechat_scripting.sr.adoc
@@ -532,6 +532,7 @@ weechat_hook_timer(1000, 0, 1, $timer_cb, 'test');
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +