diff --git a/src/plugins/script/CMakeLists.txt b/src/plugins/script/CMakeLists.txt index baee1846d..088937aad 100644 --- a/src/plugins/script/CMakeLists.txt +++ b/src/plugins/script/CMakeLists.txt @@ -29,6 +29,7 @@ add_library(script MODULE script-info.c script-info.h script-mouse.c script-mouse.h script-repo.c script-repo.h + script-theme.c script-theme.h ) set_target_properties(script PROPERTIES PREFIX "") diff --git a/src/plugins/script/script-theme.c b/src/plugins/script/script-theme.c new file mode 100644 index 000000000..dc9d5753d --- /dev/null +++ b/src/plugins/script/script-theme.c @@ -0,0 +1,92 @@ +/* + * 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 . + */ + +/* script contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "script.h" +#include "script-theme.h" + + +const char *script_theme_light[][2] = +{ + { "script.color.status_autoloaded", "default" }, + { "script.color.status_held", "202" }, + { "script.color.status_installed", "21" }, + { "script.color.status_obsolete", "magenta" }, + { "script.color.status_popular", "94" }, + { "script.color.status_running", "23" }, + { "script.color.status_unknown", "red" }, + { "script.color.text_bg_selected", "117" }, + { "script.color.text_date", "darkgray" }, + { "script.color.text_date_selected", "darkgray" }, + { "script.color.text_delimiters", "251" }, + { "script.color.text_description", "default" }, + { "script.color.text_description_selected", "default" }, + { "script.color.text_extension", "lightblue" }, + { "script.color.text_extension_selected", "lightblue" }, + { "script.color.text_name", "18" }, + { "script.color.text_name_selected", "18" }, + { "script.color.text_selected", "default" }, + { "script.color.text_tags", "94" }, + { "script.color.text_tags_selected", "94" }, + { "script.color.text_version", "58" }, + { "script.color.text_version_loaded", "default" }, + { "script.color.text_version_loaded_selected", "default" }, + { "script.color.text_version_selected", "58" }, + { NULL, NULL }, +}; + +void +script_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 +script_theme_init (void) +{ + script_theme_register ("light", script_theme_light); +} diff --git a/src/plugins/script/script-theme.h b/src/plugins/script/script-theme.h new file mode 100644 index 000000000..59563a0f8 --- /dev/null +++ b/src/plugins/script/script-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_SCRIPT_THEME_H +#define WEECHAT_PLUGIN_SCRIPT_THEME_H + +extern void script_theme_init (void); + +#endif /* WEECHAT_PLUGIN_SCRIPT_THEME_H */ diff --git a/src/plugins/script/script.c b/src/plugins/script/script.c index eeed523b1..d94eb31aa 100644 --- a/src/plugins/script/script.c +++ b/src/plugins/script/script.c @@ -37,6 +37,7 @@ #include "script-info.h" #include "script-mouse.h" #include "script-repo.h" +#include "script-theme.h" WEECHAT_PLUGIN_NAME(SCRIPT_PLUGIN_NAME); @@ -352,6 +353,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) script_config_read (); + script_theme_init (); + weechat_mkdir_home ("${weechat_cache_dir}/" SCRIPT_PLUGIN_NAME, 0755); script_command_init ();