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/it | |
parent | 0109c519375f8a54552127e71ea2b00b1baa296e (diff) | |
download | weechat-997894edc04e87b0ba0c81712c92a83ec7f5c121.zip |
core: add calculation of expression in evaluation of expressions with "calc:..." (issue #997)
Diffstat (limited to 'doc/it')
-rw-r--r-- | doc/it/autogen/user/weechat_commands.adoc | 8 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.adoc | 20 |
2 files changed, 24 insertions, 4 deletions
diff --git a/doc/it/autogen/user/weechat_commands.adoc b/doc/it/autogen/user/weechat_commands.adoc index ff30151bc..ee8b89271 100644 --- a/doc/it/autogen/user/weechat_commands.adoc +++ b/doc/it/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/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index f45eb124f..1b547fa40 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -2242,7 +2242,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" ==== string_eval_expression // TRANSLATION MISSING -_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._ // TRANSLATION MISSING Evaluate an expression and return result as a string. @@ -2642,6 +2642,24 @@ expanded to last): `+${if:${info:term_width}>80?big:small}+` | `+big+` +// TRANSLATION MISSING +| `+${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}+` | |