diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt index 71e01479f..fc64e2cda 100644 --- a/src/plugins/irc/CMakeLists.txt +++ b/src/plugins/irc/CMakeLists.txt @@ -48,6 +48,7 @@ add_library(irc MODULE irc-sasl.c irc-sasl.h irc-server.c irc-server.h irc-tag.c irc-tag.h + irc-theme.c irc-theme.h irc-typing.c irc-typing.h irc-upgrade.c irc-upgrade.h ) diff --git a/src/plugins/irc/irc-theme.c b/src/plugins/irc/irc-theme.c new file mode 100644 index 000000000..86d6218fe --- /dev/null +++ b/src/plugins/irc/irc-theme.c @@ -0,0 +1,93 @@ +/* + * 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 . + */ + +/* IRC plugin contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "irc.h" +#include "irc-theme.h" + + +/* + * IRC 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 *irc_theme_light[][2] = +{ + { "irc.color.input_nick", "cyan" }, + { "irc.color.item_lag_finished", "94" }, + { "irc.color.item_tls_version_deprecated", "202" }, + { "irc.color.list_buffer_line_selected", "default" }, + { "irc.color.message_chghost", "94" }, + { "irc.color.message_setname", "94" }, + { "irc.color.nick_prefixes", + "y:red;q:red;a:cyan;o:green;h:magenta;v:94;*:blue" }, + { "irc.color.topic_new", "28" }, + { "irc.color.topic_old", "darkgray" }, + { NULL, NULL }, +}; + +/* + * Registers IRC's contribution to one theme from a NULL-terminated + * table of {option, value} rows. + */ + +void +irc_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 IRC. + */ + +void +irc_theme_init (void) +{ + irc_theme_register ("light", irc_theme_light); +} diff --git a/src/plugins/irc/irc-theme.h b/src/plugins/irc/irc-theme.h new file mode 100644 index 000000000..3e9884171 --- /dev/null +++ b/src/plugins/irc/irc-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_IRC_THEME_H +#define WEECHAT_PLUGIN_IRC_THEME_H + +extern void irc_theme_init (void); + +#endif /* WEECHAT_PLUGIN_IRC_THEME_H */ diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index ea734b432..9f5c72473 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -47,6 +47,7 @@ #include "irc-redirect.h" #include "irc-server.h" #include "irc-tag.h" +#include "irc-theme.h" #include "irc-typing.h" #include "irc-upgrade.h" @@ -217,6 +218,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) irc_config_read (); + irc_theme_init (); + irc_list_init (); irc_raw_init ();