mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
core: register built-in "light" theme
Add a small core-theme-builtin.c module containing the core
contribution to the "light" theme: 33 overrides for
"weechat.bar.{status,title}.color_*" and "weechat.color.*" tuned for
light-background terminals.
theme_builtin_init() builds a hashtable from the static entry table and
calls theme_register("light", overrides), then frees the temporary
hashtable. It is called once from weechat_init right after theme_init.
Calling it twice is a no-op (the registry merges identical keys).
Default option values are NOT changed. Existing configs render exactly
as before; users opt in with "/theme apply light".
Add TEST(CoreTheme, BuiltinInit) covering:
- the "light" theme is absent before theme_builtin_init();
- it is present after, with >= 30 overrides;
- three spot-checked values match the source table;
- calling theme_builtin_init() a second time does not change the
override count.
Plugins contribute their own "light" overrides via weechat_theme_register
in subsequent commits.
This commit is contained in:
@@ -749,3 +749,45 @@ TEST(CoreTheme, End)
|
||||
POINTERS_EQUAL(NULL, themes);
|
||||
POINTERS_EQUAL(NULL, last_theme);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test functions:
|
||||
* theme_builtin_init
|
||||
* theme_builtin_register_entries
|
||||
*/
|
||||
|
||||
TEST(CoreTheme, BuiltinInit)
|
||||
{
|
||||
struct t_theme *theme;
|
||||
|
||||
/* registry is empty after setup() */
|
||||
POINTERS_EQUAL(NULL, theme_search ("light"));
|
||||
|
||||
theme_builtin_init ();
|
||||
|
||||
/* the "light" theme is registered */
|
||||
theme = theme_search ("light");
|
||||
CHECK(theme != NULL);
|
||||
|
||||
/* sanity check: many core color overrides (>= 30) */
|
||||
CHECK(theme->overrides->items_count >= 30);
|
||||
|
||||
/* spot-check a few known entries from the core light table */
|
||||
STRCMP_EQUAL("cyan",
|
||||
(const char *)hashtable_get (theme->overrides,
|
||||
"weechat.color.chat_nick"));
|
||||
STRCMP_EQUAL("251",
|
||||
(const char *)hashtable_get (theme->overrides,
|
||||
"weechat.color.separator"));
|
||||
STRCMP_EQUAL("254",
|
||||
(const char *)hashtable_get (theme->overrides,
|
||||
"weechat.bar.status.color_bg"));
|
||||
|
||||
/* idempotency: a second call merges (no duplicate themes, count
|
||||
stays the same because the same keys are re-inserted) */
|
||||
int count_before = theme->overrides->items_count;
|
||||
theme_builtin_init ();
|
||||
theme = theme_search ("light");
|
||||
CHECK(theme != NULL);
|
||||
LONGS_EQUAL(count_before, theme->overrides->items_count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user