From f587a9dcafcd9fe06a2520062b5c992820aed4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 May 2026 17:45:09 +0200 Subject: [PATCH] fset: contribute "light" theme overrides Add fset-theme.{c,h} with the fset plugin contribution to the built-in "light" theme: 47 overrides on fset.color.* options (line backgrounds, selected-row tuning, title and value colors) tuned for a light-background terminal. The table is a NULL-terminated 2-column array of strings (no struct wrapper, matching the pattern adopted for the irc contribution). fset_theme_register builds a hashtable from the table and calls weechat_theme_register; fset_theme_init() is called once from weechat_plugin_init after fset_config_init / fset_config_read. Default option values are NOT changed. --- src/plugins/fset/CMakeLists.txt | 1 + src/plugins/fset/fset-theme.c | 130 ++++++++++++++++++++++++++++++++ src/plugins/fset/fset-theme.h | 27 +++++++ src/plugins/fset/fset.c | 3 + 4 files changed, 161 insertions(+) create mode 100644 src/plugins/fset/fset-theme.c create mode 100644 src/plugins/fset/fset-theme.h diff --git a/src/plugins/fset/CMakeLists.txt b/src/plugins/fset/CMakeLists.txt index 892a5222c..e75101cbb 100644 --- a/src/plugins/fset/CMakeLists.txt +++ b/src/plugins/fset/CMakeLists.txt @@ -29,6 +29,7 @@ add_library(fset MODULE fset-info.c fset-info.h fset-mouse.c fset-mouse.h fset-option.c fset-option.h + fset-theme.c fset-theme.h ) set_target_properties(fset PROPERTIES PREFIX "") diff --git a/src/plugins/fset/fset-theme.c b/src/plugins/fset/fset-theme.c new file mode 100644 index 000000000..31d697396 --- /dev/null +++ b/src/plugins/fset/fset-theme.c @@ -0,0 +1,130 @@ +/* + * 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 . + */ + +/* fset contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "fset.h" +#include "fset-theme.h" + + +/* + * fset contribution to the "light" theme: option values tuned for a + * light-background terminal. Each row is { option_full_name, value }; + * the table is NULL-terminated. + */ + +const char *fset_theme_light[][2] = +{ + { "fset.color.allowed_values_selected", "default" }, + { "fset.color.color_name", "darkgray" }, + { "fset.color.color_name_selected", "darkgray" }, + { "fset.color.default_value_selected", "default" }, + { "fset.color.description_selected", "242" }, + { "fset.color.file_changed", "94" }, + { "fset.color.file_changed_selected", "94" }, + { "fset.color.file_selected", "default" }, + { "fset.color.help_default_value", "default" }, + { "fset.color.help_name", "default" }, + { "fset.color.index", "24" }, + { "fset.color.index_selected", "24" }, + { "fset.color.line_marked_bg1", "193" }, + { "fset.color.line_marked_bg2", "193" }, + { "fset.color.line_selected_bg1", "117" }, + { "fset.color.line_selected_bg2", "117" }, + { "fset.color.marked", "94" }, + { "fset.color.marked_selected", "94" }, + { "fset.color.max_selected", "default" }, + { "fset.color.min_selected", "default" }, + { "fset.color.name_changed", "red" }, + { "fset.color.name_changed_selected", "red" }, + { "fset.color.name_selected", "default" }, + { "fset.color.option_changed", "94" }, + { "fset.color.option_changed_selected", "94" }, + { "fset.color.option_selected", "default" }, + { "fset.color.parent_name_selected", "default" }, + { "fset.color.parent_value", "24" }, + { "fset.color.parent_value_selected", "24" }, + { "fset.color.quotes_changed_selected", "default" }, + { "fset.color.section_changed", "94" }, + { "fset.color.section_changed_selected", "94" }, + { "fset.color.section_selected", "default" }, + { "fset.color.string_values_selected", "default" }, + { "fset.color.title_count_options", "30" }, + { "fset.color.title_current_option", "30" }, + { "fset.color.title_filter", "18" }, + { "fset.color.title_marked_options", "94" }, + { "fset.color.title_sort", "darkgray" }, + { "fset.color.type", "58" }, + { "fset.color.type_selected", "58" }, + { "fset.color.unmarked_selected", "default" }, + { "fset.color.value", "20" }, + { "fset.color.value_changed", "red" }, + { "fset.color.value_changed_selected", "red" }, + { "fset.color.value_selected", "20" }, + { "fset.color.value_undef_selected", "magenta" }, + { NULL, NULL }, +}; + +/* + * Registers fset's contribution to one theme from a NULL-terminated + * table of {option, value} rows. + */ + +void +fset_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); +} + +/* + * Registers all built-in theme contributions from fset. + */ + +void +fset_theme_init (void) +{ + fset_theme_register ("light", fset_theme_light); +} diff --git a/src/plugins/fset/fset-theme.h b/src/plugins/fset/fset-theme.h new file mode 100644 index 000000000..623dd7380 --- /dev/null +++ b/src/plugins/fset/fset-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_FSET_THEME_H +#define WEECHAT_PLUGIN_FSET_THEME_H + +extern void fset_theme_init (void); + +#endif /* WEECHAT_PLUGIN_FSET_THEME_H */ diff --git a/src/plugins/fset/fset.c b/src/plugins/fset/fset.c index 1bd26e0d3..d18752657 100644 --- a/src/plugins/fset/fset.c +++ b/src/plugins/fset/fset.c @@ -35,6 +35,7 @@ #include "fset-info.h" #include "fset-mouse.h" #include "fset-option.h" +#include "fset-theme.h" WEECHAT_PLUGIN_NAME(FSET_PLUGIN_NAME); @@ -126,6 +127,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) fset_config_read (); + fset_theme_init (); + if (!fset_bar_item_init ()) return WEECHAT_RC_ERROR;