diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-09-20 21:37:01 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-09-20 21:37:01 +0200 |
commit | 997894edc04e87b0ba0c81712c92a83ec7f5c121 (patch) | |
tree | 8dc259f773da21c8592421da0323694843b146db /doc/en | |
parent | 0109c519375f8a54552127e71ea2b00b1baa296e (diff) | |
download | weechat-997894edc04e87b0ba0c81712c92a83ec7f5c121.zip |
core: add calculation of expression in evaluation of expressions with "calc:..." (issue #997)
Diffstat (limited to 'doc/en')
-rw-r--r-- | doc/en/autogen/user/weechat_commands.adoc | 8 | ||||
-rw-r--r-- | doc/en/weechat_dev.en.adoc | 1 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.adoc | 19 |
3 files changed, 24 insertions, 4 deletions
diff --git a/doc/en/autogen/user/weechat_commands.adoc b/doc/en/autogen/user/weechat_commands.adoc index 89aad68d6..2cf3cf4c1 100644 --- a/doc/en/autogen/user/weechat_commands.adoc +++ b/doc/en/autogen/user/weechat_commands.adoc @@ -308,9 +308,10 @@ Some variables are replaced in expression, using the format ${variable}, variabl 9. current date/time (format: "date" or "date:format") 10. an environment variable (format: "env:XXX") 11. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 12. an option (format: "file.section.option") - 13. a local variable in buffer - 14. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 12. result of an expression with parentheses and operators + - * / // % (format: "calc:xxx") + 13. an option (format: "file.section.option") + 14. a local variable in buffer + 15. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. Format for hdata can be one of following: hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) hdata[list].var1.var2...: start with a hdata using a list, for example: @@ -337,6 +338,7 @@ Examples (simple strings): /eval -n ${if:${info:term_width}>80?big:small} ==> big /eval -n ${rev:Hello} ==> olleH /eval -n ${repeat:5,-} ==> ----- + /eval -n ${calc:(5+2)*3} ==> 21 Examples (conditions): /eval -n -c ${window.buffer.number} > 2 ==> 0 diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index ce45c06e3..26a1030f8 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -120,6 +120,7 @@ WeeChat "core" is located in following directories: | core/ | Core functions: entry point, internal structures. | wee-arraylist.c | Array lists. | wee-backtrace.c | Display a backtrace after a crash. +| wee-calc.c | Calculate result of expressions. | wee-command.c | WeeChat core commands. | wee-completion.c | Default completions. | wee-config-file.c | Configuration file management. diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index f076adcd1..3a16f07c8 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -2148,7 +2148,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" ==== string_eval_expression -_WeeChat ≥ 0.4.0, updated in 0.4.2, 0.4.3, 1.0, 1.1, 1.2, 1.3, 1.6, 1.8 and 2.0._ +_WeeChat ≥ 0.4.0, updated in 0.4.2, 0.4.3, 1.0, 1.1, 1.2, 1.3, 1.6, 1.8, 2.0 and 2.7._ Evaluate an expression and return result as a string. Special variables with format `+${variable}+` are expanded (see table below). @@ -2535,6 +2535,23 @@ expanded to last): `+${if:${info:term_width}>80?big:small}+` | `+big+` +| `+${calc:xxx}+` + + (_WeeChat ≥ 2.7_) | + Result of expression, where parentheses and the following operators are + supported: + + `+`: addition + + `-`: subtraction + + `*`: multiplication + + `/`: division + + `//`: result of division without fractional part + + `%`: remainder of division. | + `+${calc:5+2*3}+` + + `+${calc:(5+2)*3}+` + + `+${calc:9.2%3}+` | + `+11+` + + `+21+` + + `+0.2+` + | `+${sec.data.name}+` | Value of the secured data `name`. | `+${sec.data.freenode_pass}+` | |