summaryrefslogtreecommitdiff
path: root/doc/sr
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-07-06 19:00:16 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-07-08 13:28:40 +0200
commit66cb9f6ea2e534887e73c885d3f131710c48382d (patch)
tree1d21dafd605395a57078f9d82d8f525bad588bb6 /doc/sr
parent8f9d88edd0106c92daf1ce624638f037f7e8fe0d (diff)
downloadweechat-66cb9f6ea2e534887e73c885d3f131710c48382d.zip
core: add option type "enum" (closes #1973)
The type "enum" replaces type "integer" when used with string values. For compatibility, any option created with type "integer" and string values is automatically created to "enum" on creation, with no error.
Diffstat (limited to 'doc/sr')
-rw-r--r--doc/sr/weechat_plugin_api.sr.adoc200
-rw-r--r--doc/sr/weechat_user.sr.adoc26
2 files changed, 170 insertions, 56 deletions
diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc
index 6074d2cf7..d9300c1c6 100644
--- a/doc/sr/weechat_plugin_api.sr.adoc
+++ b/doc/sr/weechat_plugin_api.sr.adoc
@@ -6685,7 +6685,7 @@ section = weechat.config_search_section(config_file, "section")
==== config_new_option
-_Ажурирано у верзији 1.5._
+_Ажурирано у верзији 1.5, 4.1.0._
Креира нову опцију у одељку конфигурационог фајла.
@@ -6730,11 +6730,15 @@ struct t_config_option *weechat_config_new_option (
* _name_: име опције; у програм у WeeChat верзије ≥ 1.4, име може да укључи и име родитељске опције (у случају да је ова опција „null”, вредност родитељске опције ће се приказати у излазу команде `/set`), тада је синтакса: „име << фајл.одељак.опција”
* _type_: тип опције:
** _boolean_: логичка вредност (on/off)
-** _integer_: целобројна вредност (са стринговима за вредности који нису обавезни)
+** _integer_: целобројна вредност
** _string_: стринг вредност
** _color_: боја
+// TRANSLATION MISSING
+** _enum_: list of string values (stored as integer internally)
* _description_: опис опције
-* _string_values_: вредности као стринг (раздвојене са `+|+`), користе се за _integer_ тип (није обавезно)
+// TRANSLATION MISSING
+* _string_values_: вредности као стринг (раздвојене са `+|+`) (optional, required
+ for type _enum_)
* _min_: минимална вредност (за _integer_ тип)
* _max_: максимална вредност (за _integer_ тип)
* _default_value_: подразумевана вредност опције (користи се када се опција ресетује)
@@ -6772,8 +6776,8 @@ C пример:
[source,c]
----
/* логичка */
-struct t_config_option *option1 =
- weechat_config_new_option (config_file, section, "option1", "boolean",
+struct t_config_option *option_bool =
+ weechat_config_new_option (config_file, section, "option_bool", "boolean",
"My option, type boolean",
NULL,
0, 0,
@@ -6785,8 +6789,8 @@ struct t_config_option *option1 =
NULL, NULL, NULL);
/* целобројна */
-struct t_config_option *option2 =
- weechat_config_new_option (config_file, section, "option2", "integer",
+struct t_config_option *option_int =
+ weechat_config_new_option (config_file, section, "option_int", "integer",
"My option, type integer",
NULL,
0, 100,
@@ -6797,22 +6801,9 @@ struct t_config_option *option2 =
NULL, NULL, NULL,
NULL, NULL, NULL);
-/* целобројна (са стринг вредностима) */
-struct t_config_option *option3 =
- weechat_config_new_option (config_file, section, "option3", "integer",
- "My option, type integer (with string values)",
- "top|bottom|left|right",
- 0, 0,
- "bottom",
- "bottom",
- 0,
- NULL, NULL, NULL,
- NULL, NULL, NULL,
- NULL, NULL, NULL);
-
/* стринг */
-struct t_config_option *option4 =
- weechat_config_new_option (config_file, section, "option4", "string",
+struct t_config_option *option_str =
+ weechat_config_new_option (config_file, section, "option_str", "string",
"My option, type string",
NULL,
0, 0,
@@ -6824,8 +6815,8 @@ struct t_config_option *option4 =
NULL, NULL, NULL);
/* боја */
-struct t_config_option *option5 =
- weechat_config_new_option (config_file, section, "option5", "color",
+struct t_config_option *option_col =
+ weechat_config_new_option (config_file, section, "option_col", "color",
"My option, type color",
NULL,
0, 0,
@@ -6835,6 +6826,19 @@ struct t_config_option *option5 =
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
+
+/* целобројна (са стринг вредностима) */
+struct t_config_option *option_enum =
+ weechat_config_new_option (config_file, section, "option_enum", "enum",
+ "My option, type enum",
+ "top|bottom|left|right",
+ 0, 0,
+ "bottom",
+ "bottom",
+ 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
----
Скрипта (Python):
@@ -6850,52 +6854,52 @@ def config_new_option(config_file: str, section: str, name: str, type: str, desc
callback_delete: str, callback_delete_data: str) -> str: ...
# пример
-def option4_check_value_cb(data: str, option: str, value: str) -> int:
+def option_str_check_value_cb(data: str, option: str, value: str) -> int:
# ...
return 1
# return 0
-def option4_change_cb(data: str, option: str) -> None:
+def option_str_change_cb(data: str, option: str) -> None:
# ...
-def option4_delete_cb(data: str, option: str) -> None:
+def option_str_delete_cb(data: str, option: str) -> None:
# ...
-option1 = weechat.config_new_option(config_file, section, "option1", "boolean",
+option_bool = weechat.config_new_option(config_file, section, "option_bool", "boolean",
"My option, type boolean",
"", 0, 0, "on", "on", 0,
"", "",
"", "",
"", "")
-option2 = weechat.config_new_option(config_file, section, "option2", "integer",
+option_int = weechat.config_new_option(config_file, section, "option_int", "integer",
"My option, type integer",
"", 0, 100, "15", "15", 0,
"", "",
"", "",
"", "")
-option3 = weechat.config_new_option(config_file, section, "option3", "integer",
- "My option, type integer (with string values)",
- "top|bottom|left|right",
- 0, 0, "bottom", "bottom", 0,
- "", "",
- "", "",
- "", "")
-
-option4 = weechat.config_new_option(config_file, section, "option4", "string",
+option_str = weechat.config_new_option(config_file, section, "option_str", "string",
"My option, type string",
"", 0, 0, "test", "test", 1,
- "option4_check_value_cb", "",
- "option4_change_cb", "",
- "option4_delete_cb", "")
+ "option_str_check_value_cb", "",
+ "option_str_change_cb", "",
+ "option_str_delete_cb", "")
-option5 = weechat.config_new_option(config_file, section, "option5", "color",
+option_col = weechat.config_new_option(config_file, section, "option_col", "color",
"My option, type color",
"", 0, 0, "lightblue", "lightblue", 0,
"", "",
"", "",
"", "")
+
+option_enum = weechat.config_new_option(config_file, section, "option_enum", "enum",
+ "My option, type enum",
+ "top|bottom|left|right",
+ 0, 0, "bottom", "bottom", 0,
+ "", "",
+ "", "",
+ "", "")
----
[NOTE]
@@ -7164,7 +7168,8 @@ int weechat_config_option_set (struct t_config_option *option,
* _value_: нова вредност опције, могуће су и специјалне вредности које зависе од типа опције:
** _boolean_:
*** `toggle`: пребацује текућу вредност
-** _integer_ или _color_:
+// TRANSLATION MISSING
+** _integer_, _color_ or _enum_:
*** `++N`: додаје `N` (било који цео број) на текућу вредност
*** `--N`: одузима `N` (било који цео број) од текуће вредности
* _run_callback_: 1 за позив change функције повратног позива ако је вредност измењена, у супротном 0
@@ -7395,6 +7400,7 @@ const char *weechat_config_option_get_string (struct t_config_option *option,
*** _integer_
*** _string_
*** _color_
+*** _enum_
** _description_: опис опције
Повратна вредност:
@@ -7569,6 +7575,7 @@ int weechat_config_boolean (struct t_config_option *option);
* _integer_: 0
* _string_: 0
* _color_: 0
+* _enum_: 0
C пример:
@@ -7619,6 +7626,7 @@ int weechat_config_boolean_default (struct t_config_option *option);
* _integer_: 0
* _string_: 0
* _color_: 0
+* _enum_: 0
C пример:
@@ -7669,6 +7677,8 @@ int weechat_config_integer (struct t_config_option *option);
* _integer_: целобројна вредност опције
* _string_: 0
* _color_: индекс боје
+// TRANSLATION MISSING
+* _enum_: integer value of option (index of enum value)
C пример:
@@ -7711,6 +7721,8 @@ int weechat_config_integer_default (struct t_config_option *option);
* _integer_: подразумевана целобројна вредност опције
* _string_: 0
* _color_: подразумевани индекс боје
+// TRANSLATION MISSING
+* _enum_: default integer value of option (index of enum value)
C пример:
@@ -7750,9 +7762,11 @@ const char *weechat_config_string (struct t_config_option *option);
Повратна вредност, зависи од типа опције:
* _boolean_: „on” ако је вредност истинита, у супротном „off”
-* _integer_: стринг вредност опције је цео број са стринг вредностима, у супротном је NULL
+* _integer_: NULL
* _string_: стринг вредност опције
* _color_: име боје
+// TRANSLATION MISSING
+* _enum_: string value of option
C пример:
@@ -7792,9 +7806,11 @@ const char *weechat_config_string_default (struct t_config_option *option);
Повратна вредност, зависи од типа опције:
* _boolean_: „on” ако је подразумевана вредност истинита, у супротном „off”
-* _integer_: подразумевана стринг вредност опције је цео број са стринг вредностима, у супротном је NULL
+* _integer_: NULL
* _string_: подразумевана стринг вредност опције
* _color_: име подразумеване боје
+// TRANSLATION MISSING
+* _enum_: default string value of option
C пример:
@@ -7837,6 +7853,7 @@ const char *weechat_config_color (struct t_config_option *option);
* _integer_: NULL
* _string_: NULL
* _color_: име боје
+* _enum_: NULL
C пример:
@@ -7879,6 +7896,7 @@ const char *weechat_config_color_default (struct t_config_option *option);
* _integer_: NULL
* _string_: NULL
* _color_: име подразумеване боје
+* _enum_: NULL
C пример:
@@ -7900,6 +7918,98 @@ option = weechat.config_get("plugin.section.option")
value = weechat.config_color_default(option)
----
+// TRANSLATION MISSING
+==== config_enum
+
+_WeeChat ≥ 4.1.0._
+
+Return enum value of option, as integer.
+
+Prototype:
+
+[source,c]
+----
+int weechat_config_enum (struct t_config_option *option);
+----
+
+Arguments:
+
+* _option_: option pointer
+
+Return value, depending on the option type:
+
+* _boolean_: boolean value of option (0 or 1)
+* _integer_: integer value of option
+* _string_: 0
+* _color_: color index
+* _enum_: integer value of option (index of enum value)
+
+C example:
+
+[source,c]
+----
+struct t_config_option *option = weechat_config_get ("plugin.section.option");
+int value = weechat_config_enum (option);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+def config_enum(option: str) -> int: ...
+
+# example
+option = weechat.config_get("plugin.section.option")
+value = weechat.config_enum(option)
+----
+
+// TRANSLATION MISSING
+==== config_enum_default
+
+_WeeChat ≥ 4.1.0._
+
+Return default enum value of option, as integer.
+
+Prototype:
+
+[source,c]
+----
+int weechat_config_enum_default (struct t_config_option *option);
+----
+
+Arguments:
+
+* _option_: option pointer
+
+Return value, depending on the option type:
+
+* _boolean_: default boolean value of option (0 or 1)
+* _integer_: default integer value of option
+* _string_: 0
+* _color_: default color index
+* _enum_: integer value of option (index of enum value)
+
+C example:
+
+[source,c]
+----
+struct t_config_option *option = weechat_config_get ("plugin.section.option");
+int value = weechat_config_enum_default (option);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+def config_enum_default(option: str) -> int: ...
+
+# example
+option = weechat.config_get("plugin.section.option")
+value = weechat.config_enum_default(option)
+----
+
==== config_write_option
Уписује линију у конфигурациони фајл са опцијом и њеном вредности (ова функција би требало да се позове само у „write” или „write_default” функцијама повратног позива за одељак).
diff --git a/doc/sr/weechat_user.sr.adoc b/doc/sr/weechat_user.sr.adoc
index e1ee0b1aa..5ed33f135 100644
--- a/doc/sr/weechat_user.sr.adoc
+++ b/doc/sr/weechat_user.sr.adoc
@@ -1623,8 +1623,10 @@ WeeChat нуди доста подразумеваних тастерских п
| kbd:[▼] | - | чет: fset бафер | Помера за пет линија наниже у fset баферу. | `+/fset -down 5+`
| ◾◽◽ | - | чет: fset бафер | Бира линију у fset баферу. | `+/window ${_window_number};/fset -go ${_chat_line_y}+`
| ◽◽◾ | - | чет: fset бафер | Пребацује логичку вредност (on/off) или уређује вредност опције. | `+hsignal:fset_mouse+`
-| ◽◽◾ | лево | чет: fset бафер | Умањује вредност за цео број/боју, поставља/надовезује вредност за остале типове. | `+hsignal:fset_mouse+`
-| ◽◽◾ | десно | чет: fset бафер | Увећава вредност за цео број/боју, поставља/надовезује вредност за остале типове. | `+hsignal:fset_mouse+`
+// TRANSLATION MISSING
+| ◽◽◾ | лево | чет: fset бафер | Умањује вредност за цео број/боју/enum, поставља/надовезује вредност за остале типове. | `+hsignal:fset_mouse+`
+// TRANSLATION MISSING
+| ◽◽◾ | десно | чет: fset бафер | Увећава вредност за цео број/боју/enum, поставља/надовезује вредност за остале типове. | `+hsignal:fset_mouse+`
| ◽◽◾ | горе / доле | чет: fset бафер | Маркира/уклања маркер са више опција. | `+hsignal:fset_mouse+`
| kbd:[▲] | - | чет: script бафер | Помера за пет линија навише у script баферу. | `+/script up 5+`
| kbd:[▼] | - | чет: script бафер | Помера за пет линија наниже у script баферу. | `+/script down 5+`
@@ -1671,8 +1673,10 @@ WeeChat нуди доста подразумеваних тастерских п
| kbd:[F11] | `pass:[<]` | Скролује хоризонтално у лево. | `+/fset -left+`
| kbd:[F12] | `pass:[>]` | Скролује хоризонтално у десно. | `+/fset -right+`
| kbd:[Alt+Space] | `t` | Пребацује стање логичке вредности. | `+/fset -toggle+`
-| kbd:[Alt+-] | `-` | Одузима 1 од вредности за цео број/боју, поставља вредност за остале типове. | `+/fset -add -1+`
-| kbd:[Alt++] | `+` | Додаје 1 на вредност за цео број/боју, надовезује вредност за остале типове. | `+/fset -add 1+`
+// TRANSLATION MISSING
+| kbd:[Alt+-] | `-` | Одузима 1 од вредности за цео број/боју/enum, поставља вредност за остале типове. | `+/fset -add -1+`
+// TRANSLATION MISSING
+| kbd:[Alt++] | `+` | Додаје 1 на вредност за цео број/боју/enum, надовезује вредност за остале типове. | `+/fset -add 1+`
| kbd:[Alt+f], kbd:[Alt+r] | `r` | Ресетује вредност. | `+/fset -reset+`
| kbd:[Alt+f], kbd:[Alt+u] | `u` | Поставља да је вредност празна. | `+/fset -unset+`
| kbd:[Alt+Enter] | `s` | Поставља вредност. | `+/fset -set+`
@@ -1741,7 +1745,7 @@ Fast Set додатак приказује листу опција у бафер
│2.fset │weechat.look.bare_display_exit_on_input: exit the bare display mode on any c│
│ │hanges in input [default: on] │
│ │----------------------------------------------------------------------------│
-│ │ weechat.look.align_end_of_lines integer message │
+│ │ weechat.look.align_end_of_lines enum message │
│ │ weechat.look.align_multiline_words boolean on │
│ │ weechat.look.bar_more_down string "++" │
│ │ weechat.look.bar_more_left string "<<" │
@@ -1750,12 +1754,12 @@ Fast Set додатак приказује листу опција у бафер
│ │## weechat.look.bare_display_exit_on_input boolean on ##│
│ │ weechat.look.bare_display_time_format string "%H:%M" │
│ │ weechat.look.buffer_auto_renumber boolean on │
-│ │ weechat.look.buffer_notify_default integer all │
-│ │ weechat.look.buffer_position integer end │
+│ │ weechat.look.buffer_notify_default enum all │
+│ │ weechat.look.buffer_position enum end │
│ │ weechat.look.buffer_search_case_sensitive boolean off │
│ │ weechat.look.buffer_search_force_default boolean off │
│ │ weechat.look.buffer_search_regex boolean off │
-│ │ weechat.look.buffer_search_where integer prefix_message │
+│ │ weechat.look.buffer_search_where enum prefix_message │
│ │ weechat.look.buffer_time_format string "%H:%M:%S" │
│ │ weechat.look.buffer_time_same string "" │
│ │[12:55] [2] [fset] 2:fset │
@@ -3065,7 +3069,7 @@ irc.server.libera.autorejoin_delay integer null -> 30
irc.server.libera.away_check integer null -> 0
irc.server.libera.away_check_max_nicks integer null -> 25
irc.server.libera.capabilities string null -> "*"
-irc.server.libera.charset_message integer null -> message
+irc.server.libera.charset_message enum null -> message
irc.server.libera.command string null -> ""
irc.server.libera.command_delay integer null -> 0
irc.server.libera.connection_timeout integer null -> 60
@@ -3081,9 +3085,9 @@ irc.server.libera.notify string null -> ""
irc.server.libera.password string null -> ""
irc.server.libera.proxy string null -> ""
irc.server.libera.realname string null -> ""
-irc.server.libera.sasl_fail integer null -> reconnect
+irc.server.libera.sasl_fail enum null -> reconnect
irc.server.libera.sasl_key string null -> ""
-irc.server.libera.sasl_mechanism integer null -> plain
+irc.server.libera.sasl_mechanism enum null -> plain
irc.server.libera.sasl_password string "${sec.data.libera}"
irc.server.libera.sasl_timeout integer null -> 15
irc.server.libera.sasl_username string "alice"