mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 09:43:13 +02:00
3bdb31bbf6
Add a small INI-style parser for *.theme files and wire it into the
/theme command so user themes living in directory "themes" inside the
WeeChat configuration directory can be applied (and inspected) without
ever being cached.
Parser (theme_file_parse in core-theme.c) accepts two sections:
[info]
name = "..." \ shown by /theme info; ignored for apply
description = "..." |
date = "..." |
weechat = "..." /
(unknown keys are ignored with a warning)
[options]
full.option.name = "value"
Surrounding single or double quotes around a value are stripped (same
rule used by the regular config file reader). The parsed result is a
heap-allocated t_theme; the caller frees with theme_free.
Resolution rule in theme_apply: if the path
"${weechat_config_dir}/themes/<name>.theme" is readable it is parsed
and used (file shadows any built-in of the same name); otherwise the
built-in registry is consulted. The transient t_theme is freed before
the final refresh, so user themes have no steady-state memory
footprint regardless of how many .theme files have accumulated.
/theme list now also scans the themes directory and appends user
files to the listing (each marked "(file)"). backup-*.theme are
hidden by default; pass "-backups" to include them.
/theme info <name> works for both sources: file path is shown when the
information comes from disk; "built-in (in-memory)" otherwise.
57 lines
2.2 KiB
C
57 lines
2.2 KiB
C
/*
|
|
* 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_THEME_H
|
|
#define WEECHAT_THEME_H
|
|
|
|
struct t_hashtable;
|
|
struct t_arraylist;
|
|
|
|
struct t_theme
|
|
{
|
|
char *name; /* "dark", "solarized", ... */
|
|
char *description; /* free-form text */
|
|
char *date; /* "YYYY-MM-DD HH:MM:SS" */
|
|
char *weechat_version; /* version at registration time */
|
|
struct t_hashtable *overrides; /* full_option_name -> value */
|
|
struct t_theme *prev_theme; /* link to previous theme */
|
|
struct t_theme *next_theme; /* link to next theme */
|
|
};
|
|
|
|
extern struct t_theme *themes;
|
|
extern struct t_theme *last_theme;
|
|
extern int theme_applying; /* gate for config_change_color */
|
|
|
|
extern struct t_theme *theme_search (const char *name);
|
|
extern struct t_theme *theme_register (const char *name,
|
|
struct t_hashtable *overrides);
|
|
extern struct t_arraylist *theme_list (void);
|
|
extern int theme_apply (const char *name);
|
|
extern char *theme_make_backup (void);
|
|
extern char *theme_user_file_path (const char *name);
|
|
extern struct t_theme *theme_file_parse (const char *path);
|
|
extern void theme_free (struct t_theme *theme);
|
|
|
|
extern void theme_init (void);
|
|
extern void theme_end (void);
|
|
|
|
#endif /* WEECHAT_THEME_H */
|