1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 16:53:14 +02:00

core: add evaluation of conditions in evaluation of expressions with "eval_cond:" (closes #1582)

This commit is contained in:
Sébastien Helleu
2020-11-14 09:28:46 +01:00
parent eb90a73fe8
commit b626df72fb
27 changed files with 574 additions and 468 deletions
+19 -17
View File
@@ -7431,33 +7431,34 @@ command_init ()
"Some variables are replaced in expression, using the format "
"${variable}, variable can be, by order of priority:\n"
" 1. an evaluated sub-string (format: \"eval:xxx\")\n"
" 2. a string with escaped chars (format: \"esc:xxx\" or \"\\xxx\")\n"
" 3. a string with chars to hide (format: \"hide:char,string\")\n"
" 4. a string with max chars (format: \"cut:max,suffix,string\" "
" 2. an evaluated condition (format: \"eval_cond:xxx\")\n"
" 3. a string with escaped chars (format: \"esc:xxx\" or \"\\xxx\")\n"
" 4. a string with chars to hide (format: \"hide:char,string\")\n"
" 5. a string with max chars (format: \"cut:max,suffix,string\" "
"or \"cut:+max,suffix,string\")\n"
" or max chars displayed on screen "
"(format: \"cutscr:max,suffix,string\" or "
"\"cutscr:+max,suffix,string\")\n"
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
" 6. a repeated string (format: \"repeat:count,string\")\n"
" 7. length of a string (format: \"length:xxx\" or "
" 6. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
" 7. a repeated string (format: \"repeat:count,string\")\n"
" 8. length of a string (format: \"length:xxx\" or "
"\"lengthscr:xxx\")\n"
" 8. a color (format: \"color:xxx\", see \"Plugin API "
" 9. a color (format: \"color:xxx\", see \"Plugin API "
"reference\", function \"color\")\n"
" 9. a modifier (format: \"modifier:name,data,string\")\n"
" 10. an info (format: \"info:name,arguments\", arguments are "
" 10. a modifier (format: \"modifier:name,data,string\")\n"
" 11. an info (format: \"info:name,arguments\", arguments are "
"optional)\n"
" 11. a base 16/32/64 encoded/decoded string (format: "
" 12. a base 16/32/64 encoded/decoded string (format: "
"\"base_encode:base,xxx\" or \"base_decode:base,xxx\")\n"
" 12. current date/time (format: \"date\" or \"date:format\")\n"
" 13. an environment variable (format: \"env:XXX\")\n"
" 14. a ternary operator (format: "
" 13. current date/time (format: \"date\" or \"date:format\")\n"
" 14. an environment variable (format: \"env:XXX\")\n"
" 15. a ternary operator (format: "
"\"if:condition?value_if_true:value_if_false\")\n"
" 15. result of an expression with parentheses and operators "
" 16. result of an expression with parentheses and operators "
"+ - * / // % ** (format: \"calc:xxx\")\n"
" 16. an option (format: \"file.section.option\")\n"
" 17. a local variable in buffer\n"
" 18. a hdata name/variable (the value is automatically converted "
" 17. an option (format: \"file.section.option\")\n"
" 18. a local variable in buffer\n"
" 19. a hdata name/variable (the value is automatically converted "
"to string), by default \"window\" and \"buffer\" point to current "
"window/buffer.\n"
"Format for hdata can be one of following:\n"
@@ -7477,6 +7478,7 @@ command_init ()
"reference\", function \"weechat_hdata_get\".\n"
"\n"
"Examples (simple strings):\n"
" /eval -n ${eval_cond:${window.win_width}>100} ==> 1\n"
" /eval -n ${info:version} ==> 0.4.3\n"
" /eval -n ${env:HOME} ==> /home/user\n"
" /eval -n ${weechat.look.scroll_amount} ==> 3\n"