1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

irc: contribute "light" theme overrides

Add irc-theme.{c,h} with the IRC plugin contribution to the built-in
"light" theme: 9 overrides on irc.color.* options tuned for a
light-background terminal (input_nick, item_lag_finished,
item_tls_version_deprecated, list_buffer_line_selected,
message_chghost, message_setname, nick_prefixes, topic_new, topic_old).

The registration is a small wrapper around weechat_theme_register that
builds a hashtable from a static (option, value) table and frees it
after the call. irc_theme_init() is called from weechat_plugin_init
after irc_config_init/read so the option names are already created
when the theme registry references them.

Default option values are NOT changed.
This commit is contained in:
Sébastien Helleu
2026-05-27 15:31:40 +02:00
parent ff4d9d638c
commit 2a3082636c
4 changed files with 124 additions and 0 deletions
+1
View File
@@ -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
)
+93
View File
@@ -0,0 +1,93 @@
/*
* SPDX-FileCopyrightText: 2026 Sébastien Helleu <flashcode@flashtux.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/* IRC plugin contribution to built-in themes. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stddef.h>
#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);
}
+27
View File
@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2026 Sébastien Helleu <flashcode@flashtux.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef WEECHAT_PLUGIN_IRC_THEME_H
#define WEECHAT_PLUGIN_IRC_THEME_H
extern void irc_theme_init (void);
#endif /* WEECHAT_PLUGIN_IRC_THEME_H */
+3
View File
@@ -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 ();