diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-01 22:55:38 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-01 22:55:38 +0200 |
commit | ad5fa7c99faf8a1c0b6b9b1f7f6e4b42a03a5c2c (patch) | |
tree | 34dca4da20d04e00dc5548d31bf6de73c6c7fc0e | |
parent | 9548a4cf747c54aac641544049a24fb1f270c14f (diff) | |
download | weechat-ad5fa7c99faf8a1c0b6b9b1f7f6e4b42a03a5c2c.zip |
core: add command /toggle
33 files changed, 2190 insertions, 130 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 30550ef2c..980ba0397 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] New features:: + * core: add command /toggle * api: add user variables in evaluation of expressions with "define:name,value" Bug fixes:: diff --git a/doc/de/includes/autogen_user_commands.de.adoc b/doc/de/includes/autogen_user_commands.de.adoc index 6e8dc132b..ba625da1f 100644 --- a/doc/de/includes/autogen_user_commands.de.adoc +++ b/doc/de/includes/autogen_user_commands.de.adoc @@ -1337,126 +1337,126 @@ infolists: zeigt Information über die Infolists an /eval [-n|-s] [-d] <expression> [-n] [-d [-d]] -c <expression1> <operator> <expression2> - -n: display result without sending it to buffer (debug mode) - -s: split expression before evaluating it (many commands can be separated by semicolons) - -d: display debug output after evaluation (with two -d: more verbose debug) - -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") -expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons - operator: a logical or comparison operator: - - logical operators: - && boolean "and" - || boolean "or" - - comparison operators: - == equal - != not equal - <= less or equal - < less - >= greater or equal - > greater - =~ is matching POSIX extended regex - !~ is NOT matching POSIX extended regex - ==* is matching mask, case sensitive (wildcard "*" is allowed) - !!* is NOT matching mask, case sensitive (wildcard "*" is allowed) - =* is matching mask, case insensitive (wildcard "*" is allowed) - !* is NOT matching mask, case insensitive (wildcard "*" is allowed) - ==- is included, case sensitive - !!- is NOT included, case sensitive - =- is included, case insensitive - !- is NOT included, case insensitive - -An expression is considered as "true" if it is not NULL, not empty, and different from "0". -The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats: - - integer (examples: 5, -7) - - floating point number (examples: 5.2, -7.5, 2.83e-2) - - hexadecimal number (examples: 0xA3, -0xA3) -To force a string comparison, you can add double quotes around each expression, for example: + -n: gibt das Ergebnis aus, ohne dass dieses in den Buffer gesendet wird (debug Modus) + -s: teilt Ausdrücke, bevor sie evaluiert werden (mehrere Befehle können durch Semikolon getrennt werden) + -d: eine Debug-Ausgabe nach Auswertung anzeigen (Nutzung von zwei -d: ausführliche Debug-Ausgabe) + -c: Auswertung als Bedingung: nutzt Operatoren und runde Klammern, Rückgabewert als Boolean-Wert ("0" oder "1") +expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten); mehrere Befehle werden durch ein Semikolon voneinander getrennt + operator: ein logischer oder vergleichender Operand: + - logische Operanden: + && boolean "und" + || boolean "oder" + - vergleichende Operanden: + == gleich + != ungleich + <= kleiner oder gleich + < kleiner + >= größer oder gleich + > größer + =~ stimmt mit regulärem POSIX Ausdruck überein + !~ stimmt NICHT mit regulärem POSIX Ausdruck überein + ==* stimmt mit Maske überein (Platzhalter "*" ist erlaubt) + !!* stimmt mit Maske NICHT überein (Platzhalter "*" ist erlaubt) + =* stimmt mit Maske überein, Groß- und Kleinschreibung wird nicht beachtet (Platzhalter "*" ist erlaubt) + !* stimmt mit Maske NICHT überein, Groß- und Kleinschreibung wird nicht beachtet (Platzhalter "*" ist erlaubt) + ==- ist enthalten, Groß- und Kleinschreibung wird beachtet + !!- ist NICHT enthalten, Groß- und Kleinschreibung wird beachtet + =- ist enthalten, Groß- und Kleinschreibung wird nicht beachtet + !- ist NICHT enthalten, Groß- und Kleinschreibung wird nicht beachtet + +Ein Ausdruck gilt als "wahr" sofern das Ergebnis weder NULL, nicht leer und von "0" abweichend ist. +Für einen Vergleich werden Fließkommazahlen genutzt, insofern es sich bei beiden Ausdrücken um gültige Zahlen handelt, folgende Formate werden unterstützt: + - Integer (Beispiele: 5, -7) + - Fließkommazahl (Beispiele: 5.2, -7.5, 2.83e-2) + - hexadezimale Zahl (Beispiele: 0xA3, -0xA3) +Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel: 50 > 100 ==> 0 "50" > "100" ==> 1 -Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: - 1. the string itself without evaluation (format: "raw:xxx") - 2. a user-defined variable (format: "name") - 3. an evaluated sub-string (format: "eval:xxx") - 4. an evaluated condition (format: "eval_cond:xxx") - 5. a string with escaped chars (format: "esc:xxx" or "\xxx") - 6. a string with chars to hide (format: "hide:char,string") - 7. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") - or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") - 8. a reversed string (format: "rev:xxx" or "revscr:xxx") - 9. a repeated string (format: "repeat:count,string") - 10. length of a string (format: "length:xxx" or "lengthscr:xxx") - 11. split of a string (format: "split:number,separators,flags,xxx") - 12. split of shell argmuents (format: "split_shell:number,xxx") - 13. a color (format: "color:xxx", see "Plugin API reference", function "color") - 14. a modifier (format: "modifier:name,data,string") - 15. an info (format: "info:name,arguments", arguments are optional) - 16. a base 16/32/64 encoded/decoded string (format: "base_encode:base,xxx" or "base_decode:base,xxx") - 17. current date/time (format: "date" or "date:format") - 18. an environment variable (format: "env:XXX") - 19. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 20. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") - 21. a random integer number (format: "random:min,max") - 22. a translated string (format: "translate:xxx") - 23. define a user variable (format: "define:name,value") - 24. an option (format: "file.section.option") - 25. a local variable in buffer - 26. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. -Format for hdata can be one of following: - hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) - hdata[list].var1.var2...: start with a hdata using a list/pointer/pointer name, for example: - ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers - ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins - hdata[pointer].var1.var2...: start with a hdata using a pointer, for example: - ${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers) - ${buffer[my_pointer].full_name}: full name of the buffer with this pointer name (can be used in triggers) -For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". - -Examples (simple strings): - /eval -n ${raw:${info:version}} ==> ${info:version} - /eval -n ${eval_cond:${window.win_width}>100} ==> 1 - /eval -n ${info:version} ==> 0.4.3 - /eval -n ${env:HOME} ==> /home/user - /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${sec.data.password} ==> secret - /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 ${\t} ==> <tab> - /eval -n ${hide:-,${relay.network.password}} ==> -------- - /eval -n ${cut:3,+,test} ==> tes+ - /eval -n ${cut:+3,+,test} ==> te+ - /eval -n ${date:%H:%M:%S} ==> 07:46:40 - /eval -n ${if:${info:term_width}>80?big:small} ==> big - /eval -n ${rev:Hello} ==> olleH - /eval -n ${repeat:5,-} ==> ----- - /eval -n ${length:test} ==> 4 - /eval -n ${split:1,,,abc,def,ghi} ==> abc - /eval -n ${split:-1,,,abc,def,ghi} ==> ghi - /eval -n ${split:count,,,abc,def,ghi} ==> 3 - /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} ==> arg2 - /eval -n ${split_shell:count,"arg 1" arg2} ==> 2 - /eval -n ${split_shell:random,"arg 1" arg2} ==> arg2 - /eval -n ${calc:(5+2)*3} ==> 21 - /eval -n ${random:0,10} ==> 3 - /eval -n ${base_encode:64,test} ==> dGVzdA== - /eval -n ${base_decode:64,dGVzdA==} ==> test - /eval -n ${translate:Plugin} ==> Extension +Einige Variablen werden im Ausdruck mittels der Formatierung ${variable} ersetzt. Mögliche Variablen sind, nach Reihenfolge ihrer Priorität: + 1. die Zeichenfolge selbst ohne Auswertung (Format: "raw:xxx") + 2. eine benutzerdefinierte Variable (Format: "name") + 3. eine evaluierte Teilzeichenkette (Format: "eval:xxx") + 4. eine evaluierte Bedingung (Format: "eval_cond:xxx") + 5. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx") + 6. Zeichen, die in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette") + 7. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:max,suffix,string" oder "cut:+max,suffix,string") + oder maximale Anzahl an Zeichen die auf dem Bildschirm angezeigt werden sollen (Format: "cutscr:Max,Suffix,Zeichenkette oder "cutscr:+Max,Suffix,Zeichenkette") + 8. eine Zeichenkette umkehren (Format: "rev:xxx" oder "revscr:xxx") + 9. eine Zeichenkette wiederholen (Format: "repeat:Anzahl,Zeichenkette") + 10. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx") + 11. Aufteilen einer Zeichenkette (Format: "split:Anzahl,Trennzeichen,Flags,xxx") + 12. Aufteilen von Shell-Argumenten (Format: "split_shell:Anzahl,xxx") + 13. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color") + 14. zum modifizieren (Format: "modifier:name,data,string") + 15. eine Info (Format: "Info:Name,Argumente", Argumente sind optional) + 16. eine Basis 16/32/64 kodierte / dekodierte Zeichenfolge (Format: "base_encode:base,xxx" oder "base_decode:base,xxx") + 17. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format") + 18. eine Umgebungsvariable (Format: "env:XXX") + 19. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr") + 20. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % ** (Format: "calc:xxx") + 21. eine zufällige ganze Zahl (Format: "random:min,max") + 22. eine übersetzte Zeichenkette (Format: "translate:xxx") + 23. eine Benutzervariable definieren (Format: "define:Name,Wert") + 24. eine Option (Format: "file.section.option") + 25. eine lokale Variable eines Buffers + 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. +Das Format für hdata kann wie folgt aufgebaut sein: + hdata.var1.var2...: startet mit hdata (der Pointer muss bekannt sein) und fragt eine Variable nach der anderen ab (weitere hdata können folgen) + hdata[list].var1.var2...: startet hdata mittels einer Liste, zum Beispiel: + ${buffer[gui_buffers].full_name}: der vollständige Name des ersten Buffers, in der verknüpften Liste aller Buffer + ${plugin[weechat_plugins].name}: Name der ersten Erweiterung, in der verknüpften Liste aller Erweiterungen + hdata[pointer].var1.var2...: startet hdata mittels einem Pointer, zum Beispiel: + ${buffer[0x1234abcd].full_name}: vollständiger Name eines Buffers und des dazugehörigen Pointers (kann in triggern benutzt werden) + ${buffer[my_pointer].full_name}: vollständiger Name des Buffers mit dem entsprechenden Pointernamen (kann in Triggern verwendet werden) +Die vorhandenen Namen für hdata und Variablen sind in der "Anleitung für API Erweiterung", Bereich "weechat_hdata_get". beschrieben + +Beispiele (einfache Zeichenketten): + /eval -n ${raw:${info:version}} ==> ${info:version} + /eval -n ${eval_cond:${window.win_width}>100} ==> 1 + /eval -n ${info:version} ==> 0.4.3 + /eval -n ${env:HOME} ==> /home/user + /eval -n ${weechat.look.scroll_amount} ==> 3 + /eval -n ${sec.data.password} ==> geheim + /eval -n ${window} ==> 0x2549aa0 + /eval -n ${window.buffer} ==> 0x2549320 + /eval -n ${window.buffer.full_name} ==> core.weechat + /eval -n ${window.buffer.number} ==> 1 + /eval -n ${\t} ==> <tab> + /eval -n ${hide:-,${relay.network.password}} ==> -------- + /eval -n ${cut:3,+,test} ==> tes+ + /eval -n ${cut:+3,+,test} ==> te+ + /eval -n ${date:%H:%M:%S} ==> 07:46:40 + /eval -n ${if:${info:term_width}>80?big:small} ==> big + /eval -n ${rev:Hello} ==> olleH + /eval -n ${repeat:5,-} ==> ----- + /eval -n ${length:test} ==> 4 + /eval -n ${split:1,,,abc,def,ghi} ==> abc + /eval -n ${split:-1,,,abc,def,ghi} ==> ghi + /eval -n ${split:count,,,abc,def,ghi} ==> 3 + /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} ==> arg2 + /eval -n ${split_shell:count,"arg 1" arg2} ==> 2 + /eval -n ${split_shell:random,"arg 1" arg2} ==> arg2 + /eval -n ${calc:(5+2)*3} ==> 21 + /eval -n ${random:0,10} ==> 3 + /eval -n ${base_encode:64,test} ==> dGVzdA== + /eval -n ${base_decode:64,dGVzdA==} ==> test + /eval -n ${translate:Plugin} ==> Erweiterung /eval -n ${define:len,${calc:5+3}}${len}x${len} ==> 8x8 -Examples (conditions): - /eval -n -c ${window.buffer.number} > 2 ==> 0 - /eval -n -c ${window.win_width} > 100 ==> 1 - /eval -n -c (8 > 12) || (5 > 2) ==> 1 - /eval -n -c (8 > 12) && (5 > 2) ==> 0 - /eval -n -c abcd =~ ^ABC ==> 1 - /eval -n -c abcd =~ (?-i)^ABC ==> 0 - /eval -n -c abcd =~ (?-i)^abc ==> 1 - /eval -n -c abcd !~ abc ==> 0 - /eval -n -c abcd =* a*d ==> 1 - /eval -n -c abcd =- bc ==> 1 +Beispiele (Bedingungen): + /eval -n -c ${window.buffer.number} > 2 ==> 0 + /eval -n -c ${window.win_width} > 100 ==> 1 + /eval -n -c (8 > 12) || (5 > 2) ==> 1 + /eval -n -c (8 > 12) && (5 > 2) ==> 0 + /eval -n -c abcd =~ ^ABC ==> 1 + /eval -n -c abcd =~ (?-i)^ABC ==> 0 + /eval -n -c abcd =~ (?-i)^abc ==> 1 + /eval -n -c abcd !~ abc ==> 0 + /eval -n -c abcd =* a*d ==> 1 + /eval -n -c abcd =- bc ==> 1 ---- [[command_weechat_filter]] @@ -1993,6 +1993,32 @@ Beispiele: /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]] * `+unset+`: Konfigurationsparameter freigeben/zurücksetzen diff --git a/doc/en/includes/autogen_user_commands.en.adoc b/doc/en/includes/autogen_user_commands.en.adoc index abe5fbf20..39138874a 100644 --- a/doc/en/includes/autogen_user_commands.en.adoc +++ b/doc/en/includes/autogen_user_commands.en.adoc @@ -1993,6 +1993,32 @@ Examples: /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]] * `+unset+`: unset/reset config options diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index 89bc93b1d..566f65301 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -403,6 +403,7 @@ WeeChat "core" is located in following directories: | core/ | Root of unit tests for core. | test-core-arraylist.cpp | Tests: arraylists. | 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-dir.cpp | Tests: directory/file functions. | test-core-eval.cpp | Tests: evaluation of expressions. diff --git a/doc/fr/includes/autogen_user_commands.fr.adoc b/doc/fr/includes/autogen_user_commands.fr.adoc index dba61e8e2..ce9e59115 100644 --- a/doc/fr/includes/autogen_user_commands.fr.adoc +++ b/doc/fr/includes/autogen_user_commands.fr.adoc @@ -1993,6 +1993,32 @@ Exemples : /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]] * `+unset+`: supprimer/réinitialiser des options de configuration diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index 76efc06ec..e69f1fa25 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -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. | test-core-arraylist.cpp | Tests : listes avec tableau (« arraylists »). | 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-dir.cpp | Tests : répertoires/fichiers. | test-core-eval.cpp | Tests : évaluation d'expressions. diff --git a/doc/it/includes/autogen_user_commands.it.adoc b/doc/it/includes/autogen_user_commands.it.adoc index 1c66492aa..4c9df4d33 100644 --- a/doc/it/includes/autogen_user_commands.it.adoc +++ b/doc/it/includes/autogen_user_commands.it.adoc @@ -1993,6 +1993,32 @@ Examples: /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]] * `+unset+`: annulla/ripristina opzione diff --git a/doc/ja/includes/autogen_user_commands.ja.adoc b/doc/ja/includes/autogen_user_commands.ja.adoc index 988be618e..4c0a70dc0 100644 --- a/doc/ja/includes/autogen_user_commands.ja.adoc +++ b/doc/ja/includes/autogen_user_commands.ja.adoc @@ -1993,6 +1993,32 @@ option: オプションの名前 (value を指定せずにワイルドカード /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]] * `+unset+`: オプションのアンセット/リセット diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index b041ccb92..24c5dec4d 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -424,6 +424,8 @@ WeeChat "core" は以下のディレクトリに配置されています: // TRANSLATION MISSING | test-core-calc.cpp | Tests: calculation of expressions. // TRANSLATION MISSING +| test-core-config-file.cpp | Tests: configuration files. +// TRANSLATION MISSING | test-core-crypto.cpp | Tests: cryptographic functions. // TRANSLATION MISSING | test-core-dir.cpp | Tests: directory/file functions. diff --git a/doc/pl/includes/autogen_user_commands.pl.adoc b/doc/pl/includes/autogen_user_commands.pl.adoc index c514e76b9..2541940b9 100644 --- a/doc/pl/includes/autogen_user_commands.pl.adoc +++ b/doc/pl/includes/autogen_user_commands.pl.adoc @@ -1992,6 +1992,32 @@ Przykłady: /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]] * `+unset+`: skasuj/zresetuj zmienną konfiguracyjną diff --git a/doc/sr/includes/autogen_user_commands.sr.adoc b/doc/sr/includes/autogen_user_commands.sr.adoc index 5cf00a51e..1e0c28e8e 100644 --- a/doc/sr/includes/autogen_user_commands.sr.adoc +++ b/doc/sr/includes/autogen_user_commands.sr.adoc @@ -1993,6 +1993,32 @@ passphrase: измена тајне реченице (без passphrase, под /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]] * `+unset+`: уклањање/ресетовање конфиг опција diff --git a/doc/sr/weechat_dev.sr.adoc b/doc/sr/weechat_dev.sr.adoc index b42632b6e..2f90e386e 100644 --- a/doc/sr/weechat_dev.sr.adoc +++ b/doc/sr/weechat_dev.sr.adoc @@ -403,6 +403,8 @@ WeeChat „језгро” се налази у следећим директо | core/ | Корен unit тестова језгра. | test-core-arraylist.cpp | Тестови: arraylists. | test-core-calc.cpp | Тестови: калкулација израза. +// TRANSLATION MISSING +| test-core-config-file.cpp | Tests: configuration files. | test-core-crypto.cpp | Тестови: криптографске функције. | test-core-dir.cpp | Тестови: функције директоријума/фајла. | test-core-eval.cpp | Тестови: израчунавање израза. @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2478,6 +2478,47 @@ msgstr "" " nastaví slovo pro zvýrazňování:\n" " /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" msgstr "odnastavit/resetovat konfigurační možnosti" @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <kde-i18n-de@kde.org>\n" @@ -3160,6 +3160,47 @@ msgstr "" " entfernt die Umgebungsvariable ABC:\n" " /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" msgstr "Konfigurationsparameter freigeben/zurücksetzen" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2584,6 +2584,47 @@ msgstr "" " mostrar opciones cambiadas en el plugin irc:\n" " /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" msgstr "deshacer/reiniciar opciones de configuración" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-09-20 21:12+0200\n" -"PO-Revision-Date: 2021-09-20 21:13+0200\n" +"POT-Creation-Date: 2021-10-01 22:52+0200\n" +"PO-Revision-Date: 2021-10-01 22:53+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -3086,6 +3086,73 @@ msgstr "" " réinitialiser la variable d'environnement ABC :\n" " /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" msgstr "supprimer/réinitialiser des options de configuration" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2260,6 +2260,44 @@ msgid "" 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 msgid "unset/reset config options" msgstr "konfigurációs paraméterek beállítása" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2634,6 +2634,47 @@ msgstr "" " mostra le opzioni modificate nel plugin irc:\n" " /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" msgstr "annulla/ripristina opzione" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/master/" @@ -3027,6 +3027,47 @@ msgstr "" " 環境変数 ABC の値を削除する:\n" " /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" msgstr "オプションのアンセット/リセット" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Language-Team: Polish <kde-i18n-doc@kde.org>\n" @@ -3218,6 +3218,47 @@ msgstr "" " kasuje zmienną środowiskową ABC:\n" " /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" msgstr "skasuj/zresetuj zmienną konfiguracyjną" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Language-Team: Portuguese <>\n" @@ -3021,6 +3021,47 @@ msgstr "" " não definir a variável de ambiente ABC:\n" " /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" msgstr "repor ou não definir opções de configuração" diff --git a/po/pt_BR.po b/po/pt_BR.po index 7d3e706fd..e5ff15273 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-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" "Last-Translator: Érico Nogueira <ericonr@disroot.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2694,6 +2694,47 @@ msgstr "" " indefine a variável de ambiente ABC:\n" " /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" msgstr "indefine/restaura opções de configuração" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2284,6 +2284,44 @@ msgid "" 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 msgid "unset/reset config options" msgstr "настроить параметры конфигурации" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3146,6 +3146,47 @@ msgstr "" " уклања променљиву окружења ABC:\n" " /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" msgstr "уклањање/ресетовање конфиг опција" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\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" "Last-Translator: Emir SARI <bitigchi@me.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2557,6 +2557,47 @@ msgid "" " /set env ABC \"\"" 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" msgstr "yapılandırma seçeneklerini geri al/sıfırla" diff --git a/po/weechat.pot b/po/weechat.pot index f2a445dc8..b77b0e236 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-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" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2083,6 +2083,43 @@ msgid "" " /set env ABC \"\"" 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" msgstr "" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 71ff892d7..1856d5e23 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -6303,6 +6303,78 @@ COMMAND_CALLBACK(set) } /* + * 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. */ @@ -8426,6 +8498,42 @@ command_init () " || env %(env_vars) %(env_value)", &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 ( NULL, "unset", N_("unset/reset config options"), N_("<option>" diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index de57a97d6..27050c9ed 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -1521,6 +1521,110 @@ config_file_option_set (struct t_config_option *option, const char *value, } /* + * 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. * * Returns: diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index 16d0897bb..7847277e1 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -259,6 +259,9 @@ extern int config_file_option_set (struct t_config_option *option, const char *value, int run_callback); extern int config_file_option_set_null (struct t_config_option *option, 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 void config_file_option_rename (struct t_config_option *option, const char *new_name); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 42090eef0..8cbf9d43a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories(${CPPUTEST_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} ${PROJECT_SOU set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC unit/core/test-core-arraylist.cpp unit/core/test-core-calc.cpp + unit/core/test-core-config-file.cpp unit/core/test-core-crypto.cpp unit/core/test-core-dir.cpp unit/core/test-core-eval.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index 2a6c7bf87..4e30a512a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ unit/core/test-core-calc.cpp \ + unit/core/test-core-config-file.cpp \ unit/core/test-core-crypto.cpp \ unit/core/test-core-dir.cpp \ unit/core/test-core-eval.cpp \ diff --git a/tests/tests.cpp b/tests/tests.cpp index a76a5393c..72eef95bb 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -61,6 +61,7 @@ extern "C" /* core */ IMPORT_TEST_GROUP(CoreArraylist); IMPORT_TEST_GROUP(CoreCalc); +IMPORT_TEST_GROUP(CoreConfigFile); IMPORT_TEST_GROUP(CoreCrypto); IMPORT_TEST_GROUP(CoreDir); IMPORT_TEST_GROUP(CoreEval); diff --git a/tests/unit/core/test-core-config-file.cpp b/tests/unit/core/test-core-config-file.cpp new file mode 100644 index 000000000..f9993839b --- /dev/null +++ b/tests/unit/core/test-core-config-file.cpp @@ -0,0 +1,1063 @@ +/* + * test-core-config-file.cpp - test configuration file functions + * + * Copyright (C) 2021 Sébastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "CppUTest/TestHarness.h" + +extern "C" +{ +#include <string.h> +#include "tests/tests.h" +#include "src/core/wee-config-file.h" +#include "src/core/wee-config.h" +#include "src/core/wee-secure-config.h" +#include "src/plugins/plugin.h" + +extern char *config_file_option_full_name (struct t_config_option *option); +extern int config_file_string_boolean_is_valid (const char *text); +extern const char *config_file_option_escape (const char *name); +} + +TEST_GROUP(CoreConfigFile) +{ +}; + +/* + * Tests functions: + * config_file_search + */ + +TEST(CoreConfigFile, Search) +{ + POINTERS_EQUAL(NULL, config_file_search (NULL)); + POINTERS_EQUAL(NULL, config_file_search ("")); + POINTERS_EQUAL(NULL, config_file_search ("zzz")); + + POINTERS_EQUAL(weechat_config_file, config_file_search ("weechat")); + POINTERS_EQUAL(secure_config_file, config_file_search ("sec")); +} + +/* + * Tests functions: + * config_file_config_find_pos + */ + +TEST(CoreConfigFile, FindPos) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_new + */ + +TEST(CoreConfigFile, New) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_section_find_pos + */ + +TEST(CoreConfigFile, SectionFindPos) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_new_section + */ + +TEST(CoreConfigFile, NewSection) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_search_section + */ + +TEST(CoreConfigFile, SearchSection) +{ + POINTERS_EQUAL(NULL, config_file_search_section (NULL, NULL)); + POINTERS_EQUAL(NULL, config_file_search_section (weechat_config_file, NULL)); + POINTERS_EQUAL(NULL, config_file_search_section (weechat_config_file, "zzz")); + + POINTERS_EQUAL(weechat_config_section_proxy, + config_file_search_section (weechat_config_file, "proxy")); +} + +/* + * Tests functions: + * config_file_option_full_name + */ + +TEST(CoreConfigFile, OptionFullName) +{ + char *str; + + POINTERS_EQUAL(NULL, config_file_option_full_name (NULL)); + + WEE_TEST_STR("weechat.look.buffer_time_format", + config_file_option_full_name (config_look_buffer_time_format)); +} + +/* + * Tests functions: + * config_file_hook_config_exec + */ + +TEST(CoreConfigFile, HookConfigExec) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_find_pos + */ + +TEST(CoreConfigFile, OptionFindPos) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_insert_in_section + */ + +TEST(CoreConfigFile, OptionInsertInSection) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_malloc + */ + +TEST(CoreConfigFile, OptionMalloc) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_new_option + */ + +TEST(CoreConfigFile, NewOption) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_search_option + */ + +TEST(CoreConfigFile, SearchOption) +{ + POINTERS_EQUAL(NULL, config_file_search_option (NULL, NULL, NULL)); + POINTERS_EQUAL(NULL, config_file_search_option (weechat_config_file, + NULL, NULL)); + POINTERS_EQUAL(NULL, + config_file_search_option (weechat_config_file, + weechat_config_section_color, + NULL)); + + POINTERS_EQUAL(NULL, + config_file_search_option (weechat_config_file, + weechat_config_section_color, + "xxx")); + POINTERS_EQUAL(NULL, + config_file_search_option (weechat_config_file, + NULL, + "xxx")); + POINTERS_EQUAL(NULL, + config_file_search_option (NULL, + weechat_config_section_color, + "xxx")); + + POINTERS_EQUAL(config_color_chat_channel, + config_file_search_option (weechat_config_file, + weechat_config_section_color, + "chat_channel")); + POINTERS_EQUAL(config_color_chat_channel, + config_file_search_option (weechat_config_file, + NULL, + "chat_channel")); + POINTERS_EQUAL(config_color_chat_channel, + config_file_search_option (NULL, + weechat_config_section_color, + "chat_channel")); +} + +/* + * Tests functions: + * config_file_search_section_option + */ + +TEST(CoreConfigFile, SearchSectionOption) +{ + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (NULL, NULL, NULL, + &ptr_section, &ptr_option); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (weechat_config_file, NULL, NULL, + &ptr_section, &ptr_option); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (weechat_config_file, + weechat_config_section_color, + NULL, + &ptr_section, &ptr_option); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (weechat_config_file, + weechat_config_section_color, + "xxx", + &ptr_section, &ptr_option); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (weechat_config_file, + weechat_config_section_color, + "chat_channel", + &ptr_section, &ptr_option); + POINTERS_EQUAL(weechat_config_section_color, ptr_section); + POINTERS_EQUAL(config_color_chat_channel, ptr_option); + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (weechat_config_file, + NULL, + "chat_channel", + &ptr_section, &ptr_option); + POINTERS_EQUAL(weechat_config_section_color, ptr_section); + POINTERS_EQUAL(config_color_chat_channel, ptr_option); + + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + config_file_search_section_option (NULL, + weechat_config_section_color, + "chat_channel", + &ptr_section, &ptr_option); + POINTERS_EQUAL(weechat_config_section_color, ptr_section); + POINTERS_EQUAL(config_color_chat_channel, ptr_option); +} + +/* + * Tests functions: + * config_file_search_with_string + */ + +TEST(CoreConfigFile, SearchWithString) +{ + struct t_config_file *ptr_config; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + char *pos_option_name; + + ptr_config = (struct t_config_file *)0x1; + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + pos_option_name = (char *)0x1; + config_file_search_with_string (NULL, NULL, NULL, NULL, NULL); + POINTERS_EQUAL(0x1, ptr_config); + POINTERS_EQUAL(0x1, ptr_section); + POINTERS_EQUAL(0x1, ptr_option); + POINTERS_EQUAL(0x1, pos_option_name); + + ptr_config = (struct t_config_file *)0x1; + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + pos_option_name = (char *)0x1; + config_file_search_with_string (NULL, &ptr_config, &ptr_section, + &ptr_option, &pos_option_name); + POINTERS_EQUAL(NULL, ptr_config); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + POINTERS_EQUAL(NULL, pos_option_name); + + ptr_config = (struct t_config_file *)0x1; + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + pos_option_name = (char *)0x1; + config_file_search_with_string ("", &ptr_config, &ptr_section, + &ptr_option, &pos_option_name); + POINTERS_EQUAL(NULL, ptr_config); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + POINTERS_EQUAL(NULL, pos_option_name); + + ptr_config = (struct t_config_file *)0x1; + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + pos_option_name = (char *)0x1; + config_file_search_with_string ("zzz", &ptr_config, &ptr_section, + &ptr_option, &pos_option_name); + POINTERS_EQUAL(NULL, ptr_config); + POINTERS_EQUAL(NULL, ptr_section); + POINTERS_EQUAL(NULL, ptr_option); + POINTERS_EQUAL(NULL, pos_option_name); + + ptr_config = (struct t_config_file *)0x1; + ptr_section = (struct t_config_section *)0x1; + ptr_option = (struct t_config_option *)0x1; + pos_option_name = (char *)0x1; + config_file_search_with_string ("weechat.color.chat_channel", + &ptr_config, &ptr_section, + &ptr_option, &pos_option_name); + POINTERS_EQUAL(weechat_config_file, ptr_config); + POINTERS_EQUAL(weechat_config_section_color, ptr_section); + POINTERS_EQUAL(config_color_chat_channel, ptr_option); + STRCMP_EQUAL("chat_channel", pos_option_name); +} + +/* + * Tests functions: + * config_file_string_boolean_is_valid + */ + +TEST(CoreConfigFile, StringBooleanIsValid) +{ + LONGS_EQUAL(0, config_file_string_boolean_is_valid (NULL)); + LONGS_EQUAL(0, config_file_string_boolean_is_valid ("")); + LONGS_EQUAL(0, config_file_string_boolean_is_valid ("zzz")); + + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("on")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("ON")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("yes")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("Yes")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("y")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("true")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("t")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("1")); + + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("off")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("OFF")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("no")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("No")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("n")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("false")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("f")); + LONGS_EQUAL(1, config_file_string_boolean_is_valid ("0")); +} + +/* + * Tests functions: + * config_file_string_to_boolean + */ + +TEST(CoreConfigFile, StringToBoolean) +{ + LONGS_EQUAL(0, config_file_string_to_boolean (NULL)); + LONGS_EQUAL(0, config_file_string_to_boolean ("")); + LONGS_EQUAL(0, config_file_string_to_boolean ("zzz")); + + LONGS_EQUAL(1, config_file_string_to_boolean ("on")); + LONGS_EQUAL(1, config_file_string_to_boolean ("ON")); + LONGS_EQUAL(1, config_file_string_to_boolean ("yes")); + LONGS_EQUAL(1, config_file_string_to_boolean ("Yes")); + LONGS_EQUAL(1, config_file_string_to_boolean ("y")); + LONGS_EQUAL(1, config_file_string_to_boolean ("true")); + LONGS_EQUAL(1, config_file_string_to_boolean ("t")); + LONGS_EQUAL(1, config_file_string_to_boolean ("1")); + + LONGS_EQUAL(0, config_file_string_to_boolean ("off")); + LONGS_EQUAL(0, config_file_string_to_boolean ("OFF")); + LONGS_EQUAL(0, config_file_string_to_boolean ("no")); + LONGS_EQUAL(0, config_file_string_to_boolean ("No")); + LONGS_EQUAL(0, config_file_string_to_boolean ("n")); + LONGS_EQUAL(0, config_file_string_to_boolean ("false")); + LONGS_EQUAL(0, config_file_string_to_boolean ("f")); + LONGS_EQUAL(0, config_file_string_to_boolean ("0")); +} + +/* + * Tests functions: + * config_file_option_reset + * config_file_option_set + */ + +TEST(CoreConfigFile, OptionReset) +{ + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_reset (NULL, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (NULL, NULL, 1)); + + /* boolean */ + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_look_confirm_quit, "zzz", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_confirm_quit, "on", 1)); + LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_confirm_quit, "toggle", 1)); + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_confirm_quit, "toggle", 1)); + LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_confirm_quit, 1)); + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + + /* integer */ + LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_look_mouse_timer_delay, "zzz", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_look_mouse_timer_delay, "-500", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_look_mouse_timer_delay, "99999999", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_mouse_timer_delay, "50", 1)); + LONGS_EQUAL(50, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_mouse_timer_delay, "++15", 1)); + LONGS_EQUAL(65, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_mouse_timer_delay, "--3", 1)); + LONGS_EQUAL(62, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_mouse_timer_delay, 1)); + LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay)); + + /* integer with string values */ + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE, + CONFIG_INTEGER(config_look_align_end_of_lines)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_look_align_end_of_lines, "zzz", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_align_end_of_lines, "time", 1)); + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_TIME, + CONFIG_INTEGER(config_look_align_end_of_lines)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_align_end_of_lines, 1)); + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE, + CONFIG_INTEGER(config_look_align_end_of_lines)); + + /* string */ + STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_look_separator_horizontal, "zzz", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_look_separator_horizontal, "+", 1)); + STRCMP_EQUAL("+", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_separator_horizontal, 1)); + STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal)); + + /* color */ + LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_set (config_color_chat, "zzz", 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_color_chat, "red", 1)); + LONGS_EQUAL(3, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_color_chat, "++5", 1)); + LONGS_EQUAL(8, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_set (config_color_chat, "--3", 1)); + LONGS_EQUAL(5, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_color_chat, 1)); + LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat)); +} + +/* + * Tests functions: + * config_file_option_toggle + */ + +TEST(CoreConfigFile, OptionToggle) +{ + const char *value_boolean_ok[] = { "on", NULL }; + const char *values_boolean_ok[] = { "on", "off", NULL }; + const char *values_boolean_error[] = { "xxx", "zzz", NULL }; + const char *value_integer_ok[] = { "50", NULL }; + const char *values_integer_ok[] = { "75", "92", NULL }; + const char *values_integer_error[] = { "-500", "99999999", NULL }; + const char *value_integer_str_ok[] = { "time", NULL }; + const char *values_integer_str_ok[] = { "prefix", "suffix", NULL }; + const char *values_integer_str_error[] = { "xxx", "zzz", NULL }; + const char *value_string_ok[] = { "+", NULL }; + const char *values_string_ok[] = { "$", "*", NULL }; + const char *values_string_error[] = { "xxx", "zzz", NULL }; + const char *value_color_ok[] = { "red", NULL }; + const char *values_color_ok[] = { "green", "blue", NULL }; + const char *values_color_error[] = { "xxx", "zzz", NULL }; + + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (NULL, NULL, 0, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_confirm_quit, NULL, -1, 1)); + + /* boolean */ + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_confirm_quit, + values_boolean_error, 2, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_confirm_quit, NULL, 0, 1)); + LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_confirm_quit, NULL, 0, 1)); + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_confirm_quit, value_boolean_ok, 1, 1)); + LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_confirm_quit, value_boolean_ok, 1, 1)); + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_confirm_quit, values_boolean_ok, 2, 1)); + LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_confirm_quit, values_boolean_ok, 2, 1)); + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE, + config_file_option_reset (config_look_confirm_quit, 1)); + LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit)); + + /* integer */ + LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_mouse_timer_delay, + values_integer_error, 2, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_mouse_timer_delay, + NULL, 0, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_mouse_timer_delay, + value_integer_ok, 1, 1)); + LONGS_EQUAL(50, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_mouse_timer_delay, + value_integer_ok, 1, 1)); + LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_mouse_timer_delay, + values_integer_ok, 2, 1)); + LONGS_EQUAL(75, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_mouse_timer_delay, + values_integer_ok, 2, 1)); + LONGS_EQUAL(92, CONFIG_INTEGER(config_look_mouse_timer_delay)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_mouse_timer_delay, 1)); + LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay)); + + /* integer with string values */ + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE, + CONFIG_INTEGER(config_look_align_end_of_lines)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_align_end_of_lines, + values_integer_str_error, 2, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_align_end_of_lines, + NULL, 0, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_align_end_of_lines, + value_integer_str_ok, 1, 1)); + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_TIME, + CONFIG_INTEGER(config_look_align_end_of_lines)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_align_end_of_lines, + values_integer_str_ok, 2, 1)); + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_PREFIX, + CONFIG_INTEGER(config_look_align_end_of_lines)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_align_end_of_lines, + values_integer_str_ok, 2, 1)); + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_SUFFIX, + CONFIG_INTEGER(config_look_align_end_of_lines)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_align_end_of_lines, 1)); + LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE, + CONFIG_INTEGER(config_look_align_end_of_lines)); + + /* string */ + STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_look_separator_horizontal, + values_string_error, 2, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_separator_horizontal, + NULL, 0, 1)); + STRCMP_EQUAL("", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_separator_horizontal, + NULL, 0, 1)); + STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_separator_horizontal, + value_string_ok, 1, 1)); + STRCMP_EQUAL("+", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_separator_horizontal, + values_string_ok, 2, 1)); + STRCMP_EQUAL("$", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_look_separator_horizontal, + values_string_ok, 2, 1)); + STRCMP_EQUAL("*", CONFIG_STRING(config_look_separator_horizontal)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_look_separator_horizontal, 1)); + STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal)); + + /* color */ + LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_color_chat, + values_color_error, 2, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR, + config_file_option_toggle (config_color_chat, NULL, 0, 1)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_color_chat, + value_color_ok, 1, 1)); + LONGS_EQUAL(3, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_color_chat, + values_color_ok, 2, 1)); + LONGS_EQUAL(5, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_toggle (config_color_chat, + values_color_ok, 2, 1)); + LONGS_EQUAL(9, CONFIG_COLOR(config_color_chat)); + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + config_file_option_reset (config_color_chat, 1)); + LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat)); +} + +/* + * Tests functions: + * config_file_option_set_null + */ + +TEST(CoreConfigFile, OptionSetNull) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_unset + */ + +TEST(CoreConfigFile, OptionUnset) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_rename + */ + +TEST(CoreConfigFile, OptionRename) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_value_to_string + */ + +TEST(CoreConfigFile, OptionValueToString) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_get_string + */ + +TEST(CoreConfigFile, OptionGetString) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_get_pointer + */ + +TEST(CoreConfigFile, OptionGetPointer) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_is_null + */ + +TEST(CoreConfigFile, OptionIsNull) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_default_is_null + */ + +TEST(CoreConfigFile, OptionDefaultIsNull) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_has_changed + */ + +TEST(CoreConfigFile, OptionHasChanged) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_set_with_string + */ + +TEST(CoreConfigFile, OptionSetWithString) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_boolean + */ + +TEST(CoreConfigFile, OptionBoolean) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_boolean_default + */ + +TEST(CoreConfigFile, OptionBooleanDefault) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_integer + */ + +TEST(CoreConfigFile, OptionInteger) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_integer_default + */ + +TEST(CoreConfigFile, OptionIntegerDefault) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_string + */ + +TEST(CoreConfigFile, OptionString) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_string_default + */ + +TEST(CoreConfigFile, OptionStringDefault) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_color + */ + +TEST(CoreConfigFile, OptionColor) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_color_default + */ + +TEST(CoreConfigFile, OptionColorDefault) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_escape + */ + +TEST(CoreConfigFile, OptionEscape) +{ + STRCMP_EQUAL("\\", config_file_option_escape (NULL)); + + STRCMP_EQUAL("", config_file_option_escape ("")); + STRCMP_EQUAL("", config_file_option_escape ("test")); + STRCMP_EQUAL("", config_file_option_escape ("|test")); + STRCMP_EQUAL("", config_file_option_escape ("]test")); + + STRCMP_EQUAL("\\", config_file_option_escape ("#test")); + STRCMP_EQUAL("\\", config_file_option_escape ("[test")); + STRCMP_EQUAL("\\", config_file_option_escape ("\\test")); +} + +/* + * Tests functions: + * config_file_write_option + */ + +TEST(CoreConfigFile, WriteOption) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_write_line + */ + +TEST(CoreConfigFile, WriteLine) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_write_internal + */ + +TEST(CoreConfigFile, WriteInternal) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_write + */ + +TEST(CoreConfigFile, Write) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_read + */ + +TEST(CoreConfigFile, Read) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_reload + */ + +TEST(CoreConfigFile, Reload) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_free_data + */ + +TEST(CoreConfigFile, OptionFreeData) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_option_free + */ + +TEST(CoreConfigFile, OptionFree) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_section_free_options + */ + +TEST(CoreConfigFile, SectionFreeOptions) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_section_free + */ + +TEST(CoreConfigFile, SectionFree) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_free + */ + +TEST(CoreConfigFile, Free) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_free_all + */ + +TEST(CoreConfigFile, FreeAll) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_free_all_plugin + */ + +TEST(CoreConfigFile, FreeAllPlugin) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_hdata_config_file_cb + */ + +TEST(CoreConfigFile, HdataConfigFileCb) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_hdata_config_section_cb + */ + +TEST(CoreConfigFile, HdataConfigSectionCb) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_hdata_config_option_cb + */ + +TEST(CoreConfigFile, HdataConfigOptionCb) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_add_option_to_infolist + */ + +TEST(CoreConfigFile, AddOptionToInfolist) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_add_to_infolist + */ + +TEST(CoreConfigFile, AddToInfolist) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * config_file_print_log + */ + +TEST(CoreConfigFile, PrintLog) +{ + /* TODO: write tests */ +} |