diff --git a/doc/de/weechat_user.de.adoc b/doc/de/weechat_user.de.adoc index 6e1ab8850..434db8f9c 100644 --- a/doc/de/weechat_user.de.adoc +++ b/doc/de/weechat_user.de.adoc @@ -2197,6 +2197,129 @@ Um der Vordergrundfarbe des Terminals das Attribut "fett" zuzuordnen: /set weechat.color.status_time *99999 ---- +// TRANSLATION MISSING +[[themes]] +=== Themen + +A theme is a named bundle of option overrides that can be applied with +the <> command. WeeChat ships a built-in +`"light"` theme tuned for light-background terminals and supports +user-defined themes loaded transiently from files. + +[[themes_themable_options]] +==== Themable options + +Themes can only set options marked as _themable_. All `*.color.*` +options are themable by default; a few string options that hold format +expressions with `+${color:...}+` references (such as +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` or the +`+buflist.format.*+` formats) are explicitly opted in. + +You can list the full themable surface area from the +<> buffer with the `+t:themable+` filter. + +[[themes_apply]] +==== Applying a theme + +To switch to the built-in light-background theme: + +---- +/theme apply light +---- + +The current state of every themable option is saved beforehand to a +backup theme file named like `+backup-YYYYMMDD-HHMMSS-uuuuuu+` in +directory `+themes+` inside the WeeChat configuration directory, so the +previous look can be restored at any time with: + +---- +/theme apply backup-YYYYMMDD-HHMMSS-uuuuuu +---- + +Backup creation can be disabled (not recommended): + +---- +/set weechat.look.theme_backup off +---- + +If backup is enabled and the backup file cannot be written, the apply +is aborted before any option is changed. + +The name of the last applied theme is stored in +`+weechat.look.theme+` (informational only; not re-applied at startup). + +[[themes_save_delete]] +==== Saving and deleting user themes + +Save the current themable options as a new user theme file: + +---- +/theme save mytheme +---- + +By default only options whose value differs from their hardcoded +default are written, keeping the file small and focused. To capture +every themable option: + +---- +/theme save mytheme -full +---- + +Reserved names (built-in theme names like `+light+` and any name +starting with `+backup-+`) are refused. Files live at +`+${weechat_config_dir}/themes/.theme+`. + +Delete a user theme: + +---- +/theme delete mytheme +---- + +This removes the file on disk; built-in themes cannot be deleted. + +[[themes_file_format]] +==== Theme file format + +A theme file is INI-like with two sections: + +---- +[info] +name = "solarized_light" +description = "Light-background theme inspired by Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` is informational metadata shown by `/theme info`. `+[options]+` +holds the actual overrides; keys are the full option names that would +appear in `/set`. String values can be enclosed in double or single +quotes; quotes are stripped at parse time. Non-themable options listed +in a theme file are refused at apply time and logged to the core +buffer (so a `.theme` file imported from an untrusted source cannot +overwrite passwords, autoload lists, or startup commands). + +User theme files are never cached: on every `/theme apply ` the +file is parsed, applied, and freed. + +[[themes_resolution]] +==== Resolution order + +When `+/theme apply +` is run: + +* If `+${weechat_config_dir}/themes/.theme+` exists, the file + is parsed and used (it shadows any built-in with the same name). +* Otherwise the built-in theme registry is consulted; built-ins are + registered programmatically by core, plugins and scripts (see the + plugin and scripting documentation for `+weechat_theme_register+`). + +If neither source provides the name, the apply is refused. + [[charset]] === Charset diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index ecdec4cfd..e0beb5e17 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -9627,6 +9627,89 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR: # ... ---- +[[themes]] +=== Themes + +Functions to contribute color (and other themable option) overrides to +built-in themes. See the +link:weechat_user.en.html#themes[user's guide / Themes] section for the +end-user side and the `+/theme+` command. + +==== theme_register + +_WeeChat ≥ 4.10.0._ + +Register a contribution of option overrides under a named theme. The +caller's plugin is the owner of the contribution; subsequent calls +with the same theme name from the same plugin merge into the existing +contribution (later keys win for duplicates). + +When the calling plugin is unloaded, all its contributions are +automatically dropped from every theme. + +Prototype: + +[source,c] +---- +struct t_theme *weechat_theme_register (const char *name, + struct t_hashtable *overrides); +---- + +Arguments: + +* _name_: theme name (for example `+light+` or a custom name) +* _overrides_: hashtable mapping full option names + (e.g. `+irc.color.input_nick+`) to their string values; the caller + retains ownership and may free the hashtable right after the call + +Return value: + +* pointer to the registered theme (existing or newly created), NULL on + error + +C example: + +[source,c] +---- +struct t_hashtable *overrides = weechat_hashtable_new ( + 8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); +if (overrides) +{ + weechat_hashtable_set (overrides, "irc.color.input_nick", "cyan"); + weechat_hashtable_set (overrides, "irc.color.topic_old", "darkgray"); + weechat_theme_register ("light", overrides); + weechat_hashtable_free (overrides); +} +---- + +Script (Python): + +[source,python] +---- +# prototype +def theme_register(name: str, overrides: Dict[str, str]) -> str: ... + +# example +weechat.theme_register("light", { + "irc.color.input_nick": "cyan", + "irc.color.topic_old": "darkgray", +}) +---- + +[NOTE] +Only options that have the _themable_ flag will be set by `/theme apply`. +All `*.color.*` options are themable by default; string options that +hold `+${color:...}+` references are explicitly opted in. Entries +targeting non-themable options are silently skipped at apply-time with +a warning logged to the _core_ buffer. + +[NOTE] +When called from a script, the contribution is automatically dropped +when the script unloads (no manual cleanup is needed). + [[key_bindings]] === Key bindings diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc index 183dc87ba..407800c22 100644 --- a/doc/en/weechat_user.en.adoc +++ b/doc/en/weechat_user.en.adoc @@ -2185,6 +2185,128 @@ Example of bold with terminal foreground color: /set weechat.color.status_time *99999 ---- +[[themes]] +=== Themes + +A theme is a named bundle of option overrides that can be applied with +the <> command. WeeChat ships a built-in +`"light"` theme tuned for light-background terminals and supports +user-defined themes loaded transiently from files. + +[[themes_themable_options]] +==== Themable options + +Themes can only set options marked as _themable_. All `*.color.*` +options are themable by default; a few string options that hold format +expressions with `+${color:...}+` references (such as +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` or the +`+buflist.format.*+` formats) are explicitly opted in. + +You can list the full themable surface area from the +<> buffer with the `+t:themable+` filter. + +[[themes_apply]] +==== Applying a theme + +To switch to the built-in light-background theme: + +---- +/theme apply light +---- + +The current state of every themable option is saved beforehand to a +backup theme file named like `+backup-YYYYMMDD-HHMMSS-uuuuuu+` in +directory `+themes+` inside the WeeChat configuration directory, so the +previous look can be restored at any time with: + +---- +/theme apply backup-YYYYMMDD-HHMMSS-uuuuuu +---- + +Backup creation can be disabled (not recommended): + +---- +/set weechat.look.theme_backup off +---- + +If backup is enabled and the backup file cannot be written, the apply +is aborted before any option is changed. + +The name of the last applied theme is stored in +`+weechat.look.theme+` (informational only; not re-applied at startup). + +[[themes_save_delete]] +==== Saving and deleting user themes + +Save the current themable options as a new user theme file: + +---- +/theme save mytheme +---- + +By default only options whose value differs from their hardcoded +default are written, keeping the file small and focused. To capture +every themable option: + +---- +/theme save mytheme -full +---- + +Reserved names (built-in theme names like `+light+` and any name +starting with `+backup-+`) are refused. Files live at +`+${weechat_config_dir}/themes/.theme+`. + +Delete a user theme: + +---- +/theme delete mytheme +---- + +This removes the file on disk; built-in themes cannot be deleted. + +[[themes_file_format]] +==== Theme file format + +A theme file is INI-like with two sections: + +---- +[info] +name = "solarized_light" +description = "Light-background theme inspired by Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` is informational metadata shown by `/theme info`. `+[options]+` +holds the actual overrides; keys are the full option names that would +appear in `/set`. String values can be enclosed in double or single +quotes; quotes are stripped at parse time. Non-themable options listed +in a theme file are refused at apply time and logged to the core +buffer (so a `.theme` file imported from an untrusted source cannot +overwrite passwords, autoload lists, or startup commands). + +User theme files are never cached: on every `/theme apply ` the +file is parsed, applied, and freed. + +[[themes_resolution]] +==== Resolution order + +When `+/theme apply +` is run: + +* If `+${weechat_config_dir}/themes/.theme+` exists, the file + is parsed and used (it shadows any built-in with the same name). +* Otherwise the built-in theme registry is consulted; built-ins are + registered programmatically by core, plugins and scripts (see the + plugin and scripting documentation for `+weechat_theme_register+`). + +If neither source provides the name, the apply is refused. + [[charset]] === Charset diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index 49f43569a..37cc42ffb 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -9771,6 +9771,95 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR: # ... ---- +[[themes]] +=== Thèmes + +Fonctions permettant de contribuer des surcharges d'options de couleur +(et autres options modifiables par un thème) à des thèmes intégrés. +Voir la section +link:weechat_user.fr.html#themes[guide utilisateur / Thèmes] pour le +côté utilisateur final et la commande `+/theme+`. + +==== theme_register + +_WeeChat ≥ 4.10.0._ + +Enregistrer une contribution de surcharges d'options sous un thème +nommé. L'extension appelante est le propriétaire de la contribution ; +les appels suivants avec le même nom de thème depuis la même extension +sont fusionnés dans la contribution existante (en cas de doublons, les +dernières clés gagnent). + +Lorsque l'extension appelante est déchargée, toutes ses contributions +sont automatiquement retirées de tous les thèmes. + +Prototype : + +[source,c] +---- +struct t_theme *weechat_theme_register (const char *name, + struct t_hashtable *overrides); +---- + +Paramètres : + +* _name_ : nom du thème (par exemple `+light+` ou un nom personnalisé) +* _overrides_ : table de hachage associant des noms d'options complets + (par exemple `+irc.color.input_nick+`) à leurs valeurs chaîne ; + l'appelant en conserve la propriété et peut la libérer juste après + l'appel + +Valeur de retour : + +* pointeur vers le thème enregistré (existant ou nouvellement créé), + NULL en cas d'erreur + +Exemple en C : + +[source,c] +---- +struct t_hashtable *overrides = weechat_hashtable_new ( + 8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); +if (overrides) +{ + weechat_hashtable_set (overrides, "irc.color.input_nick", "cyan"); + weechat_hashtable_set (overrides, "irc.color.topic_old", "darkgray"); + weechat_theme_register ("light", overrides); + weechat_hashtable_free (overrides); +} +---- + +Script (Python) : + +[source,python] +---- +# prototype +def theme_register(name: str, overrides: Dict[str, str]) -> str: ... + +# exemple +weechat.theme_register("light", { + "irc.color.input_nick": "cyan", + "irc.color.topic_old": "darkgray", +}) +---- + +[NOTE] +Seules les options possédant le flag _themable_ seront modifiées par +`/theme apply`. Toutes les options `*.color.*` sont modifiables par +défaut ; les options de type chaîne contenant des références +`+${color:...}+` sont explicitement déclarées comme modifiables. Les +entrées ciblant des options non modifiables sont silencieusement +ignorées au moment de l'application avec un avertissement écrit sur +le tampon _core_. + +[NOTE] +Lorsqu'elle est appelée depuis un script, la contribution est +automatiquement retirée lorsque le script est déchargé (aucun nettoyage +manuel n'est nécessaire). + [[key_bindings]] === Associations de touches diff --git a/doc/fr/weechat_user.fr.adoc b/doc/fr/weechat_user.fr.adoc index 658f2a98c..c38c29948 100644 --- a/doc/fr/weechat_user.fr.adoc +++ b/doc/fr/weechat_user.fr.adoc @@ -2227,6 +2227,141 @@ Exemple de gras avec la couleur de texte du terminal : /set weechat.color.status_time *99999 ---- +[[themes]] +=== Thèmes + +Un thème est un ensemble nommé de surcharges d'options qui peut être +appliqué par la commande <>. WeeChat est +livré avec un thème intégré `"light"` adapté aux terminaux à fond clair +et permet de charger temporairement des thèmes utilisateur depuis des +fichiers. + +[[themes_themable_options]] +==== Options modifiables par un thème + +Les thèmes ne peuvent modifier que les options marquées comme +_themable_ (modifiables par un thème). Toutes les options `*.color.*` +le sont par défaut ; certaines options de type chaîne contenant des +références `+${color:...}+` (par exemple +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` ou les +formats `+buflist.format.*+`) sont explicitement déclarées comme +modifiables. + +La liste complète des options modifiables peut être affichée depuis le +tampon <> avec le filtre `+t:themable+`. + +[[themes_apply]] +==== Appliquer un thème + +Pour basculer vers le thème intégré pour fond clair : + +---- +/theme apply light +---- + +L'état actuel de toutes les options modifiables est sauvegardé au +préalable dans un fichier de sauvegarde nommé +`+backup-AAAAMMJJ-HHMMSS-uuuuuu+` dans le répertoire `+themes+` du +répertoire de configuration de WeeChat. L'apparence précédente peut +ainsi être restaurée à tout moment avec : + +---- +/theme apply backup-AAAAMMJJ-HHMMSS-uuuuuu +---- + +La création de la sauvegarde peut être désactivée (déconseillé) : + +---- +/set weechat.look.theme_backup off +---- + +Si la sauvegarde est activée et que le fichier ne peut pas être écrit, +l'application est annulée avant qu'aucune option ne soit modifiée. + +Le nom du dernier thème appliqué est conservé dans +`+weechat.look.theme+` (à titre informatif uniquement ; il n'est pas +ré-appliqué au démarrage). + +[[themes_save_delete]] +==== Sauvegarder et supprimer des thèmes utilisateur + +Sauvegarder l'état actuel des options modifiables en tant que nouveau +thème utilisateur : + +---- +/theme save monTheme +---- + +Par défaut, seules les options dont la valeur diffère de la valeur par +défaut codée en dur sont écrites, ce qui garde le fichier compact et +ciblé. Pour capturer toutes les options modifiables : + +---- +/theme save monTheme -full +---- + +Les noms réservés (noms de thèmes intégrés comme `+light+` et tout nom +commençant par `+backup-+`) sont refusés. Les fichiers sont placés +dans `+${weechat_config_dir}/themes/.theme+`. + +Supprimer un thème utilisateur : + +---- +/theme delete monTheme +---- + +Cela supprime le fichier sur le disque ; les thèmes intégrés ne +peuvent pas être supprimés. + +[[themes_file_format]] +==== Format du fichier de thème + +Un fichier de thème est de type INI avec deux sections : + +---- +[info] +name = "solarized_light" +description = "Thème fond clair inspiré de Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` est une section de métadonnées informatives affichées par +`/theme info`. `+[options]+` contient les surcharges réelles ; les clés +sont les noms complets d'options tels qu'affichés par `/set`. Les +valeurs de type chaîne peuvent être encadrées par des guillemets +simples ou doubles ; les guillemets sont retirés à l'analyse. Les +options non modifiables par un thème listées dans un fichier sont +refusées au moment de l'application et signalées sur le tampon _core_ +(ainsi, un fichier `.theme` importé depuis une source non fiable ne +peut pas écraser des mots de passe, des listes d'auto-chargement ou +des commandes de démarrage). + +Les fichiers de thème utilisateur ne sont jamais mis en cache : à +chaque `/theme apply `, le fichier est analysé, appliqué, puis +libéré. + +[[themes_resolution]] +==== Ordre de résolution + +Lors de l'exécution de `+/theme apply +` : + +* Si `+${weechat_config_dir}/themes/.theme+` existe, le fichier + est analysé et utilisé (il masque tout thème intégré du même nom). +* Sinon, le registre des thèmes intégrés est consulté ; les thèmes + intégrés sont enregistrés par programmation par le cœur, les + extensions et les scripts (voir la documentation des extensions et + des scripts pour `+weechat_theme_register+`). + +Si aucune des deux sources ne fournit le nom, l'application est +refusée. + [[charset]] === Charset diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index a490dd8a6..e25b5d8f7 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -9967,6 +9967,90 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR: # ... ---- +// TRANSLATION MISSING +[[themes]] +=== Themes + +Functions to contribute color (and other themable option) overrides to +built-in themes. See the +link:weechat_user.it.html#themes[user's guide / Themes] section for the +end-user side and the `+/theme+` command. + +==== theme_register + +_WeeChat ≥ 4.10.0._ + +Register a contribution of option overrides under a named theme. The +caller's plugin is the owner of the contribution; subsequent calls +with the same theme name from the same plugin merge into the existing +contribution (later keys win for duplicates). + +When the calling plugin is unloaded, all its contributions are +automatically dropped from every theme. + +Prototype: + +[source,c] +---- +struct t_theme *weechat_theme_register (const char *name, + struct t_hashtable *overrides); +---- + +Arguments: + +* _name_: theme name (for example `+light+` or a custom name) +* _overrides_: hashtable mapping full option names + (e.g. `+irc.color.input_nick+`) to their string values; the caller + retains ownership and may free the hashtable right after the call + +Return value: + +* pointer to the registered theme (existing or newly created), NULL on + error + +C example: + +[source,c] +---- +struct t_hashtable *overrides = weechat_hashtable_new ( + 8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); +if (overrides) +{ + weechat_hashtable_set (overrides, "irc.color.input_nick", "cyan"); + weechat_hashtable_set (overrides, "irc.color.topic_old", "darkgray"); + weechat_theme_register ("light", overrides); + weechat_hashtable_free (overrides); +} +---- + +Script (Python): + +[source,python] +---- +# prototype +def theme_register(name: str, overrides: Dict[str, str]) -> str: ... + +# example +weechat.theme_register("light", { + "irc.color.input_nick": "cyan", + "irc.color.topic_old": "darkgray", +}) +---- + +[NOTE] +Only options that have the _themable_ flag will be set by `/theme apply`. +All `*.color.*` options are themable by default; string options that +hold `+${color:...}+` references are explicitly opted in. Entries +targeting non-themable options are silently skipped at apply-time with +a warning logged to the _core_ buffer. + +[NOTE] +When called from a script, the contribution is automatically dropped +when the script unloads (no manual cleanup is needed). + [[key_bindings]] === Combinazione tasti diff --git a/doc/it/weechat_user.it.adoc b/doc/it/weechat_user.it.adoc index e758d66a0..4e372000a 100644 --- a/doc/it/weechat_user.it.adoc +++ b/doc/it/weechat_user.it.adoc @@ -2439,6 +2439,129 @@ Esempio di grassetto con il colore di primo piano del terminale: /set weechat.color.status_time *99999 ---- +// TRANSLATION MISSING +[[themes]] +=== Themes + +A theme is a named bundle of option overrides that can be applied with +the <> command. WeeChat ships a built-in +`"light"` theme tuned for light-background terminals and supports +user-defined themes loaded transiently from files. + +[[themes_themable_options]] +==== Themable options + +Themes can only set options marked as _themable_. All `*.color.*` +options are themable by default; a few string options that hold format +expressions with `+${color:...}+` references (such as +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` or the +`+buflist.format.*+` formats) are explicitly opted in. + +You can list the full themable surface area from the +<> buffer with the `+t:themable+` filter. + +[[themes_apply]] +==== Applying a theme + +To switch to the built-in light-background theme: + +---- +/theme apply light +---- + +The current state of every themable option is saved beforehand to a +backup theme file named like `+backup-YYYYMMDD-HHMMSS-uuuuuu+` in +directory `+themes+` inside the WeeChat configuration directory, so the +previous look can be restored at any time with: + +---- +/theme apply backup-YYYYMMDD-HHMMSS-uuuuuu +---- + +Backup creation can be disabled (not recommended): + +---- +/set weechat.look.theme_backup off +---- + +If backup is enabled and the backup file cannot be written, the apply +is aborted before any option is changed. + +The name of the last applied theme is stored in +`+weechat.look.theme+` (informational only; not re-applied at startup). + +[[themes_save_delete]] +==== Saving and deleting user themes + +Save the current themable options as a new user theme file: + +---- +/theme save mytheme +---- + +By default only options whose value differs from their hardcoded +default are written, keeping the file small and focused. To capture +every themable option: + +---- +/theme save mytheme -full +---- + +Reserved names (built-in theme names like `+light+` and any name +starting with `+backup-+`) are refused. Files live at +`+${weechat_config_dir}/themes/.theme+`. + +Delete a user theme: + +---- +/theme delete mytheme +---- + +This removes the file on disk; built-in themes cannot be deleted. + +[[themes_file_format]] +==== Theme file format + +A theme file is INI-like with two sections: + +---- +[info] +name = "solarized_light" +description = "Light-background theme inspired by Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` is informational metadata shown by `/theme info`. `+[options]+` +holds the actual overrides; keys are the full option names that would +appear in `/set`. String values can be enclosed in double or single +quotes; quotes are stripped at parse time. Non-themable options listed +in a theme file are refused at apply time and logged to the core +buffer (so a `.theme` file imported from an untrusted source cannot +overwrite passwords, autoload lists, or startup commands). + +User theme files are never cached: on every `/theme apply ` the +file is parsed, applied, and freed. + +[[themes_resolution]] +==== Resolution order + +When `+/theme apply +` is run: + +* If `+${weechat_config_dir}/themes/.theme+` exists, the file + is parsed and used (it shadows any built-in with the same name). +* Otherwise the built-in theme registry is consulted; built-ins are + registered programmatically by core, plugins and scripts (see the + plugin and scripting documentation for `+weechat_theme_register+`). + +If neither source provides the name, the apply is refused. + [[charset]] === Charset diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index aa9eb0ca0..6778f5228 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -9746,6 +9746,90 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR: # ... ---- +// TRANSLATION MISSING +[[themes]] +=== Themes + +Functions to contribute color (and other themable option) overrides to +built-in themes. See the +link:weechat_user.ja.html#themes[user's guide / Themes] section for the +end-user side and the `+/theme+` command. + +==== theme_register + +_WeeChat ≥ 4.10.0._ + +Register a contribution of option overrides under a named theme. The +caller's plugin is the owner of the contribution; subsequent calls +with the same theme name from the same plugin merge into the existing +contribution (later keys win for duplicates). + +When the calling plugin is unloaded, all its contributions are +automatically dropped from every theme. + +Prototype: + +[source,c] +---- +struct t_theme *weechat_theme_register (const char *name, + struct t_hashtable *overrides); +---- + +Arguments: + +* _name_: theme name (for example `+light+` or a custom name) +* _overrides_: hashtable mapping full option names + (e.g. `+irc.color.input_nick+`) to their string values; the caller + retains ownership and may free the hashtable right after the call + +Return value: + +* pointer to the registered theme (existing or newly created), NULL on + error + +C example: + +[source,c] +---- +struct t_hashtable *overrides = weechat_hashtable_new ( + 8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); +if (overrides) +{ + weechat_hashtable_set (overrides, "irc.color.input_nick", "cyan"); + weechat_hashtable_set (overrides, "irc.color.topic_old", "darkgray"); + weechat_theme_register ("light", overrides); + weechat_hashtable_free (overrides); +} +---- + +Script (Python): + +[source,python] +---- +# prototype +def theme_register(name: str, overrides: Dict[str, str]) -> str: ... + +# example +weechat.theme_register("light", { + "irc.color.input_nick": "cyan", + "irc.color.topic_old": "darkgray", +}) +---- + +[NOTE] +Only options that have the _themable_ flag will be set by `/theme apply`. +All `*.color.*` options are themable by default; string options that +hold `+${color:...}+` references are explicitly opted in. Entries +targeting non-themable options are silently skipped at apply-time with +a warning logged to the _core_ buffer. + +[NOTE] +When called from a script, the contribution is automatically dropped +when the script unloads (no manual cleanup is needed). + [[key_bindings]] === キー割り当て diff --git a/doc/ja/weechat_user.ja.adoc b/doc/ja/weechat_user.ja.adoc index 0e72c9733..d5073e594 100644 --- a/doc/ja/weechat_user.ja.adoc +++ b/doc/ja/weechat_user.ja.adoc @@ -2375,6 +2375,129 @@ WeeChat は画面に色が表示された時点で色ペアを動的に割り当 /set weechat.color.status_time *99999 ---- +// TRANSLATION MISSING +[[themes]] +=== Themes + +A theme is a named bundle of option overrides that can be applied with +the <> command. WeeChat ships a built-in +`"light"` theme tuned for light-background terminals and supports +user-defined themes loaded transiently from files. + +[[themes_themable_options]] +==== Themable options + +Themes can only set options marked as _themable_. All `*.color.*` +options are themable by default; a few string options that hold format +expressions with `+${color:...}+` references (such as +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` or the +`+buflist.format.*+` formats) are explicitly opted in. + +You can list the full themable surface area from the +<> buffer with the `+t:themable+` filter. + +[[themes_apply]] +==== Applying a theme + +To switch to the built-in light-background theme: + +---- +/theme apply light +---- + +The current state of every themable option is saved beforehand to a +backup theme file named like `+backup-YYYYMMDD-HHMMSS-uuuuuu+` in +directory `+themes+` inside the WeeChat configuration directory, so the +previous look can be restored at any time with: + +---- +/theme apply backup-YYYYMMDD-HHMMSS-uuuuuu +---- + +Backup creation can be disabled (not recommended): + +---- +/set weechat.look.theme_backup off +---- + +If backup is enabled and the backup file cannot be written, the apply +is aborted before any option is changed. + +The name of the last applied theme is stored in +`+weechat.look.theme+` (informational only; not re-applied at startup). + +[[themes_save_delete]] +==== Saving and deleting user themes + +Save the current themable options as a new user theme file: + +---- +/theme save mytheme +---- + +By default only options whose value differs from their hardcoded +default are written, keeping the file small and focused. To capture +every themable option: + +---- +/theme save mytheme -full +---- + +Reserved names (built-in theme names like `+light+` and any name +starting with `+backup-+`) are refused. Files live at +`+${weechat_config_dir}/themes/.theme+`. + +Delete a user theme: + +---- +/theme delete mytheme +---- + +This removes the file on disk; built-in themes cannot be deleted. + +[[themes_file_format]] +==== Theme file format + +A theme file is INI-like with two sections: + +---- +[info] +name = "solarized_light" +description = "Light-background theme inspired by Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` is informational metadata shown by `/theme info`. `+[options]+` +holds the actual overrides; keys are the full option names that would +appear in `/set`. String values can be enclosed in double or single +quotes; quotes are stripped at parse time. Non-themable options listed +in a theme file are refused at apply time and logged to the core +buffer (so a `.theme` file imported from an untrusted source cannot +overwrite passwords, autoload lists, or startup commands). + +User theme files are never cached: on every `/theme apply ` the +file is parsed, applied, and freed. + +[[themes_resolution]] +==== Resolution order + +When `+/theme apply +` is run: + +* If `+${weechat_config_dir}/themes/.theme+` exists, the file + is parsed and used (it shadows any built-in with the same name). +* Otherwise the built-in theme registry is consulted; built-ins are + registered programmatically by core, plugins and scripts (see the + plugin and scripting documentation for `+weechat_theme_register+`). + +If neither source provides the name, the apply is refused. + [[charset]] === Charset diff --git a/doc/pl/weechat_user.pl.adoc b/doc/pl/weechat_user.pl.adoc index a31903f85..9494b1529 100644 --- a/doc/pl/weechat_user.pl.adoc +++ b/doc/pl/weechat_user.pl.adoc @@ -2191,6 +2191,129 @@ Przykład pogrubienia z domyślnym kolorem terminala: /set weechat.color.status_time *99999 ---- +// TRANSLATION MISSING +[[themes]] +=== Motywy + +A theme is a named bundle of option overrides that can be applied with +the <> command. WeeChat ships a built-in +`"light"` theme tuned for light-background terminals and supports +user-defined themes loaded transiently from files. + +[[themes_themable_options]] +==== Themable options + +Themes can only set options marked as _themable_. All `*.color.*` +options are themable by default; a few string options that hold format +expressions with `+${color:...}+` references (such as +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` or the +`+buflist.format.*+` formats) are explicitly opted in. + +You can list the full themable surface area from the +<> buffer with the `+t:themable+` filter. + +[[themes_apply]] +==== Applying a theme + +To switch to the built-in light-background theme: + +---- +/theme apply light +---- + +The current state of every themable option is saved beforehand to a +backup theme file named like `+backup-YYYYMMDD-HHMMSS-uuuuuu+` in +directory `+themes+` inside the WeeChat configuration directory, so the +previous look can be restored at any time with: + +---- +/theme apply backup-YYYYMMDD-HHMMSS-uuuuuu +---- + +Backup creation can be disabled (not recommended): + +---- +/set weechat.look.theme_backup off +---- + +If backup is enabled and the backup file cannot be written, the apply +is aborted before any option is changed. + +The name of the last applied theme is stored in +`+weechat.look.theme+` (informational only; not re-applied at startup). + +[[themes_save_delete]] +==== Saving and deleting user themes + +Save the current themable options as a new user theme file: + +---- +/theme save mytheme +---- + +By default only options whose value differs from their hardcoded +default are written, keeping the file small and focused. To capture +every themable option: + +---- +/theme save mytheme -full +---- + +Reserved names (built-in theme names like `+light+` and any name +starting with `+backup-+`) are refused. Files live at +`+${weechat_config_dir}/themes/.theme+`. + +Delete a user theme: + +---- +/theme delete mytheme +---- + +This removes the file on disk; built-in themes cannot be deleted. + +[[themes_file_format]] +==== Theme file format + +A theme file is INI-like with two sections: + +---- +[info] +name = "solarized_light" +description = "Light-background theme inspired by Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` is informational metadata shown by `/theme info`. `+[options]+` +holds the actual overrides; keys are the full option names that would +appear in `/set`. String values can be enclosed in double or single +quotes; quotes are stripped at parse time. Non-themable options listed +in a theme file are refused at apply time and logged to the core +buffer (so a `.theme` file imported from an untrusted source cannot +overwrite passwords, autoload lists, or startup commands). + +User theme files are never cached: on every `/theme apply ` the +file is parsed, applied, and freed. + +[[themes_resolution]] +==== Resolution order + +When `+/theme apply +` is run: + +* If `+${weechat_config_dir}/themes/.theme+` exists, the file + is parsed and used (it shadows any built-in with the same name). +* Otherwise the built-in theme registry is consulted; built-ins are + registered programmatically by core, plugins and scripts (see the + plugin and scripting documentation for `+weechat_theme_register+`). + +If neither source provides the name, the apply is refused. + [[charset]] === Charset diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc index 51fb0670e..d131eb923 100644 --- a/doc/sr/weechat_plugin_api.sr.adoc +++ b/doc/sr/weechat_plugin_api.sr.adoc @@ -9436,6 +9436,90 @@ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR: # ... ---- +// TRANSLATION MISSING +[[themes]] +=== Теме + +Functions to contribute color (and other themable option) overrides to +built-in themes. See the +link:weechat_user.sr.html#themes[user's guide / Themes] section for the +end-user side and the `+/theme+` command. + +==== theme_register + +_WeeChat ≥ 4.10.0._ + +Register a contribution of option overrides under a named theme. The +caller's plugin is the owner of the contribution; subsequent calls +with the same theme name from the same plugin merge into the existing +contribution (later keys win for duplicates). + +When the calling plugin is unloaded, all its contributions are +automatically dropped from every theme. + +Prototype: + +[source,c] +---- +struct t_theme *weechat_theme_register (const char *name, + struct t_hashtable *overrides); +---- + +Arguments: + +* _name_: theme name (for example `+light+` or a custom name) +* _overrides_: hashtable mapping full option names + (e.g. `+irc.color.input_nick+`) to their string values; the caller + retains ownership and may free the hashtable right after the call + +Return value: + +* pointer to the registered theme (existing or newly created), NULL on + error + +C example: + +[source,c] +---- +struct t_hashtable *overrides = weechat_hashtable_new ( + 8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); +if (overrides) +{ + weechat_hashtable_set (overrides, "irc.color.input_nick", "cyan"); + weechat_hashtable_set (overrides, "irc.color.topic_old", "darkgray"); + weechat_theme_register ("light", overrides); + weechat_hashtable_free (overrides); +} +---- + +Script (Python): + +[source,python] +---- +# prototype +def theme_register(name: str, overrides: Dict[str, str]) -> str: ... + +# example +weechat.theme_register("light", { + "irc.color.input_nick": "cyan", + "irc.color.topic_old": "darkgray", +}) +---- + +[NOTE] +Only options that have the _themable_ flag will be set by `/theme apply`. +All `*.color.*` options are themable by default; string options that +hold `+${color:...}+` references are explicitly opted in. Entries +targeting non-themable options are silently skipped at apply-time with +a warning logged to the _core_ buffer. + +[NOTE] +When called from a script, the contribution is automatically dropped +when the script unloads (no manual cleanup is needed). + [[key_bindings]] === Тастерске пречице diff --git a/doc/sr/weechat_user.sr.adoc b/doc/sr/weechat_user.sr.adoc index 484b63650..b25544cd5 100644 --- a/doc/sr/weechat_user.sr.adoc +++ b/doc/sr/weechat_user.sr.adoc @@ -2093,6 +2093,129 @@ include::{autogendir}/autogen_user_options.sr.adoc[tag=fset_options] /set weechat.color.status_time *99999 ---- +// TRANSLATION MISSING +[[themes]] +=== Теме + +A theme is a named bundle of option overrides that can be applied with +the <> command. WeeChat ships a built-in +`"light"` theme tuned for light-background terminals and supports +user-defined themes loaded transiently from files. + +[[themes_themable_options]] +==== Themable options + +Themes can only set options marked as _themable_. All `*.color.*` +options are themable by default; a few string options that hold format +expressions with `+${color:...}+` references (such as +`+weechat.color.chat_nick_colors+`, `+weechat.look.prefix_error+` or the +`+buflist.format.*+` formats) are explicitly opted in. + +You can list the full themable surface area from the +<> buffer with the `+t:themable+` filter. + +[[themes_apply]] +==== Applying a theme + +To switch to the built-in light-background theme: + +---- +/theme apply light +---- + +The current state of every themable option is saved beforehand to a +backup theme file named like `+backup-YYYYMMDD-HHMMSS-uuuuuu+` in +directory `+themes+` inside the WeeChat configuration directory, so the +previous look can be restored at any time with: + +---- +/theme apply backup-YYYYMMDD-HHMMSS-uuuuuu +---- + +Backup creation can be disabled (not recommended): + +---- +/set weechat.look.theme_backup off +---- + +If backup is enabled and the backup file cannot be written, the apply +is aborted before any option is changed. + +The name of the last applied theme is stored in +`+weechat.look.theme+` (informational only; not re-applied at startup). + +[[themes_save_delete]] +==== Saving and deleting user themes + +Save the current themable options as a new user theme file: + +---- +/theme save mytheme +---- + +By default only options whose value differs from their hardcoded +default are written, keeping the file small and focused. To capture +every themable option: + +---- +/theme save mytheme -full +---- + +Reserved names (built-in theme names like `+light+` and any name +starting with `+backup-+`) are refused. Files live at +`+${weechat_config_dir}/themes/.theme+`. + +Delete a user theme: + +---- +/theme delete mytheme +---- + +This removes the file on disk; built-in themes cannot be deleted. + +[[themes_file_format]] +==== Theme file format + +A theme file is INI-like with two sections: + +---- +[info] +name = "solarized_light" +description = "Light-background theme inspired by Solarized" +date = "2026-05-25 09:42:10" +weechat = "4.10.0-dev" + +[options] +weechat.color.chat = "darkgray" +weechat.color.separator = "blue" +irc.color.input_nick = "magenta" +buflist.format.number = "${color:28}${number}${if:${number_displayed}?.: }" +---- + +`+[info]+` is informational metadata shown by `/theme info`. `+[options]+` +holds the actual overrides; keys are the full option names that would +appear in `/set`. String values can be enclosed in double or single +quotes; quotes are stripped at parse time. Non-themable options listed +in a theme file are refused at apply time and logged to the core +buffer (so a `.theme` file imported from an untrusted source cannot +overwrite passwords, autoload lists, or startup commands). + +User theme files are never cached: on every `/theme apply ` the +file is parsed, applied, and freed. + +[[themes_resolution]] +==== Resolution order + +When `+/theme apply +` is run: + +* If `+${weechat_config_dir}/themes/.theme+` exists, the file + is parsed and used (it shadows any built-in with the same name). +* Otherwise the built-in theme registry is consulted; built-ins are + registered programmatically by core, plugins and scripts (see the + plugin and scripting documentation for `+weechat_theme_register+`). + +If neither source provides the name, the apply is refused. + [[charset]] === Charset