core: add command /toggle

This commit is contained in:
Sébastien Helleu 2021-10-01 22:55:38 +02:00
parent 9548a4cf74
commit ad5fa7c99f
33 changed files with 2188 additions and 128 deletions

View File

@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
New features:: New features::
* core: add command /toggle
* api: add user variables in evaluation of expressions with "define:name,value" * api: add user variables in evaluation of expressions with "define:name,value"
Bug fixes:: Bug fixes::

View File

@ -1337,126 +1337,126 @@ infolists: zeigt Information über die Infolists an
/eval [-n|-s] [-d] <expression> /eval [-n|-s] [-d] <expression>
[-n] [-d [-d]] -c <expression1> <operator> <expression2> [-n] [-d [-d]] -c <expression1> <operator> <expression2>
-n: display result without sending it to buffer (debug mode) -n: gibt das Ergebnis aus, ohne dass dieses in den Buffer gesendet wird (debug Modus)
-s: split expression before evaluating it (many commands can be separated by semicolons) -s: teilt Ausdrücke, bevor sie evaluiert werden (mehrere Befehle können durch Semikolon getrennt werden)
-d: display debug output after evaluation (with two -d: more verbose debug) -d: eine Debug-Ausgabe nach Auswertung anzeigen (Nutzung von zwei -d: ausführliche Debug-Ausgabe)
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") -c: Auswertung als Bedingung: nutzt Operatoren und runde Klammern, Rückgabewert als Boolean-Wert ("0" oder "1")
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten); mehrere Befehle werden durch ein Semikolon voneinander getrennt
operator: a logical or comparison operator: operator: ein logischer oder vergleichender Operand:
- logical operators: - logische Operanden:
&& boolean "and" && boolean "und"
|| boolean "or" || boolean "oder"
- comparison operators: - vergleichende Operanden:
== equal == gleich
!= not equal != ungleich
<= less or equal <= kleiner oder gleich
< less < kleiner
>= greater or equal >= größer oder gleich
> greater > größer
=~ is matching POSIX extended regex =~ stimmt mit regulärem POSIX Ausdruck überein
!~ is NOT matching POSIX extended regex !~ stimmt NICHT mit regulärem POSIX Ausdruck überein
==* is matching mask, case sensitive (wildcard "*" is allowed) ==* stimmt mit Maske überein (Platzhalter "*" ist erlaubt)
!!* is NOT matching mask, case sensitive (wildcard "*" is allowed) !!* stimmt mit Maske NICHT überein (Platzhalter "*" ist erlaubt)
=* is matching mask, case insensitive (wildcard "*" is allowed) =* stimmt mit Maske überein, Groß- und Kleinschreibung wird nicht beachtet (Platzhalter "*" ist erlaubt)
!* is NOT matching mask, case insensitive (wildcard "*" is allowed) !* stimmt mit Maske NICHT überein, Groß- und Kleinschreibung wird nicht beachtet (Platzhalter "*" ist erlaubt)
==- is included, case sensitive ==- ist enthalten, Groß- und Kleinschreibung wird beachtet
!!- is NOT included, case sensitive !!- ist NICHT enthalten, Groß- und Kleinschreibung wird beachtet
=- is included, case insensitive =- ist enthalten, Groß- und Kleinschreibung wird nicht beachtet
!- is NOT included, case insensitive !- ist NICHT enthalten, Groß- und Kleinschreibung wird nicht beachtet
An expression is considered as "true" if it is not NULL, not empty, and different from "0". Ein Ausdruck gilt als "wahr" sofern das Ergebnis weder NULL, nicht leer und von "0" abweichend ist.
The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats: 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 (examples: 5, -7) - Integer (Beispiele: 5, -7)
- floating point number (examples: 5.2, -7.5, 2.83e-2) - Fließkommazahl (Beispiele: 5.2, -7.5, 2.83e-2)
- hexadecimal number (examples: 0xA3, -0xA3) - hexadezimale Zahl (Beispiele: 0xA3, -0xA3)
To force a string comparison, you can add double quotes around each expression, for example: Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel:
50 > 100 ==> 0 50 > 100 ==> 0
"50" > "100" ==> 1 "50" > "100" ==> 1
Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: Einige Variablen werden im Ausdruck mittels der Formatierung ${variable} ersetzt. Mögliche Variablen sind, nach Reihenfolge ihrer Priorität:
1. the string itself without evaluation (format: "raw:xxx") 1. die Zeichenfolge selbst ohne Auswertung (Format: "raw:xxx")
2. a user-defined variable (format: "name") 2. eine benutzerdefinierte Variable (Format: "name")
3. an evaluated sub-string (format: "eval:xxx") 3. eine evaluierte Teilzeichenkette (Format: "eval:xxx")
4. an evaluated condition (format: "eval_cond:xxx") 4. eine evaluierte Bedingung (Format: "eval_cond:xxx")
5. a string with escaped chars (format: "esc:xxx" or "\xxx") 5. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx")
6. a string with chars to hide (format: "hide:char,string") 6. Zeichen, die in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette")
7. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") 7. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:max,suffix,string" oder "cut:+max,suffix,string")
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+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")
8. a reversed string (format: "rev:xxx" or "revscr:xxx") 8. eine Zeichenkette umkehren (Format: "rev:xxx" oder "revscr:xxx")
9. a repeated string (format: "repeat:count,string") 9. eine Zeichenkette wiederholen (Format: "repeat:Anzahl,Zeichenkette")
10. length of a string (format: "length:xxx" or "lengthscr:xxx") 10. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx")
11. split of a string (format: "split:number,separators,flags,xxx") 11. Aufteilen einer Zeichenkette (Format: "split:Anzahl,Trennzeichen,Flags,xxx")
12. split of shell argmuents (format: "split_shell:number,xxx") 12. Aufteilen von Shell-Argumenten (Format: "split_shell:Anzahl,xxx")
13. a color (format: "color:xxx", see "Plugin API reference", function "color") 13. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color")
14. a modifier (format: "modifier:name,data,string") 14. zum modifizieren (Format: "modifier:name,data,string")
15. an info (format: "info:name,arguments", arguments are optional) 15. eine Info (Format: "Info:Name,Argumente", Argumente sind optional)
16. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") 16. eine Basis 16/32/64 kodierte / dekodierte Zeichenfolge (Format: "base_encode:base,xxx" oder "base_decode:base,xxx")
17. current date/time (format: "date" or "date:format") 17. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format")
18. an environment variable (format: "env:XXX") 18. eine Umgebungsvariable (Format: "env:XXX")
19. a ternary operator (format: "if:condition?value_if_true:value_if_false") 19. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr")
20. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") 20. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % ** (Format: "calc:xxx")
21. a random integer number (format: "random:min,max") 21. eine zufällige ganze Zahl (Format: "random:min,max")
22. a translated string (format: "translate:xxx") 22. eine übersetzte Zeichenkette (Format: "translate:xxx")
23. define a user variable (format: "define:name,value") 23. eine Benutzervariable definieren (Format: "define:Name,Wert")
24. an option (format: "file.section.option") 24. eine Option (Format: "file.section.option")
25. a local variable in buffer 25. eine lokale Variable eines Buffers
26. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. 26. 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.
Format for hdata can be one of following: Das Format für hdata kann wie folgt aufgebaut sein:
hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) 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...: start with a hdata using a list/pointer/pointer name, for example: hdata[list].var1.var2...: startet hdata mittels einer Liste, zum Beispiel:
${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers ${buffer[gui_buffers].full_name}: der vollständige Name des ersten Buffers, in der verknüpften Liste aller Buffer
${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins ${plugin[weechat_plugins].name}: Name der ersten Erweiterung, in der verknüpften Liste aller Erweiterungen
hdata[pointer].var1.var2...: start with a hdata using a pointer, for example: hdata[pointer].var1.var2...: startet hdata mittels einem Pointer, zum Beispiel:
${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers) ${buffer[0x1234abcd].full_name}: vollständiger Name eines Buffers und des dazugehörigen Pointers (kann in triggern benutzt werden)
${buffer[my_pointer].full_name}: full name of the buffer with this pointer name (can be used in triggers) ${buffer[my_pointer].full_name}: vollständiger Name des Buffers mit dem entsprechenden Pointernamen (kann in Triggern verwendet werden)
For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". Die vorhandenen Namen für hdata und Variablen sind in der "Anleitung für API Erweiterung", Bereich "weechat_hdata_get". beschrieben
Examples (simple strings): Beispiele (einfache Zeichenketten):
/eval -n ${raw:${info:version}} ==> ${info:version} /eval -n ${raw:${info:version}} ==> ${info:version}
/eval -n ${eval_cond:${window.win_width}>100} ==> 1 /eval -n ${eval_cond:${window.win_width}>100} ==> 1
/eval -n ${info:version} ==> 0.4.3 /eval -n ${info:version} ==> 0.4.3
/eval -n ${env:HOME} ==> /home/user /eval -n ${env:HOME} ==> /home/user
/eval -n ${weechat.look.scroll_amount} ==> 3 /eval -n ${weechat.look.scroll_amount} ==> 3
/eval -n ${sec.data.password} ==> secret /eval -n ${sec.data.password} ==> geheim
/eval -n ${window} ==> 0x2549aa0 /eval -n ${window} ==> 0x2549aa0
/eval -n ${window.buffer} ==> 0x2549320 /eval -n ${window.buffer} ==> 0x2549320
/eval -n ${window.buffer.full_name} ==> core.weechat /eval -n ${window.buffer.full_name} ==> core.weechat
/eval -n ${window.buffer.number} ==> 1 /eval -n ${window.buffer.number} ==> 1
/eval -n ${\t} ==> <tab> /eval -n ${\t} ==> <tab>
/eval -n ${hide:-,${relay.network.password}} ==> -------- /eval -n ${hide:-,${relay.network.password}} ==> --------
/eval -n ${cut:3,+,test} ==> tes+ /eval -n ${cut:3,+,test} ==> tes+
/eval -n ${cut:+3,+,test} ==> te+ /eval -n ${cut:+3,+,test} ==> te+
/eval -n ${date:%H:%M:%S} ==> 07:46:40 /eval -n ${date:%H:%M:%S} ==> 07:46:40
/eval -n ${if:${info:term_width}>80?big:small} ==> big /eval -n ${if:${info:term_width}>80?big:small} ==> big
/eval -n ${rev:Hello} ==> olleH /eval -n ${rev:Hello} ==> olleH
/eval -n ${repeat:5,-} ==> ----- /eval -n ${repeat:5,-} ==> -----
/eval -n ${length:test} ==> 4 /eval -n ${length:test} ==> 4
/eval -n ${split:1,,,abc,def,ghi} ==> abc /eval -n ${split:1,,,abc,def,ghi} ==> abc
/eval -n ${split:-1,,,abc,def,ghi} ==> ghi /eval -n ${split:-1,,,abc,def,ghi} ==> ghi
/eval -n ${split:count,,,abc,def,ghi} ==> 3 /eval -n ${split:count,,,abc,def,ghi} ==> 3
/eval -n ${split:random,,,abc,def,ghi} ==> def /eval -n ${split:random,,,abc,def,ghi} ==> def
/eval -n ${split_shell:1,"arg 1" arg2} ==> arg 1 /eval -n ${split_shell:1,"arg 1" arg2} ==> arg 1
/eval -n ${split_shell:-1,"arg 1" arg2} ==> arg2 /eval -n ${split_shell:-1,"arg 1" arg2} ==> arg2
/eval -n ${split_shell:count,"arg 1" arg2} ==> 2 /eval -n ${split_shell:count,"arg 1" arg2} ==> 2
/eval -n ${split_shell:random,"arg 1" arg2} ==> arg2 /eval -n ${split_shell:random,"arg 1" arg2} ==> arg2
/eval -n ${calc:(5+2)*3} ==> 21 /eval -n ${calc:(5+2)*3} ==> 21
/eval -n ${random:0,10} ==> 3 /eval -n ${random:0,10} ==> 3
/eval -n ${base_encode:64,test} ==> dGVzdA== /eval -n ${base_encode:64,test} ==> dGVzdA==
/eval -n ${base_decode:64,dGVzdA==} ==> test /eval -n ${base_decode:64,dGVzdA==} ==> test
/eval -n ${translate:Plugin} ==> Extension /eval -n ${translate:Plugin} ==> Erweiterung
/eval -n ${define:len,${calc:5+3}}${len}x${len} ==> 8x8 /eval -n ${define:len,${calc:5+3}}${len}x${len} ==> 8x8
Examples (conditions): Beispiele (Bedingungen):
/eval -n -c ${window.buffer.number} > 2 ==> 0 /eval -n -c ${window.buffer.number} > 2 ==> 0
/eval -n -c ${window.win_width} > 100 ==> 1 /eval -n -c ${window.win_width} > 100 ==> 1
/eval -n -c (8 > 12) || (5 > 2) ==> 1 /eval -n -c (8 > 12) || (5 > 2) ==> 1
/eval -n -c (8 > 12) && (5 > 2) ==> 0 /eval -n -c (8 > 12) && (5 > 2) ==> 0
/eval -n -c abcd =~ ^ABC ==> 1 /eval -n -c abcd =~ ^ABC ==> 1
/eval -n -c abcd =~ (?-i)^ABC ==> 0 /eval -n -c abcd =~ (?-i)^ABC ==> 0
/eval -n -c abcd =~ (?-i)^abc ==> 1 /eval -n -c abcd =~ (?-i)^abc ==> 1
/eval -n -c abcd !~ abc ==> 0 /eval -n -c abcd !~ abc ==> 0
/eval -n -c abcd =* a*d ==> 1 /eval -n -c abcd =* a*d ==> 1
/eval -n -c abcd =- bc ==> 1 /eval -n -c abcd =- bc ==> 1
---- ----
[[command_weechat_filter]] [[command_weechat_filter]]
@ -1993,6 +1993,32 @@ Beispiele:
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: toggle value of a config option
----
/toggle <option> [<value> [<value>...]]
option: name of an option
value: possible values for the option (values are split like the shell command arguments: quotes can be used to preserve spaces at the beginning/end of values)
Behavior:
- only an option of type boolean or string can be toggled without a value:
- boolean: toggle between on/off according to current value
- string: toggle between empty string and default value (works only if empty string is allowed for the option)
- with a single value given, toggle between this value and the default value of option
- with multiple values given, toggle between these values: the value used is the one following the current value of option; if the current value of option is not in list, the first value in the list is used
- the special value "null" can be given, but only as first value in the list and without quotes around.
Examples:
toggle display of time in chat area (without displaying the new value used):
/mute /toggle weechat.look.buffer_time_format
switch format of time in chat area (with seconds, without seconds, disabled):
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
toggle autojoin of #weechat channel on libera server:
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: Konfigurationsparameter freigeben/zurücksetzen * `+unset+`: Konfigurationsparameter freigeben/zurücksetzen

View File

@ -1993,6 +1993,32 @@ Examples:
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: toggle value of a config option
----
/toggle <option> [<value> [<value>...]]
option: name of an option
value: possible values for the option (values are split like the shell command arguments: quotes can be used to preserve spaces at the beginning/end of values)
Behavior:
- only an option of type boolean or string can be toggled without a value:
- boolean: toggle between on/off according to current value
- string: toggle between empty string and default value (works only if empty string is allowed for the option)
- with a single value given, toggle between this value and the default value of option
- with multiple values given, toggle between these values: the value used is the one following the current value of option; if the current value of option is not in list, the first value in the list is used
- the special value "null" can be given, but only as first value in the list and without quotes around.
Examples:
toggle display of time in chat area (without displaying the new value used):
/mute /toggle weechat.look.buffer_time_format
switch format of time in chat area (with seconds, without seconds, disabled):
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
toggle autojoin of #weechat channel on libera server:
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: unset/reset config options * `+unset+`: unset/reset config options

View File

@ -403,6 +403,7 @@ WeeChat "core" is located in following directories:
|       core/ | Root of unit tests for core. |       core/ | Root of unit tests for core.
|          test-core-arraylist.cpp | Tests: arraylists. |          test-core-arraylist.cpp | Tests: arraylists.
|          test-core-calc.cpp | Tests: calculation of expressions. |          test-core-calc.cpp | Tests: calculation of expressions.
|          test-core-config-file.cpp | Tests: configuration files.
|          test-core-crypto.cpp | Tests: cryptographic functions. |          test-core-crypto.cpp | Tests: cryptographic functions.
|          test-core-dir.cpp | Tests: directory/file functions. |          test-core-dir.cpp | Tests: directory/file functions.
|          test-core-eval.cpp | Tests: evaluation of expressions. |          test-core-eval.cpp | Tests: evaluation of expressions.

View File

@ -1993,6 +1993,32 @@ Exemples :
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: basculer la valeur d'une option de configuration
----
/toggle <option> [<valeur> [<valeur>...]]
option : nom d'une option
valeur : valeurs possibles pour l'option (les valeurs sont découpées comme le les paramètres d'une commande par le shell : des guillemets peuvent être utilisés pour préserver les espaces au début et à la fin des valeurs)
Comportement :
- seule une option de type booléen ou chaîne peut être basculée sans valeur :
- booléen : basculer on/off selon la valeur courante
- chaîne : basculer entre chaîne vide et la valeur par défaut (fonctionne seulement si une chaîne vide est autorisée pour l'option)
- avec une seule valeur donnée, basculer entre cette valeur et la valeur par défaut de l'option
- avec plusieurs valeurs données, basculer entre les valeurs : la valeur utilisée est celle qui suit la valeur courante de l'option ; si la valeur courante n'est pas dans la liste, la première valeur de la liste est utilisée
- la valeur spéciale "null" peut être donnée, mais seulement comme première valeur dans la liste et sans guillemets autour.
Exemples :
basculer l'affichage de l'heure dans la zone de discussion (sans afficher la nouvelle valeur utilisée) :
/mute /toggle weechat.look.buffer_time_format
basculer le format de l'heure dans la zone de discussion (avec secondes, sans secondes, désactivé) :
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
basculer le "join" automatique du canal #weechat sur le serveur libera :
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: supprimer/réinitialiser des options de configuration * `+unset+`: supprimer/réinitialiser des options de configuration

View File

@ -405,6 +405,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|       core/ | Racine des tests unitaires pour le cœur. |       core/ | Racine des tests unitaires pour le cœur.
|          test-core-arraylist.cpp | Tests : listes avec tableau (« arraylists »). |          test-core-arraylist.cpp | Tests : listes avec tableau (« arraylists »).
|          test-core-calc.cpp | Tests : calcul d'expressions. |          test-core-calc.cpp | Tests : calcul d'expressions.
|          test-core-config-file.cpp | Tests : fichiers de configuration.
|          test-core-crypto.cpp | Tests : fonctions cryptographiques. |          test-core-crypto.cpp | Tests : fonctions cryptographiques.
|          test-core-dir.cpp | Tests : répertoires/fichiers. |          test-core-dir.cpp | Tests : répertoires/fichiers.
|          test-core-eval.cpp | Tests : évaluation d'expressions. |          test-core-eval.cpp | Tests : évaluation d'expressions.

View File

@ -1993,6 +1993,32 @@ Examples:
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: toggle value of a config option
----
/toggle <option> [<value> [<value>...]]
option: name of an option
value: possible values for the option (values are split like the shell command arguments: quotes can be used to preserve spaces at the beginning/end of values)
Behavior:
- only an option of type boolean or string can be toggled without a value:
- boolean: toggle between on/off according to current value
- string: toggle between empty string and default value (works only if empty string is allowed for the option)
- with a single value given, toggle between this value and the default value of option
- with multiple values given, toggle between these values: the value used is the one following the current value of option; if the current value of option is not in list, the first value in the list is used
- the special value "null" can be given, but only as first value in the list and without quotes around.
Examples:
toggle display of time in chat area (without displaying the new value used):
/mute /toggle weechat.look.buffer_time_format
switch format of time in chat area (with seconds, without seconds, disabled):
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
toggle autojoin of #weechat channel on libera server:
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: annulla/ripristina opzione * `+unset+`: annulla/ripristina opzione

View File

@ -1993,6 +1993,32 @@ option: オプションの名前 (value を指定せずにワイルドカード
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: toggle value of a config option
----
/toggle <option> [<value> [<value>...]]
option: name of an option
value: possible values for the option (values are split like the shell command arguments: quotes can be used to preserve spaces at the beginning/end of values)
Behavior:
- only an option of type boolean or string can be toggled without a value:
- boolean: toggle between on/off according to current value
- string: toggle between empty string and default value (works only if empty string is allowed for the option)
- with a single value given, toggle between this value and the default value of option
- with multiple values given, toggle between these values: the value used is the one following the current value of option; if the current value of option is not in list, the first value in the list is used
- the special value "null" can be given, but only as first value in the list and without quotes around.
Examples:
toggle display of time in chat area (without displaying the new value used):
/mute /toggle weechat.look.buffer_time_format
switch format of time in chat area (with seconds, without seconds, disabled):
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
toggle autojoin of #weechat channel on libera server:
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: オプションのアンセット/リセット * `+unset+`: オプションのアンセット/リセット

View File

@ -424,6 +424,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
// TRANSLATION MISSING // TRANSLATION MISSING
|          test-core-calc.cpp | Tests: calculation of expressions. |          test-core-calc.cpp | Tests: calculation of expressions.
// TRANSLATION MISSING // TRANSLATION MISSING
|          test-core-config-file.cpp | Tests: configuration files.
// TRANSLATION MISSING
|          test-core-crypto.cpp | Tests: cryptographic functions. |          test-core-crypto.cpp | Tests: cryptographic functions.
// TRANSLATION MISSING // TRANSLATION MISSING
|          test-core-dir.cpp | Tests: directory/file functions. |          test-core-dir.cpp | Tests: directory/file functions.

View File

@ -1992,6 +1992,32 @@ Przykłady:
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: toggle value of a config option
----
/toggle <option> [<value> [<value>...]]
option: name of an option
value: possible values for the option (values are split like the shell command arguments: quotes can be used to preserve spaces at the beginning/end of values)
Behavior:
- only an option of type boolean or string can be toggled without a value:
- boolean: toggle between on/off according to current value
- string: toggle between empty string and default value (works only if empty string is allowed for the option)
- with a single value given, toggle between this value and the default value of option
- with multiple values given, toggle between these values: the value used is the one following the current value of option; if the current value of option is not in list, the first value in the list is used
- the special value "null" can be given, but only as first value in the list and without quotes around.
Examples:
toggle display of time in chat area (without displaying the new value used):
/mute /toggle weechat.look.buffer_time_format
switch format of time in chat area (with seconds, without seconds, disabled):
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
toggle autojoin of #weechat channel on libera server:
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: skasuj/zresetuj zmienną konfiguracyjną * `+unset+`: skasuj/zresetuj zmienną konfiguracyjną

View File

@ -1993,6 +1993,32 @@ passphrase: измена тајне реченице (без passphrase, под
/set env ABC "" /set env ABC ""
---- ----
[[command_weechat_toggle]]
* `+toggle+`: toggle value of a config option
----
/toggle <option> [<value> [<value>...]]
option: name of an option
value: possible values for the option (values are split like the shell command arguments: quotes can be used to preserve spaces at the beginning/end of values)
Behavior:
- only an option of type boolean or string can be toggled without a value:
- boolean: toggle between on/off according to current value
- string: toggle between empty string and default value (works only if empty string is allowed for the option)
- with a single value given, toggle between this value and the default value of option
- with multiple values given, toggle between these values: the value used is the one following the current value of option; if the current value of option is not in list, the first value in the list is used
- the special value "null" can be given, but only as first value in the list and without quotes around.
Examples:
toggle display of time in chat area (without displaying the new value used):
/mute /toggle weechat.look.buffer_time_format
switch format of time in chat area (with seconds, without seconds, disabled):
/toggle weechat.look.buffer_time_format "%H:%M:%S" "%H:%M" ""
toggle autojoin of #weechat channel on libera server:
/toggle irc.server.libera.autojoin null #weechat
----
[[command_weechat_unset]] [[command_weechat_unset]]
* `+unset+`: уклањање/ресетовање конфиг опција * `+unset+`: уклањање/ресетовање конфиг опција

View File

@ -403,6 +403,8 @@ WeeChat „језгро” се налази у следећим директо
|       core/ | Корен unit тестова језгра. |       core/ | Корен unit тестова језгра.
|          test-core-arraylist.cpp | Тестови: arraylists. |          test-core-arraylist.cpp | Тестови: arraylists.
|          test-core-calc.cpp | Тестови: калкулација израза. |          test-core-calc.cpp | Тестови: калкулација израза.
// TRANSLATION MISSING
|          test-core-config-file.cpp | Tests: configuration files.
|          test-core-crypto.cpp | Тестови: криптографске функције. |          test-core-crypto.cpp | Тестови: криптографске функције.
|          test-core-dir.cpp | Тестови: функције директоријума/фајла. |          test-core-dir.cpp | Тестови: функције директоријума/фајла.
|          test-core-eval.cpp | Тестови: израчунавање израза. |          test-core-eval.cpp | Тестови: израчунавање израза.

View File

@ -21,7 +21,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2478,6 +2478,47 @@ msgstr ""
" nastaví slovo pro zvýrazňování:\n" " nastaví slovo pro zvýrazňování:\n"
" /set weechat.look.highlight \"word\"" " /set weechat.look.highlight \"word\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "hodnoty pro konfigurační nastavení"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<soubor> [<soubor>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "odnastavit/resetovat konfigurační možnosti" msgstr "odnastavit/resetovat konfigurační možnosti"

View File

@ -24,7 +24,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-09-26 20:24+0200\n" "PO-Revision-Date: 2021-09-26 20:24+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n" "Language-Team: German <kde-i18n-de@kde.org>\n"
@ -3160,6 +3160,47 @@ msgstr ""
" entfernt die Umgebungsvariable ABC:\n" " entfernt die Umgebungsvariable ABC:\n"
" /set env ABC \"\"" " /set env ABC \"\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "Werte für eine Konfigurationsoption"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<file> [<file>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "Konfigurationsparameter freigeben/zurücksetzen" msgstr "Konfigurationsparameter freigeben/zurücksetzen"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2584,6 +2584,47 @@ msgstr ""
" mostrar opciones cambiadas en el plugin irc:\n" " mostrar opciones cambiadas en el plugin irc:\n"
" /set diff irc.*" " /set diff irc.*"
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "valores de una opción de configuración"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<archivo> [<archivo>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "deshacer/reiniciar opciones de configuración" msgstr "deshacer/reiniciar opciones de configuración"

View File

@ -21,8 +21,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-09-20 21:13+0200\n" "PO-Revision-Date: 2021-10-01 22:53+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n" "Language: fr\n"
@ -3086,6 +3086,73 @@ msgstr ""
" réinitialiser la variable d'environnement ABC :\n" " réinitialiser la variable d'environnement ABC :\n"
" /set env ABC \"\"" " /set env ABC \"\""
msgid "toggle value of a config option"
msgstr "basculer la valeur d'une option de configuration"
msgid "<option> [<value> [<value>...]]"
msgstr "<option> [<valeur> [<valeur>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
"option : nom d'une option\n"
"valeur : valeurs possibles pour l'option (les valeurs sont découpées comme "
"le les paramètres d'une commande par le shell : des guillemets peuvent être "
"utilisés pour préserver les espaces au début et à la fin des valeurs)\n"
"\n"
"Comportement :\n"
" - seule une option de type booléen ou chaîne peut être basculée sans "
"valeur :\n"
" - booléen : basculer on/off selon la valeur courante\n"
" - chaîne : basculer entre chaîne vide et la valeur par défaut "
"(fonctionne seulement si une chaîne vide est autorisée pour l'option)\n"
" - avec une seule valeur donnée, basculer entre cette valeur et la valeur "
"par défaut de l'option\n"
" - avec plusieurs valeurs données, basculer entre les valeurs : la valeur "
"utilisée est celle qui suit la valeur courante de l'option ; si la valeur "
"courante n'est pas dans la liste, la première valeur de la liste est "
"utilisée\n"
" - la valeur spéciale \"null\" peut être donnée, mais seulement comme "
"première valeur dans la liste et sans guillemets autour.\n"
"\n"
"Exemples :\n"
" basculer l'affichage de l'heure dans la zone de discussion (sans afficher "
"la nouvelle valeur utilisée) :\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" basculer le format de l'heure dans la zone de discussion (avec secondes, "
"sans secondes, désactivé) :\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" basculer le \"join\" automatique du canal #weechat sur le serveur "
"libera :\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "supprimer/réinitialiser des options de configuration" msgstr "supprimer/réinitialiser des options de configuration"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2259,6 +2259,44 @@ msgid ""
" /set env ABC \"\"" " /set env ABC \"\""
msgstr "" msgstr ""
#, fuzzy
msgid "toggle value of a config option"
msgstr "Nem található az opció\n"
msgid "<option> [<value> [<value>...]]"
msgstr ""
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
#, fuzzy #, fuzzy
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "konfigurációs paraméterek beállítása" msgstr "konfigurációs paraméterek beállítása"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2634,6 +2634,47 @@ msgstr ""
" mostra le opzioni modificate nel plugin irc:\n" " mostra le opzioni modificate nel plugin irc:\n"
" /set diff irc.*" " /set diff irc.*"
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "valori per una opzione di configurazione"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<file> [<file....>]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "annulla/ripristina opzione" msgstr "annulla/ripristina opzione"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/" "Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@ -3027,6 +3027,47 @@ msgstr ""
" 環境変数 ABC の値を削除する:\n" " 環境変数 ABC の値を削除する:\n"
" /set env ABC \"\"" " /set env ABC \"\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "設定オプションの値"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<file> [<file>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "オプションのアンセット/リセット" msgstr "オプションのアンセット/リセット"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <kde-i18n-doc@kde.org>\n" "Language-Team: Polish <kde-i18n-doc@kde.org>\n"
@ -3218,6 +3218,47 @@ msgstr ""
" kasuje zmienną środowiskową ABC:\n" " kasuje zmienną środowiskową ABC:\n"
" /set env ABC \"\"" " /set env ABC \"\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "wartości opcji konfiguracyjnych"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<plik> [<plik>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "skasuj/zresetuj zmienną konfiguracyjną" msgstr "skasuj/zresetuj zmienną konfiguracyjną"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n" "Language-Team: Portuguese <>\n"
@ -3021,6 +3021,47 @@ msgstr ""
" não definir a variável de ambiente ABC:\n" " não definir a variável de ambiente ABC:\n"
" /set env ABC \"\"" " /set env ABC \"\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "valores de uma opção de configuração"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<ficheiro> [<ficheiro>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "repor ou não definir opções de configuração" msgstr "repor ou não definir opções de configuração"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Érico Nogueira <ericonr@disroot.org>\n" "Last-Translator: Érico Nogueira <ericonr@disroot.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2694,6 +2694,47 @@ msgstr ""
" indefine a variável de ambiente ABC:\n" " indefine a variável de ambiente ABC:\n"
" /set env ABC \"\"" " /set env ABC \"\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "valores para uma opção de configuração"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<arquivo> [<arquivo>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "indefine/restaura opções de configuração" msgstr "indefine/restaura opções de configuração"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2283,6 +2283,44 @@ msgid ""
" /set env ABC \"\"" " /set env ABC \"\""
msgstr "" msgstr ""
#, fuzzy
msgid "toggle value of a config option"
msgstr "Не найден параметр\n"
msgid "<option> [<value> [<value>...]]"
msgstr ""
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
#, fuzzy #, fuzzy
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "настроить параметры конфигурации" msgstr "настроить параметры конфигурации"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-09-01 02:38+0400\n" "PO-Revision-Date: 2021-09-01 02:38+0400\n"
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n" "Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3146,6 +3146,47 @@ msgstr ""
" уклања променљиву окружења ABC:\n" " уклања променљиву окружења ABC:\n"
" /set env ABC \"\"" " /set env ABC \"\""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "вредности за опцију конфигурације"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<фајл> [<фајл>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "уклањање/ресетовање конфиг опција" msgstr "уклањање/ресетовање конфиг опција"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2021-07-10 16:01+0200\n" "PO-Revision-Date: 2021-07-10 16:01+0200\n"
"Last-Translator: Emir SARI <bitigchi@me.com>\n" "Last-Translator: Emir SARI <bitigchi@me.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2557,6 +2557,47 @@ msgid ""
" /set env ABC \"\"" " /set env ABC \"\""
msgstr "" msgstr ""
#, fuzzy
#| msgid "values for a configuration option"
msgid "toggle value of a config option"
msgstr "bir yapılandırma seçeneğinin değerleri"
#, fuzzy
#| msgid "[<file> [<file>...]]"
msgid "<option> [<value> [<value>...]]"
msgstr "[<dosya> [<dosya>...]]"
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "yapılandırma seçeneklerini geri al/sıfırla" msgstr "yapılandırma seçeneklerini geri al/sıfırla"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat\n" "Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2021-09-20 21:12+0200\n" "POT-Creation-Date: 2021-10-01 22:52+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2083,6 +2083,43 @@ msgid ""
" /set env ABC \"\"" " /set env ABC \"\""
msgstr "" msgstr ""
msgid "toggle value of a config option"
msgstr ""
msgid "<option> [<value> [<value>...]]"
msgstr ""
msgid ""
"option: name of an option\n"
" value: possible values for the option (values are split like the shell "
"command arguments: quotes can be used to preserve spaces at the beginning/"
"end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled without a "
"value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value (works only if "
"empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and the default "
"value of option\n"
" - with multiple values given, toggle between these values: the value used "
"is the one following the current value of option; if the current value of "
"option is not in list, the first value in the list is used\n"
" - the special value \"null\" can be given, but only as first value in the "
"list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the new value "
"used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without seconds, "
"disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" \"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"
msgstr ""
msgid "unset/reset config options" msgid "unset/reset config options"
msgstr "" msgstr ""

View File

@ -6302,6 +6302,78 @@ COMMAND_CALLBACK(set)
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
} }
/*
* Callback for command "/toggle": toggles value of configuration option.
*/
COMMAND_CALLBACK(toggle)
{
char **sargv;
int sargc, rc;
struct t_config_option *ptr_option;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) buffer;
COMMAND_MIN_ARGS(2, "");
config_file_search_with_string (argv[1], NULL, NULL, &ptr_option, NULL);
if (!ptr_option)
{
gui_chat_printf (NULL,
_("%sOption \"%s\" not found"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return WEECHAT_RC_OK;
}
if ((ptr_option->type != CONFIG_OPTION_TYPE_BOOLEAN)
&& (ptr_option->type != CONFIG_OPTION_TYPE_STRING))
{
/* only boolean options can be toggled without a value */
COMMAND_MIN_ARGS(3, "");
}
if (argc > 2)
{
sargv = string_split_shell (argv_eol[2], &sargc);
if (!sargv)
COMMAND_ERROR;
if (string_strcasecmp (argv[2], WEECHAT_CONFIG_OPTION_NULL) == 0)
{
if (sargv[0])
free (sargv[0]);
sargv[0] = NULL;
}
}
else
{
sargv = NULL;
sargc = 0;
}
rc = config_file_option_toggle (ptr_option, (const char **)sargv, sargc, 1);
string_free_split (sargv);
switch (rc)
{
case WEECHAT_CONFIG_OPTION_SET_ERROR:
gui_chat_printf (NULL,
_("%sFailed to set option \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return WEECHAT_RC_OK;
case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
command_set_display_option (ptr_option, _("Option changed: "));
break;
default:
break;
}
return WEECHAT_RC_OK;
}
/* /*
* Unsets/resets one option. * Unsets/resets one option.
*/ */
@ -8425,6 +8497,42 @@ command_init ()
" || diff %(config_options)|%*" " || diff %(config_options)|%*"
" || env %(env_vars) %(env_value)", " || env %(env_vars) %(env_value)",
&command_set, NULL, NULL); &command_set, NULL, NULL);
hook_command (
NULL, "toggle",
N_("toggle value of a config option"),
N_("<option> [<value> [<value>...]]"),
N_("option: name of an option\n"
" value: possible values for the option (values are split like the "
"shell command arguments: quotes can be used to preserve spaces at "
"the beginning/end of values)\n"
"\n"
"Behavior:\n"
" - only an option of type boolean or string can be toggled "
"without a value:\n"
" - boolean: toggle between on/off according to current value\n"
" - string: toggle between empty string and default value "
"(works only if empty string is allowed for the option)\n"
" - with a single value given, toggle between this value and "
"the default value of option\n"
" - with multiple values given, toggle between these values: "
"the value used is the one following the current value of option; "
"if the current value of option is not in list, the first value in "
"the list is used\n"
" - the special value \"null\" can be given, but only as first "
"value in the list and without quotes around.\n"
"\n"
"Examples:\n"
" toggle display of time in chat area (without displaying the "
"new value used):\n"
" /mute /toggle weechat.look.buffer_time_format\n"
" switch format of time in chat area (with seconds, without "
"seconds, disabled):\n"
" /toggle weechat.look.buffer_time_format \"%H:%M:%S\" "
"\"%H:%M\" \"\"\n"
" toggle autojoin of #weechat channel on libera server:\n"
" /toggle irc.server.libera.autojoin null #weechat"),
"%(config_options) %(config_option_values)",
&command_toggle, NULL, NULL);
hook_command ( hook_command (
NULL, "unset", NULL, "unset",
N_("unset/reset config options"), N_("unset/reset config options"),

View File

@ -1520,6 +1520,110 @@ config_file_option_set (struct t_config_option *option, const char *value,
return rc; return rc;
} }
/*
* Toggles value of an option.
*
* Returns:
* WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: OK, value has been changed
* WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE: OK, value not changed
* WEECHAT_CONFIG_OPTION_SET_ERROR: error
*/
int
config_file_option_toggle (struct t_config_option *option,
const char **values, int num_values,
int run_callback)
{
char *current_value;
const char *ptr_new_value, *empty_string = "";
int i, rc, index_found, value_is_null, reset_value;
if (!option || (num_values < 0))
return WEECHAT_CONFIG_OPTION_SET_ERROR;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
ptr_new_value = NULL;
reset_value = 0;
value_is_null = (option->value == NULL);
current_value = config_file_option_value_to_string (option, 0, 0, 0);
switch (option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
if (!values)
{
ptr_new_value = (option->value && CONFIG_BOOLEAN(option)) ?
config_boolean_false[0] : config_boolean_true[0];
}
break;
case CONFIG_OPTION_TYPE_INTEGER:
if (!values)
goto end;
break;
case CONFIG_OPTION_TYPE_STRING:
if (!values)
{
if (option->value && (strcmp (CONFIG_STRING(option), "") == 0))
ptr_new_value = CONFIG_STRING_DEFAULT(option);
else
ptr_new_value = empty_string;
}
break;
case CONFIG_OPTION_TYPE_COLOR:
if (!values)
goto end;
break;
case CONFIG_NUM_OPTION_TYPES:
/* make C compiler happy */
break;
}
/* search new value to use with the provided list of values */
if (!ptr_new_value && values)
{
index_found = -1;
for (i = 0; i < num_values; i++)
{
if ((value_is_null && !values[i])
|| (!value_is_null && current_value && values[i]
&& strcmp (current_value, values[i]) == 0))
{
index_found = i;
break;
}
}
if (index_found >= 0)
{
if (index_found + 1 < num_values)
{
ptr_new_value = values[index_found + 1];
}
else
{
if (num_values < 2)
reset_value = 1;
else
ptr_new_value = values[0];
}
}
else
{
ptr_new_value = values[0];
}
}
if (reset_value)
rc = config_file_option_reset (option, run_callback);
else
rc = config_file_option_set (option, ptr_new_value, run_callback);
end:
if (current_value)
free (current_value);
return rc;
}
/* /*
* Sets null (undefined) value for an option. * Sets null (undefined) value for an option.
* *

View File

@ -259,6 +259,9 @@ extern int config_file_option_set (struct t_config_option *option,
const char *value, int run_callback); const char *value, int run_callback);
extern int config_file_option_set_null (struct t_config_option *option, extern int config_file_option_set_null (struct t_config_option *option,
int run_callback); int run_callback);
extern int config_file_option_toggle (struct t_config_option *option,
const char **values, int num_values,
int run_callback);
extern int config_file_option_unset (struct t_config_option *option); extern int config_file_option_unset (struct t_config_option *option);
extern void config_file_option_rename (struct t_config_option *option, extern void config_file_option_rename (struct t_config_option *option,
const char *new_name); const char *new_name);

View File

@ -26,6 +26,7 @@ include_directories(${CPPUTEST_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} ${PROJECT_SOU
set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC
unit/core/test-core-arraylist.cpp unit/core/test-core-arraylist.cpp
unit/core/test-core-calc.cpp unit/core/test-core-calc.cpp
unit/core/test-core-config-file.cpp
unit/core/test-core-crypto.cpp unit/core/test-core-crypto.cpp
unit/core/test-core-dir.cpp unit/core/test-core-dir.cpp
unit/core/test-core-eval.cpp unit/core/test-core-eval.cpp

View File

@ -23,6 +23,7 @@ noinst_LIBRARIES = lib_weechat_unit_tests_core.a
lib_weechat_unit_tests_core_a_SOURCES = unit/core/test-core-arraylist.cpp \ lib_weechat_unit_tests_core_a_SOURCES = unit/core/test-core-arraylist.cpp \
unit/core/test-core-calc.cpp \ unit/core/test-core-calc.cpp \
unit/core/test-core-config-file.cpp \
unit/core/test-core-crypto.cpp \ unit/core/test-core-crypto.cpp \
unit/core/test-core-dir.cpp \ unit/core/test-core-dir.cpp \
unit/core/test-core-eval.cpp \ unit/core/test-core-eval.cpp \

View File

@ -61,6 +61,7 @@ extern "C"
/* core */ /* core */
IMPORT_TEST_GROUP(CoreArraylist); IMPORT_TEST_GROUP(CoreArraylist);
IMPORT_TEST_GROUP(CoreCalc); IMPORT_TEST_GROUP(CoreCalc);
IMPORT_TEST_GROUP(CoreConfigFile);
IMPORT_TEST_GROUP(CoreCrypto); IMPORT_TEST_GROUP(CoreCrypto);
IMPORT_TEST_GROUP(CoreDir); IMPORT_TEST_GROUP(CoreDir);
IMPORT_TEST_GROUP(CoreEval); IMPORT_TEST_GROUP(CoreEval);

File diff suppressed because it is too large Load Diff