From 797d3c0db2e484d92beb0844003508a9b5f61087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 May 2026 18:08:50 +0200 Subject: [PATCH] logger: contribute "light" theme overrides Add logger-theme.{c,h} with the logger plugin contribution to the built-in "light" theme: 2 entries (logger.color.backlog_end=darkgray, logger.color.backlog_line=darkgray) tuned for a light-background terminal. Same 2D-array pattern as the other plugin contributions. Default option values are NOT changed. --- src/plugins/logger/CMakeLists.txt | 1 + src/plugins/logger/logger-theme.c | 70 +++++++++++++++++++++++++++++++ src/plugins/logger/logger-theme.h | 27 ++++++++++++ src/plugins/logger/logger.c | 3 ++ 4 files changed, 101 insertions(+) create mode 100644 src/plugins/logger/logger-theme.c create mode 100644 src/plugins/logger/logger-theme.h diff --git a/src/plugins/logger/CMakeLists.txt b/src/plugins/logger/CMakeLists.txt index a6886e0c6..1da01d100 100644 --- a/src/plugins/logger/CMakeLists.txt +++ b/src/plugins/logger/CMakeLists.txt @@ -27,6 +27,7 @@ add_library(logger MODULE logger-config.c logger-config.h logger-info.c logger-info.h logger-tail.c logger-tail.h + logger-theme.c logger-theme.h ) set_target_properties(logger PROPERTIES PREFIX "") diff --git a/src/plugins/logger/logger-theme.c b/src/plugins/logger/logger-theme.c new file mode 100644 index 000000000..6e9638915 --- /dev/null +++ b/src/plugins/logger/logger-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 . + */ + +/* logger contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "logger.h" +#include "logger-theme.h" + + +const char *logger_theme_light[][2] = +{ + { "logger.color.backlog_end", "darkgray" }, + { "logger.color.backlog_line", "darkgray" }, + { NULL, NULL }, +}; + +void +logger_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 +logger_theme_init (void) +{ + logger_theme_register ("light", logger_theme_light); +} diff --git a/src/plugins/logger/logger-theme.h b/src/plugins/logger/logger-theme.h new file mode 100644 index 000000000..3ffe25736 --- /dev/null +++ b/src/plugins/logger/logger-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_LOGGER_THEME_H +#define WEECHAT_PLUGIN_LOGGER_THEME_H + +extern void logger_theme_init (void); + +#endif /* WEECHAT_PLUGIN_LOGGER_THEME_H */ diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index f726b2291..1e6d370f2 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -36,6 +36,7 @@ #include "logger-command.h" #include "logger-config.h" #include "logger-info.h" +#include "logger-theme.h" WEECHAT_PLUGIN_NAME(LOGGER_PLUGIN_NAME); @@ -785,6 +786,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) logger_config_read (); + logger_theme_init (); + logger_command_init (); logger_buffer_start_all (1);