mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
config: add [colors-dark] and [colors-light], replacing [colors] and [colors2]
The main reason for having two color sections is to be able to switch between dark and light. Thus, it's better if the section names reflect this, rather than the more generic 'colors' and 'colors2' (which was the dark one and which was the light one, now again?) When the second color section was added, we kept the original name, colors, to make sure we didn't break existing configurations, and third-party themes. However, in the long run, it's probably better to be specific in the section naming, to avoid confusion. So, add 'colors-dark', and 'colors-light'. Keep 'colors' and 'colors2' as aliases for now, but mark them as deprecated. They WILL be removed in a future release. Also rename the option values for initial-color-theme, from 1/2, to dark/light. Keep the old ones for now, marked as deprecated. Update all bundled themes to use the new names. In the light-only themes (i.e. themes that define a single, light, theme), use colors-light, and set initial-color-theme=light. Possible improvements: disable color switching if only one color section has been explicitly configured (todo: figure out how to handle the default color theme values...)
This commit is contained in:
parent
4e96780eef
commit
cf2b390f6e
103 changed files with 542 additions and 298 deletions
38
terminal.c
38
terminal.c
|
|
@ -1271,8 +1271,10 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
|
||||
const struct color_theme *theme = NULL;
|
||||
switch (conf->initial_color_theme) {
|
||||
case COLOR_THEME1: theme = &conf->colors; break;
|
||||
case COLOR_THEME2: theme = &conf->colors2; break;
|
||||
case COLOR_THEME_DARK: theme = &conf->colors_dark; break;
|
||||
case COLOR_THEME_LIGHT: theme = &conf->colors_light; break;
|
||||
case COLOR_THEME_1: BUG("COLOR_THEME_1 should not be used"); break;
|
||||
case COLOR_THEME_2: BUG("COLOR_THEME_2 should not be used"); break;
|
||||
}
|
||||
|
||||
/* Initialize configure-based terminal attributes */
|
||||
|
|
@ -2177,8 +2179,10 @@ term_reset(struct terminal *term, bool hard)
|
|||
const struct color_theme *theme = NULL;
|
||||
|
||||
switch (term->conf->initial_color_theme) {
|
||||
case COLOR_THEME1: theme = &term->conf->colors; break;
|
||||
case COLOR_THEME2: theme = &term->conf->colors2; break;
|
||||
case COLOR_THEME_DARK: theme = &term->conf->colors_dark; break;
|
||||
case COLOR_THEME_LIGHT: theme = &term->conf->colors_light; break;
|
||||
case COLOR_THEME_1: BUG("COLOR_THEME_1 should not be used"); break;
|
||||
case COLOR_THEME_2: BUG("COLOR_THEME_2 should not be used"); break;
|
||||
}
|
||||
|
||||
term->flash.active = false;
|
||||
|
|
@ -4742,13 +4746,13 @@ term_send_size_notification(struct terminal *term)
|
|||
}
|
||||
|
||||
void
|
||||
term_theme_switch_to_1(struct terminal *term)
|
||||
term_theme_switch_to_dark(struct terminal *term)
|
||||
{
|
||||
if (term->colors.active_theme == COLOR_THEME1)
|
||||
if (term->colors.active_theme == COLOR_THEME_DARK)
|
||||
return;
|
||||
|
||||
term_theme_apply(term, &term->conf->colors);
|
||||
term->colors.active_theme = COLOR_THEME1;
|
||||
term_theme_apply(term, &term->conf->colors_dark);
|
||||
term->colors.active_theme = COLOR_THEME_DARK;
|
||||
|
||||
wayl_win_alpha_changed(term->window);
|
||||
term_font_subpixel_changed(term);
|
||||
|
|
@ -4762,13 +4766,13 @@ term_theme_switch_to_1(struct terminal *term)
|
|||
}
|
||||
|
||||
void
|
||||
term_theme_switch_to_2(struct terminal *term)
|
||||
term_theme_switch_to_light(struct terminal *term)
|
||||
{
|
||||
if (term->colors.active_theme == COLOR_THEME2)
|
||||
if (term->colors.active_theme == COLOR_THEME_LIGHT)
|
||||
return;
|
||||
|
||||
term_theme_apply(term, &term->conf->colors2);
|
||||
term->colors.active_theme = COLOR_THEME2;
|
||||
term_theme_apply(term, &term->conf->colors_light);
|
||||
term->colors.active_theme = COLOR_THEME_LIGHT;
|
||||
|
||||
wayl_win_alpha_changed(term->window);
|
||||
term_font_subpixel_changed(term);
|
||||
|
|
@ -4784,15 +4788,15 @@ term_theme_switch_to_2(struct terminal *term)
|
|||
void
|
||||
term_theme_toggle(struct terminal *term)
|
||||
{
|
||||
if (term->colors.active_theme == COLOR_THEME1) {
|
||||
term_theme_apply(term, &term->conf->colors2);
|
||||
term->colors.active_theme = COLOR_THEME2;
|
||||
if (term->colors.active_theme == COLOR_THEME_DARK) {
|
||||
term_theme_apply(term, &term->conf->colors_light);
|
||||
term->colors.active_theme = COLOR_THEME_LIGHT;
|
||||
|
||||
if (term->report_theme_changes)
|
||||
term_to_slave(term, "\033[?997;2n", 9);
|
||||
} else {
|
||||
term_theme_apply(term, &term->conf->colors);
|
||||
term->colors.active_theme = COLOR_THEME1;
|
||||
term_theme_apply(term, &term->conf->colors_dark);
|
||||
term->colors.active_theme = COLOR_THEME_DARK;
|
||||
|
||||
if (term->report_theme_changes)
|
||||
term_to_slave(term, "\033[?997;1n", 9);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue