doc: fix style of C/Python examples in docs

v2.8-utf8proc
Sébastien Helleu 2014-07-05 16:45:48 +02:00
parent bdcb9fb5d7
commit 2b7b8cb365
10 changed files with 621 additions and 621 deletions

View File

@ -594,9 +594,9 @@ Beispiele:
----
buffer = weechat.current_buffer()
nummer = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
kurz_name = weechat.buffer_get_string(buffer, "short_name")
nummer = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
kurz_name = weechat.buffer_get_string(buffer, "short_name")
----
Es ist möglich lokale Variablen eines Buffers hinzuzufügen, zu
@ -745,7 +745,7 @@ def my_process_cb(data, command, rc, out, err):
return weechat.WEECHAT_RC_OK
weechat.hook_process_hashtable("url:http://weechat.org/files/src/weechat-devel.tar.gz",
{ "file_out": "/tmp/weechat-devel.tar.gz" },
{"file_out": "/tmp/weechat-devel.tar.gz"},
30 * 1000, "my_process_cb", "")
----
@ -889,7 +889,7 @@ Man kann IRC Nachrichten mittels einer info_hashtable mit dem Namen "irc_message
[source,python]
----
dict = weechat.info_get_hashtable("irc_message_parse",
{ "message": ":nick!user@host PRIVMSG #weechat :message here" })
{"message": ":nick!user@host PRIVMSG #weechat :message here"})
weechat.prnt("", "dict: %s" % dict)
# output:

View File

