diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-04 08:56:56 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-04 08:56:56 +0200 |
commit | dc878c5b69d498e3edb225e1997455510579deed (patch) | |
tree | 2c6dbd6bb5640ce17d23b937463310656ec7f126 /doc | |
parent | b94a1ce59baa99e2076c83d82f25cbe5d9a7c19b (diff) | |
download | weechat-dc878c5b69d498e3edb225e1997455510579deed.zip |
api: add argument "options" in function string_eval_expression, add option "-c" for command /eval (to evaluate a condition)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/de/autogen/user/weechat_commands.txt | 91 | ||||
-rw-r--r-- | doc/en/autogen/user/weechat_commands.txt | 29 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.txt | 34 | ||||
-rw-r--r-- | doc/fr/autogen/user/weechat_commands.txt | 29 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.txt | 34 | ||||
-rw-r--r-- | doc/it/autogen/user/weechat_commands.txt | 93 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.txt | 35 | ||||
-rw-r--r-- | doc/ja/autogen/user/weechat_commands.txt | 91 |
8 files changed, 245 insertions, 191 deletions
diff --git a/doc/de/autogen/user/weechat_commands.txt b/doc/de/autogen/user/weechat_commands.txt index dde392745..d67b971ce 100644 --- a/doc/de/autogen/user/weechat_commands.txt +++ b/doc/de/autogen/user/weechat_commands.txt @@ -207,55 +207,56 @@ infolists: zeigt Information über die Infolists an [command]*`eval`* wertet einen Ausdruck aus und gibt das Resultat im Buffer aus:: ........................................ /eval [-n] <expression> - [-n] <expression1> <operator> <expression2> - - -n: zeigt das Ergebnis an, ohne das dieses in den Buffer geschrieben wird (debug Modus) -expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten) - 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 Ausdruck überein - !~ stimmt NICHT mit regulärem Ausdruck überein - -Ein Ausdruck gilt als "wahr", sofern das Ergebnis nicht NULL, nicht leer und von "0" abweichend ist. -Der Vergleich findet zwischen zwei Integer Werten statt, sofern die beiden Ausdrücke gültige Integer-Werte sind. -Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel: + [-n] -c <expression1> <operator> <expression2> + + -n: display result without sending it to buffer (debug mode) + -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) + 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 regex + !~ is NOT matching regex + +An expression is considered as "true" if it is not NULL, not empty, and different from "0". +The comparison is made using integers if the two expressions are valid integers. +To force a string comparison, 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. der Name einer Option (file.section.option) - 2. der Name der lokalen Variablen für Buffer - 3. ein hdata Name/Variable (der Wert wird automatisch als Zeichenkette konvertiert), Standardmäßig wird für "window" und "buffer" das aktuelle Fenster/Buffer verwendet. -Das Format für hdata: - 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 -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 name of an option (file.section.option) + 2. the name of a local variable in buffer + 3. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. +Format for hdata can be one of following: + hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) + hdata[list].var1.var2...: start with a hdata using a list, for example: + ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers + ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -Beispiele: - /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${window} ==> 0x2549aa0 - /eval -n ${window.buffer} ==> 0x2549320 - /eval -n ${window.buffer.full_name} ==> core.weechat - /eval -n ${window.buffer.number} ==> 1 - /eval -n ${window.buffer.number} > 2 ==> 0 - /eval -n ${window.win_width} > 100 ==> 1 - /eval -n (8 > 12) || (5 > 2) ==> 1 - /eval -n (8 > 12) && (5 > 2) ==> 0 - /eval -n abcd =~ ^ABC ==> 1 - /eval -n abcd =~ (?-i)^ABC ==> 0 - /eval -n abcd =~ (?-i)^abc ==> 1 - /eval -n abcd !~ abc ==> 0 +Examples: + /eval -n ${weechat.look.scroll_amount} ==> 3 + /eval -n ${window} ==> 0x2549aa0 + /eval -n ${window.buffer} ==> 0x2549320 + /eval -n ${window.buffer.full_name} ==> core.weechat + /eval -n ${window.buffer.number} ==> 1 + /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 ........................................ [[command_weechat_filter]] diff --git a/doc/en/autogen/user/weechat_commands.txt b/doc/en/autogen/user/weechat_commands.txt index 992e470b6..0885078d3 100644 --- a/doc/en/autogen/user/weechat_commands.txt +++ b/doc/en/autogen/user/weechat_commands.txt @@ -207,9 +207,10 @@ infolists: display infos about infolists [command]*`eval`* evaluate expression and send result to buffer:: ........................................ /eval [-n] <expression> - [-n] <expression1> <operator> <expression2> + [-n] -c <expression1> <operator> <expression2> -n: display result without sending it to buffer (debug mode) + -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) operator: a logical or comparison operator: - logical operators: @@ -243,19 +244,19 @@ Format for hdata can be one of following: For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". Examples: - /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${window} ==> 0x2549aa0 - /eval -n ${window.buffer} ==> 0x2549320 - /eval -n ${window.buffer.full_name} ==> core.weechat - /eval -n ${window.buffer.number} ==> 1 - /eval -n ${window.buffer.number} > 2 ==> 0 - /eval -n ${window.win_width} > 100 ==> 1 - /eval -n (8 > 12) || (5 > 2) ==> 1 - /eval -n (8 > 12) && (5 > 2) ==> 0 - /eval -n abcd =~ ^ABC ==> 1 - /eval -n abcd =~ (?-i)^ABC ==> 0 - /eval -n abcd =~ (?-i)^abc ==> 1 - /eval -n abcd !~ abc ==> 0 + /eval -n ${weechat.look.scroll_amount} ==> 3 + /eval -n ${window} ==> 0x2549aa0 + /eval -n ${window.buffer} ==> 0x2549320 + /eval -n ${window.buffer.full_name} ==> core.weechat + /eval -n ${window.buffer.number} ==> 1 + /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 ........................................ [[command_weechat_filter]] diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 30e162daa..03e042876 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -1699,7 +1699,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" weechat_string_eval_expression ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -_New in version 0.4.0._ +_New in version 0.4.0, updated in 0.4.2._ Evaluate an expression and return result as a string. Special variables with format `${variable}` are expanded (see command `/eval` in @@ -1711,7 +1711,8 @@ Prototype: ---------------------------------------- char *weechat_string_eval_expression (const char *expr, struct t_hashtable *pointers, - struct t_hashtable *extra_vars); + struct t_hashtable *extra_vars, + struct t_hashtable *options); ---------------------------------------- Arguments: @@ -1721,6 +1722,14 @@ Arguments: pointer); pointers "window" and "buffer" are automatically added if they are not in hashtable (with pointer to current window/buffer) (can be NULL) * 'extra_vars': extra variables that will be expanded (can be NULL) +* 'options': a hashtable with some options (keys and values must be string) + (can be NULL): +** 'type': default behaviour is just to replace values in expression, other + types can be selected: +*** 'condition': the expression is evaluated as a condition: operators and + parentheses are used, result is a boolean ("0" or "1") +** 'prefix': prefix before variables to replace (default: "${") +** 'suffix': suffix after variables to replace (default: "}") Return value: @@ -1731,9 +1740,16 @@ C examples: [source,C] ---------------------------------------- -char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */ -char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */ -char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */ +struct t_hashtable *options = weechat_hashtable_new (8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); +if (options) + weechat_hashtable_set (options, "type", "condition"); +char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */ +char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */ +char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */ ---------------------------------------- Script (Python): @@ -1741,12 +1757,12 @@ Script (Python): [source,python] ---------------------------------------- # prototype -str = weechat.string_eval_expression(expr, pointers, extra_vars) +str = weechat.string_eval_expression(expr, pointers, extra_vars, options) # examples -str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}) # "core.weechat" -str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}) # "1" -str3 = weechat.string_eval_expression("abc =~ def", {}, {}) # "0" +str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat" +str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1" +str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0" ---------------------------------------- [[utf-8]] diff --git a/doc/fr/autogen/user/weechat_commands.txt b/doc/fr/autogen/user/weechat_commands.txt index ad4d214c0..6752c7592 100644 --- a/doc/fr/autogen/user/weechat_commands.txt +++ b/doc/fr/autogen/user/weechat_commands.txt @@ -207,9 +207,10 @@ infolists: afficher des infos sur les infolists [command]*`eval`* évaluer une expression et envoyer le résultat au tampon:: ........................................ /eval [-n] <expression> - [-n] <expression1> <opérateur> <expression2> + [-n] -c <expression1> <opérateur> <expression2> -n: afficher le résultat sans envoyer au tampon (mode debug) + -c: évaluer comme une condition : utiliser les opérateurs et les parenthèses, retourner une valeur booléenne ("0" ou "1") expression: expression à évaluer, les variables avec le format ${variable} sont remplacées (voir ci-dessous) opérateur: un opérateur logique ou de comparaison : - opérateurs logiques : @@ -243,19 +244,19 @@ Le format du hdata peut être le suivant : Pour le nom du hdata et des variables, voir la "Référence API extension", fonction "weechat_hdata_get". Exemples: - /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${window} ==> 0x2549aa0 - /eval -n ${window.buffer} ==> 0x2549320 - /eval -n ${window.buffer.full_name} ==> core.weechat - /eval -n ${window.buffer.number} ==> 1 - /eval -n ${window.buffer.number} > 2 ==> 0 - /eval -n ${window.win_width} > 100 ==> 1 - /eval -n (8 > 12) || (5 > 2) ==> 1 - /eval -n (8 > 12) && (5 > 2) ==> 0 - /eval -n abcd =~ ^ABC ==> 1 - /eval -n abcd =~ (?-i)^ABC ==> 0 - /eval -n abcd =~ (?-i)^abc ==> 1 - /eval -n abcd !~ abc ==> 0 + /eval -n ${weechat.look.scroll_amount} ==> 3 + /eval -n ${window} ==> 0x2549aa0 + /eval -n ${window.buffer} ==> 0x2549320 + /eval -n ${window.buffer.full_name} ==> core.weechat + /eval -n ${window.buffer.number} ==> 1 + /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 ........................................ [[command_weechat_filter]] diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 5db4d9c16..72df89327 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -1723,7 +1723,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" weechat_string_eval_expression ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -_Nouveau dans la version 0.4.0._ +_Nouveau dans la version 0.4.0, mis à jour dans la 0.4.2._ Evalue l'expression et retourne le résultat sous forme de chaîne. Les variables spéciales avec le format `${variable}` sont étendues (voir la @@ -1735,7 +1735,8 @@ Prototype : ---------------------------------------- char *weechat_string_eval_expression (const char *expr, struct t_hashtable *pointers, - struct t_hashtable *extra_vars); + struct t_hashtable *extra_vars, + struct t_hashtable *options); ---------------------------------------- Paramètres : @@ -1746,6 +1747,14 @@ Paramètres : sont automatiquement ajoutés s'ils ne sont pas dans la hashtable (avec le pointer vers fenêtre/tampon courants) (peut être NULL) * 'extra_vars' : variables additionnelles qui seront étendues (peut être NULL) +* 'options' : hashtable avec des options (les clés et valeurs doivent être des + des chaînes) (peut être NULL) : +** 'type' : le comportement par défaut est de juste remplacer les valeurs dans + l'expression, d'autres types peuvent être choisis : +*** 'condition' : l'expression est évaluée comme une condition : les opérateurs + et parenthèses sont utilisés, le résultat est un booléen ("0" ou "1") +** 'prefix' : préfixe avant les variables à remplacer (par défaut: "${") +** 'suffix' : suffixe après les variables à remplacer (par défaut: "}") Valeur de retour : @@ -1757,9 +1766,16 @@ Exemples en C : [source,C] ---------------------------------------- -char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */ -char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */ -char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */ +struct t_hashtable *options = weechat_hashtable_new (8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); +if (options) + weechat_hashtable_set (options, "type", "condition"); +char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */ +char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */ +char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */ ---------------------------------------- Script (Python) : @@ -1767,12 +1783,12 @@ Script (Python) : [source,python] ---------------------------------------- # prototype -str = weechat.string_eval_expression(expr, pointers, extra_vars) +str = weechat.string_eval_expression(expr, pointers, extra_vars, options) # exemples -str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}) # "core.weechat" -str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}) # "1" -str3 = weechat.string_eval_expression("abc =~ def", {}, {}) # "0" +str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat" +str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1" +str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0" ---------------------------------------- [[utf-8]] diff --git a/doc/it/autogen/user/weechat_commands.txt b/doc/it/autogen/user/weechat_commands.txt index 21207d11a..e58f4e8a6 100644 --- a/doc/it/autogen/user/weechat_commands.txt +++ b/doc/it/autogen/user/weechat_commands.txt @@ -206,56 +206,57 @@ infolists: mostra informazioni sulle liste info [[command_weechat_eval]] [command]*`eval`* analizza l'espressione e invia il risultato al buffer:: ........................................ -/eval [-n] <espressione> - [-n] <espressione1> <operatore> <espressione2> - - -n: mostra il risultato senza inviarlo al buffer (modalità debug) -espressione: espressione da analizzare, le variabili con il formato ${variable} vengono sostituite (vedere sotto) - operatore: operatore logico o di confronto: - - operatori logici: - && "and" booleano - || "or" booleano - - operatori di confronto: - == uguale - != non uguale - <= minore o uguale - < minore - >= maggiore o uguale - > maggiore - =~ corrisponde alla regex - !~ NON corrisponde alla regex - -Un'espressione è considerata come "true" se non è NULL, non vuota, e diversa da "0". -Il confronto viene fatto usando gli interi se le due espressioni sono interi validi. -Per forzare il confronto stringa, aggiungere un doppio apice all'espressione, ad esempio: +/eval [-n] <expression> + [-n] -c <expression1> <operator> <expression2> + + -n: display result without sending it to buffer (debug mode) + -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) + 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 regex + !~ is NOT matching regex + +An expression is considered as "true" if it is not NULL, not empty, and different from "0". +The comparison is made using integers if the two expressions are valid integers. +To force a string comparison, add double quotes around each expression, for example: 50 > 100 ==> 0 "50" > "100" ==> 1 -Alcune variabili vengono sostituite nell'espressione, usando il formato ${variable}, la variabile può essere, in ordine di priorità : - 1. il nome di un'opzione (file.sezione.opzione) - 2. il nome di una variabile locale nel buffer - 3. un nome/variabile hdata (il valore viene automaticamente convertito in stringa, per default "window" e "buffer" puntano alla finestra/buffer correnti. -Il formato per hdata può essere uno dei seguenti: - hdata.var1.var2...: inizia con un hdata (il puntatore deve essere noto), e richiedere le variabili a seguire (possono seguire altri hdata) - hdata[list].var1.var2...: inizia con un hdata usando una lista, ad esempio: - ${buffer[gui_buffers].full_name}: nome completo del primo buffer nell'elenco collegato dei buffer - ${plugin[weechat_plugins].name}: nome del primo plugin nell'elenco collegato dei plugin -Per il nome degli hdata e delle variabili, per favore consultare "Referenze API per Plugin", funzione "weechat_hdata_get". +Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority : + 1. the name of an option (file.section.option) + 2. the name of a local variable in buffer + 3. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. +Format for hdata can be one of following: + hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) + hdata[list].var1.var2...: start with a hdata using a list, for example: + ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers + ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -Esempi: - /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${window} ==> 0x2549aa0 - /eval -n ${window.buffer} ==> 0x2549320 - /eval -n ${window.buffer.full_name} ==> core.weechat - /eval -n ${window.buffer.number} ==> 1 - /eval -n ${window.buffer.number} > 2 ==> 0 - /eval -n ${window.win_width} > 100 ==> 1 - /eval -n (8 > 12) || (5 > 2) ==> 1 - /eval -n (8 > 12) && (5 > 2) ==> 0 - /eval -n abcd =~ ^ABC ==> 1 - /eval -n abcd =~ (?-i)^ABC ==> 0 - /eval -n abcd =~ (?-i)^abc ==> 1 - /eval -n abcd !~ abc ==> 0 +Examples: + /eval -n ${weechat.look.scroll_amount} ==> 3 + /eval -n ${window} ==> 0x2549aa0 + /eval -n ${window.buffer} ==> 0x2549320 + /eval -n ${window.buffer.full_name} ==> core.weechat + /eval -n ${window.buffer.number} ==> 1 + /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 ........................................ [[command_weechat_filter]] diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index ceee1ac49..e2267e4a6 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -1683,7 +1683,8 @@ str3 = weechat.string_input_for_buffer("//test") # "/test" weechat_string_eval_expression ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -_Novità nella versione 0.4.0._ +// TRANSLATION MISSING +_Novità nella versione 0.4.0, updated in 0.4.2._ // TRANSLATION MISSING Evaluate an expression and return result as a string. @@ -1696,7 +1697,8 @@ Prototipo: ---------------------------------------- char *weechat_string_eval_expression (const char *expr, struct t_hashtable *pointers, - struct t_hashtable *extra_vars); + struct t_hashtable *extra_vars, + struct t_hashtable *options); ---------------------------------------- Argomenti: @@ -1707,6 +1709,14 @@ Argomenti: pointer); pointers "window" and "buffer" are automatically added if they are not in hashtable (with pointer to current window/buffer) (can be NULL) * 'extra_vars': extra variables that will be expanded (can be NULL) +* 'options': a hashtable with some options (keys and values must be string) + (can be NULL): +** 'type': default behaviour is just to replace values in expression, other + types can be selected: +*** 'condition': the expression is evaluated as a condition: operators and + parentheses are used, result is a boolean ("0" or "1") +** 'prefix': prefix before variables to replace (default: "${") +** 'suffix': suffix after variables to replace (default: "}") Valore restituito: @@ -1718,9 +1728,16 @@ Esempi in C: [source,C] ---------------------------------------- -char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */ -char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */ -char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */ +struct t_hashtable *options = weechat_hashtable_new (8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); +if (options) + weechat_hashtable_set (options, "type", "condition"); +char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */ +char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */ +char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */ ---------------------------------------- Script (Python): @@ -1728,12 +1745,12 @@ Script (Python): [source,python] ---------------------------------------- # prototipo -str = weechat.string_eval_expression(expr, pointers, extra_vars) +str = weechat.string_eval_expression(expr, pointers, extra_vars, options) # esempi -str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}) # "core.weechat" -str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}) # "1" -str3 = weechat.string_eval_expression("abc =~ def", {}, {}) # "0" +str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat" +str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1" +str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0" ---------------------------------------- [[utf-8]] diff --git a/doc/ja/autogen/user/weechat_commands.txt b/doc/ja/autogen/user/weechat_commands.txt index 9e7a75043..fa4876108 100644 --- a/doc/ja/autogen/user/weechat_commands.txt +++ b/doc/ja/autogen/user/weechat_commands.txt @@ -207,55 +207,56 @@ infolists: infolist に関する情報を表示 [command]*`eval`* 式を評価して結果をバッファに送信:: ........................................ /eval [-n] <expression> - [-n] <expression1> <operator> <expression2> - - -n: 結果をバッファに送信せずに表示 (デバッグモード) -expression: 評価する式、フォーマット、${variable} 型のフォーマットの変数は置換されます (以下を参照) - operator: 論理演算子や比較演算子: - - 論理演算子: - && ブール演算の "and" - || ブール演算の "or" - - 比較演算子: - == 等しい - != 等しくない - <= 以下 - < より少ない - >= 以上 - > より大きい - =~ 正規表現にマッチ - !~ 正規表現にマッチしない - -式が NULL でない場合、空でない場合、"0" でない場合、式は "真" と評価されます。 -両方の式が有効な整数である場合、比較は整数を使って行われます。 -文字列比較を強制するには、それぞれの式をダブルクォートで囲みます、例えば: + [-n] -c <expression1> <operator> <expression2> + + -n: display result without sending it to buffer (debug mode) + -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) + 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 regex + !~ is NOT matching regex + +An expression is considered as "true" if it is not NULL, not empty, and different from "0". +The comparison is made using integers if the two expressions are valid integers. +To force a string comparison, add double quotes around each expression, for example: 50 > 100 ==> 0 "50" > "100" ==> 1 -式中の ${variable} 型のフォーマットの変数は置換さます。変数は以下の優先順位に従います。 - 1. オプションの名前 (file.section.option) - 2. バッファのローカル変数の名前 - 3. hdata の名前/変数 (値は自動的に文字列に変換されます)、デフォルトでは "window" と "buffer" は現在のウィンドウ/バッファを指します。 -hdata のフォーマットは以下の 1 つです: - hdata.var1.var2...: hdata (ポインタは既知) で始まり、1 個ずつ変数を続ける (他の hdata を続けることも可能) - hdata(list).var1.var2...: リストを使って hdata を始める、例: - ${buffer[gui_buffers].full_name}: バッファリストにリンクされた最初のバッファのフルネーム - ${plugin[weechat_plugins].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 name of an option (file.section.option) + 2. the name of a local variable in buffer + 3. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. +Format for hdata can be one of following: + hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) + hdata[list].var1.var2...: start with a hdata using a list, for example: + ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers + ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -例: - /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${window} ==> 0x2549aa0 - /eval -n ${window.buffer} ==> 0x2549320 - /eval -n ${window.buffer.full_name} ==> core.weechat - /eval -n ${window.buffer.number} ==> 1 - /eval -n ${window.buffer.number} > 2 ==> 0 - /eval -n ${window.win_width} > 100 ==> 1 - /eval -n (8 > 12) || (5 > 2) ==> 1 - /eval -n (8 > 12) && (5 > 2) ==> 0 - /eval -n abcd =~ ^ABC ==> 1 - /eval -n abcd =~ (?-i)^ABC ==> 0 - /eval -n abcd =~ (?-i)^abc ==> 1 - /eval -n abcd !~ abc ==> 0 +Examples: + /eval -n ${weechat.look.scroll_amount} ==> 3 + /eval -n ${window} ==> 0x2549aa0 + /eval -n ${window.buffer} ==> 0x2549320 + /eval -n ${window.buffer.full_name} ==> core.weechat + /eval -n ${window.buffer.number} ==> 1 + /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 ........................................ [[command_weechat_filter]] |