From b626df72fb7cdc9d9f23a0e5a81209faace87c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 14 Nov 2020 09:28:46 +0100 Subject: [PATCH] core: add evaluation of conditions in evaluation of expressions with "eval_cond:" (closes #1582) --- ChangeLog.adoc | 4 + doc/de/includes/autogen_user_commands.de.adoc | 148 +++++++++--------- doc/en/includes/autogen_user_commands.en.adoc | 36 +++-- doc/en/weechat_plugin_api.en.adoc | 8 +- doc/fr/includes/autogen_user_commands.fr.adoc | 36 +++-- doc/fr/weechat_plugin_api.fr.adoc | 8 +- doc/it/includes/autogen_user_commands.it.adoc | 36 +++-- doc/it/weechat_plugin_api.it.adoc | 8 +- doc/ja/includes/autogen_user_commands.ja.adoc | 36 +++-- doc/ja/weechat_plugin_api.ja.adoc | 9 +- doc/pl/includes/autogen_user_commands.pl.adoc | 36 +++-- po/cs.po | 38 ++--- po/de.po | 39 ++--- po/es.po | 38 ++--- po/fr.po | 76 ++++----- po/hu.po | 38 ++--- po/it.po | 38 ++--- po/ja.po | 38 ++--- po/pl.po | 38 ++--- po/pt.po | 38 ++--- po/pt_BR.po | 38 ++--- po/ru.po | 38 ++--- po/tr.po | 38 ++--- po/weechat.pot | 38 ++--- src/core/wee-command.c | 36 +++-- src/core/wee-eval.c | 103 +++++++----- tests/unit/core/test-core-eval.cpp | 5 + 27 files changed, 574 insertions(+), 468 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 21d156859..ceb11855b 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -18,6 +18,10 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] [[v3.1]] == Version 3.1 (under dev) +New features:: + + * core: add evaluation of conditions in evaluation of expressions with "eval_cond:" (issue #1582) + Bug fixes:: * spell: fix refresh of bar item "spell_suggest" when the input becomes empty (issue #1586) diff --git a/doc/de/includes/autogen_user_commands.de.adoc b/doc/de/includes/autogen_user_commands.de.adoc index 209fe804c..57dbcc3b6 100644 --- a/doc/de/includes/autogen_user_commands.de.adoc +++ b/doc/de/includes/autogen_user_commands.de.adoc @@ -1298,76 +1298,78 @@ infolists: zeigt Information über die Infolists an /eval [-n|-s] [-d] [-n] [-d] -c - -n: gibt das Ergebnis aus, ohne dass dieses in den Buffer gesendet wird (debug Modus) - -s: teilt Ausdrücke, bevor sie evaluiert werden (mehrere Befehle können durch Semikolon getrennt werden) - -d: eine Debug-Ausgabe nach Auswertung anzeigen - -c: Auswertung als Bedingung: nutzt Operatoren und runde Klammern, Rückgabewert als Boolean-Wert ("0" oder "1") -expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten); mehrere Befehle werden durch ein Semikolon voneinander getrennt - operator: ein logischer oder vergleichender Operand: - - logische Operanden: - && boolean "und" - || boolean "oder" - - vergleichende Operanden: - == gleich - != ungleich - <= kleiner oder gleich - < kleiner - >= größer oder gleich - > größer - =~ stimmt mit regulärem POSIX Ausdruck überein - !~ stimmt NICHT mit regulärem POSIX Ausdruck überein - ==* stimmt mit Maske überein (Platzhalter "*" ist erlaubt) - !!* stimmt mit Maske NICHT überein (Platzhalter "*" ist erlaubt) - =* stimmt mit Maske überein, Groß- und Kleinschreibung wird nicht beachtet (Platzhalter "*" ist erlaubt) - !* stimmt mit Maske NICHT überein, Groß- und Kleinschreibung wird nicht beachtet (Platzhalter "*" ist erlaubt) - ==- ist enthalten, Groß- und Kleinschreibung wird beachtet - !!- ist NICHT enthalten, Groß- und Kleinschreibung wird beachtet - =- ist enthalten, Groß- und Kleinschreibung wird nicht beachtet - !- ist NICHT enthalten, Groß- und Kleinschreibung wird nicht beachtet + -n: display result without sending it to buffer (debug mode) + -s: split expression before evaluating it (many commands can be separated by semicolons) + -d: display debug output after evaluation + -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") +expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons + operator: a logical or comparison operator: + - logical operators: + && boolean "and" + || boolean "or" + - comparison operators: + == equal + != not equal + <= less or equal + < less + >= greater or equal + > greater + =~ is matching POSIX extended regex + !~ is NOT matching POSIX extended regex + ==* is matching mask, case sensitive (wildcard "*" is allowed) + !!* is NOT matching mask, case sensitive (wildcard "*" is allowed) + =* is matching mask, case insensitive (wildcard "*" is allowed) + !* is NOT matching mask, case insensitive (wildcard "*" is allowed) + ==- is included, case sensitive + !!- is NOT included, case sensitive + =- is included, case insensitive + !- is NOT included, case insensitive -Ein Ausdruck gilt als "wahr" sofern das Ergebnis weder NULL, nicht leer und von "0" abweichend ist. -Für einen Vergleich werden Fließkommazahlen genutzt, insofern es sich bei beiden Ausdrücken um gültige Zahlen handelt, folgende Formate werden unterstützt: - - Integer (Beispiele: 5, -7) - - Fließkommazahl (Beispiele: 5.2, -7.5, 2.83e-2) - - hexadezimale Zahl (Beispiele: 0xA3, -0xA3) -Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel: +An expression is considered as "true" if it is not NULL, not empty, and different from "0". +The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats: + - integer (examples: 5, -7) + - floating point number (examples: 5.2, -7.5, 2.83e-2) + - hexadecimal number (examples: 0xA3, -0xA3) +To force a string comparison, you can add double quotes around each expression, for example: 50 > 100 ==> 0 "50" > "100" ==> 1 -Einige Variablen werden im Ausdruck mittels der Formatierung ${variable} ersetzt. Mögliche Variablen sind, nach Reihenfolge ihrer Priorität: - 1. eine evaluierte Teilzeichenkette (Format: "eval:xxx") - 2. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx") - 3. Zeichen, die in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette") - 4. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:+Max,Suffix,Zeichenkette") - oder maximale Anzahl an Zeichen die auf dem Bildschirm angezeigt werden sollen (Format: "cutscr:Max,Suffix,Zeichenkette oder "cutscr:+Max,Suffix,Zeichenkette") - 5. eine Zeichenkette umkehren (Format: "rev:xxx" oder "revscr:xxx") - 6. eine Zeichenkette wiederholen (Format: "repeat:Anzahl,Zeichenkette") - 7. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx") - 8. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color") - 9. ein Modifizierer (Format: "info:Name,Argumente", Argumente sind optional) - 10. eine Info (Format: "Info:Name,Argumente", Argumente sind optional) - 11. eine Basis 16/32/64 kodierte / dekodierte Zeichenfolge (Format: "base_encode:base,xxx" oder "base_decode:base,xxx") - 12. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format") - 13. eine Umgebungsvariable (Format: "env:XXX") - 14. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr") - 15. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % ** (Format: "calc:xxx") - 16. eine Option (Format: "file.section.option") - 17. eine lokale Variable eines Buffers - 18. ein(e) hdata - Name/Variable (der Wert wird automatisch in eine Zeichenkette konvertiert), standardmäßig wird für "window" und "buffer" das aktuelle Fenster/Buffer verwendet. -Das Format für hdata kann wie folgt aufgebaut sein: - hdata.var1.var2...: startet mit hdata (der Pointer muss bekannt sein) und fragt eine Variable nach der anderen ab (weitere hdata können folgen) - hdata[list].var1.var2...: startet hdata mittels einer Liste, zum Beispiel: - ${buffer[gui_buffers].full_name}: der vollständige Name des ersten Buffers, in der verknüpften Liste aller Buffer - ${plugin[weechat_plugins].name}: Name der ersten Erweiterung, in der verknüpften Liste aller Erweiterungen - hdata[pointer].var1.var2...: startet hdata mittels einem Pointer, zum Beispiel: - ${buffer[0x1234abcd].full_name}: vollständiger Name eines Buffers und des dazugehörigen Pointers (kann in triggern benutzt werden) -Die vorhandenen Namen für hdata und Variablen sind in der "Anleitung für API Erweiterung", Bereich "weechat_hdata_get". beschrieben +Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: + 1. an evaluated sub-string (format: "eval:xxx") + 2. an evaluated condition (format: "eval_cond:xxx") + 3. a string with escaped chars (format: "esc:xxx" or "\xxx") + 4. a string with chars to hide (format: "hide:char,string") + 5. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") + or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") + 6. a reversed string (format: "rev:xxx" or "revscr:xxx") + 7. a repeated string (format: "repeat:count,string") + 8. length of a string (format: "length:xxx" or "lengthscr:xxx") + 9. a color (format: "color:xxx", see "Plugin API reference", function "color") + 10. a modifier (format: "modifier:name,data,string") + 11. an info (format: "info:name,arguments", arguments are optional) + 12. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") + 13. current date/time (format: "date" or "date:format") + 14. an environment variable (format: "env:XXX") + 15. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 16. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 17. an option (format: "file.section.option") + 18. a local variable in buffer + 19. 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: + ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers + ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins + hdata[pointer].var1.var2...: start with a hdata using a pointer, for example: + ${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers) +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -Beispiele (einfache Zeichenketten): +Examples (simple strings): + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${sec.data.freenode_password} ==> geheim + /eval -n ${sec.data.freenode_password} ==> secret /eval -n ${window} ==> 0x2549aa0 /eval -n ${window.buffer} ==> 0x2549320 /eval -n ${window.buffer.full_name} ==> core.weechat @@ -1385,17 +1387,17 @@ Beispiele (einfache Zeichenketten): /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test -Beispiele (Bedingungen): - /eval -n -c ${window.buffer.number} > 2 ==> 0 - /eval -n -c ${window.win_width} > 100 ==> 1 - /eval -n -c (8 > 12) || (5 > 2) ==> 1 - /eval -n -c (8 > 12) && (5 > 2) ==> 0 - /eval -n -c abcd =~ ^ABC ==> 1 - /eval -n -c abcd =~ (?-i)^ABC ==> 0 - /eval -n -c abcd =~ (?-i)^abc ==> 1 - /eval -n -c abcd !~ abc ==> 0 - /eval -n -c abcd =* a*d ==> 1 - /eval -n -c abcd =- bc ==> 1 +Examples (conditions): + /eval -n -c ${window.buffer.number} > 2 ==> 0 + /eval -n -c ${window.win_width} > 100 ==> 1 + /eval -n -c (8 > 12) || (5 > 2) ==> 1 + /eval -n -c (8 > 12) && (5 > 2) ==> 0 + /eval -n -c abcd =~ ^ABC ==> 1 + /eval -n -c abcd =~ (?-i)^ABC ==> 0 + /eval -n -c abcd =~ (?-i)^abc ==> 1 + /eval -n -c abcd !~ abc ==> 0 + /eval -n -c abcd =* a*d ==> 1 + /eval -n -c abcd =- bc ==> 1 ---- [[command_weechat_filter]] diff --git a/doc/en/includes/autogen_user_commands.en.adoc b/doc/en/includes/autogen_user_commands.en.adoc index 602e8bfe4..f8a44cdda 100644 --- a/doc/en/includes/autogen_user_commands.en.adoc +++ b/doc/en/includes/autogen_user_commands.en.adoc @@ -1336,24 +1336,25 @@ To force a string comparison, you can add double quotes around each expression, Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: 1. an evaluated sub-string (format: "eval:xxx") - 2. a string with escaped chars (format: "esc:xxx" or "\xxx") - 3. a string with chars to hide (format: "hide:char,string") - 4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") + 2. an evaluated condition (format: "eval_cond:xxx") + 3. a string with escaped chars (format: "esc:xxx" or "\xxx") + 4. a string with chars to hide (format: "hide:char,string") + 5. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") - 5. a reversed string (format: "rev:xxx" or "revscr:xxx") - 6. a repeated string (format: "repeat:count,string") - 7. length of a string (format: "length:xxx" or "lengthscr:xxx") - 8. a color (format: "color:xxx", see "Plugin API reference", function "color") - 9. a modifier (format: "modifier:name,data,string") - 10. an info (format: "info:name,arguments", arguments are optional) - 11. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") - 12. current date/time (format: "date" or "date:format") - 13. an environment variable (format: "env:XXX") - 14. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 15. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 16. an option (format: "file.section.option") - 17. a local variable in buffer - 18. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 6. a reversed string (format: "rev:xxx" or "revscr:xxx") + 7. a repeated string (format: "repeat:count,string") + 8. length of a string (format: "length:xxx" or "lengthscr:xxx") + 9. a color (format: "color:xxx", see "Plugin API reference", function "color") + 10. a modifier (format: "modifier:name,data,string") + 11. an info (format: "info:name,arguments", arguments are optional) + 12. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") + 13. current date/time (format: "date" or "date:format") + 14. an environment variable (format: "env:XXX") + 15. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 16. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 17. an option (format: "file.section.option") + 18. a local variable in buffer + 19. 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: @@ -1364,6 +1365,7 @@ Format for hdata can be one of following: For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". Examples (simple strings): + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index f19c29f95..1ea6ff588 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -2198,7 +2198,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, 2.0, -2.2, 2.3, 2.7 and 2.9._ +2.2, 2.3, 2.7, 2.9 and 3.1._ Evaluate an expression and return result as a string. Special variables with format `+${variable}+` are expanded (see table below). @@ -2521,6 +2521,12 @@ expanded to last): `+19:02:45+` (with colors if there are color codes in the option weechat.look.buffer_time_format) +| `+${eval_cond:xxx}+` + + _(WeeChat ≥ 3.1)_ | + String to evaluate as condition. | + `+${eval_cond:${window.win_width} > 100}+` | + `+1+` + | `+${esc:xxx}+` + `+${\xxx}+` + _(WeeChat ≥ 1.0)_ | diff --git a/doc/fr/includes/autogen_user_commands.fr.adoc b/doc/fr/includes/autogen_user_commands.fr.adoc index 18afdea01..a47c82bed 100644 --- a/doc/fr/includes/autogen_user_commands.fr.adoc +++ b/doc/fr/includes/autogen_user_commands.fr.adoc @@ -1336,24 +1336,25 @@ Pour forcer une comparaison de chaînes, vous pouvez ajouter des guillemets auto Des variables sont remplacées dans l'expression, en utilisant le format ${variable}, la variable pouvant être, par ordre de priorité : 1. une sous-chaîne évaluée (format : "eval:xxx") - 2. une chaîne avec les caractères échappés (format : "esc:xxx" ou "\xxx") - 3. une chaîne avec des caractères à cacher (format : "hide:caractère,chaîne") - 4. une chaîne avec un maximum de caractères (format : "cut:max,suffixe,chaîne" ou "cut:+max,suffixe,chaîne") + 2. une condition évaluée (format : "eval_cond:xxx") + 3. une chaîne avec les caractères échappés (format : "esc:xxx" ou "\xxx") + 4. une chaîne avec des caractères à cacher (format : "hide:caractère,chaîne") + 5. une chaîne avec un maximum de caractères (format : "cut:max,suffixe,chaîne" ou "cut:+max,suffixe,chaîne") ou un maximum de caractères affichés à l'écran (format : "cutscr:max,suffixe,chaîne" ou "cutscr:+max,suffixe,chaîne") - 5. une chaîne inversée (format : "rev:xxx" ou "revscr:xxx") - 6. une chaîne répétée (format : "repeat:nombre,chaîne") - 7. longueur d'une chaîne (format : "length:xxx" ou "lengthscr:xxx") - 8. une couleur (format : "color:xxx", voir la "Référence API extension", fonction "color") - 9. un modificateur (format : "modifier:nom,données,chaîne") - 10. une info (format : "info:nom,paramètres", les paramètres sont optionnels) - 11. une chaîne encodée/decodée en base 16, 32 ou 64 (format : "base_encode:base,xxx" ou "base_decode:base,xxx") - 12. la date/heure courante (format : "date" ou "date:format") - 13. une variable d'environnement (format : "env:XXX") - 14. un opérateur ternaire (format : "if:condition?valeur_si_vrai:valeur_si_faux") - 15. le résultat d'une expression avec parenthèses et les opérateurs + - * / // % ** (format: "calc:xxx") - 16. une option (format : "fichier.section.option") - 17. une variable locale du tampon - 18. un hdata/variable (la valeur est automatiquement convertie en chaîne), par défaut "window" et "buffer" pointent vers la fenêtre et le tampon courants. + 6. une chaîne inversée (format : "rev:xxx" ou "revscr:xxx") + 7. une chaîne répétée (format : "repeat:nombre,chaîne") + 8. longueur d'une chaîne (format : "length:xxx" ou "lengthscr:xxx") + 9. une couleur (format : "color:xxx", voir la "Référence API extension", fonction "color") + 10. un modificateur (format : "modifier:nom,données,chaîne") + 11. une info (format : "info:nom,paramètres", les paramètres sont optionnels) + 12. une chaîne encodée/decodée en base 16, 32 ou 64 (format : "base_encode:base,xxx" ou "base_decode:base,xxx") + 13. la date/heure courante (format : "date" ou "date:format") + 14. une variable d'environnement (format : "env:XXX") + 15. un opérateur ternaire (format : "if:condition?valeur_si_vrai:valeur_si_faux") + 16. le résultat d'une expression avec parenthèses et les opérateurs + - * / // % ** (format: "calc:xxx") + 17. une option (format : "fichier.section.option") + 18. une variable locale du tampon + 19. un hdata/variable (la valeur est automatiquement convertie en chaîne), par défaut "window" et "buffer" pointent vers la fenêtre et le tampon courants. Le format du hdata peut être le suivant : hdata.var1.var2... : démarrer avec un hdata (le pointeur doit être connu), et demander les variables l'une après l'autre (d'autres hdata peuvent être suivis) hdata[liste].var1.var2... : démarrer avec un hdata en utilisant une liste, par exemple : @@ -1364,6 +1365,7 @@ Le format du hdata peut être le suivant : Pour le nom du hdata et des variables, voir la "Référence API extension", fonction "weechat_hdata_get". Exemples (chaînes simples) : + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index ed6bf238d..90e253b59 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -2235,7 +2235,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" ==== string_eval_expression _WeeChat ≥ 0.4.0, mis à jour dans la 0.4.2, 0.4.3, 1.0, 1.1, 1.2, 1.3, 1.6, 1.8, -2.0, 2.2, 2.3, 2.7 et 2.9._ +2.0, 2.2, 2.3, 2.7, 2.9 et 3.1._ Évaluer l'expression et retourner le résultat sous forme de chaîne. Les variables spéciales avec le format `+${variable}+` sont étendues (voir le @@ -2564,6 +2564,12 @@ première étendue à la dernière) : `+19:02:45+` (avec des couleurs s'il y a des codes couleur dans l'option weechat.look.buffer_time_format) +| `+${eval_cond:xxx}+` + + _(WeeChat ≥ 3.1)_ | + Chaîne à évaluer comme condition. | + `+${eval_cond:${window.win_width} > 100}+` | + `+1+` + | `+${esc:xxx}+` + `+${\xxx}+` + _(WeeChat ≥ 1.0)_ | diff --git a/doc/it/includes/autogen_user_commands.it.adoc b/doc/it/includes/autogen_user_commands.it.adoc index 097a190f2..4a35cbbcb 100644 --- a/doc/it/includes/autogen_user_commands.it.adoc +++ b/doc/it/includes/autogen_user_commands.it.adoc @@ -1336,24 +1336,25 @@ To force a string comparison, you can add double quotes around each expression, Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: 1. an evaluated sub-string (format: "eval:xxx") - 2. a string with escaped chars (format: "esc:xxx" or "\xxx") - 3. a string with chars to hide (format: "hide:char,string") - 4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") + 2. an evaluated condition (format: "eval_cond:xxx") + 3. a string with escaped chars (format: "esc:xxx" or "\xxx") + 4. a string with chars to hide (format: "hide:char,string") + 5. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") - 5. a reversed string (format: "rev:xxx" or "revscr:xxx") - 6. a repeated string (format: "repeat:count,string") - 7. length of a string (format: "length:xxx" or "lengthscr:xxx") - 8. a color (format: "color:xxx", see "Plugin API reference", function "color") - 9. a modifier (format: "modifier:name,data,string") - 10. an info (format: "info:name,arguments", arguments are optional) - 11. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") - 12. current date/time (format: "date" or "date:format") - 13. an environment variable (format: "env:XXX") - 14. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 15. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 16. an option (format: "file.section.option") - 17. a local variable in buffer - 18. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 6. a reversed string (format: "rev:xxx" or "revscr:xxx") + 7. a repeated string (format: "repeat:count,string") + 8. length of a string (format: "length:xxx" or "lengthscr:xxx") + 9. a color (format: "color:xxx", see "Plugin API reference", function "color") + 10. a modifier (format: "modifier:name,data,string") + 11. an info (format: "info:name,arguments", arguments are optional) + 12. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") + 13. current date/time (format: "date" or "date:format") + 14. an environment variable (format: "env:XXX") + 15. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 16. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 17. an option (format: "file.section.option") + 18. a local variable in buffer + 19. 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: @@ -1364,6 +1365,7 @@ Format for hdata can be one of following: For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". Examples (simple strings): + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index a7588feca..35f43922e 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -2294,7 +2294,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" // 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, 2.0, -2.2, 2.3, 2.7 and 2.9._ +2.2, 2.3, 2.7, 2.9 and 3.1._ // TRANSLATION MISSING Evaluate an expression and return result as a string. @@ -2631,6 +2631,12 @@ expanded to last): `+19:02:45+` (with colors if there are color codes in the option weechat.look.buffer_time_format) +| `+${eval_cond:xxx}+` + + _(WeeChat ≥ 3.1)_ | + String to evaluate as condition. | + `+${eval_cond:${window.win_width} > 100}+` | + `+1+` + | `+${esc:xxx}+` + `+${\xxx}+` + _(WeeChat ≥ 1.0)_ | diff --git a/doc/ja/includes/autogen_user_commands.ja.adoc b/doc/ja/includes/autogen_user_commands.ja.adoc index 1a41fe941..e7d0cbdf2 100644 --- a/doc/ja/includes/autogen_user_commands.ja.adoc +++ b/doc/ja/includes/autogen_user_commands.ja.adoc @@ -1336,24 +1336,25 @@ To force a string comparison, you can add double quotes around each expression, Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: 1. an evaluated sub-string (format: "eval:xxx") - 2. a string with escaped chars (format: "esc:xxx" or "\xxx") - 3. a string with chars to hide (format: "hide:char,string") - 4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") + 2. an evaluated condition (format: "eval_cond:xxx") + 3. a string with escaped chars (format: "esc:xxx" or "\xxx") + 4. a string with chars to hide (format: "hide:char,string") + 5. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") - 5. a reversed string (format: "rev:xxx" or "revscr:xxx") - 6. a repeated string (format: "repeat:count,string") - 7. length of a string (format: "length:xxx" or "lengthscr:xxx") - 8. a color (format: "color:xxx", see "Plugin API reference", function "color") - 9. a modifier (format: "modifier:name,data,string") - 10. an info (format: "info:name,arguments", arguments are optional) - 11. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") - 12. current date/time (format: "date" or "date:format") - 13. an environment variable (format: "env:XXX") - 14. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 15. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 16. an option (format: "file.section.option") - 17. a local variable in buffer - 18. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 6. a reversed string (format: "rev:xxx" or "revscr:xxx") + 7. a repeated string (format: "repeat:count,string") + 8. length of a string (format: "length:xxx" or "lengthscr:xxx") + 9. a color (format: "color:xxx", see "Plugin API reference", function "color") + 10. a modifier (format: "modifier:name,data,string") + 11. an info (format: "info:name,arguments", arguments are optional) + 12. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") + 13. current date/time (format: "date" or "date:format") + 14. an environment variable (format: "env:XXX") + 15. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 16. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 17. an option (format: "file.section.option") + 18. a local variable in buffer + 19. 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: @@ -1364,6 +1365,7 @@ Format for hdata can be one of following: For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". Examples (simple strings): + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 0ce3866f4..419e86281 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -2214,7 +2214,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" // 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, 2.0, -2.2, 2.3, 2.7 and 2.9._ +2.2, 2.3, 2.7, 2.9 and 3.1._ 式を評価して文字列として返す。`+${variable}+` という書式で書かれた特殊変数は展開されます (以下の表を参照)。 @@ -2543,6 +2543,13 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio `+19:02:45+` (オプション weechat.look.buffer_time_format 内に色コードが存在する場合色付き) +// TRANSLATION MISSING +| `+${eval_cond:xxx}+` + + _(WeeChat バージョン 3.1 以上で利用可)_ | + String to evaluate as condition. | + `+${eval_cond:${window.win_width} > 100}+` | + `+1+` + | `+${esc:xxx}+` + `+${\xxx}+` + _(WeeChat バージョン 1.0 以上で利用可)_ | diff --git a/doc/pl/includes/autogen_user_commands.pl.adoc b/doc/pl/includes/autogen_user_commands.pl.adoc index 7cae1a8a3..73e8ee6f6 100644 --- a/doc/pl/includes/autogen_user_commands.pl.adoc +++ b/doc/pl/includes/autogen_user_commands.pl.adoc @@ -1335,24 +1335,25 @@ To force a string comparison, you can add double quotes around each expression, Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: 1. an evaluated sub-string (format: "eval:xxx") - 2. a string with escaped chars (format: "esc:xxx" or "\xxx") - 3. a string with chars to hide (format: "hide:char,string") - 4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") + 2. an evaluated condition (format: "eval_cond:xxx") + 3. a string with escaped chars (format: "esc:xxx" or "\xxx") + 4. a string with chars to hide (format: "hide:char,string") + 5. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") - 5. a reversed string (format: "rev:xxx" or "revscr:xxx") - 6. a repeated string (format: "repeat:count,string") - 7. length of a string (format: "length:xxx" or "lengthscr:xxx") - 8. a color (format: "color:xxx", see "Plugin API reference", function "color") - 9. a modifier (format: "modifier:name,data,string") - 10. an info (format: "info:name,arguments", arguments are optional) - 11. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") - 12. current date/time (format: "date" or "date:format") - 13. an environment variable (format: "env:XXX") - 14. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 15. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 16. an option (format: "file.section.option") - 17. a local variable in buffer - 18. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 6. a reversed string (format: "rev:xxx" or "revscr:xxx") + 7. a repeated string (format: "repeat:count,string") + 8. length of a string (format: "length:xxx" or "lengthscr:xxx") + 9. a color (format: "color:xxx", see "Plugin API reference", function "color") + 10. a modifier (format: "modifier:name,data,string") + 11. an info (format: "info:name,arguments", arguments are optional) + 12. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") + 13. current date/time (format: "date" or "date:format") + 14. an environment variable (format: "env:XXX") + 15. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 16. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 17. an option (format: "file.section.option") + 18. a local variable in buffer + 19. 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: @@ -1363,6 +1364,7 @@ Format for hdata can be one of following: For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". Examples (simple strings): + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 diff --git a/po/cs.po b/po/cs.po index b74c0c074..82d965cd9 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -1591,30 +1591,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1633,6 +1634,7 @@ msgid "" "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" diff --git a/po/de.po b/po/de.po index af80f5e9f..3e5fd2322 100644 --- a/po/de.po +++ b/po/de.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-10-16 16:30+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -1682,6 +1682,7 @@ msgstr "" "[-n|-s] [-d] || [-n] [-d] -c " "" +#, fuzzy msgid "" " -n: display result without sending it to buffer (debug mode)\n" " -s: split expression before evaluating it (many commands can be " @@ -1732,30 +1733,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1774,6 +1776,7 @@ msgid "" "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" diff --git a/po/es.po b/po/es.po index f52538d55..af495752e 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -1621,30 +1621,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1663,6 +1664,7 @@ msgid "" "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" diff --git a/po/fr.po b/po/fr.po index 798b47975..3f63469df 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" -"PO-Revision-Date: 2020-10-11 16:24+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" +"PO-Revision-Date: 2020-11-14 09:22+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -1704,30 +1704,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1746,6 +1747,7 @@ msgid "" "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" @@ -1830,33 +1832,34 @@ msgstr "" "Des variables sont remplacées dans l'expression, en utilisant le format " "${variable}, la variable pouvant être, par ordre de priorité :\n" " 1. une sous-chaîne évaluée (format : \"eval:xxx\")\n" -" 2. une chaîne avec les caractères échappés (format : \"esc:xxx\" ou \"\\xxx" +" 2. une condition évaluée (format : \"eval_cond:xxx\")\n" +" 3. une chaîne avec les caractères échappés (format : \"esc:xxx\" ou \"\\xxx" "\")\n" -" 3. une chaîne avec des caractères à cacher (format : \"hide:caractère," +" 4. une chaîne avec des caractères à cacher (format : \"hide:caractère," "chaîne\")\n" -" 4. une chaîne avec un maximum de caractères (format : \"cut:max,suffixe," +" 5. une chaîne avec un maximum de caractères (format : \"cut:max,suffixe," "chaîne\" ou \"cut:+max,suffixe,chaîne\")\n" " ou un maximum de caractères affichés à l'écran (format : \"cutscr:max," "suffixe,chaîne\" ou \"cutscr:+max,suffixe,chaîne\")\n" -" 5. une chaîne inversée (format : \"rev:xxx\" ou \"revscr:xxx\")\n" -" 6. une chaîne répétée (format : \"repeat:nombre,chaîne\")\n" -" 7. longueur d'une chaîne (format : \"length:xxx\" ou \"lengthscr:xxx\")\n" -" 8. une couleur (format : \"color:xxx\", voir la \"Référence API extension" +" 6. une chaîne inversée (format : \"rev:xxx\" ou \"revscr:xxx\")\n" +" 7. une chaîne répétée (format : \"repeat:nombre,chaîne\")\n" +" 8. longueur d'une chaîne (format : \"length:xxx\" ou \"lengthscr:xxx\")\n" +" 9. une couleur (format : \"color:xxx\", voir la \"Référence API extension" "\", fonction \"color\")\n" -" 9. un modificateur (format : \"modifier:nom,données,chaîne\")\n" -" 10. une info (format : \"info:nom,paramètres\", les paramètres sont " +" 10. un modificateur (format : \"modifier:nom,données,chaîne\")\n" +" 11. une info (format : \"info:nom,paramètres\", les paramètres sont " "optionnels)\n" -" 11. une chaîne encodée/decodée en base 16, 32 ou 64 (format : " +" 12. une chaîne encodée/decodée en base 16, 32 ou 64 (format : " "\"base_encode:base,xxx\" ou \"base_decode:base,xxx\")\n" -" 12. la date/heure courante (format : \"date\" ou \"date:format\")\n" -" 13. une variable d'environnement (format : \"env:XXX\")\n" -" 14. un opérateur ternaire (format : \"if:condition?valeur_si_vrai:" +" 13. la date/heure courante (format : \"date\" ou \"date:format\")\n" +" 14. une variable d'environnement (format : \"env:XXX\")\n" +" 15. un opérateur ternaire (format : \"if:condition?valeur_si_vrai:" "valeur_si_faux\")\n" -" 15. le résultat d'une expression avec parenthèses et les opérateurs + - " +" 16. le résultat d'une expression avec parenthèses et les opérateurs + - " "* / // % ** (format: \"calc:xxx\")\n" -" 16. une option (format : \"fichier.section.option\")\n" -" 17. une variable locale du tampon\n" -" 18. un hdata/variable (la valeur est automatiquement convertie en chaîne), " +" 17. une option (format : \"fichier.section.option\")\n" +" 18. une variable locale du tampon\n" +" 19. un hdata/variable (la valeur est automatiquement convertie en chaîne), " "par défaut \"window\" et \"buffer\" pointent vers la fenêtre et le tampon " "courants.\n" "Le format du hdata peut être le suivant :\n" @@ -1877,6 +1880,7 @@ msgstr "" "fonction \"weechat_hdata_get\".\n" "\n" "Exemples (chaînes simples) :\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" diff --git a/po/hu.po b/po/hu.po index 76b35806b..784d7a8fa 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1509,30 +1509,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1551,6 +1552,7 @@ msgid "" "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" diff --git a/po/it.po b/po/it.po index 484dbc0a0..3a44a8164 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -1604,30 +1604,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1646,6 +1647,7 @@ msgid "" "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" diff --git a/po/ja.po b/po/ja.po index bab42f1d8..10b92cbca 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese 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" diff --git a/po/pl.po b/po/pl.po index 177288044..11fc51ced 100644 --- a/po/pl.po +++ b/po/pl.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: Polish \n" @@ -1697,30 +1697,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1739,6 +1740,7 @@ msgid "" "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" diff --git a/po/pt.po b/po/pt.po index e8de5bae6..08f0103a2 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -1663,30 +1663,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1705,6 +1706,7 @@ msgid "" "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" diff --git a/po/pt_BR.po b/po/pt_BR.po index 56df20c3d..6b4fbbc12 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-18 11:34+0200\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -1667,30 +1667,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1709,6 +1710,7 @@ msgid "" "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" diff --git a/po/ru.po b/po/ru.po index 524b5a498..082f3e488 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2020-04-28 16:40+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -1531,30 +1531,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1573,6 +1574,7 @@ msgid "" "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" diff --git a/po/tr.po b/po/tr.po index dc8d27794..54ae58ca3 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2019-11-03 08:38+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -1362,30 +1362,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1404,6 +1405,7 @@ msgid "" "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" diff --git a/po/weechat.pot b/po/weechat.pot index 7c9855e52..49cd18503 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-10-11 16:22+0200\n" +"POT-Creation-Date: 2020-11-14 09:19+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -1364,30 +1364,31 @@ msgid "" "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\" or \"cut:" +" 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 \"lengthscr:xxx\")\n" -" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function " +" 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" +" 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 optional)\n" -" 11. a base 16/32/64 encoded/decoded string (format: \"base_encode:base,xxx" +" 10. a modifier (format: \"modifier:name,data,string\")\n" +" 11. an info (format: \"info:name,arguments\", arguments are optional)\n" +" 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: \"if:condition?value_if_true:value_if_false" +" 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 to " +" 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" @@ -1406,6 +1407,7 @@ msgid "" "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" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 0c0314c3f..40d05c94e 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -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" diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index c36192f09..4cef33685 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -188,6 +188,27 @@ eval_strstr_level (const char *string, const char *search, return NULL; } +/* + * Evaluates a condition and returns boolean result: + * "0" if false + * "1" if true + * + * Note: result must be freed after use. + */ + +char * +eval_string_eval_cond (const char *text, struct t_eval_context *eval_context) +{ + char *tmp; + int rc; + + tmp = eval_expression_condition (text, eval_context); + rc = eval_is_true (tmp); + if (tmp) + free (tmp); + return strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE); +} + /* * Hides chars in a string. * @@ -569,7 +590,7 @@ eval_string_date (const char *text) } /* - * Evaluates a condition. + * Evaluates a condition and returns evaluated if/else clause. * * Note: result must be freed after use. */ @@ -893,29 +914,30 @@ end: * Replaces variables, which can be, by order of priority: * 1. an extra variable from hashtable "extra_vars" * 2. a string to evaluate (format: eval:xxx) - * 3. a string with escaped chars (format: esc:xxx or \xxx) - * 4. a string with chars to hide (format: hide:char,string) - * 5. a string with max chars (format: cut:max,suffix,string or + * 3. a condition to evaluate (format: eval_cond:xxx) + * 4. a string with escaped chars (format: esc:xxx or \xxx) + * 5. a string with chars to hide (format: hide:char,string) + * 6. a string with max chars (format: cut:max,suffix,string or * cut:+max,suffix,string) or max chars on screen * (format: cutscr:max,suffix,string or cutscr:+max,suffix,string) - * 6. a reversed string (format: rev:xxx) or reversed string for screen, + * 7. a reversed string (format: rev:xxx) or reversed string for screen, * color codes are not reversed (format: revscr:xxx) - * 7. a repeated string (format: repeat:count,string) - * 8. length of a string (format: length:xxx) or length of a string on screen + * 8. a repeated string (format: repeat:count,string) + * 9. length of a string (format: length:xxx) or length of a string on screen * (format: lengthscr:xxx); color codes are ignored - * 9. a regex group captured (format: re:N (0.99) or re:+) - * 10. a color (format: color:xxx) - * 11. a modifier (format: modifier:name,data,xxx) - * 12. an info (format: info:name,arguments) - * 13. a base 16/32/64 encoded/decoded string (format: base_encode:base,xxx + * 10. a regex group captured (format: re:N (0.99) or re:+) + * 11. a color (format: color:xxx) + * 12. a modifier (format: modifier:name,data,xxx) + * 13. an info (format: info:name,arguments) + * 14. a base 16/32/64 encoded/decoded string (format: base_encode:base,xxx * or base_decode:base,xxx) - * 14. current date/time (format: date or date:xxx) - * 15. an environment variable (format: env:XXX) - * 16. a ternary operator (format: if:condition?value_if_true:value_if_false) - * 17. calculate result of an expression (format: calc:xxx) - * 18. an option (format: file.section.option) - * 19. a buffer local variable - * 20. a hdata variable (format: hdata.var1.var2 or hdata[list].var1.var2 + * 15. current date/time (format: date or date:xxx) + * 16. an environment variable (format: env:XXX) + * 17. a ternary operator (format: if:condition?value_if_true:value_if_false) + * 18. calculate result of an expression (format: calc:xxx) + * 19. an option (format: file.section.option) + * 20. a buffer local variable + * 21. a hdata variable (format: hdata.var1.var2 or hdata[list].var1.var2 * or hdata[ptr].var1.var2) * * See /help in WeeChat for examples. @@ -969,18 +991,25 @@ eval_replace_vars_cb (void *data, const char *text) if (strncmp (text, "eval:", 5) == 0) return eval_replace_vars (text + 5, eval_context); - /* 3. convert escaped chars */ + /* + * 3. force evaluation of condition (recursive call) + * --> use with caution: the text must be safe! + */ + if (strncmp (text, "eval_cond:", 10) == 0) + return eval_string_eval_cond (text + 10, eval_context); + + /* 4. convert escaped chars */ if (strncmp (text, "esc:", 4) == 0) return string_convert_escaped_chars (text + 4); if ((text[0] == '\\') && text[1] && (text[1] != '\\')) return string_convert_escaped_chars (text); - /* 4. hide chars: replace all chars by a given char/string */ + /* 5. hide chars: replace all chars by a given char/string */ if (strncmp (text, "hide:", 5) == 0) return eval_string_hide (text + 5); /* - * 5. cut chars: + * 6. cut chars: * cut: max number of chars, and add an optional suffix when the * string is cut * cutscr: max number of chars displayed on screen, and add an optional @@ -991,18 +1020,18 @@ eval_replace_vars_cb (void *data, const char *text) if (strncmp (text, "cutscr:", 7) == 0) return eval_string_cut (text + 7, 1); - /* 6. reverse string */ + /* 7. reverse string */ if (strncmp (text, "rev:", 4) == 0) return string_reverse (text + 4); if (strncmp (text, "revscr:", 7) == 0) return string_reverse_screen (text + 7); - /* 7. repeated string */ + /* 8. repeated string */ if (strncmp (text, "repeat:", 7) == 0) return eval_string_repeat (text + 7); /* - * 8. length of string: + * 9. length of string: * length: number of chars * lengthscr: number of chars displayed on screen */ @@ -1019,33 +1048,33 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (str_value); } - /* 9. regex group captured */ + /* 10. regex group captured */ if (strncmp (text, "re:", 3) == 0) return eval_string_regex_group (text + 3, eval_context); - /* 10. color code */ + /* 11. color code */ if (strncmp (text, "color:", 6) == 0) return eval_string_color (text + 6); - /* 11. modifier */ + /* 12. modifier */ if (strncmp (text, "modifier:", 9) == 0) return eval_string_modifier (text + 9); - /* 12. info */ + /* 13. info */ if (strncmp (text, "info:", 5) == 0) return eval_string_info (text + 5); - /* 13. base_encode/base_decode */ + /* 14. base_encode/base_decode */ if (strncmp (text, "base_encode:", 12) == 0) return eval_string_base_encode (text + 12); if (strncmp (text, "base_decode:", 12) == 0) return eval_string_base_decode (text + 12); - /* 14. current date/time */ + /* 15. current date/time */ if ((strncmp (text, "date", 4) == 0) && (!text[4] || (text[4] == ':'))) return eval_string_date (text + 4); - /* 15. environment variable */ + /* 16. environment variable */ if (strncmp (text, "env:", 4) == 0) { ptr_value = getenv (text + 4); @@ -1053,18 +1082,18 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (ptr_value); } - /* 16: ternary operator: if:condition?value_if_true:value_if_false */ + /* 17: ternary operator: if:condition?value_if_true:value_if_false */ if (strncmp (text, "if:", 3) == 0) return eval_string_if (text + 3, eval_context); /* - * 17. calculate the result of an expression + * 18. calculate the result of an expression * (with number, operators and parentheses) */ if (strncmp (text, "calc:", 5) == 0) return calc_expression (text + 5); - /* 18. option: if found, return this value */ + /* 19. option: if found, return this value */ if (strncmp (text, "sec.data.", 9) == 0) { ptr_value = hashtable_get (secure_hashtable_data, text + 9); @@ -1094,7 +1123,7 @@ eval_replace_vars_cb (void *data, const char *text) } } - /* 19. local variable in buffer */ + /* 20. local variable in buffer */ ptr_buffer = hashtable_get (eval_context->pointers, "buffer"); if (ptr_buffer) { @@ -1103,7 +1132,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (ptr_value); } - /* 20. hdata */ + /* 21. hdata */ return eval_string_hdata (text, eval_context); } diff --git a/tests/unit/core/test-core-eval.cpp b/tests/unit/core/test-core-eval.cpp index a5821ab9a..5e5f9762b 100644 --- a/tests/unit/core/test-core-eval.cpp +++ b/tests/unit/core/test-core-eval.cpp @@ -384,6 +384,11 @@ TEST(CoreEval, EvalExpression) /* test eval of substring */ WEE_CHECK_EVAL("\t", "${eval:${\\t}}"); + /* test eval of condition */ + WEE_CHECK_EVAL("0", "${eval_cond:}"); + WEE_CHECK_EVAL("0", "${eval_cond:${buffer.number} == 2}"); + WEE_CHECK_EVAL("1", "${eval_cond:${buffer.number} == 1}"); + /* test value from extra_vars */ WEE_CHECK_EVAL("value", "${test}");