From d89c4f559c817a92da94d98baf9f3829238b0392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 3 Aug 2021 19:46:41 +0200 Subject: [PATCH] api: add random integer number in evaluation of expressions with "random:min,max" --- ChangeLog.adoc | 1 + doc/de/includes/autogen_user_commands.de.adoc | 158 +++++++++--------- doc/en/includes/autogen_user_commands.en.adoc | 10 +- doc/en/weechat_plugin_api.en.adoc | 8 +- doc/fr/includes/autogen_user_commands.fr.adoc | 10 +- doc/fr/weechat_plugin_api.fr.adoc | 8 +- doc/it/includes/autogen_user_commands.it.adoc | 10 +- doc/it/weechat_plugin_api.it.adoc | 8 +- doc/ja/includes/autogen_user_commands.ja.adoc | 10 +- doc/ja/weechat_plugin_api.ja.adoc | 9 +- doc/pl/includes/autogen_user_commands.pl.adoc | 136 +++++++-------- doc/sr/includes/autogen_user_commands.sr.adoc | 136 +++++++-------- doc/sr/weechat_plugin_api.sr.adoc | 9 +- po/cs.po | 12 +- po/de.po | 147 +++++++++++++++- po/es.po | 12 +- po/fr.po | 24 +-- po/hu.po | 12 +- po/it.po | 12 +- po/ja.po | 12 +- po/pl.po | 147 +++++++++++++++- po/pt.po | 12 +- po/pt_BR.po | 12 +- po/ru.po | 12 +- po/sr.po | 147 +++++++++++++++- po/tr.po | 12 +- po/weechat.pot | 12 +- src/core/wee-command.c | 10 +- src/core/wee-eval.c | 78 ++++++++- src/core/weechat.c | 6 + tests/unit/core/test-core-eval.cpp | 21 ++- 31 files changed, 892 insertions(+), 321 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 13c0f9ebb..df2ba226e 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] New features:: * core: add option "certs" in command /debug + * api: add random integer number in evaluation of expressions with "random:min,max" * api: add function string_cut * api: add function file_copy (issue #1667) * api: remember insertion order in hashtables diff --git a/doc/de/includes/autogen_user_commands.de.adoc b/doc/de/includes/autogen_user_commands.de.adoc index 119038324..ecfb25dc1 100644 --- a/doc/de/includes/autogen_user_commands.de.adoc +++ b/doc/de/includes/autogen_user_commands.de.adoc @@ -1334,82 +1334,83 @@ infolists: zeigt Information über die Infolists an /eval [-n|-s] [-d] [-n] [-d [-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 (Nutzung von zwei -d: ausführliche Debug-Ausgabe) - -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 (with two -d: more verbose debug) + -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. die Zeichenfolge selbst ohne Auswertung (Format: "raw:xxx")\n - 2. eine evaluierte Teilzeichenkette (Format: "eval:xxx") - 3. eine evaluierte Bedingung (Format: "eval_cond:xxx") - 4. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx") - 5. Zeichen, die in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette") - 6. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:max,suffix,string" oder "cut:+max,suffix,string") - oder maximale Anzahl an Zeichen die auf dem Bildschirm angezeigt werden sollen (Format: "cutscr:Max,Suffix,Zeichenkette oder "cutscr:+Max,Suffix,Zeichenkette") - 7. eine Zeichenkette umkehren (Format: "rev:xxx" oder "revscr:xxx") - 8. eine Zeichenkette wiederholen (Format: "repeat:Anzahl,Zeichenkette") - 9. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx") - 10. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color") - 11. zum modifizieren (Format: "modifier:name,data,string") - 12. eine Info (Format: "Info:Name,Argumente", Argumente sind optional) - 13. eine Basis 16/32/64 kodierte / dekodierte Zeichenfolge (Format: "base_encode:base,xxx" oder "base_decode:base,xxx") - 14. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format") - 15. eine Umgebungsvariable (Format: "env:XXX") - 16. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr") - 17. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % ** (Format: "calc:xxx") - 18. eine übersetzte Zeichenkette (Format: "translate:xxx") - 19. eine Option (Format: "file.section.option") - 20. eine lokale Variable eines Buffers - 21. 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) - ${buffer[my_pointer].full_name}: vollständiger Name des Buffers mit dem entsprechenden Pointernamen (kann in Triggern verwendet 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. the string itself without evaluation (format: "raw:xxx") + 2. an evaluated sub-string (format: "eval:xxx") + 3. an evaluated condition (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 displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") + 7. a reversed string (format: "rev:xxx" or "revscr:xxx") + 8. a repeated string (format: "repeat:count,string") + 9. length of a string (format: "length:xxx" or "lengthscr:xxx") + 10. a color (format: "color:xxx", see "Plugin API reference", function "color") + 11. a modifier (format: "modifier:name,data,string") + 12. an info (format: "info:name,arguments", arguments are optional) + 13. 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:format") + 15. an environment variable (format: "env:XXX") + 16. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 17. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 18. a random integer number (format: "random:min,max") + 19. a translated string (format: "translate:xxx") + 20. an option (format: "file.section.option") + 21. a local variable in buffer + 22. 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/pointer/pointer name, 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) + ${buffer[my_pointer].full_name}: full name of the buffer with this pointer name (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 ${raw:${info:version}} ==> ${info:version} /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.password} ==> geheim + /eval -n ${sec.data.password} ==> secret /eval -n ${window} ==> 0x2549aa0 /eval -n ${window.buffer} ==> 0x2549320 /eval -n ${window.buffer.full_name} ==> core.weechat @@ -1424,21 +1425,22 @@ Beispiele (einfache Zeichenketten): /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test - /eval -n ${translate:Plugin} ==> Erweiterung + /eval -n ${translate:Plugin} ==> Extension -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 87a6e4040..6604d2496 100644 --- a/doc/en/includes/autogen_user_commands.en.adoc +++ b/doc/en/includes/autogen_user_commands.en.adoc @@ -1389,10 +1389,11 @@ Some variables are replaced in expression, using the format ${variable}, variabl 15. an environment variable (format: "env:XXX") 16. a ternary operator (format: "if:condition?value_if_true:value_if_false") 17. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 18. a translated string (format: "translate:xxx") - 19. an option (format: "file.section.option") - 20. a local variable in buffer - 21. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 18. a random integer number (format: "random:min,max") + 19. a translated string (format: "translate:xxx") + 20. an option (format: "file.section.option") + 21. a local variable in buffer + 22. 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/pointer/pointer name, for example: @@ -1424,6 +1425,7 @@ Examples (simple strings): /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test /eval -n ${translate:Plugin} ==> Extension diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index 8a6f43ea4..f1751f4f7 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -2253,7 +2253,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, 2.9, 3.1 and 3.2._ +2.2, 2.3, 2.7, 2.9, 3.1, 3.2 and 3.3._ Evaluate an expression and return result as a string. Special variables with format `+${variable}+` are expanded (see table below). @@ -2796,6 +2796,12 @@ expanded to last): `+0.2+` + `+65536+` +| `+${random:min,max}+` + + _(WeeChat ≥ 3.3)_ | + Random integer number in the range from `min` to `max` (inclusive). | + `+${random:0,10}+` | + `+3+` + | `+${translate:xxx}+` + _(WeeChat ≥ 3.2)_ | Translated string (depends on the language used by WeeChat to display messages). | diff --git a/doc/fr/includes/autogen_user_commands.fr.adoc b/doc/fr/includes/autogen_user_commands.fr.adoc index 0ecc5e7e1..ef2daad69 100644 --- a/doc/fr/includes/autogen_user_commands.fr.adoc +++ b/doc/fr/includes/autogen_user_commands.fr.adoc @@ -1389,10 +1389,11 @@ Des variables sont remplacées dans l'expression, en utilisant le format ${varia 15. une variable d'environnement (format : "env:XXX") 16. un opérateur ternaire (format : "if:condition?valeur_si_vrai:valeur_si_faux") 17. le résultat d'une expression avec parenthèses et les opérateurs + - * / // % ** (format: "calc:xxx") - 18. une chaîne traduite (format : "translate:xxx") - 19. une option (format : "fichier.section.option") - 20. une variable locale du tampon - 21. 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. + 18. un nombre entier aléatoire (format : "random:min,max") + 19. une chaîne traduite (format : "translate:xxx") + 20. une option (format : "fichier.section.option") + 21. une variable locale du tampon + 22. 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/pointeur/nom de pointeur, par exemple : @@ -1424,6 +1425,7 @@ Exemples (chaînes simples) : /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test /eval -n ${translate:Plugin} ==> Extension diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index 6dd686f8a..b7b6b777a 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -2291,7 +2291,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, 2.9, 3.1 et 3.2._ +2.0, 2.2, 2.3, 2.7, 2.9, 3.1, 3.2 et 3.3._ É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 @@ -2842,6 +2842,12 @@ première étendue à la dernière) : `+0.2+` + `+65536+` +| `+${random:min,max}+` + + _(WeeChat ≥ 3.3)_ | + Nombre entier aléatoire dans l'intervalle de `min` à `max` (inclus). | + `+${random:0,10}+` | + `+3+` + | `+${translate:xxx}+` + _(WeeChat ≥ 3.2)_ | Chaîne traduite (dépend de la langue utilisée par WeeChat pour afficher les diff --git a/doc/it/includes/autogen_user_commands.it.adoc b/doc/it/includes/autogen_user_commands.it.adoc index bfa0abee7..05bb80097 100644 --- a/doc/it/includes/autogen_user_commands.it.adoc +++ b/doc/it/includes/autogen_user_commands.it.adoc @@ -1389,10 +1389,11 @@ Some variables are replaced in expression, using the format ${variable}, variabl 15. an environment variable (format: "env:XXX") 16. a ternary operator (format: "if:condition?value_if_true:value_if_false") 17. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 18. a translated string (format: "translate:xxx") - 19. an option (format: "file.section.option") - 20. a local variable in buffer - 21. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 18. a random integer number (format: "random:min,max") + 19. a translated string (format: "translate:xxx") + 20. an option (format: "file.section.option") + 21. a local variable in buffer + 22. 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/pointer/pointer name, for example: @@ -1424,6 +1425,7 @@ Examples (simple strings): /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test /eval -n ${translate:Plugin} ==> Extension diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index 6840f374f..671eb2fbf 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -2351,7 +2351,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, 2.9, 3.1 and 3.2._ +2.2, 2.3, 2.7, 2.9, 3.1, 3.2 and 3.3._ Evaluate an expression and return result as a string. Special variables with format `+${variable}+` are expanded (see table below). @@ -2893,6 +2893,12 @@ expanded to last): `+0.2+` + `+65536+` +| `+${random:min,max}+` + + _(WeeChat ≥ 3.3)_ | + Random integer number in the range from `min` to `max` (inclusive). | + `+${random:0,10}+` | + `+3+` + | `+${translate:xxx}+` + _(WeeChat ≥ 3.2)_ | Translated string (depends on the language used by WeeChat to display messages). | diff --git a/doc/ja/includes/autogen_user_commands.ja.adoc b/doc/ja/includes/autogen_user_commands.ja.adoc index 21aca71da..d180d219b 100644 --- a/doc/ja/includes/autogen_user_commands.ja.adoc +++ b/doc/ja/includes/autogen_user_commands.ja.adoc @@ -1389,10 +1389,11 @@ Some variables are replaced in expression, using the format ${variable}, variabl 15. an environment variable (format: "env:XXX") 16. a ternary operator (format: "if:condition?value_if_true:value_if_false") 17. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 18. a translated string (format: "translate:xxx") - 19. an option (format: "file.section.option") - 20. a local variable in buffer - 21. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. + 18. a random integer number (format: "random:min,max") + 19. a translated string (format: "translate:xxx") + 20. an option (format: "file.section.option") + 21. a local variable in buffer + 22. 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/pointer/pointer name, for example: @@ -1424,6 +1425,7 @@ Examples (simple strings): /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test /eval -n ${translate:Plugin} ==> Extension diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 13b95e648..60b94aa98 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -2274,7 +2274,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, 2.9, 3.1 and 3.2._ +2.2, 2.3, 2.7, 2.9, 3.1, 3.2 and 3.3._ 式を評価して文字列として返す。`+${variable}+` という書式で書かれた特殊変数は展開されます (以下の表を参照)。 @@ -2835,6 +2835,13 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio `+0.2+` + `+65536+` +// TRANSLATION MISSING +| `+${random:min,max}+` + + _(WeeChat ≥ 3.3)_ | + Random integer number in the range from `min` to `max` (inclusive). | + `+${random:0,10}+` | + `+3+` + // TRANSLATION MISSING | `+${translate:xxx}+` + _(WeeChat ≥ 3.2)_ | diff --git a/doc/pl/includes/autogen_user_commands.pl.adoc b/doc/pl/includes/autogen_user_commands.pl.adoc index 51e539c03..1c0ab6cfc 100644 --- a/doc/pl/includes/autogen_user_commands.pl.adoc +++ b/doc/pl/includes/autogen_user_commands.pl.adoc @@ -1333,76 +1333,77 @@ infolists: wyświetla informacje o infolistach /eval [-n|-s] [-d] [-n] [-d [-d]] -c - -n: wyświetla wynik bez wysyłania go do buforu (tryb debugowania) - -s: podziel wyrażenie przed przetworzeniem go (wiele komend może być oddzielonych średnikami) - -d: wyświetl wyjście debugowe po ewaluacji (drugie -d wyświetli więcej informacji) - -c: przetwarza jako warunek: użyj operatorów i nawiasów, zwraca wartość logiczną ("0" lub "1") -wyrażenie: wyrażenie do przetworzenia, zmienne o formacie ${zmienna} są zastępowane (zobacz niżej); wiele komend można oddzielić średnikami - operator: operator logiczny lub porównania: - - operatory logiczne: - && logiczne „i” - || logiczne „lub” - - operatory porównania: - == równy - != różny - <= mniejszy lub równy - < mniejszy - >= większy lub równy - > większy - =~ pasuje do rozszerzonego wyrażenia regularnego POSIX - !~ NIE pasuje do rozszerzonego wyrażenia regularnego POSIX - ==* pasuje do maski, rozróżnia wielkość znaków (dzika karta „*” dozwolona) - !!* NIE pasuje do maski, rozróżnia wielkość znaków (dzika karta „*” dozwolona) - =* pasuje do maski, nie rozróżnia wielkość znaków (dzika karta „*” dozwolona) - !* NIE pasuje do maski, nie rozróżnia wielkość znaków (dzika karta „*” dozwolona) - ==- jest zawarte, rozróżnia wielkość znaków - !!- NIE jest zawarte,rozróżnia wielkość znaków - =- jest zawarte, nie rozróżnia wielkość znaków - !- NIE jest zawarte, nie rozróżnia wielkość znaków + -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 (with two -d: more verbose debug) + -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 -Wyrażenie jest uznawane za „prawdziwe” jeśli nie jest NULL, nie jest puste, oraz różni się od „0”. -Porównania dokonuje się z użyciem liczb całkowitych jeśli oba wyrażenia są liczbami całkowitymi, w jednym z następujących formatów: - - liczby całkowite (przykłady: 5, -7) - - liczby zmiennoprzecinkowe (przykłady: 5.2, -7.5, 2.83e-2) - - liczby szesnastkowe (przykłady: 0xA3, -0xA3) -W celu wymuszenia porównywania ciągów, należy umieścić każde wyrażenie w cudzysłowie, na przykład: +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 -Niektóre zmienne w wyrażeniach są zamieniane, poprzez zastosowanie formatu ${zmienna}, według priorytetu zmienną może być: - 1. nieprzetworzony ciąg (format: "raw:xxx") - 2. przetworzony ciąg (format: "eval:xxx") - 3. przetworzony warunek (format: "eval_cond:xxx") - 4. ciąg z wyescapowanymi znakami (format: "esc:xxx" lub "\xxx") - 5. ciąg ze znakami do ukrycia (format: "hide:char,string") - 6. ciąg o maksymalnej długości (format: "cut:max,suffix,string" lub "cut:+max,suffix,string") - lub maksymalna ilość znaków wyświetlanych na ekranie (format: "cutscr:max,suffix,string" lub "cutscr:+max,suffix,string") - 7. odwrócony ciąg (format: "rev:xxx") - 8. powtórzony ciąg (format: "repeat:ilość,ciąg") - 9. długość ciągu (format: "length:xxx" or "lengthscr:xxx") - 10. kolor (format "color:xxx", zobacz „Opis API wtyczek”, funkcja "color") - 11. modyfikator (format: "modifier:name,data,string") - 12. informacja (format: "info:nazwa,argumenty", argumenty są opcjonalne) - 13. ciąg zakodowany/zdekodowany z base 16/32/64 (format: "base_encode:base,xxx" lub "base_decode:base,xxx") - 14. obecna data/czas (format: "date" lub "date:format") - 15. zmienna środowiskowa (format: "env:XXX") - 16. wyrażenie warunkowe (format: "if:condition?value_if_true:value_if_false") - 17. wynik wyrażenia z nawiasami i operatorami + - * / // % ** (format: "calc:xxx") - 18. przetłumaczony ciąg (format: "translate:xxx") - 19. opcja (format: plik.sekcja.opcja) - 20. zmienna lokalna w buforze - 21. nazwa hdatay/zmiennej (wartość jest automatycznie konwertowana na ciąg znaków), domyślnie „window” i „buffer” wskazują na aktualne okno/bufor. -Format dla hdata może być jednym z poniższych: - hdata.zmienna1.zmienna2...: inicjuje hdata (wskaźnik musi być znany), następnie wypytuje zmienne jedna po drugiej (inne hdata mogą być następne) - hdata[list].zmienna1.zmienna2...: inicjuje hdata z wykorzystaniem listy, na przykład: - ${buffer[gui_buffers].full_name}: pełna nazwa buforu w połączonej liście buforów - ${plugin[weechat_plugins].name}: nazwa pierwszej wtyczki w połączonej liście wtyczek - hdata[wskaźnik].zmienna1.zmienna2...: zacznij z hdata używając wskaźnika, na przykład: - ${buffer[0x1234abcd].full_name}: pełna nazwa buforu z tym wskaźnikiem (może zostać użyte w triggerach) - ${buffer[my_pointer].full_name}: pełna nazwa buforu z jego wskaźnikiem (może zostać użyte w triggerach) -Nazwy hdata i zmiennych, można znaleźć w „Opisie API wtyczek”, funkcja "weechat_hdata_get". +Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: + 1. the string itself without evaluation (format: "raw:xxx") + 2. an evaluated sub-string (format: "eval:xxx") + 3. an evaluated condition (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 displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") + 7. a reversed string (format: "rev:xxx" or "revscr:xxx") + 8. a repeated string (format: "repeat:count,string") + 9. length of a string (format: "length:xxx" or "lengthscr:xxx") + 10. a color (format: "color:xxx", see "Plugin API reference", function "color") + 11. a modifier (format: "modifier:name,data,string") + 12. an info (format: "info:name,arguments", arguments are optional) + 13. 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:format") + 15. an environment variable (format: "env:XXX") + 16. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 17. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 18. a random integer number (format: "random:min,max") + 19. a translated string (format: "translate:xxx") + 20. an option (format: "file.section.option") + 21. a local variable in buffer + 22. 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/pointer/pointer name, 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) + ${buffer[my_pointer].full_name}: full name of the buffer with this pointer name (can be used in triggers) +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -Przykłady (proste ciągi): +Examples (simple strings): /eval -n ${raw:${info:version}} ==> ${info:version} /eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${info:version} ==> 0.4.3 @@ -1423,11 +1424,12 @@ Przykłady (proste ciągi): /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test - /eval -n ${translate:Plugin} ==> Wtyczka + /eval -n ${translate:Plugin} ==> Extension -Przykłady (warunki): +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 diff --git a/doc/sr/includes/autogen_user_commands.sr.adoc b/doc/sr/includes/autogen_user_commands.sr.adoc index cbcb40abe..6b35a0a2a 100644 --- a/doc/sr/includes/autogen_user_commands.sr.adoc +++ b/doc/sr/includes/autogen_user_commands.sr.adoc @@ -1334,82 +1334,83 @@ infolists: исписује инфо о инфолистама /eval [-n|-s] [-d] <израз> [-n] [-d [-d]] -c <израз1> <оператор> <израз2> - -n: приказује резултат и не шаље га у бафер (дибаг режим) - -s: дели израз пре израчунавања (многе команде могу да се раздвоје са тачка зарезима) - -d: приказује дибаг излаз након израчунавања (са два -d: детаљнији дибаг) - -c: израчунава као услов: користе се оператори и заграде, враћа логичку вредност („0” или „1”) - израз: израз који се израчунава, променљиве у формату ${променљива} се замењују (погледајте испод); више команди може да се раздвоји са тачка зарезима - оператор: логички или оператор поређења: - - логички оператори: - && логичко „и” - || логичко „или” - - оператори поређења: - == једнако - != није једнако - <= мање или једнако - < мање - >= веће или једнако - > веће - =~ подудара се са POSIX проширеним регуларним изразом - !~ НЕ подудара се са POSIX проширеним регуларним изразом - ==* је маска подударања, разликује величину слова (дозвољен је џокер „*”) - !!* НИЈЕ маска подударања, разликује величину слова (дозвољен је џокер „*”) - =* је маска подударања, не разликује величину слова (дозвољен је џокер „*”) - !* НИЈЕ маска подударања, не разликује величину слова (дозвољен је џокер „*”) - ==- је укључено, разликује величину слова - !!- НИЈЕ укључено, разликује величину слова - =- је укључено, не разликује величину слова - !- НИЈЕ укључено, не разликује величину слова + -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 (with two -d: more verbose debug) + -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 -Сматра се да је израз „true” ако није NULL, није празан и различит је од „0”. -Поређење се врши употребом бројева у покретном зарезу ако су два израза важећи бројеви, у једном од следећих формата: - - целобројни (примери: 5, -7) - - број у покретном зарезу (примери: 5.2, -7.5, 2.83e-2) - - хексадецимални број (примери: 0xA3, -0xA3) -Ако желите да форсирате поређење стрингова, можете да додате знаке навода око сваког израза, на пример: +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 -У изразима се замењују неке променљиве, користећи формат ${променљива}, променљива може да буде, према редоследу приоритета: - 1. сам стринг без израчунавања (формат: „raw:xxx”) - 2. израчунати под-стринг (формат: „eval:xxx”) - 3. израчунати услов (формат: „eval_cond:xxx”) - 4. стринг са означеним карактерима (формат: „esc:xxx” или „\xxx”) - 5. стринг са карактерима за сакривање (формат: „hide:кар,стринг”) - 6. стринг са највише карактера (формат: „cut:макс,суфикс,стринг” или „cut:+макс,суфикс,стринг") - или макс број карактера који се приказује на екрану (формат: „cutscr:макс,суфикс,стринг” или „cutscr:+макс,суфикс,стринг”) - 7. обрнути стринг (формат: „rev:xxx” или „revscr:xxx”) - 8. поновљени стринг (формат: „repeat:број,стринг”) - 9. дужина стринга (формат: „length:xxx” или „lengthscr:xxx”) - 10. боја (формат: „color:xxx”, погледајте „Референтни приручник API додатака”, функција „color”) - 11. модификатор (формат: „modifier:име,подаци,стринг”) - 12. инфо (формат: „info:име,аргументи”, аргументи нису обавезни) - 13. base 16/32/64 шифриран/дешифрован стринг (формат: „base_encode:основа,xxx” или „base_decode:основа,xxx”) - 14. текући датум/време (формат: „date” или „date:формат”) - 15. променљива окружења (формат: „env:XXX”) - 16. тернарни оператор (формат: „if:услов?вредност_ако_је_тачно:вредност_ако_је_нетачно”) - 17. резултат израза са заградама и операторима + - * / // % ** (формат: „calc:xxx”) - 18. преведени стринг (формат: „translate:xxx”) - 19. опција (формат: „фајл.секција.опција”) - 20. локална променљива у баферу - 21. hdata име/променљива (вредност се аутоматски конвертује у стринг), „window” и „buffer” подразумевано показују на текући прозор/бафер. -Формат за hdata може да буде једно од следећег: - hdata.пром1.пром2...: почиње са hdata (показивач мора да буде познат), и пита променљиве једну за другом (могу да следе и остала hdata) - hdata[листа].пром1.пром2...: почиње са hdata користећи листу, на пример: - ${buffer[gui_buffers].full_name}: пуно име првог бафера у увезаној листи бафера - ${plugin[weechat_plugins].name}: име првог бафера у увезаној листи додатака - hdata[показивач].пром1.пром2...: почиње са hdata користећи показивач, на пример: - ${buffer[0x1234abcd].full_name}: пуно име бафера са овим показивачем (може да се користи у окидачима) - ${buffer[my_pointer].full_name}: пуно име бафера са овим именом показивача (може да се користи у окидачима) -У вези имена hdata и променљивих, молим вас да погледате „Референтни приручник API додатака”, функцију „weechat_hdata_get”. +Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: + 1. the string itself without evaluation (format: "raw:xxx") + 2. an evaluated sub-string (format: "eval:xxx") + 3. an evaluated condition (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 displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") + 7. a reversed string (format: "rev:xxx" or "revscr:xxx") + 8. a repeated string (format: "repeat:count,string") + 9. length of a string (format: "length:xxx" or "lengthscr:xxx") + 10. a color (format: "color:xxx", see "Plugin API reference", function "color") + 11. a modifier (format: "modifier:name,data,string") + 12. an info (format: "info:name,arguments", arguments are optional) + 13. 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:format") + 15. an environment variable (format: "env:XXX") + 16. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 17. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 18. a random integer number (format: "random:min,max") + 19. a translated string (format: "translate:xxx") + 20. an option (format: "file.section.option") + 21. a local variable in buffer + 22. 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/pointer/pointer name, 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) + ${buffer[my_pointer].full_name}: full name of the buffer with this pointer name (can be used in triggers) +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -Примери (једноставни стрингови): +Examples (simple strings): /eval -n ${raw:${info:version}} ==> ${info:version} /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} ==> secret + /eval -n ${sec.data.password} ==> secret /eval -n ${window} ==> 0x2549aa0 /eval -n ${window.buffer} ==> 0x2549320 /eval -n ${window.buffer.full_name} ==> core.weechat @@ -1424,11 +1425,12 @@ infolists: исписује инфо о инфолистама /eval -n ${repeat:5,-} ==> ----- /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 /eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_decode:64,dGVzdA==} ==> test /eval -n ${translate:Plugin} ==> Extension -Примери (услови): +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 diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index b114f2b34..5a6c71624 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -2160,7 +2160,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" ==== string_eval_expression -_WeeChat ≥ 0.4.0, ажурирано у верзијама 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, 2.9, 3.1 и 3.2._ +_WeeChat ≥ 0.4.0, ажурирано у верзијама 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, 2.9, 3.1, 3.2 и 3.3._ Израчунава израз и враћа вредност као стринг. Специјалне променљиве у формату `+${променљива}+` се развијају (погледајте табелу испод). @@ -2680,6 +2680,13 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio `+0.2+` + `+65536+` +// TRANSLATION MISSING +| `+${random:min,max}+` + + _(WeeChat ≥ 3.3)_ | + Random integer number in the range from `min` to `max` (inclusive). | + `+${random:0,10}+` | + `+3+` + | `+${translate:xxx}+` + _(WeeChat ≥ 3.2)_ | Преведени стринг (зависи од језика који програм WeeChat користи за приказ порука). | diff --git a/po/cs.po b/po/cs.po index bd7e6fd21..63fa1db60 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -1617,10 +1617,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1662,6 +1663,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/de.po b/po/de.po index 154fbc62e..509e3584b 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-08-03 18:29+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -1686,6 +1686,141 @@ msgstr "" "[-n|-s] [-d] || [-n] [-d [-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 " +#| "separated by semicolons)\n" +#| " -d: display debug output after evaluation (with two -d: more " +#| "verbose debug)\n" +#| " -c: evaluate as condition: use operators and parentheses, return " +#| "a boolean value (\"0\" or \"1\")\n" +#| "expression: expression to evaluate, variables with format ${variable} are " +#| "replaced (see below); many commands can be separated by semicolons\n" +#| " operator: a logical or comparison operator:\n" +#| " - logical operators:\n" +#| " && boolean \"and\"\n" +#| " || boolean \"or\"\n" +#| " - comparison operators:\n" +#| " == equal\n" +#| " != not equal\n" +#| " <= less or equal\n" +#| " < less\n" +#| " >= greater or equal\n" +#| " > greater\n" +#| " =~ is matching POSIX extended regex\n" +#| " !~ is NOT matching POSIX extended regex\n" +#| " ==* is matching mask, case sensitive (wildcard \"*\" is " +#| "allowed)\n" +#| " !!* is NOT matching mask, case sensitive (wildcard \"*\" " +#| "is allowed)\n" +#| " =* is matching mask, case insensitive (wildcard \"*\" " +#| "is allowed)\n" +#| " !* is NOT matching mask, case insensitive (wildcard \"*" +#| "\" is allowed)\n" +#| " ==- is included, case sensitive\n" +#| " !!- is NOT included, case sensitive\n" +#| " =- is included, case insensitive\n" +#| " !- is NOT included, case insensitive\n" +#| "\n" +#| "An expression is considered as \"true\" if it is not NULL, not empty, and " +#| "different from \"0\".\n" +#| "The comparison is made using floating point numbers if the two " +#| "expressions are valid numbers, with one of the following formats:\n" +#| " - integer (examples: 5, -7)\n" +#| " - floating point number (examples: 5.2, -7.5, 2.83e-2)\n" +#| " - hexadecimal number (examples: 0xA3, -0xA3)\n" +#| "To force a string comparison, you can add double quotes around each " +#| "expression, for example:\n" +#| " 50 > 100 ==> 0\n" +#| " \"50\" > \"100\" ==> 1\n" +#| "\n" +#| "Some variables are replaced in expression, using the format ${variable}, " +#| "variable can be, by order of priority:\n" +#| " 1. the string itself without evaluation (format: \"raw:xxx\")\n" +#| " 2. an evaluated sub-string (format: \"eval:xxx\")\n" +#| " 3. an evaluated condition (format: \"eval_cond:xxx\")\n" +#| " 4. a string with escaped chars (format: \"esc:xxx\" or \"\\xxx\")\n" +#| " 5. a string with chars to hide (format: \"hide:char,string\")\n" +#| " 6. 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" +#| " 7. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n" +#| " 8. a repeated string (format: \"repeat:count,string\")\n" +#| " 9. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n" +#| " 10. a color (format: \"color:xxx\", see \"Plugin API reference\", " +#| "function \"color\")\n" +#| " 11. a modifier (format: \"modifier:name,data,string\")\n" +#| " 12. an info (format: \"info:name,arguments\", arguments are optional)\n" +#| " 13. a base 16/32/64 encoded/decoded string (format: \"base_encode:base," +#| "xxx\" or \"base_decode:base,xxx\")\n" +#| " 14. current date/time (format: \"date\" or \"date:format\")\n" +#| " 15. an environment variable (format: \"env:XXX\")\n" +#| " 16. a ternary operator (format: \"if:condition?value_if_true:" +#| "value_if_false\")\n" +#| " 17. result of an expression with parentheses and operators + - * / // % " +#| "** (format: \"calc:xxx\")\n" +#| " 18. a translated string (format: \"translate:xxx\")\n" +#| " 19. an option (format: \"file.section.option\")\n" +#| " 20. a local variable in buffer\n" +#| " 21. 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" +#| " hdata.var1.var2...: start with a hdata (pointer must be known), and ask " +#| "variables one after one (other hdata can be followed)\n" +#| " hdata[list].var1.var2...: start with a hdata using a list/pointer/" +#| "pointer name, for example:\n" +#| " ${buffer[gui_buffers].full_name}: full name of first buffer in linked " +#| "list of buffers\n" +#| " ${plugin[weechat_plugins].name}: name of first plugin in linked list " +#| "of plugins\n" +#| " hdata[pointer].var1.var2...: start with a hdata using a pointer, for " +#| "example:\n" +#| " ${buffer[0x1234abcd].full_name}: full name of the buffer with this " +#| "pointer (can be used in triggers)\n" +#| " ${buffer[my_pointer].full_name}: full name of the buffer with this " +#| "pointer name (can be used in triggers)\n" +#| "For name of hdata and variables, please look at \"Plugin API reference\", " +#| "function \"weechat_hdata_get\".\n" +#| "\n" +#| "Examples (simple strings):\n" +#| " /eval -n ${raw:${info:version}} ==> ${info:version}\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" +#| " /eval -n ${sec.data.password} ==> secret\n" +#| " /eval -n ${window} ==> 0x2549aa0\n" +#| " /eval -n ${window.buffer} ==> 0x2549320\n" +#| " /eval -n ${window.buffer.full_name} ==> core.weechat\n" +#| " /eval -n ${window.buffer.number} ==> 1\n" +#| " /eval -n ${\\t} ==> \n" +#| " /eval -n ${hide:-,${relay.network.password}} ==> --------\n" +#| " /eval -n ${cut:3,+,test} ==> tes+\n" +#| " /eval -n ${cut:+3,+,test} ==> te+\n" +#| " /eval -n ${date:%H:%M:%S} ==> 07:46:40\n" +#| " /eval -n ${if:${info:term_width}>80?big:small} ==> big\n" +#| " /eval -n ${rev:Hello} ==> olleH\n" +#| " /eval -n ${repeat:5,-} ==> -----\n" +#| " /eval -n ${length:test} ==> 4\n" +#| " /eval -n ${calc:(5+2)*3} ==> 21\n" +#| " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" +#| " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" +#| " /eval -n ${translate:Plugin} ==> Extension\n" +#| "\n" +#| "Examples (conditions):\n" +#| " /eval -n -c ${window.buffer.number} > 2 ==> 0\n" +#| " /eval -n -c ${window.win_width} > 100 ==> 1\n" +#| " /eval -n -c (8 > 12) || (5 > 2) ==> 1\n" +#| " /eval -n -c (8 > 12) && (5 > 2) ==> 0\n" +#| " /eval -n -c abcd =~ ^ABC ==> 1\n" +#| " /eval -n -c abcd =~ (?-i)^ABC ==> 0\n" +#| " /eval -n -c abcd =~ (?-i)^abc ==> 1\n" +#| " /eval -n -c abcd !~ abc ==> 0\n" +#| " /eval -n -c abcd =* a*d ==> 1\n" +#| " /eval -n -c abcd =- bc ==> 1" msgid "" " -n: display result without sending it to buffer (debug mode)\n" " -s: split expression before evaluating it (many commands can be " @@ -1760,10 +1895,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1805,6 +1941,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/es.po b/po/es.po index 115c5108f..57aabeb71 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -1645,10 +1645,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1690,6 +1691,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/fr.po b/po/fr.po index 859dd52b6..60062dcd1 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: 2021-08-01 10:24+0200\n" -"PO-Revision-Date: 2021-08-01 10:25+0200\n" +"POT-Creation-Date: 2021-08-02 21:49+0200\n" +"PO-Revision-Date: 2021-08-02 21:49+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -1733,10 +1733,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1778,6 +1779,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" @@ -1872,10 +1874,11 @@ msgstr "" "valeur_si_faux\")\n" " 17. le résultat d'une expression avec parenthèses et les opérateurs + - " "* / // % ** (format: \"calc:xxx\")\n" -" 18. une chaîne traduite (format : \"translate:xxx\")\n" -" 19. une option (format : \"fichier.section.option\")\n" -" 20. une variable locale du tampon\n" -" 21. un hdata/variable (la valeur est automatiquement convertie en chaîne), " +" 18. un nombre entier aléatoire (format : \"random:min,max\")\n" +" 19. une chaîne traduite (format : \"translate:xxx\")\n" +" 20. une option (format : \"fichier.section.option\")\n" +" 21. une variable locale du tampon\n" +" 22. 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" @@ -1918,6 +1921,7 @@ msgstr "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/hu.po b/po/hu.po index 02bdd8a44..109b4349f 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1532,10 +1532,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1577,6 +1578,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/it.po b/po/it.po index 362f1441b..890931bfd 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -1628,10 +1628,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1673,6 +1674,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/ja.po b/po/ja.po index 58573c3db..bbdc29cbf 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/pl.po b/po/pl.po index 1393e630c..4f1db9f21 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: Polish \n" @@ -1653,6 +1653,141 @@ msgstr "" "[-n|-s] [-d] || [-n] [-d [-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 " +#| "separated by semicolons)\n" +#| " -d: display debug output after evaluation (with two -d: more " +#| "verbose debug)\n" +#| " -c: evaluate as condition: use operators and parentheses, return " +#| "a boolean value (\"0\" or \"1\")\n" +#| "expression: expression to evaluate, variables with format ${variable} are " +#| "replaced (see below); many commands can be separated by semicolons\n" +#| " operator: a logical or comparison operator:\n" +#| " - logical operators:\n" +#| " && boolean \"and\"\n" +#| " || boolean \"or\"\n" +#| " - comparison operators:\n" +#| " == equal\n" +#| " != not equal\n" +#| " <= less or equal\n" +#| " < less\n" +#| " >= greater or equal\n" +#| " > greater\n" +#| " =~ is matching POSIX extended regex\n" +#| " !~ is NOT matching POSIX extended regex\n" +#| " ==* is matching mask, case sensitive (wildcard \"*\" is " +#| "allowed)\n" +#| " !!* is NOT matching mask, case sensitive (wildcard \"*\" " +#| "is allowed)\n" +#| " =* is matching mask, case insensitive (wildcard \"*\" " +#| "is allowed)\n" +#| " !* is NOT matching mask, case insensitive (wildcard \"*" +#| "\" is allowed)\n" +#| " ==- is included, case sensitive\n" +#| " !!- is NOT included, case sensitive\n" +#| " =- is included, case insensitive\n" +#| " !- is NOT included, case insensitive\n" +#| "\n" +#| "An expression is considered as \"true\" if it is not NULL, not empty, and " +#| "different from \"0\".\n" +#| "The comparison is made using floating point numbers if the two " +#| "expressions are valid numbers, with one of the following formats:\n" +#| " - integer (examples: 5, -7)\n" +#| " - floating point number (examples: 5.2, -7.5, 2.83e-2)\n" +#| " - hexadecimal number (examples: 0xA3, -0xA3)\n" +#| "To force a string comparison, you can add double quotes around each " +#| "expression, for example:\n" +#| " 50 > 100 ==> 0\n" +#| " \"50\" > \"100\" ==> 1\n" +#| "\n" +#| "Some variables are replaced in expression, using the format ${variable}, " +#| "variable can be, by order of priority:\n" +#| " 1. the string itself without evaluation (format: \"raw:xxx\")\n" +#| " 2. an evaluated sub-string (format: \"eval:xxx\")\n" +#| " 3. an evaluated condition (format: \"eval_cond:xxx\")\n" +#| " 4. a string with escaped chars (format: \"esc:xxx\" or \"\\xxx\")\n" +#| " 5. a string with chars to hide (format: \"hide:char,string\")\n" +#| " 6. 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" +#| " 7. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n" +#| " 8. a repeated string (format: \"repeat:count,string\")\n" +#| " 9. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n" +#| " 10. a color (format: \"color:xxx\", see \"Plugin API reference\", " +#| "function \"color\")\n" +#| " 11. a modifier (format: \"modifier:name,data,string\")\n" +#| " 12. an info (format: \"info:name,arguments\", arguments are optional)\n" +#| " 13. a base 16/32/64 encoded/decoded string (format: \"base_encode:base," +#| "xxx\" or \"base_decode:base,xxx\")\n" +#| " 14. current date/time (format: \"date\" or \"date:format\")\n" +#| " 15. an environment variable (format: \"env:XXX\")\n" +#| " 16. a ternary operator (format: \"if:condition?value_if_true:" +#| "value_if_false\")\n" +#| " 17. result of an expression with parentheses and operators + - * / // % " +#| "** (format: \"calc:xxx\")\n" +#| " 18. a translated string (format: \"translate:xxx\")\n" +#| " 19. an option (format: \"file.section.option\")\n" +#| " 20. a local variable in buffer\n" +#| " 21. 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" +#| " hdata.var1.var2...: start with a hdata (pointer must be known), and ask " +#| "variables one after one (other hdata can be followed)\n" +#| " hdata[list].var1.var2...: start with a hdata using a list/pointer/" +#| "pointer name, for example:\n" +#| " ${buffer[gui_buffers].full_name}: full name of first buffer in linked " +#| "list of buffers\n" +#| " ${plugin[weechat_plugins].name}: name of first plugin in linked list " +#| "of plugins\n" +#| " hdata[pointer].var1.var2...: start with a hdata using a pointer, for " +#| "example:\n" +#| " ${buffer[0x1234abcd].full_name}: full name of the buffer with this " +#| "pointer (can be used in triggers)\n" +#| " ${buffer[my_pointer].full_name}: full name of the buffer with this " +#| "pointer name (can be used in triggers)\n" +#| "For name of hdata and variables, please look at \"Plugin API reference\", " +#| "function \"weechat_hdata_get\".\n" +#| "\n" +#| "Examples (simple strings):\n" +#| " /eval -n ${raw:${info:version}} ==> ${info:version}\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" +#| " /eval -n ${sec.data.password} ==> secret\n" +#| " /eval -n ${window} ==> 0x2549aa0\n" +#| " /eval -n ${window.buffer} ==> 0x2549320\n" +#| " /eval -n ${window.buffer.full_name} ==> core.weechat\n" +#| " /eval -n ${window.buffer.number} ==> 1\n" +#| " /eval -n ${\\t} ==> \n" +#| " /eval -n ${hide:-,${relay.network.password}} ==> --------\n" +#| " /eval -n ${cut:3,+,test} ==> tes+\n" +#| " /eval -n ${cut:+3,+,test} ==> te+\n" +#| " /eval -n ${date:%H:%M:%S} ==> 07:46:40\n" +#| " /eval -n ${if:${info:term_width}>80?big:small} ==> big\n" +#| " /eval -n ${rev:Hello} ==> olleH\n" +#| " /eval -n ${repeat:5,-} ==> -----\n" +#| " /eval -n ${length:test} ==> 4\n" +#| " /eval -n ${calc:(5+2)*3} ==> 21\n" +#| " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" +#| " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" +#| " /eval -n ${translate:Plugin} ==> Extension\n" +#| "\n" +#| "Examples (conditions):\n" +#| " /eval -n -c ${window.buffer.number} > 2 ==> 0\n" +#| " /eval -n -c ${window.win_width} > 100 ==> 1\n" +#| " /eval -n -c (8 > 12) || (5 > 2) ==> 1\n" +#| " /eval -n -c (8 > 12) && (5 > 2) ==> 0\n" +#| " /eval -n -c abcd =~ ^ABC ==> 1\n" +#| " /eval -n -c abcd =~ (?-i)^ABC ==> 0\n" +#| " /eval -n -c abcd =~ (?-i)^abc ==> 1\n" +#| " /eval -n -c abcd !~ abc ==> 0\n" +#| " /eval -n -c abcd =* a*d ==> 1\n" +#| " /eval -n -c abcd =- bc ==> 1" msgid "" " -n: display result without sending it to buffer (debug mode)\n" " -s: split expression before evaluating it (many commands can be " @@ -1727,10 +1862,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1772,6 +1908,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/pt.po b/po/pt.po index f4f2ea3e7..8fb5f847a 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -1716,10 +1716,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1761,6 +1762,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index 8f86781f5..e27818bcc 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Érico Nogueira \n" "Language-Team: weechat-dev \n" @@ -1691,10 +1691,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1736,6 +1737,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/ru.po b/po/ru.po index 9673a3b08..d1a78de35 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -1555,10 +1555,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1600,6 +1601,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/sr.po b/po/sr.po index fa52402f6..8b48d3fe0 100644 --- a/po/sr.po +++ b/po/sr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Ivan Pešić \n" "Language-Team: weechat-dev \n" @@ -1638,6 +1638,141 @@ msgid "" "" msgstr "[-n|-s] [-d] <израз> || [-n] [-d [-d]] -c <израз1> <оператор> <израз2>" +#, fuzzy +#| msgid "" +#| " -n: display result without sending it to buffer (debug mode)\n" +#| " -s: split expression before evaluating it (many commands can be " +#| "separated by semicolons)\n" +#| " -d: display debug output after evaluation (with two -d: more " +#| "verbose debug)\n" +#| " -c: evaluate as condition: use operators and parentheses, return " +#| "a boolean value (\"0\" or \"1\")\n" +#| "expression: expression to evaluate, variables with format ${variable} are " +#| "replaced (see below); many commands can be separated by semicolons\n" +#| " operator: a logical or comparison operator:\n" +#| " - logical operators:\n" +#| " && boolean \"and\"\n" +#| " || boolean \"or\"\n" +#| " - comparison operators:\n" +#| " == equal\n" +#| " != not equal\n" +#| " <= less or equal\n" +#| " < less\n" +#| " >= greater or equal\n" +#| " > greater\n" +#| " =~ is matching POSIX extended regex\n" +#| " !~ is NOT matching POSIX extended regex\n" +#| " ==* is matching mask, case sensitive (wildcard \"*\" is " +#| "allowed)\n" +#| " !!* is NOT matching mask, case sensitive (wildcard \"*\" " +#| "is allowed)\n" +#| " =* is matching mask, case insensitive (wildcard \"*\" " +#| "is allowed)\n" +#| " !* is NOT matching mask, case insensitive (wildcard \"*" +#| "\" is allowed)\n" +#| " ==- is included, case sensitive\n" +#| " !!- is NOT included, case sensitive\n" +#| " =- is included, case insensitive\n" +#| " !- is NOT included, case insensitive\n" +#| "\n" +#| "An expression is considered as \"true\" if it is not NULL, not empty, and " +#| "different from \"0\".\n" +#| "The comparison is made using floating point numbers if the two " +#| "expressions are valid numbers, with one of the following formats:\n" +#| " - integer (examples: 5, -7)\n" +#| " - floating point number (examples: 5.2, -7.5, 2.83e-2)\n" +#| " - hexadecimal number (examples: 0xA3, -0xA3)\n" +#| "To force a string comparison, you can add double quotes around each " +#| "expression, for example:\n" +#| " 50 > 100 ==> 0\n" +#| " \"50\" > \"100\" ==> 1\n" +#| "\n" +#| "Some variables are replaced in expression, using the format ${variable}, " +#| "variable can be, by order of priority:\n" +#| " 1. the string itself without evaluation (format: \"raw:xxx\")\n" +#| " 2. an evaluated sub-string (format: \"eval:xxx\")\n" +#| " 3. an evaluated condition (format: \"eval_cond:xxx\")\n" +#| " 4. a string with escaped chars (format: \"esc:xxx\" or \"\\xxx\")\n" +#| " 5. a string with chars to hide (format: \"hide:char,string\")\n" +#| " 6. 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" +#| " 7. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n" +#| " 8. a repeated string (format: \"repeat:count,string\")\n" +#| " 9. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n" +#| " 10. a color (format: \"color:xxx\", see \"Plugin API reference\", " +#| "function \"color\")\n" +#| " 11. a modifier (format: \"modifier:name,data,string\")\n" +#| " 12. an info (format: \"info:name,arguments\", arguments are optional)\n" +#| " 13. a base 16/32/64 encoded/decoded string (format: \"base_encode:base," +#| "xxx\" or \"base_decode:base,xxx\")\n" +#| " 14. current date/time (format: \"date\" or \"date:format\")\n" +#| " 15. an environment variable (format: \"env:XXX\")\n" +#| " 16. a ternary operator (format: \"if:condition?value_if_true:" +#| "value_if_false\")\n" +#| " 17. result of an expression with parentheses and operators + - * / // % " +#| "** (format: \"calc:xxx\")\n" +#| " 18. a translated string (format: \"translate:xxx\")\n" +#| " 19. an option (format: \"file.section.option\")\n" +#| " 20. a local variable in buffer\n" +#| " 21. 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" +#| " hdata.var1.var2...: start with a hdata (pointer must be known), and ask " +#| "variables one after one (other hdata can be followed)\n" +#| " hdata[list].var1.var2...: start with a hdata using a list/pointer/" +#| "pointer name, for example:\n" +#| " ${buffer[gui_buffers].full_name}: full name of first buffer in linked " +#| "list of buffers\n" +#| " ${plugin[weechat_plugins].name}: name of first plugin in linked list " +#| "of plugins\n" +#| " hdata[pointer].var1.var2...: start with a hdata using a pointer, for " +#| "example:\n" +#| " ${buffer[0x1234abcd].full_name}: full name of the buffer with this " +#| "pointer (can be used in triggers)\n" +#| " ${buffer[my_pointer].full_name}: full name of the buffer with this " +#| "pointer name (can be used in triggers)\n" +#| "For name of hdata and variables, please look at \"Plugin API reference\", " +#| "function \"weechat_hdata_get\".\n" +#| "\n" +#| "Examples (simple strings):\n" +#| " /eval -n ${raw:${info:version}} ==> ${info:version}\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" +#| " /eval -n ${sec.data.password} ==> secret\n" +#| " /eval -n ${window} ==> 0x2549aa0\n" +#| " /eval -n ${window.buffer} ==> 0x2549320\n" +#| " /eval -n ${window.buffer.full_name} ==> core.weechat\n" +#| " /eval -n ${window.buffer.number} ==> 1\n" +#| " /eval -n ${\\t} ==> \n" +#| " /eval -n ${hide:-,${relay.network.password}} ==> --------\n" +#| " /eval -n ${cut:3,+,test} ==> tes+\n" +#| " /eval -n ${cut:+3,+,test} ==> te+\n" +#| " /eval -n ${date:%H:%M:%S} ==> 07:46:40\n" +#| " /eval -n ${if:${info:term_width}>80?big:small} ==> big\n" +#| " /eval -n ${rev:Hello} ==> olleH\n" +#| " /eval -n ${repeat:5,-} ==> -----\n" +#| " /eval -n ${length:test} ==> 4\n" +#| " /eval -n ${calc:(5+2)*3} ==> 21\n" +#| " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" +#| " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" +#| " /eval -n ${translate:Plugin} ==> Extension\n" +#| "\n" +#| "Examples (conditions):\n" +#| " /eval -n -c ${window.buffer.number} > 2 ==> 0\n" +#| " /eval -n -c ${window.win_width} > 100 ==> 1\n" +#| " /eval -n -c (8 > 12) || (5 > 2) ==> 1\n" +#| " /eval -n -c (8 > 12) && (5 > 2) ==> 0\n" +#| " /eval -n -c abcd =~ ^ABC ==> 1\n" +#| " /eval -n -c abcd =~ (?-i)^ABC ==> 0\n" +#| " /eval -n -c abcd =~ (?-i)^abc ==> 1\n" +#| " /eval -n -c abcd !~ abc ==> 0\n" +#| " /eval -n -c abcd =* a*d ==> 1\n" +#| " /eval -n -c abcd =- bc ==> 1" msgid "" " -n: display result without sending it to buffer (debug mode)\n" " -s: split expression before evaluating it (many commands can be " @@ -1712,10 +1847,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1757,6 +1893,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/tr.po b/po/tr.po index 8fe83a963..976e12991 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n" "Last-Translator: Emir SARI \n" "Language-Team: weechat-dev \n" @@ -1701,10 +1701,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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 "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/po/weechat.pot b/po/weechat.pot index 73f249db8..721ddcc8e 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: 2021-08-01 10:24+0200\n" +"POT-Creation-Date: 2021-08-03 19:41+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -1389,10 +1389,11 @@ msgid "" "\")\n" " 17. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" -" 18. a translated string (format: \"translate:xxx\")\n" -" 19. an option (format: \"file.section.option\")\n" -" 20. a local variable in buffer\n" -" 21. a hdata name/variable (the value is automatically converted to " +" 18. a random integer number (format: \"random:min,max\")\n" +" 19. a translated string (format: \"translate:xxx\")\n" +" 20. an option (format: \"file.section.option\")\n" +" 21. a local variable in buffer\n" +" 22. 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" @@ -1434,6 +1435,7 @@ msgid "" " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" +" /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 80a1bb444..beacd126f 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -7586,10 +7586,11 @@ command_init () "\"if:condition?value_if_true:value_if_false\")\n" " 17. result of an expression with parentheses and operators " "+ - * / // % ** (format: \"calc:xxx\")\n" - " 18. a translated string (format: \"translate:xxx\")\n" - " 19. an option (format: \"file.section.option\")\n" - " 20. a local variable in buffer\n" - " 21. a hdata name/variable (the value is automatically converted " + " 18. a random integer number (format: \"random:min,max\")\n" + " 19. a translated string (format: \"translate:xxx\")\n" + " 20. an option (format: \"file.section.option\")\n" + " 21. a local variable in buffer\n" + " 22. 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" @@ -7631,6 +7632,7 @@ command_init () " /eval -n ${repeat:5,-} ==> -----\n" " /eval -n ${length:test} ==> 4\n" " /eval -n ${calc:(5+2)*3} ==> 21\n" + " /eval -n ${random:0,10} ==> 3\n" " /eval -n ${base_encode:64,test} ==> dGVzdA==\n" " /eval -n ${base_decode:64,dGVzdA==} ==> test\n" " /eval -n ${translate:Plugin} ==> Extension\n" diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index a1020ce9e..397b951ce 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -725,6 +725,57 @@ eval_string_if (const char *text, struct t_eval_context *eval_context) return (value) ? value : strdup (""); } +/* + * Returns a random integer number. + * + * Note: result must be freed after use. + */ + +char * +eval_string_random (const char *text) +{ + char *pos, *error, *tmp, result[128]; + long min_number, max_number; + + if (!text || !text[0]) + goto error; + + pos = strchr (text, ','); + if (!pos) + goto error; + + tmp = strndup (text, pos - text); + if (!tmp) + goto error; + min_number = strtol (tmp, &error, 10); + if (!error || error[0]) + { + free (tmp); + goto error; + } + free (tmp); + + max_number = strtol (pos + 1, &error, 10); + if (!error || error[0]) + goto error; + + if (min_number > max_number) + goto error; + if (max_number - min_number > RAND_MAX) + goto error; + + /* + * using modulo division on the random() value produces a biased result, + * but this is enough for our usage here + */ + snprintf (result, sizeof (result), + "%ld", min_number + (random () % (max_number - min_number + 1))); + return strdup (result); + +error: + return strdup ("0"); +} + /* * Translates text. * @@ -732,7 +783,7 @@ eval_string_if (const char *text, struct t_eval_context *eval_context) */ char * -eval_translate (const char *text) +eval_string_translate (const char *text) { const char *ptr_string; @@ -1053,11 +1104,13 @@ end: * 18. an environment variable (format: env:XXX) * 19. a ternary operator (format: if:condition?value_if_true:value_if_false) * 20. calculate result of an expression (format: calc:xxx) - * 21. a translated string (format: translate:xxx) - * 22. an option (format: file.section.option) - * 23. a buffer local variable - * 24. a pointer name from hashtable "pointers" - * 25. a hdata variable (format: hdata.var1.var2 or hdata[list].var1.var2 + * 21. a random integer number in the range from "min" to "max" + * (format: random:min,max) + * 22. a translated string (format: translate:xxx) + * 23. an option (format: file.section.option) + * 24. a buffer local variable + * 25. a pointer name from hashtable "pointers" + * 26. a hdata variable (format: hdata.var1.var2 or hdata[list].var1.var2 * or hdata[ptr].var1.var2 or hdata[ptr_name].var1.var2) * * See /help in WeeChat for examples. @@ -1306,11 +1359,20 @@ eval_replace_vars_cb (void *data, const char *text) } /* - * 21. translated text + * 21. random number + */ + if (strncmp (text, "random:", 7) == 0) + { + value = eval_string_random (text + 7); + goto end; + } + + /* + * 22. translated text */ if (strncmp (text, "translate:", 10) == 0) { - value = eval_translate (text + 10); + value = eval_string_translate (text + 10); goto end; } diff --git a/src/core/weechat.c b/src/core/weechat.c index cd83add1f..1900ca6e1 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -610,6 +611,11 @@ weechat_init (int argc, char *argv[], void (*gui_init_cb)()) weechat_first_start_time = time (NULL); /* initialize start time */ gettimeofday (&weechat_current_start_timeval, NULL); + /* set the seed for the pseudo-random integer generator */ + srand ((weechat_current_start_timeval.tv_sec + * weechat_current_start_timeval.tv_usec) + ^ getpid ()); + signal_init (); /* initialize signals */ hdata_init (); /* initialize hdata */ hook_init (); /* initialize hooks */ diff --git a/tests/unit/core/test-core-eval.cpp b/tests/unit/core/test-core-eval.cpp index 4cdd5f477..f542641da 100644 --- a/tests/unit/core/test-core-eval.cpp +++ b/tests/unit/core/test-core-eval.cpp @@ -453,7 +453,7 @@ TEST(CoreEval, EvalExpression) { struct t_hashtable *pointers, *extra_vars, *options; struct t_config_option *ptr_option; - char *value, str_value[256]; + char *value, str_value[256], str_expr[256]; const char *ptr_debug_output; pointers = hashtable_new (32, @@ -751,6 +751,25 @@ TEST(CoreEval, EvalExpression) WEE_CHECK_EVAL("18", "${calc:(5+1)*3}"); WEE_CHECK_EVAL("123129", "${calc:${repeat:2,123}+2*3}"); + /* test random */ + WEE_CHECK_EVAL("0", "${random:}"); + WEE_CHECK_EVAL("0", "${random:1}"); + WEE_CHECK_EVAL("0", "${random:1,}"); + WEE_CHECK_EVAL("0", "${random:5,1}"); + WEE_CHECK_EVAL("2", "${random:2,2}"); + snprintf (str_expr, sizeof (str_expr), + "${random:-1,%ld}", + (long)RAND_MAX); + WEE_CHECK_EVAL("0", str_expr); + snprintf (str_expr, sizeof (str_expr), + "${random:%ld,%ld}", + (long)RAND_MAX, + (long)RAND_MAX); + snprintf (str_value, sizeof (str_value), + "%ld", + (long)RAND_MAX); + WEE_CHECK_EVAL(str_value, str_expr); + /* test translation */ WEE_CHECK_EVAL("", "${translate:}"); WEE_CHECK_EVAL("abcdef", "${translate:abcdef}");