@ -484,7 +484,7 @@ C example:
[source,C]
----
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
/* ... */
free (str);
----
@ -512,7 +512,7 @@ C example:
[source,C]
----
char str[] = "AbCdé";
weechat_string_tolower (str); /* str is now: "abcdé" */
weechat_string_tolower (str); /* str is now: "abcdé" */
----
[NOTE]
@ -538,7 +538,7 @@ C example:
[source,C]
----
char str[] = "AbCdé";
weechat_string_toupper (str); /* str is now: "ABCDé" */
weechat_string_toupper (str); /* str is now: "ABCDé" */
----
[NOTE]
@ -572,7 +572,7 @@ C example:
[source,C]
----
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -614,7 +614,7 @@ C example:
[source,C]
----
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
----
[NOTE]
@ -649,7 +649,7 @@ C example:
[source,C]
----
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----
[NOTE]
@ -692,7 +692,7 @@ C example:
[source,C]
----
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
----
[NOTE]
@ -731,7 +731,7 @@ C example:
[source,C]
----
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----
[NOTE]
@ -761,7 +761,7 @@ C example:
[source,C]
----
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */
----
[NOTE]
@ -794,7 +794,7 @@ C example:
[source,C]
----
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
----
Script (Python):
@ -805,7 +805,7 @@ Script (Python):
length = weechat.strlen_screen(string)
# example
length = weechat.strlen_screen("é") # 1
length = weechat.strlen_screen("é") # 1
----
==== weechat_string_match
@ -841,11 +841,11 @@ C example:
[source,C]
----
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
----
Script (Python):
@ -856,11 +856,11 @@ Script (Python):
match = weechat.string_match(string, mask, case_sensitive)
# examples
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
----
==== weechat_string_expand_home
@ -961,7 +961,7 @@ C example:
[source,C]
----
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* result: ".abc" */
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* result: ".abc" */
/* ... */
free (str);
----
@ -1057,7 +1057,7 @@ Script (Python):
regex = weechat.string_mask_to_regex(mask)
# example
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
----
==== weechat_string_regex_flags
@ -1181,7 +1181,7 @@ C example:
[source,C]
----
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
----
Script (Python):
@ -1192,7 +1192,7 @@ Script (Python):
highlight = weechat.string_has_highlight(string, highlight_words)
# example
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
----
==== weechat_string_has_highlight_regex
@ -1224,7 +1224,7 @@ C example:
[source,C]
----
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
----
Script (Python):
@ -1235,7 +1235,7 @@ Script (Python):
highlight = weechat.string_has_highlight_regex(string, regex)
# example
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
----
==== weechat_string_replace
@ -1265,7 +1265,7 @@ C example:
[source,C]
----
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
/* ... */
free (str);
----
@ -1598,19 +1598,19 @@ C examples:
----
/* examples with English locale */
char *str = weechat_string_format_size (0); /* str == "0 byte" */
char *str = weechat_string_format_size (0); /* str == "0 byte" */
/* ... */
free (str);
char *str = weechat_string_format_size (200); /* str == "200 bytes" */
char *str = weechat_string_format_size (200); /* str == "200 bytes" */
/* ... */
free (str);
char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
/* ... */
free (str);
char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
/* ... */
free (str);
----
@ -1760,8 +1760,8 @@ C examples:
[source,C]
----
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
----
Script (Python):
@ -1772,8 +1772,8 @@ Script (Python):
is_cmdchar = weechat.string_is_command_char(string)
# examples
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
----
==== weechat_string_input_for_buffer
@ -1802,9 +1802,9 @@ C examples:
[source,C]
----
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
----
Script (Python):
@ -1815,9 +1815,9 @@ Script (Python):
str = weechat.string_input_for_buffer(string)
# examples
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----
==== weechat_string_eval_expression
@ -1874,9 +1874,9 @@ struct t_hashtable *options = weechat_hashtable_new (8,
NULL);
if (options)
weechat_hashtable_set (options, "type", "condition");
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----
Script (Python):
@ -1887,9 +1887,9 @@ Script (Python):
str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# examples
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----
[[utf-8]]
@ -2077,7 +2077,7 @@ C example:
[source,C]
----
int char_int = weechat_utf8_char_int ("être"); /* "ê" as integer */
int char_int = weechat_utf8_char_int ("être"); /* "ê" as integer */
----
[NOTE]
@ -2106,7 +2106,7 @@ C example:
[source,C]
----
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----
[NOTE]
@ -2135,7 +2135,7 @@ C example:
[source,C]
----
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----
[NOTE]
@ -2165,7 +2165,7 @@ C example:
[source,C]
----
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2194,7 +2194,7 @@ C example:
[source,C]
----
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----
[NOTE]
@ -2228,7 +2228,7 @@ C example:
[source,C]
----
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----
[NOTE]
@ -2262,7 +2262,7 @@ C example:
[source,C]
----
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -2291,7 +2291,7 @@ C example:
[source,C]
----
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----
[NOTE]
@ -2322,7 +2322,7 @@ C example:
[source,C]
----
char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
----
[NOTE]
@ -2352,7 +2352,7 @@ C example:
[source,C]
----
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----
[NOTE]
@ -2382,7 +2382,7 @@ C example:
[source,C]
----
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2412,7 +2412,7 @@ C example:
[source,C]
----
char *string = weechat_utf8_strndup ("chêne", 3); /* returns "chê" */
char *string = weechat_utf8_strndup ("chêne", 3); /* returns "chê" */
/* ... */
free (string);
----
@ -2712,7 +2712,7 @@ C example:
[source,C]
----
weechat_util_timeval_add (&tv, 2000); /* add 2 seconds */
weechat_util_timeval_add (&tv, 2000); /* add 2 seconds */
----
[NOTE]
@ -2768,10 +2768,10 @@ C example:
[source,C]
----
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
----
[NOTE]
@ -3047,7 +3047,7 @@ C example:
[source,C]
----
struct t_weelist_item *item = weechat_list_get (list, 0); /* first item */
struct t_weelist_item *item = weechat_list_get (list, 0); /* first item */
----
Script (Python):
@ -4197,11 +4197,11 @@ my_section_delete_option_cb (void *data, struct t_config_file *config_file,
/* standard section, user can not add/delete options */
struct t_config_section *new_section1 =
weechat_config_new_section (config_file, "section1", 0, 0,
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
/* special section, user can add/delete options, and options need
callback to be read/written */
@ -4385,66 +4385,66 @@ C example:
struct t_config_option *option1 =
weechat_config_new_option (config_file, section, "option1", "boolean",
"My option, type boolean"
NULL, /* string values */
0, 0, /* min, max */
"on", /* default */
"on", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 0, /* min, max */
"on", /* default */
"on", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* integer */
struct t_config_option *option2 =
weechat_config_new_option (config_file, section, "option2", "integer",
"My option, type integer"
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* integer (with string values) */
struct t_config_option *option3 =
weechat_config_new_option (config_file, section, "option3", "integer",
"My option, type integer (with string values)"
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* default */
"bottom", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* default */
"bottom", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* string */
struct t_config_option *option4 =
weechat_config_new_option (config_file, section, "option4", "string",
"My option, type string"
NULL, /* string values */
0, 0, /* min, max */
"test", /* default */
"test", /* value */
1, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 0, /* min, max */
"test", /* default */
"test", /* value */
1, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* color */
struct t_config_option *option5 =
weechat_config_new_option (config_file, section, "option5", "color",
"My option, type color"
NULL, /* string values */
0, 0, /* min, max */
"lightblue", /* default */
"lightblue", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 0, /* min, max */
"lightblue", /* default */
"lightblue", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
----
Script (Python):
@ -6208,9 +6208,9 @@ Script (Python):
num_keys = weechat.key_bind(context, keys)
# example
keys = { "@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down" }
keys = {"@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down"}
weechat.key_bind("mouse", keys)
----
@ -6441,7 +6441,7 @@ weechat_printf (buffer, "Hello on this buffer");
weechat_printf (buffer, "%sThis is an error!", weechat_prefix ("error"));
weechat_printf (buffer, " \tMessage without prefix but with \t some \t tabs");
weechat_printf (buffer, "\t\tMessage without time/alignment");
weechat_printf (buffer, "\t\t"); /* empty line (without time) */
weechat_printf (buffer, "\t\t"); /* empty line (without time) */
----
Script (Python):
@ -6457,7 +6457,7 @@ weechat.prnt(buffer, "Hello on this buffer")
weechat.prnt(buffer, "%sThis is an error!" % weechat.prefix("error"))
weechat.prnt(buffer, " \tMessage without prefix but with \t some \t tabs")
weechat.prnt(buffer, "\t\tMessage without time/alignment")
weechat.prnt(buffer, "\t\t") # empty line (without time)
weechat.prnt(buffer, "\t\t") # empty line (without time)
----
[NOTE]
@ -7317,7 +7317,7 @@ if (options_cmd1)
weechat_hashtable_set (options_cmd1, "arg1", "-from");
weechat_hashtable_set (options_cmd1, "arg2", nick);
weechat_hashtable_set (options_cmd1, "arg3", "-msg");
weechat_hashtable_set (options_cmd1, "arg4", message); /* untrusted argument */
weechat_hashtable_set (options_cmd1, "arg4", message); /* untrusted argument */
struct t_hook *my_process_hook = weechat_hook_process_hashtable ("my-notify-command",
options_cmd1,
20000,
@ -7365,21 +7365,21 @@ def my_process_cb(data, command, return_code, out, err):
# example 1: download URL
hook1 = weechat.hook_process_hashtable("url:http://weechat.org/",
{ "file_out": "/tmp/weechat.org.html" },
{"file_out": "/tmp/weechat.org.html"},
20000, "my_process_cb", "")
# example 2: execute a notify program with a message from someone
hook2 = weechat.hook_process_hashtable("my-notify-command",
{ "arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message }, # untrusted argument
{"arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message}, # untrusted argument
20000, "my_process_cb", "")
# example 3: call shell to execute a command (command must be SAFE)
hook3 = weechat.hook_process_hashtable("sh",
{ "arg1": "-c",
"arg2": "ls -l /tmp | grep something" },
{"arg1": "-c",
"arg2": "ls -l /tmp | grep something"},
20000, "my_process_cb", "")
----
@ -7510,7 +7510,7 @@ my_connect_cb (void *data, int status, int gnutls_rc, int sock,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
NULL, NULL, 0, /* GnuTLS */
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL);
----
@ -8692,7 +8692,7 @@ Script (Python):
rc = weechat.hook_hsignal_send(signal, hashtable)
# example
rc = weechat.hook_hsignal_send("my_hsignal", { "key": "value" })
rc = weechat.hook_hsignal_send("my_hsignal", {"key": "value"})
----
[[hsignal_irc_redirect_command]]
@ -8793,8 +8793,8 @@ def test_whois_cb(data, signal, hashtable):
weechat.hook_hsignal ("irc_redirection_test_whois", "test_whois_cb", "")
weechat.hook_hsignal_send("irc_redirect_command",
{ "server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode" })
{"server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode"})
weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING,
"freenode;;2;;/whois FlashCode")
----
@ -8862,10 +8862,10 @@ Script (Python):
[source,python]
----
weechat.hook_hsignal_send("irc_redirect_pattern",
{ "pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1" })
{"pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1"})
# now redirect irc whois command with hsignal irc_redirect_command
# using pattern "my_whois"
# ...
@ -9492,7 +9492,7 @@ hook = weechat.hook_info_hashtable(info_name, description, args_description,
# example
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_key": "test_value" }
return {"test_key": "test_value"}
hook = weechat.hook_info_hashtable("my_info_hashtable", "Some info",
"Info about input hashtable",
@ -9845,7 +9845,7 @@ def my_process_cb(data, command, return_code, out, err):
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_process_hashtable("/path/to/command", { "stdin": "1" },
hook = weechat.hook_process_hashtable("/path/to/command", {"stdin": "1"},
20000, "my_process_cb", "")
weechat.hook_set(hook, "stdin", "data sent to stdin of child process")
weechat.hook_set(hook, "stdin_close", "") # optional
@ -10073,7 +10073,7 @@ C examples:
[source,C]
----
struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
----
Script (Python):
@ -10811,10 +10811,10 @@ C example:
struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
if (buffer)
{
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
}
----
@ -10828,10 +10828,10 @@ match = weechat.buffer_match_list(buffer, string)
# example
buffer = weechat.buffer_search("irc", "freenode.#weechat")
if buffer:
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
----
[[windows]]
@ -12587,7 +12587,7 @@ Script (Python):
dict = weechat.info_get_hashtable(info_name, dict_in)
# example
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message here" }
dict_in = {"message": ":nick!user@host PRIVMSG #weechat :message here"}
weechat.prnt("", "message parsed: %s"
% weechat.info_get_hashtable("irc_message_parse", dict_in))
----
@ -14679,13 +14679,13 @@ Script (Python):
count = weechat.hdata_update(hdata, pointer, hashtable)
# example: subtract one hour on last message displayed in current buffer
own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), weechat.current_buffer(), 'own_lines')
own_lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), weechat.current_buffer(), "own_lines")
if own_lines:
line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines, 'last_line')
line = weechat.hdata_pointer(weechat.hdata_get("lines"), own_lines, "last_line")
if line:
line_data = weechat.hdata_pointer(weechat.hdata_get('line'), line, 'data')
hdata = weechat.hdata_get('line_data')
weechat.hdata_update(hdata, line_data, { 'date': str(weechat.hdata_time(hdata, line_data, 'date') - 3600) })
line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line, "data")
hdata = weechat.hdata_get("line_data")
weechat.hdata_update(hdata, line_data, {"date": str(weechat.hdata_time(hdata, line_data, "date") - 3600)})
----
==== weechat_hdata_get_string

View File

@ -583,8 +583,8 @@ Examples:
----
buffer = weechat.current_buffer()
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
short_name = weechat.buffer_get_string(buffer, "short_name")
----
@ -730,7 +730,7 @@ def my_process_cb(data, command, rc, out, err):
return weechat.WEECHAT_RC_OK
weechat.hook_process_hashtable("url:http://weechat.org/files/src/weechat-devel.tar.gz",
{ "file_out": "/tmp/weechat-devel.tar.gz" },
{"file_out": "/tmp/weechat-devel.tar.gz"},
30 * 1000, "my_process_cb", "")
----
@ -873,7 +873,7 @@ You can parse an IRC message with info_hashtable called "irc_message_parse".
[source,python]
----
dict = weechat.info_get_hashtable("irc_message_parse",
{ "message": ":nick!user@host PRIVMSG #weechat :message here" })
{"message": ":nick!user@host PRIVMSG #weechat :message here"})
weechat.prnt("", "dict: %s" % dict)
# output:

View File

@ -491,7 +491,7 @@ Exemple en C :
[source,C]
----
char *str = weechat_strndup ("abcdef", 3); /* résultat : "abc" */
char *str = weechat_strndup ("abcdef", 3); /* résultat : "abc" */
/* ... */
free (str);
----
@ -519,7 +519,7 @@ Exemple en C :
[source,C]
----
char str[] = "AbCdé";
weechat_string_tolower (str); /* str vaut maintenant : "abcdé" */
weechat_string_tolower (str); /* str vaut maintenant : "abcdé" */
----
[NOTE]
@ -545,7 +545,7 @@ Exemple en C :
[source,C]
----
char str[] = "AbCdé";
weechat_string_toupper (str); /* str vaut maintenant : "ABCDé" */
weechat_string_toupper (str); /* str vaut maintenant : "ABCDé" */
----
[NOTE]
@ -579,7 +579,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -621,7 +621,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
----
[NOTE]
@ -657,7 +657,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----
[NOTE]
@ -700,7 +700,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
----
[NOTE]
@ -739,7 +739,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----
[NOTE]
@ -769,7 +769,7 @@ Exemple en C :
[source,C]
----
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* résultat : pointeur vers "DeF" */
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* résultat : pointeur vers "DeF" */
----
[NOTE]
@ -803,7 +803,7 @@ Exemple en C :
[source,C]
----
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
----
Script (Python) :
@ -814,7 +814,7 @@ Script (Python) :
length = weechat.strlen_screen(string)
# exemple
length = weechat.strlen_screen("é") # 1
length = weechat.strlen_screen("é") # 1
----
==== weechat_string_match
@ -850,11 +850,11 @@ Exemple en C :
[source,C]
----
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
----
Script (Python) :
@ -865,11 +865,11 @@ Script (Python) :
match = weechat.string_match(string, mask, case_sensitive)
# exemples
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
----
==== weechat_string_expand_home
@ -971,7 +971,7 @@ Exemple en C :
[source,C]
----
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* résultat : ".abc" */
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* résultat : ".abc" */
/* ... */
free (str);
----
@ -1071,7 +1071,7 @@ Script (Python) :
regex = weechat.string_mask_to_regex(mask)
# exemple
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
----
==== weechat_string_regex_flags
@ -1199,7 +1199,7 @@ Exemple en C :
[source,C]
----
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
----
Script (Python) :
@ -1210,7 +1210,7 @@ Script (Python) :
highlight = weechat.string_has_highlight(string, highlight_words)
# exemple
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
----
==== weechat_string_has_highlight_regex
@ -1242,7 +1242,7 @@ Exemple en C :
[source,C]
----
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
----
Script (Python) :
@ -1253,7 +1253,7 @@ Script (Python) :
highlight = weechat.string_has_highlight_regex(string, regex)
# exemple
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
----
==== weechat_string_replace
@ -1283,7 +1283,7 @@ Exemple en C :
[source,C]
----
char *str = weechat_string_replace ("test, test", "s", "x"); /* résultat : "text" */
char *str = weechat_string_replace ("test, test", "s", "x"); /* résultat : "text" */
/* ... */
free (str);
----
@ -1628,19 +1628,19 @@ Exemples en C :
----
/* exemples avec la langue française */
char *str = weechat_string_format_size (0); /* str == "0 octet" */
char *str = weechat_string_format_size (0); /* str == "0 octet" */
/* ... */
free (str);
char *str = weechat_string_format_size (200); /* str == "200 octets" */
char *str = weechat_string_format_size (200); /* str == "200 octets" */
/* ... */
free (str);
char *str = weechat_string_format_size (1536); /* str == "1.5 Ko" */
char *str = weechat_string_format_size (1536); /* str == "1.5 Ko" */
/* ... */
free (str);
char *str = weechat_string_format_size (2097152); /* str == "2 Mo" */
char *str = weechat_string_format_size (2097152); /* str == "2 Mo" */
/* ... */
free (str);
----
@ -1792,8 +1792,8 @@ Exemples en C :
[source,C]
----
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
----
Script (Python) :
@ -1804,8 +1804,8 @@ Script (Python) :
is_cmdchar = weechat.string_is_command_char(string)
# exemples
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
----
==== weechat_string_input_for_buffer
@ -1834,9 +1834,9 @@ Exemples en C :
[source,C]
----
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
----
Script (Python) :
@ -1847,9 +1847,9 @@ Script (Python) :
str = weechat.string_input_for_buffer(string)
# exemples
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----
==== weechat_string_eval_expression
@ -1908,9 +1908,9 @@ struct t_hashtable *options = weechat_hashtable_new (8,
NULL);
if (options)
weechat_hashtable_set (options, "type", "condition");
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----
Script (Python) :
@ -1921,9 +1921,9 @@ Script (Python) :
str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# exemples
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----
[[utf-8]]
@ -2115,7 +2115,7 @@ Exemple en C :
[source,C]
----
int char_int = weechat_utf8_char_int ("être"); /* "ê" comme entier */
int char_int = weechat_utf8_char_int ("être"); /* "ê" comme entier */
----
[NOTE]
@ -2144,7 +2144,7 @@ Exemple en C :
[source,C]
----
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----
[NOTE]
@ -2173,7 +2173,7 @@ Exemple en C :
[source,C]
----
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----
[NOTE]
@ -2204,7 +2204,7 @@ Exemple en C :
[source,C]
----
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2234,7 +2234,7 @@ Exemple en C :
[source,C]
----
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----
[NOTE]
@ -2268,7 +2268,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----
[NOTE]
@ -2302,7 +2302,7 @@ Exemple en C :
[source,C]
----
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -2332,7 +2332,7 @@ Exemple en C :
[source,C]
----
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----
[NOTE]
@ -2364,7 +2364,7 @@ Exemple en C :
[source,C]
----
char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* pointe vers "ne" */
char *str2 = weechat_utf8_add_offset (str, 3); /* pointe vers "ne" */
----
[NOTE]
@ -2394,7 +2394,7 @@ Exemple en C :
[source,C]
----
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----
[NOTE]
@ -2424,7 +2424,7 @@ Exemple en C :
[source,C]
----
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2455,7 +2455,7 @@ Exemple en C :
[source,C]
----
char *string = weechat_utf8_strndup ("chêne", 3); /* retourne "chê" */
char *string = weechat_utf8_strndup ("chêne", 3); /* retourne "chê" */
/* ... */
free (str);
----
@ -2757,7 +2757,7 @@ Exemple en C :
[source,C]
----
weechat_util_timeval_add (&tv, 2000); /* ajoute 2 secondes */
weechat_util_timeval_add (&tv, 2000); /* ajoute 2 secondes */
----
[NOTE]
@ -2814,10 +2814,10 @@ Exemple en C :
[source,C]
----
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
----
[NOTE]
@ -3094,7 +3094,7 @@ Exemple en C :
[source,C]
----
struct t_weelist_item *item = weechat_list_get (list, 0); /* premier élément */
struct t_weelist_item *item = weechat_list_get (list, 0); /* premier élément */
----
Script (Python) :
@ -4262,11 +4262,11 @@ my_section_delete_option_cb (void *data, struct t_config_file *config_file,
/* section standard, l'utilisateur ne peut pas ajouter/supprimer des options */
struct t_config_section *new_section1 =
weechat_config_new_section (config_file, "section1", 0, 0,
NULL, NULL, /* callback de lecture */
NULL, NULL, /* callback d'écriture */
NULL, NULL, /* callback d'écriture (valeurs par défaut) */
NULL, NULL, /* callback de création d'option */
NULL, NULL); /* callback de suppression d'option */
NULL, NULL, /* callback de lecture */
NULL, NULL, /* callback d'écriture */
NULL, NULL, /* callback d'écriture (valeurs par défaut) */
NULL, NULL, /* callback de création d'option */
NULL, NULL); /* callback de suppression d'option */
/* section spéciale, l'utilisateur peut ajouter/supprimer des options, et les
options nécessitent un callback pour la lecture/écriture */
@ -4451,67 +4451,67 @@ Exemple en C :
struct t_config_option *option1 =
weechat_config_new_option (config_file, section, "option1", "boolean",
"Mon option, type booléen"
NULL, /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"on", /* défaut */
"on", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
NULL, /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"on", /* défaut */
"on", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
/* entier */
struct t_config_option *option2 =
weechat_config_new_option (config_file, section, "option2", "integer",
"Mon option, type entier"
NULL, /* valeurs sous forme de chaînes */
0, 100, /* min, max */
"15", /* défaut */
"15", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
NULL, /* valeurs sous forme de chaînes */
0, 100, /* min, max */
"15", /* défaut */
"15", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
/* entier (avec valeurs sous forme de chaînes) */
struct t_config_option *option3 =
weechat_config_new_option (config_file, section, "option3", "integer",
"Mon option, type entier "
"(avec valeurs sous forme de chaînes)"
"top|bottom|left|right", /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"bottom", /* défaut */
"bottom", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
"top|bottom|left|right", /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"bottom", /* défaut */
"bottom", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
/* chaîne */
struct t_config_option *option4 =
weechat_config_new_option (config_file, section, "option4", "string",
"Mon option, type chaîne"
NULL, /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"test", /* défaut */
"test", /* valeur */
1, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
NULL, /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"test", /* défaut */
"test", /* valeur */
1, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
/* couleur */
struct t_config_option *option5 =
weechat_config_new_option (config_file, section, "option5", "color",
"Mon option, type couleur"
NULL, /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"lightblue", /* défaut */
"lightblue", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
NULL, /* valeurs sous forme de chaînes */
0, 0, /* min, max */
"lightblue", /* défaut */
"lightblue", /* valeur */
0, /* valeur null autorisée */
NULL, NULL, /* callback de vérification */
NULL, NULL, /* callback de changement de valeur */
NULL, NULL); /* callback de suppression de l'option */
----
Script (Python) :
@ -6296,9 +6296,9 @@ Script (Python) :
num_keys = weechat.key_bind(context, keys)
# exemple
keys = { "@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down" }
keys = {"@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down"}
weechat.key_bind("mouse", keys)
----
@ -6537,7 +6537,7 @@ weechat_printf (buffer, "Bonjour sur ce tampon");
weechat_printf (buffer, "%sCeci est une erreur !", weechat_prefix ("error"));
weechat_printf (buffer, " \tMessage sans préfixe mais avec \t quelques \t tabulations");
weechat_printf (buffer, "\t\tMessage sans heure/alignement");
weechat_printf (buffer, "\t\t"); /* ligne vide (sans heure) */
weechat_printf (buffer, "\t\t"); /* ligne vide (sans heure) */
----
Script (Python) :
@ -6553,7 +6553,7 @@ weechat.prnt(buffer, "Bonjour sur ce tampon")
weechat.prnt(buffer, "%sCeci est une erreur !" % weechat.prefix("error"))
weechat.prnt(buffer, " \tMessage sans préfixe mais avec \t quelques \t tabulations")
weechat.prnt(buffer, "\t\tMessage sans heure/alignement")
weechat.prnt(buffer, "\t\t") # ligne vide (sans heure)
weechat.prnt(buffer, "\t\t") # ligne vide (sans heure)
----
[NOTE]
@ -7444,7 +7444,7 @@ if (options_cmd1)
weechat_hashtable_set (options_cmd1, "arg1", "-from");
weechat_hashtable_set (options_cmd1, "arg2", nick);
weechat_hashtable_set (options_cmd1, "arg3", "-msg");
weechat_hashtable_set (options_cmd1, "arg4", message); /* paramètre non sûr */
weechat_hashtable_set (options_cmd1, "arg4", message); /* paramètre non sûr */
struct t_hook *my_process_hook = weechat_hook_process_hashtable ("my-notify-command",
options_cmd1,
20000,
@ -7492,21 +7492,21 @@ def my_process_cb(data, command, return_code, out, err):
# exemple 1 : téléchargement d'une URL
hook1 = weechat.hook_process_hashtable("url:http://weechat.org/",
{ "file_out": "/tmp/weechat.org.html" },
{"file_out": "/tmp/weechat.org.html"},
20000, "my_process_cb", "")
# exemple 2 : exécution d'un programme de notification avec le message de quelqu'un
hook2 = weechat.hook_process_hashtable("my-notify-command",
{ "arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message }, # paramètre non sûr
{"arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message}, # paramètre non sûr
20000, "my_process_cb", "")
# exemple 3 : appeler le shell pour exécuter la commande (la commande doit être SURE)
hook3 = weechat.hook_process_hashtable("sh",
{ "arg1": "-c",
"arg2": "ls -l /tmp | grep something" },
{"arg1": "-c",
"arg2": "ls -l /tmp | grep something"},
20000, "my_process_cb", "")
----
@ -7642,7 +7642,7 @@ my_connect_cb (void *data, int status, int gnutls_rc, int sock,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
NULL, NULL, 0, /* GnuTLS */
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL);
----
@ -8842,7 +8842,7 @@ Script (Python) :
rc = weechat.hook_hsignal_send(signal, hashtable)
# exemple
rc = weechat.hook_hsignal_send("my_hsignal", { "clé": "valeur" })
rc = weechat.hook_hsignal_send("my_hsignal", {"clé": "valeur"})
----
[[hsignal_irc_redirect_command]]
@ -8948,8 +8948,8 @@ def test_whois_cb(data, signal, hashtable):
weechat.hook_hsignal ("irc_redirection_test_whois", "test_whois_cb", "")
weechat.hook_hsignal_send("irc_redirect_command",
{ "server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode" })
{"server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode"})
weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING,
"freenode;;2;;/whois FlashCode")
----
@ -9022,10 +9022,10 @@ Script (Python) :
[source,python]
----
weechat.hook_hsignal_send("irc_redirect_pattern",
{ "pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1" })
{"pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1"})
# rediriger maintenant la commande irc whois avec le hsignal irc_redirect_command,
# en utilisant le modèle "my_whois"
# ...
@ -9677,7 +9677,7 @@ hook = weechat.hook_info_hashtable(info_name, description, args_description,
# exemple
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_cle": "test_valeur" }
return {"test_cle": "test_valeur"}
hook = weechat.hook_info_hashtable("mon_info_hashtable", "Une information",
"Info sur la table de hachage en entrée",
@ -10039,7 +10039,7 @@ def my_process_cb(data, command, return_code, out, err):
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_process_hashtable("/chemin/vers/commande", { "stdin": "1" },
hook = weechat.hook_process_hashtable("/chemin/vers/commande", {"stdin": "1"},
20000, "my_process_cb", "")
weechat.hook_set(hook, "stdin", "données envoyées sur le stdin du processus fils")
weechat.hook_set(hook, "stdin_close", "") # facultatif
@ -10270,7 +10270,7 @@ Exemples en C :
[source,C]
----
struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
----
Script (Python) :
@ -11027,10 +11027,10 @@ Exemple en C :
struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
if (buffer)
{
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
}
----
@ -11044,10 +11044,10 @@ match = weechat.buffer_match_list(buffer, string)
# exemple
buffer = weechat.buffer_search("irc", "freenode.#weechat")
if buffer:
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
----
[[windows]]
@ -12830,7 +12830,7 @@ Script (Python) :
dict = weechat.info_get_hashtable(info_name, dict_in)
# exemple
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message ici" }
dict_in = {"message": ":nick!user@host PRIVMSG #weechat :message ici"}
weechat.prnt("", "message analysé: %s"
% weechat.info_get_hashtable("irc_message_parse", dict_in))
----
@ -14969,13 +14969,13 @@ Script (Python) :
count = weechat.hdata_update(hdata, pointer, hashtable)
# exemple : soustrait une heure sur le dernier message affiché dans le tampon courant
own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), weechat.current_buffer(), 'own_lines')
own_lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), weechat.current_buffer(), "own_lines")
if own_lines:
line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines, 'last_line')
line = weechat.hdata_pointer(weechat.hdata_get("lines"), own_lines, "last_line")
if line:
line_data = weechat.hdata_pointer(weechat.hdata_get('line'), line, 'data')
hdata = weechat.hdata_get('line_data')
weechat.hdata_update(hdata, line_data, { 'date': str(weechat.hdata_time(hdata, line_data, 'date') - 3600) })
line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line, "data")
hdata = weechat.hdata_get("line_data")
weechat.hdata_update(hdata, line_data, {"date": str(weechat.hdata_time(hdata, line_data, "date") - 3600)})
----
==== weechat_hdata_get_string

View File

@ -597,8 +597,8 @@ Exemples :
----
buffer = weechat.current_buffer()
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
short_name = weechat.buffer_get_string(buffer, "short_name")
----
@ -749,7 +749,7 @@ def my_process_cb(data, command, rc, out, err):
return weechat.WEECHAT_RC_OK
weechat.hook_process_hashtable("url:http://weechat.org/files/src/weechat-devel.tar.gz",
{ "file_out": "/tmp/weechat-devel.tar.gz" },
{"file_out": "/tmp/weechat-devel.tar.gz"},
30 * 1000, "my_process_cb", "")
----
@ -897,7 +897,7 @@ Vous pouvez analyser un message IRC avec l'info_hashtable appelée
[source,python]
----
dict = weechat.info_get_hashtable("irc_message_parse",
{ "message": ":nick!user@host PRIVMSG #weechat :message ici" })
{"message": ":nick!user@host PRIVMSG #weechat :message ici"})
weechat.prnt("", "dict: %s" % dict)
# output:

View File

@ -500,7 +500,7 @@ Esempio in C:
[source,C]
----
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
/* ... */
free (str);
----
@ -528,7 +528,7 @@ Esempio in C:
[source,C]
----
char str[] = "AbCdé";
weechat_string_tolower (str); /* str ora è: "abcdé" */
weechat_string_tolower (str); /* str ora è: "abcdé" */
----
[NOTE]
@ -554,7 +554,7 @@ Esempio in C:
[source,C]
----
char str[] = "AbCdé";
weechat_string_toupper (str); /* str ora è: "ABCDé" */
weechat_string_toupper (str); /* str ora è: "ABCDé" */
----
[NOTE]
@ -589,7 +589,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -632,7 +632,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
----
[NOTE]
@ -669,7 +669,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----
[NOTE]
@ -713,7 +713,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
----
[NOTE]
@ -753,7 +753,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----
[NOTE]
@ -784,7 +784,7 @@ Esempio in C:
[source,C]
----
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* risultato: puntatore a "DeF" */
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* risultato: puntatore a "DeF" */
----
[NOTE]
@ -820,7 +820,7 @@ Esempio in C:
[source,C]
----
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
----
Script (Python):
@ -831,7 +831,7 @@ Script (Python):
length = weechat.strlen_screen(string)
# esempio
length = weechat.strlen_screen("é") # 1
length = weechat.strlen_screen("é") # 1
----
==== weechat_string_match
@ -870,11 +870,11 @@ Esempio in C:
[source,C]
----
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
----
Script (Python):
@ -885,11 +885,11 @@ Script (Python):
match = weechat.string_match(string, mask, case_sensitive)
# esempio
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
----
==== weechat_string_expand_home
@ -990,7 +990,7 @@ Esempio in C:
[source,C]
----
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* risultato: ".abc" */
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* risultato: ".abc" */
/* ... */
free (str);
----
@ -1090,7 +1090,7 @@ Script (Python):
regex = weechat.string_mask_to_regex(mask)
# esempio
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
----
==== weechat_string_regex_flags
@ -1224,7 +1224,7 @@ Esempio in C:
[source,C]
----
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
----
Script (Python):
@ -1235,7 +1235,7 @@ Script (Python):
highlight = weechat.string_has_highlight(string, highlight_words)
# esempio
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
----
==== weechat_string_has_highlight_regex
@ -1269,7 +1269,7 @@ Esempio in C:
[source,C]
----
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
----
Script (Python):
@ -1280,7 +1280,7 @@ Script (Python):
highlight = weechat.string_has_highlight_regex(string, regex)
# esempio
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
----
==== weechat_string_replace
@ -1310,7 +1310,7 @@ Esempio in C:
[source,C]
----
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
/* ... */
free (str);
----
@ -1650,19 +1650,19 @@ Esempi in C:
----
/* esempi in lingua inglese */
char *str = weechat_string_format_size (0); /* str == "0 byte" */
char *str = weechat_string_format_size (0); /* str == "0 byte" */
/* ... */
free (str);
char *str = weechat_string_format_size (200); /* str == "200 bytes" */
char *str = weechat_string_format_size (200); /* str == "200 bytes" */
/* ... */
free (str);
char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
/* ... */
free (str);
char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
/* ... */
free (str);
----
@ -1812,8 +1812,8 @@ Esempi in C:
[source,C]
----
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
----
Script (Python):
@ -1824,8 +1824,8 @@ Script (Python):
is_cmdchar = weechat.string_is_command_char(string)
# esempi
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
----
==== weechat_string_input_for_buffer
@ -1854,9 +1854,9 @@ Esempi in C:
[source,C]
----
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
----
Script (Python):
@ -1867,9 +1867,9 @@ Script (Python):
str = weechat.string_input_for_buffer(string)
# esempi
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----
==== weechat_string_eval_expression
@ -1931,9 +1931,9 @@ struct t_hashtable *options = weechat_hashtable_new (8,
NULL);
if (options)
weechat_hashtable_set (options, "type", "condition");
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----
Script (Python):
@ -1944,9 +1944,9 @@ Script (Python):
str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# esempi
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----
[[utf-8]]
@ -2137,7 +2137,7 @@ Esempio in C:
[source,C]
----
int char_int = weechat_utf8_char_int ("être"); /* "ê" come intero */
int char_int = weechat_utf8_char_int ("être"); /* "ê" come intero */
----
[NOTE]
@ -2166,7 +2166,7 @@ Esempio in C:
[source,C]
----
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----
[NOTE]
@ -2195,7 +2195,7 @@ Esempio in C:
[source,C]
----
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----
[NOTE]
@ -2226,7 +2226,7 @@ Esempio in C:
[source,C]
----
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2257,7 +2257,7 @@ Esempio in C:
[source,C]
----
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----
[NOTE]
@ -2292,7 +2292,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----
[NOTE]
@ -2327,7 +2327,7 @@ Esempio in C:
[source,C]
----
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -2358,7 +2358,7 @@ Esempio in C:
[source,C]
----
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----
[NOTE]
@ -2389,7 +2389,7 @@ Esempio in C:
[source,C]
----
char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
----
[NOTE]
@ -2419,7 +2419,7 @@ Esempio in C:
[source,C]
----
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----
[NOTE]
@ -2449,7 +2449,7 @@ Esempio in C:
[source,C]
----
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2479,7 +2479,7 @@ Esempio in C:
[source,C]
----
char *string = weechat_utf8_strndup ("chêne", 3); /* restituisce "chê" */
char *string = weechat_utf8_strndup ("chêne", 3); /* restituisce "chê" */
/* ... */
free (string);
----
@ -2780,7 +2780,7 @@ Esempio in C:
[source,C]
----
weechat_util_timeval_add (&tv, 2000); /* aggiunge 2 secondi */
weechat_util_timeval_add (&tv, 2000); /* aggiunge 2 secondi */
----
[NOTE]
@ -2838,10 +2838,10 @@ Esempio in C:
[source,C]
----
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
----
[NOTE]
@ -3118,7 +3118,7 @@ Esempio in C:
[source,C]
----
struct t_weelist_item *item = weechat_list_get (list, 0); /* primo elemento */
struct t_weelist_item *item = weechat_list_get (list, 0); /* primo elemento */
----
Script (Python):
@ -4283,11 +4283,11 @@ my_section_delete_option_cb (void *data, struct t_config_file *config_file,
/* sezione standard, l'utente non può aggiungere/rimuovere opzioni */
struct t_config_section *new_section1 =
weechat_config_new_section (config_file, "section1", 0, 0,
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
/* sezione speciale, l'utente può aggiungere/eliminare opzioni, e le
opzioni necessitano di un callback per essere lette/scritte */
@ -4471,66 +4471,66 @@ Esempio in C:
struct t_config_option *option1 =
weechat_config_new_option (config_file, section, "option1", "boolean",
"My option, type boolean"
NULL, /* valori stringa */
0, 0, /* min, max */
"on", /* predefinito */
"on", /* valore */
0, /* null value allowed */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
NULL, /* valori stringa */
0, 0, /* min, max */
"on", /* predefinito */
"on", /* valore */
0, /* null value allowed */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
/* intero */
struct t_config_option *option2 =
weechat_config_new_option (config_file, section, "option2", "integer",
"My option, type integer"
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
0, /* null value allowed */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
0, /* null value allowed */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
/* intero (con valori stringa) */
struct t_config_option *option3 =
weechat_config_new_option (config_file, section, "option3", "integer",
"My option, type integer (with string values)"
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* predefinito */
"bottom", /* valoree */
0, /* null value allowed */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* predefinito */
"bottom", /* valoree */
0, /* null value allowed */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
/* stringa */
struct t_config_option *option4 =
weechat_config_new_option (config_file, section, "option4", "string",
"My option, type string"
NULL, /* valori stringa */
0, 0, /* min, max */
"test", /* predefinito */
"test", /* valore */
1, /* valore null consentito */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
NULL, /* valori stringa */
0, 0, /* min, max */
"test", /* predefinito */
"test", /* valore */
1, /* valore null consentito */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
/* colore */
struct t_config_option *option5 =
weechat_config_new_option (config_file, section, "option5", "color",
"My option, type color"
NULL, /* valori stringa */
0, 0, /* min, max */
"lightblue", /* predefinito */
"lightblue", /* valore */
0, /* valore null consentito */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
NULL, /* valori stringa */
0, 0, /* min, max */
"lightblue", /* predefinito */
"lightblue", /* valore */
0, /* valore null consentito */
NULL, NULL, /* verifica callback */
NULL, NULL, /* modifica callback */
NULL, NULL); /* elimina callback */
----
Script (Python):
@ -6309,9 +6309,9 @@ Script (Python):
num_keys = weechat.key_bind(context, keys)
# esempio
keys = { "@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down" }
keys = {"@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down"}
weechat.key_bind("mouse", keys)
----
@ -6549,7 +6549,7 @@ weechat_printf (buffer, "Benvenuto su questo buffer");
weechat_printf (buffer, "%sQuesto è un errore!", weechat_prefix ("error"));
weechat_printf (buffer, " \tMessaggio senza prefisso ma con \t alcune \t tabulazioni");
weechat_printf (buffer, "\t\tMessage without time/alignment");
weechat_printf (buffer, "\t\t"); /* empty line (without time) */
weechat_printf (buffer, "\t\t"); /* empty line (without time) */
----
Script (Python):
@ -6566,7 +6566,7 @@ weechat.prnt(buffer, "Benvenuto su questo buffer")
weechat.prnt(buffer, "%sQuesto è un errore!" % weechat.prefix("error"))
weechat.prnt(buffer, " \tMessaggio senza prefisso ma con \t alcune \t tabulazioni")
weechat.prnt(buffer, "\t\tMessage without time/alignment")
weechat.prnt(buffer, "\t\t") # empty line (without time)
weechat.prnt(buffer, "\t\t") # empty line (without time)
----
[NOTE]
@ -7455,7 +7455,7 @@ if (options_cmd1)
weechat_hashtable_set (options_cmd1, "arg1", "-from");
weechat_hashtable_set (options_cmd1, "arg2", nick);
weechat_hashtable_set (options_cmd1, "arg3", "-msg");
weechat_hashtable_set (options_cmd1, "arg4", message); /* unsafe argument */
weechat_hashtable_set (options_cmd1, "arg4", message); /* unsafe argument */
struct t_hook *my_process_hook = weechat_hook_process_hashtable ("my-notify-command",
options_cmd1,
20000,
@ -7503,21 +7503,21 @@ def my_process_cb(data, command, return_code, out, err):
# example 1: download URL
hook1 = weechat.hook_process_hashtable("url:http://weechat.org/",
{ "file_out": "/tmp/weechat.org.html" },
{"file_out": "/tmp/weechat.org.html"},
20000, "my_process_cb", "")
# example 2: execute a notify program with a message from someone
hook2 = weechat.hook_process_hashtable("my-notify-command",
{ "arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message }, # unsafe argument
{"arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message}, # unsafe argument
20000, "my_process_cb", "")
# example 3: call shell to execute a command (command must be SAFE)
hook3 = weechat.hook_process_hashtable("sh",
{ "arg1": "-c",
"arg2": "ls -l /tmp | grep something" },
{"arg1": "-c",
"arg2": "ls -l /tmp | grep something"},
20000, "my_process_cb", "")
----
@ -7652,7 +7652,7 @@ my_connect_cb (void *data, int status, int gnutls_rc, int sock,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
NULL, NULL, 0, /* GnuTLS */
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL);
----
@ -8931,7 +8931,7 @@ Script (Python):
rc = weechat.hook_hsignal_send(signal, hashtable)
# esempio
rc = weechat.hook_hsignal_send("my_hsignal", { "key": "value" })
rc = weechat.hook_hsignal_send("my_hsignal", {"key": "value"})
----
[[hsignal_irc_redirect_command]]
@ -9034,8 +9034,8 @@ def test_whois_cb(data, signal, hashtable):
weechat.hook_hsignal ("irc_redirection_test_whois", "test_whois_cb", "")
weechat.hook_hsignal_send("irc_redirect_command",
{ "server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode" })
{"server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode"})
weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING,
"freenode;;2;;/whois FlashCode")
----
@ -9104,10 +9104,10 @@ Script (Python):
[source,python]
----
weechat.hook_hsignal_send("irc_redirect_pattern",
{ "pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1" })
{"pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1"})
# now redirect irc whois command with hsignal irc_redirect_command
# using pattern "my_whois"
# ...
@ -9751,7 +9751,7 @@ hook = weechat.hook_info_hashtable(info_name, description, args_description,
# esempio
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_key": "test_value" }
return {"test_key": "test_value"}
hook = weechat.hook_info_hashtable("my_info_hashtable", "Some info",
"Info about input hashtable",
@ -10118,7 +10118,7 @@ def my_process_cb(data, command, return_code, out, err):
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_process_hashtable("/path/to/command", { "stdin": "1" },
hook = weechat.hook_process_hashtable("/path/to/command", {"stdin": "1"},
20000, "my_process_cb", "")
weechat.hook_set(hook, "stdin", "data sent to stdin of child process")
weechat.hook_set(hook, "stdin_close", "") # optional
@ -10351,7 +10351,7 @@ Esempio in C:
[source,C]
----
struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
----
Script (Python):
@ -11134,10 +11134,10 @@ Esempio in C:
struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
if (buffer)
{
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
}
----
@ -11151,10 +11151,10 @@ match = weechat.buffer_match_list(buffer, string)
# esempio
buffer = weechat.buffer_search("irc", "freenode.#weechat")
if buffer:
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
----
[[windows]]
@ -12952,7 +12952,7 @@ Script (Python):
dict = weechat.info_get_hashtable(info_name, dict_in)
# esempio
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message here" }
dict_in = {"message": ":nick!user@host PRIVMSG #weechat :message here"}
weechat.prnt("", "message parsed: %s"
% weechat.info_get_hashtable("irc_message_parse", dict_in))
----
@ -15109,13 +15109,13 @@ Script (Python):
count = weechat.hdata_update(hdata, pointer, hashtable)
# example: subtract one hour on last message displayed in current buffer
own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), weechat.current_buffer(), 'own_lines')
own_lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), weechat.current_buffer(), "own_lines")
if own_lines:
line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines, 'last_line')
line = weechat.hdata_pointer(weechat.hdata_get("lines"), own_lines, "last_line")
if line:
line_data = weechat.hdata_pointer(weechat.hdata_get('line'), line, 'data')
hdata = weechat.hdata_get('line_data')
weechat.hdata_update(hdata, line_data, { 'date': str(weechat.hdata_time(hdata, line_data, 'date') - 3600) })
line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line, "data")
hdata = weechat.hdata_get("line_data")
weechat.hdata_update(hdata, line_data, {"date": str(weechat.hdata_time(hdata, line_data, "date") - 3600)})
----
==== weechat_hdata_get_string

View File

@ -595,8 +595,8 @@ Esempi:
----
buffer = weechat.current_buffer()
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
short_name = weechat.buffer_get_string(buffer, "short_name")
----
@ -747,7 +747,7 @@ def my_process_cb(data, command, rc, out, err):
return weechat.WEECHAT_RC_OK
weechat.hook_process_hashtable("url:http://weechat.org/files/src/weechat-devel.tar.gz",
{ "file_out": "/tmp/weechat-devel.tar.gz" },
{"file_out": "/tmp/weechat-devel.tar.gz"},
30 * 1000, "my_process_cb", "")
----
@ -895,7 +895,7 @@ _Novità nella versione 0.3.4._
[source,python]
----
dict = weechat.info_get_hashtable("irc_message_parse",
{ "message": ":nick!user@host PRIVMSG #weechat :message here" })
{"message": ":nick!user@host PRIVMSG #weechat :message here"})
weechat.prnt("", "dict: %s" % dict)
# output:

View File

@ -484,7 +484,7 @@ C 言語での使用例:
[source,C]
----
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
/* ... */
free (str);
----
@ -512,7 +512,7 @@ C 言語での使用例:
[source,C]
----
char str[] = "AbCdé";
weechat_string_tolower (str); /* str is now: "abcdé" */
weechat_string_tolower (str); /* str is now: "abcdé" */
----
[NOTE]
@ -538,7 +538,7 @@ C 言語での使用例:
[source,C]
----
char str[] = "AbCdé";
weechat_string_toupper (str); /* str is now: "ABCDé" */
weechat_string_toupper (str); /* str is now: "ABCDé" */
----
[NOTE]
@ -573,7 +573,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -616,7 +616,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */
----
[NOTE]
@ -652,7 +652,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----
[NOTE]
@ -697,7 +697,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == 0 */
----
[NOTE]
@ -737,7 +737,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----
[NOTE]
@ -767,7 +767,7 @@ C 言語での使用例:
[source,C]
----
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */
----
[NOTE]
@ -800,7 +800,7 @@ C 言語での使用例:
[source,C]
----
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
----
スクリプト (Python) での使用例:
@ -811,7 +811,7 @@ int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
length = weechat.strlen_screen(string)
# 例
length = weechat.strlen_screen("é") # 1
length = weechat.strlen_screen("é") # 1
----
==== weechat_string_match
@ -847,11 +847,11 @@ C 言語での使用例:
[source,C]
----
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
----
スクリプト (Python) での使用例:
@ -862,11 +862,11 @@ int match5 = weechat_string_match ("abcdef", "*b*d*", 0); /* == 1 */
match = weechat.string_match(string, mask, case_sensitive)
# 例s
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1
match5 = weechat.string_match("abcdef", "*b*d*", 0) # 1
----
==== weechat_string_expand_home
@ -967,7 +967,7 @@ C 言語での使用例:
[source,C]
----
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* result: ".abc" */
char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* result: ".abc" */
/* ... */
free (str);
----
@ -1063,7 +1063,7 @@ free (str_regex);
regex = weechat.string_mask_to_regex(mask)
# 例
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
----
==== weechat_string_regex_flags
@ -1186,7 +1186,7 @@ C 言語での使用例:
[source,C]
----
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
----
スクリプト (Python) での使用例:
@ -1197,7 +1197,7 @@ int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1
highlight = weechat.string_has_highlight(string, highlight_words)
# 例
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
----
==== weechat_string_has_highlight_regex
@ -1229,7 +1229,7 @@ C 言語での使用例:
[source,C]
----
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
----
スクリプト (Python) での使用例:
@ -1240,7 +1240,7 @@ int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /*
highlight = weechat.string_has_highlight_regex(string, regex)
# 例
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
----
==== weechat_string_replace
@ -1270,7 +1270,7 @@ C 言語での使用例:
[source,C]
----
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
/* ... */
free (str);
----
@ -1601,19 +1601,19 @@ C 言語での使用例:
----
/* examples with English locale */
char *str = weechat_string_format_size (0); /* str == "0 byte" */
char *str = weechat_string_format_size (0); /* str == "0 byte" */
/* ... */
free (str);
char *str = weechat_string_format_size (200); /* str == "200 bytes" */
char *str = weechat_string_format_size (200); /* str == "200 bytes" */
/* ... */
free (str);
char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
/* ... */
free (str);
char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
/* ... */
free (str);
----
@ -1763,8 +1763,8 @@ C 言語での使用例:
[source,C]
----
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
----
スクリプト (Python) での使用例:
@ -1775,8 +1775,8 @@ int command_char2 = weechat_string_is_command_char ("test"); /* == 0 */
is_cmdchar = weechat.string_is_command_char(string)
# 例s
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
----
==== weechat_string_input_for_buffer
@ -1805,9 +1805,9 @@ C 言語での使用例:
[source,C]
----
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
const char *str1 = weechat_string_input_for_buffer ("test"); /* "test" */
const char *str2 = weechat_string_input_for_buffer ("/test"); /* NULL */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
----
スクリプト (Python) での使用例:
@ -1818,9 +1818,9 @@ const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */
str = weechat.string_input_for_buffer(string)
# 例s
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----
==== weechat_string_eval_expression
@ -1877,9 +1877,9 @@ struct t_hashtable *options = weechat_hashtable_new (8,
NULL);
if (options)
weechat_hashtable_set (options, "type", "condition");
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----
スクリプト (Python) での使用例:
@ -1890,9 +1890,9 @@ char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options);
str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# 例s
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----
[[utf-8]]
@ -2080,7 +2080,7 @@ C 言語での使用例:
[source,C]
----
int char_int = weechat_utf8_char_int ("être"); /* "ê" as integer */
int char_int = weechat_utf8_char_int ("être"); /* "ê" as integer */
----
[NOTE]
@ -2109,7 +2109,7 @@ C 言語での使用例:
[source,C]
----
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----
[NOTE]
@ -2138,7 +2138,7 @@ C 言語での使用例:
[source,C]
----
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----
[NOTE]
@ -2168,7 +2168,7 @@ C 言語での使用例:
[source,C]
----
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2197,7 +2197,7 @@ C 言語での使用例:
[source,C]
----
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----
[NOTE]
@ -2232,7 +2232,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----
[NOTE]
@ -2267,7 +2267,7 @@ C 言語での使用例:
[source,C]
----
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----
[NOTE]
@ -2296,7 +2296,7 @@ C 言語での使用例:
[source,C]
----
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----
[NOTE]
@ -2327,7 +2327,7 @@ C 言語での使用例:
[source,C]
----
char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
----
[NOTE]
@ -2357,7 +2357,7 @@ C 言語での使用例:
[source,C]
----
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----
[NOTE]
@ -2387,7 +2387,7 @@ C 言語での使用例:
[source,C]
----
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----
[NOTE]
@ -2417,7 +2417,7 @@ C 言語での使用例:
[source,C]
----
char *string = weechat_utf8_strndup ("chêne", 3); /* returns "chê" */
char *string = weechat_utf8_strndup ("chêne", 3); /* returns "chê" */
/* ... */
free (string);
----
@ -2717,7 +2717,7 @@ C 言語での使用例:
[source,C]
----
weechat_util_timeval_add (&tv, 2000); /* add 2 seconds */
weechat_util_timeval_add (&tv, 2000); /* add 2 seconds */
----
[NOTE]
@ -2773,10 +2773,10 @@ C 言語での使用例:
[source,C]
----
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.8"); /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1"); /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9"); /* == 0x00030900 */
----
[NOTE]
@ -3052,7 +3052,7 @@ C 言語での使用例:
[source,C]
----
struct t_weelist_item *item = weechat_list_get (list, 0); /* first item */
struct t_weelist_item *item = weechat_list_get (list, 0); /* first item */
----
スクリプト (Python) での使用例:
@ -4202,11 +4202,11 @@ my_section_delete_option_cb (void *data, struct t_config_file *config_file,
/* standard section, user can not add/delete options */
struct t_config_section *new_section1 =
weechat_config_new_section (config_file, "section1", 0, 0,
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
/* special section, user can add/delete options, and options need
callback to be read/written */
@ -4390,66 +4390,66 @@ C 言語での使用例:
struct t_config_option *option1 =
weechat_config_new_option (config_file, section, "option1", "boolean",
"My option, type boolean"
NULL, /* string values */
0, 0, /* min, max */
"on", /* default */
"on", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 0, /* min, max */
"on", /* default */
"on", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* integer */
struct t_config_option *option2 =
weechat_config_new_option (config_file, section, "option2", "integer",
"My option, type integer"
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* integer (with string values) */
struct t_config_option *option3 =
weechat_config_new_option (config_file, section, "option3", "integer",
"My option, type integer (with string values)"
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* default */
"bottom", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* default */
"bottom", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* string */
struct t_config_option *option4 =
weechat_config_new_option (config_file, section, "option4", "string",
"My option, type string"
NULL, /* string values */
0, 0, /* min, max */
"test", /* default */
"test", /* value */
1, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 0, /* min, max */
"test", /* default */
"test", /* value */
1, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* color */
struct t_config_option *option5 =
weechat_config_new_option (config_file, section, "option5", "color",
"My option, type color"
NULL, /* string values */
0, 0, /* min, max */
"lightblue", /* default */
"lightblue", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
NULL, /* string values */
0, 0, /* min, max */
"lightblue", /* default */
"lightblue", /* value */
0, /* null value allowed */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
----
スクリプト (Python) での使用例:
@ -6213,9 +6213,9 @@ if (keys)
num_keys = weechat.key_bind(context, keys)
# 例
keys = { "@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down" }
keys = {"@chat(python.test):button1": "hsignal:test_mouse",
"@chat(python.test):wheelup": "/mycommand up",
"@chat(python.test):wheeldown": "/mycommand down"}
weechat.key_bind("mouse", keys)
----
@ -6446,7 +6446,7 @@ weechat_printf (buffer, "Hello on this buffer");
weechat_printf (buffer, "%sThis is an error!", weechat_prefix ("error"));
weechat_printf (buffer, " \tMessage without prefix but with \t some \t tabs");
weechat_printf (buffer, "\t\tMessage without time/alignment");
weechat_printf (buffer, "\t\t"); /* empty line (without time) */
weechat_printf (buffer, "\t\t"); /* empty line (without time) */
----
スクリプト (Python) での使用例:
@ -6462,7 +6462,7 @@ weechat.prnt(buffer, "Hello on this buffer")
weechat.prnt(buffer, "%sThis is an error!" % weechat.prefix("error"))
weechat.prnt(buffer, " \tMessage without prefix but with \t some \t tabs")
weechat.prnt(buffer, "\t\tMessage without time/alignment")
weechat.prnt(buffer, "\t\t") # empty line (without time)
weechat.prnt(buffer, "\t\t") # empty line (without time)
----
[NOTE]
@ -7320,7 +7320,7 @@ if (options_cmd1)
weechat_hashtable_set (options_cmd1, "arg1", "-from");
weechat_hashtable_set (options_cmd1, "arg2", nick);
weechat_hashtable_set (options_cmd1, "arg3", "-msg");
weechat_hashtable_set (options_cmd1, "arg4", message); /* untrusted argument */
weechat_hashtable_set (options_cmd1, "arg4", message); /* untrusted argument */
struct t_hook *my_process_hook = weechat_hook_process_hashtable ("my-notify-command",
options_cmd1,
20000,
@ -7368,21 +7368,21 @@ def my_process_cb(data, command, return_code, out, err):
# 例 1: URL をダウンロード
hook1 = weechat.hook_process_hashtable("url:http://weechat.org/",
{ "file_out": "/tmp/weechat.org.html" },
{"file_out": "/tmp/weechat.org.html"},
20000, "my_process_cb", "")
# 例 2: メッセージを渡して通知プログラムを実行
hook2 = weechat.hook_process_hashtable("my-notify-command",
{ "arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message }, # untrusted argument
{"arg1": "-from",
"arg2": nick,
"arg3": "-msg",
"arg4": message}, # untrusted argument
20000, "my_process_cb", "")
# 例 3: コマンドを実行するためにシェルを呼び出す (必ず安全なコマンドを実行してください)
hook3 = weechat.hook_process_hashtable("sh",
{ "arg1": "-c",
"arg2": "ls -l /tmp | grep something" },
{"arg1": "-c",
"arg2": "ls -l /tmp | grep something"},
20000, "my_process_cb", "")
----
@ -7513,7 +7513,7 @@ my_connect_cb (void *data, int status, int gnutls_rc, int sock,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
NULL, NULL, 0, /* GnuTLS */
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL);
----
@ -8695,7 +8695,7 @@ if (hashtable)
rc = weechat.hook_hsignal_send(signal, hashtable)
# 例
rc = weechat.hook_hsignal_send("my_hsignal", { "key": "value" })
rc = weechat.hook_hsignal_send("my_hsignal", {"key": "value"})
----
[[hsignal_irc_redirect_command]]
@ -8796,8 +8796,8 @@ def test_whois_cb(data, signal, hashtable):
weechat.hook_hsignal ("irc_redirection_test_whois", "test_whois_cb", "")
weechat.hook_hsignal_send("irc_redirect_command",
{ "server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode" })
{"server": "freenode", "pattern": "whois", "signal": "test",
"string": "FlashCode"})
weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING,
"freenode;;2;;/whois FlashCode")
----
@ -8865,10 +8865,10 @@ if (hashtable)
[source,python]
----
weechat.hook_hsignal_send("irc_redirect_pattern",
{ "pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1" })
{"pattern": "my_whois", "timeout": "30",
"cmd_start": "311:1",
"cmd_stop": "318:1,401:1,402:1,431:1,461",
"cmd_extra": "318:1"})
# now redirect irc whois command with hsignal irc_redirect_command
# using pattern "my_whois"
# ...
@ -9493,7 +9493,7 @@ hook = weechat.hook_info_hashtable(info_name, description, args_description,
# 例
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_key": "test_value" }
return {"test_key": "test_value"}
hook = weechat.hook_info_hashtable("my_info_hashtable", "Some info",
"Info about input hashtable",
@ -9846,7 +9846,7 @@ def my_process_cb(data, command, return_code, out, err):
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_process_hashtable("/path/to/command", { "stdin": "1" },
hook = weechat.hook_process_hashtable("/path/to/command", {"stdin": "1"},
20000, "my_process_cb", "")
weechat.hook_set(hook, "stdin", "data sent to stdin of child process")
weechat.hook_set(hook, "stdin_close", "") # optional
@ -10074,7 +10074,7 @@ C 言語での使用例:
[source,C]
----
struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 1.0 */
----
スクリプト (Python) での使用例:
@ -10811,10 +10811,10 @@ C 言語での使用例:
struct t_gui_buffer *buffer = weechat_buffer_search ("irc", "freenode.#weechat");
if (buffer)
{
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "*,!*#weechat*")); /* 0 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.freenode.*")); /* 1 */
weechat_printf (NULL, "%d", weechat_buffer_match_list (buffer, "irc.oftc.*,python.*")); /* 0 */
}
----
@ -10828,10 +10828,10 @@ match = weechat.buffer_match_list(buffer, string)
# 例
buffer = weechat.buffer_search("irc", "freenode.#weechat")
if buffer:
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.freenode.*")) # 1
weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
----
[[windows]]
@ -12587,7 +12587,7 @@ if (hashtable_in)
dict = weechat.info_get_hashtable(info_name, dict_in)
# 例
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message here" }
dict_in = {"message": ":nick!user@host PRIVMSG #weechat :message here"}
weechat.prnt("", "message parsed: %s"
% weechat.info_get_hashtable("irc_message_parse", dict_in))
----
@ -14679,13 +14679,13 @@ if (own_lines)
count = weechat.hdata_update(hdata, pointer, hashtable)
# 例: 現在のバッファに表示されている最後のメッセージの時間を 1 時間前にする
own_lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), weechat.current_buffer(), 'own_lines')
own_lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), weechat.current_buffer(), "own_lines")
if own_lines:
line = weechat.hdata_pointer(weechat.hdata_get('lines'), own_lines, 'last_line')
line = weechat.hdata_pointer(weechat.hdata_get("lines"), own_lines, "last_line")
if line:
line_data = weechat.hdata_pointer(weechat.hdata_get('line'), line, 'data')
hdata = weechat.hdata_get('line_data')
weechat.hdata_update(hdata, line_data, { 'date': str(weechat.hdata_time(hdata, line_data, 'date') - 3600) })
line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line, "data")
hdata = weechat.hdata_get("line_data")
weechat.hdata_update(hdata, line_data, {"date": str(weechat.hdata_time(hdata, line_data, "date") - 3600)})
----
==== weechat_hdata_get_string

View File

@ -586,8 +586,8 @@ weechat.buffer_set(buffer, "localvar_set_no_log", "1")
----
buffer = weechat.current_buffer()
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
short_name = weechat.buffer_get_string(buffer, "short_name")
----
@ -733,7 +733,7 @@ def my_process_cb(data, command, rc, out, err):
return weechat.WEECHAT_RC_OK
weechat.hook_process_hashtable("url:http://weechat.org/files/src/weechat-devel.tar.gz",
{ "file_out": "/tmp/weechat-devel.tar.gz" },
{"file_out": "/tmp/weechat-devel.tar.gz"},
30 * 1000, "my_process_cb", "")
----
@ -876,7 +876,7 @@ _バージョン 0.3.4 の新機能_
[source,python]
----
dict = weechat.info_get_hashtable("irc_message_parse",
{ "message": ":nick!user@host PRIVMSG #weechat :message here" })
{"message": ":nick!user@host PRIVMSG #weechat :message here"})
weechat.prnt("", "dict: %s" % dict)
# 出力:

View File

@ -581,8 +581,8 @@ Przykłady:
----
buffer = weechat.current_buffer()
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
number = weechat.buffer_get_integer(buffer, "number")
name = weechat.buffer_get_string(buffer, "name")
short_name = weechat.buffer_get_string(buffer, "short_name")
----
@ -728,7 +728,7 @@ def my_process_cb(data, command, rc, out, err):
return weechat.WEECHAT_RC_OK
weechat.hook_process_hashtable("url:http://weechat.org/files/src/weechat-devel.tar.gz",
{ "file_out": "/tmp/weechat-devel.tar.gz" },
{"file_out": "/tmp/weechat-devel.tar.gz"},
30 * 1000, "my_process_cb", "")
----
@ -871,7 +871,7 @@ Można przetwarzać wiadomości IRC za pomocą info_hashtable zwanej "irc_messag
[source,python]
----
dict = weechat.info_get_hashtable("irc_message_parse",
{ "message": ":nick!user@host PRIVMSG #weechat :message here" })
{"message": ":nick!user@host PRIVMSG #weechat :message here"})
weechat.prnt("", "dict: %s" % dict)
# wyjście: