From 4550c3e33ad6c1aaab96a8e844087359a4d69dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 26 May 2026 13:15:20 +0200 Subject: [PATCH] core: add weechat.look.theme option and theme_applying guard Add a new string option "weechat.look.theme" holding the name of the last theme applied via the upcoming /theme command. It is set automatically by /theme apply and persisted on disk for /theme info to display after restart; it is NOT re-applied at startup (the user's saved color values win to avoid clobbering manual post-apply tweaks). Amend config_change_color so it skips the gui_color_init_weechat () and gui_window_ask_refresh (1) calls when theme_applying is set. /theme apply will set this flag while iterating overrides so the N individual option changes do not trigger N redundant screen refreshes; the apply path then performs a single refresh at the end. --- src/core/core-config.c | 12 +++++++++++- src/core/core-config.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/core-config.c b/src/core/core-config.c index 27daeb44e..ca731457c 100644 --- a/src/core/core-config.c +++ b/src/core/core-config.c @@ -50,6 +50,7 @@ #include "core-proxy.h" #include "core-string.h" #include "core-sys.h" +#include "core-theme.h" #include "core-util.h" #include "core-version.h" #include "../gui/gui-bar.h" @@ -222,6 +223,7 @@ struct t_config_option *config_look_separator_horizontal = NULL; struct t_config_option *config_look_separator_vertical = NULL; struct t_config_option *config_look_tab_whitespace_char = NULL; struct t_config_option *config_look_tab_width = NULL; +struct t_config_option *config_look_theme = NULL; struct t_config_option *config_look_time_format = NULL; struct t_config_option *config_look_whitespace_char = NULL; struct t_config_option *config_look_window_auto_zoom = NULL; @@ -1381,7 +1383,7 @@ config_change_color (const void *pointer, void *data, (void) data; (void) option; - if (gui_init_ok) + if (gui_init_ok && !theme_applying) { gui_color_init_weechat (); gui_window_ask_refresh (1); @@ -4423,6 +4425,14 @@ config_weechat_init_options (void) NULL, NULL, NULL, &config_change_tab, NULL, NULL, NULL, NULL, NULL); + config_look_theme = config_file_new_option ( + weechat_config_file, weechat_config_section_look, + "theme", "string", + N_("name of the last theme applied with command /theme " + "(set automatically, do not change manually); informational " + "only, the theme is not re-applied at startup"), + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); config_look_time_format = config_file_new_option ( weechat_config_file, weechat_config_section_look, "time_format", "string", diff --git a/src/core/core-config.h b/src/core/core-config.h index 32de3cba6..68396a31f 100644 --- a/src/core/core-config.h +++ b/src/core/core-config.h @@ -277,6 +277,7 @@ extern struct t_config_option *config_look_separator_horizontal; extern struct t_config_option *config_look_separator_vertical; extern struct t_config_option *config_look_tab_whitespace_char; extern struct t_config_option *config_look_tab_width; +extern struct t_config_option *config_look_theme; extern struct t_config_option *config_look_time_format; extern struct t_config_option *config_look_whitespace_char; extern struct t_config_option *config_look_window_auto_zoom;