From 7051d7e08b686a10eada8db35bc1a6e2ddc645ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 May 2026 18:11:53 +0200 Subject: [PATCH] spell: contribute "light" theme overrides Add spell-theme.{c,h} with the spell plugin contribution to the built-in "light" theme: 1 entry (spell.color.misspelled=red) tuned for a light-background terminal. Same 2D-array pattern as the other plugin contributions. Default option values are NOT changed. --- src/plugins/spell/CMakeLists.txt | 1 + src/plugins/spell/spell-theme.c | 69 ++++++++++++++++++++++++++++++++ src/plugins/spell/spell-theme.h | 27 +++++++++++++ src/plugins/spell/spell.c | 3 ++ 4 files changed, 100 insertions(+) create mode 100644 src/plugins/spell/spell-theme.c create mode 100644 src/plugins/spell/spell-theme.h diff --git a/src/plugins/spell/CMakeLists.txt b/src/plugins/spell/CMakeLists.txt index 219762c28..ba833fb68 100644 --- a/src/plugins/spell/CMakeLists.txt +++ b/src/plugins/spell/CMakeLists.txt @@ -34,6 +34,7 @@ add_library(spell MODULE spell-config.c spell-config.h spell-info.c spell-info.h spell-speller.c spell-speller.h + spell-theme.c spell-theme.h ) set_target_properties(spell PROPERTIES PREFIX "") diff --git a/src/plugins/spell/spell-theme.c b/src/plugins/spell/spell-theme.c new file mode 100644 index 000000000..03dfcebda --- /dev/null +++ b/src/plugins/spell/spell-theme.c @@ -0,0 +1,69 @@ +/* + * 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 . + */ + +/* spell contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "spell.h" +#include "spell-theme.h" + + +const char *spell_theme_light[][2] = +{ + { "spell.color.misspelled", "red" }, + { NULL, NULL }, +}; + +void +spell_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 +spell_theme_init (void) +{ + spell_theme_register ("light", spell_theme_light); +} diff --git a/src/plugins/spell/spell-theme.h b/src/plugins/spell/spell-theme.h new file mode 100644 index 000000000..ebb776922 --- /dev/null +++ b/src/plugins/spell/spell-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_SPELL_THEME_H +#define WEECHAT_PLUGIN_SPELL_THEME_H + +extern void spell_theme_init (void); + +#endif /* WEECHAT_PLUGIN_SPELL_THEME_H */ diff --git a/src/plugins/spell/spell.c b/src/plugins/spell/spell.c index 533041007..08e20d67e 100644 --- a/src/plugins/spell/spell.c +++ b/src/plugins/spell/spell.c @@ -43,6 +43,7 @@ #include "spell-config.h" #include "spell-info.h" #include "spell-speller.h" +#include "spell-theme.h" WEECHAT_PLUGIN_NAME(SPELL_PLUGIN_NAME); @@ -1196,6 +1197,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) spell_config_read (); + spell_theme_init (); + spell_command_init (); spell_completion_init ();