From 91223591e9e1cc297dae87ca7ae4af5d94e0e5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 May 2026 18:08:05 +0200 Subject: [PATCH] exec: contribute "light" theme overrides Add exec-theme.{c,h} with the exec plugin contribution to the built-in "light" theme: 2 entries (exec.color.flag_finished=red, exec.color.flag_running=green) tuned for a light-background terminal. Same 2D-array pattern as the other plugin contributions. Default option values are NOT changed. --- src/plugins/exec/CMakeLists.txt | 1 + src/plugins/exec/exec-theme.c | 70 +++++++++++++++++++++++++++++++++ src/plugins/exec/exec-theme.h | 27 +++++++++++++ src/plugins/exec/exec.c | 3 ++ 4 files changed, 101 insertions(+) create mode 100644 src/plugins/exec/exec-theme.c create mode 100644 src/plugins/exec/exec-theme.h diff --git a/src/plugins/exec/CMakeLists.txt b/src/plugins/exec/CMakeLists.txt index 5db449c2f..caca45625 100644 --- a/src/plugins/exec/CMakeLists.txt +++ b/src/plugins/exec/CMakeLists.txt @@ -25,6 +25,7 @@ add_library(exec MODULE exec-command.c exec-command.h exec-completion.c exec-completion.h exec-config.c exec-config.h + exec-theme.c exec-theme.h ) set_target_properties(exec PROPERTIES PREFIX "") diff --git a/src/plugins/exec/exec-theme.c b/src/plugins/exec/exec-theme.c new file mode 100644 index 000000000..c56120dfb --- /dev/null +++ b/src/plugins/exec/exec-theme.c @@ -0,0 +1,70 @@ +/* + * SPDX-FileCopyrightText: 2026 Sébastien Helleu + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * 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 . + */ + +/* exec contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "exec.h" +#include "exec-theme.h" + + +const char *exec_theme_light[][2] = +{ + { "exec.color.flag_finished", "red" }, + { "exec.color.flag_running", "green" }, + { NULL, NULL }, +}; + +void +exec_theme_register (const char *name, const char *entries[][2]) +{ + struct t_hashtable *overrides; + int i; + + if (!name || !entries) + return; + + overrides = weechat_hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + if (!overrides) + return; + + for (i = 0; entries[i][0]; i++) + weechat_hashtable_set (overrides, entries[i][0], entries[i][1]); + + weechat_theme_register (name, overrides); + + weechat_hashtable_free (overrides); +} + +void +exec_theme_init (void) +{ + exec_theme_register ("light", exec_theme_light); +} diff --git a/src/plugins/exec/exec-theme.h b/src/plugins/exec/exec-theme.h new file mode 100644 index 000000000..ba9c0aed3 --- /dev/null +++ b/src/plugins/exec/exec-theme.h @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2026 Sébastien Helleu + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * 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 . + */ + +#ifndef WEECHAT_PLUGIN_EXEC_THEME_H +#define WEECHAT_PLUGIN_EXEC_THEME_H + +extern void exec_theme_init (void); + +#endif /* WEECHAT_PLUGIN_EXEC_THEME_H */ diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c index 3793f389e..676386f03 100644 --- a/src/plugins/exec/exec.c +++ b/src/plugins/exec/exec.c @@ -32,6 +32,7 @@ #include "exec-command.h" #include "exec-completion.h" #include "exec-config.h" +#include "exec-theme.h" WEECHAT_PLUGIN_NAME(EXEC_PLUGIN_NAME); @@ -742,6 +743,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) if (!exec_config_init ()) return WEECHAT_RC_ERROR; + exec_theme_init (); + exec_config_read (); /* hook some signals */