1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

core: allow pointer as list name in evaluation of hdata (closes #450)

This commit is contained in:
Sébastien Helleu
2015-06-23 20:55:52 +02:00
parent 43f471b9c2
commit a79c0fcff3
27 changed files with 301 additions and 157 deletions
+39 -37
View File
@@ -251,47 +251,49 @@ infolists: wyświetla informacje o infolistach
/eval [-n|-s] <wyrażenie>
[-n] -c <wyrażenie1> <operator> <wyrażenie2>
-n: wyświetla wynik bez wysyłania go do buforu (tryb debugowania)
-s: podziel wyażenie przed przetworzeniem go (wiele komend może być oddzielonych średnikami)
-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:
&& boolowskie "i"
|| boolowskie "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
-n: display result without sending it to buffer (debug mode)
-s: split expression before evaluating it (many commands can be separated by semicolons)
-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
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 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 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
Niektóre zmienne w wyrażeniach są zamieniane, poprzez zastosowanie formatu ${zmienna}, według priorytetu zmienną może być:
1. ciąg z wyescapowanymi znakami (format: "esc:xxx" lub "\xxx")
2. ciąg ze znakami do ukrycia (format: "hide:char,string")
3. kolor (format color:xxx)
4. informacja (format: "info:nazwa,argumenty", argumenty są opcjonalne)
5. zmienna środowiskowa (format: "env:XXX")
6. opcja (format: plik.sekcja.opcja)
7. zmienna lokalna w buforze
8. 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
Nazwy hdata i zmiennych, można znaleźć w "Opisie API wtyczek", fukcja "weechat_hdata_get".
Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority:
1. a string with escaped chars (format: "esc:xxx" or "\xxx")
2. a string with chars to hide (format: "hide:char,string")
3. a color (format: "color:xxx")
4. an info (format: "info:name,arguments", arguments are optional)
5. an environment variable (format: "env:XXX")
6. an option (format: "file.section.option")
7. a local variable in buffer
8. 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, for example:
${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
hdata[pointer].var1.var2...: start with a hdata using a list, for example:
${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers)
${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".
Przykłady (proste ciągi):
Examples (simple strings):
/eval -n ${info:version} ==> 0.4.3
/eval -n ${env:HOME} ==> /home/user
/eval -n ${weechat.look.scroll_amount} ==> 3
@@ -302,7 +304,7 @@ Przykłady (proste ciągi):
/eval -n ${\t} ==> <tab>
/eval -n ${hide:-,${relay.network.password}} ==> --------
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
+8
View File
@@ -3267,6 +3267,14 @@ są dodawane do tablicy hashy:
| arguments | ciąg | Argumenty komendy (razem z wartością 'channel')
|===
// TRANSLATION MISSING
When the data is a pointer, the variable `tg_signal_data` can be used like this
to read a hdata property (in this example this is a pointer on a buffer):
----
${buffer[${tg_signal_data}].full_name}
----
[[trigger_data_hsignal]]
===== Hsignal