templates: removed the duality for terminal colors, all terminal use proper terminal colors. the engine synthesize those when in wallpaper mode

This commit is contained in:
Lemmy
2026-05-03 10:11:10 -04:00
parent e95bcc97ea
commit 0da3a94aef
15 changed files with 377 additions and 230 deletions
+30 -30
View File
@@ -1,10 +1,10 @@
[colors.primary]
background = '{{colors.background.default.hex}}'
foreground = '{{colors.on_surface.default.hex}}'
background = '{{colors.terminal_background.default.hex}}'
foreground = '{{colors.terminal_foreground.default.hex}}'
[colors.cursor]
text = '{{colors.on_surface.default.hex}}'
cursor = '{{colors.on_surface_variant.default.hex}}'
text = '{{colors.terminal_cursor_text.default.hex}}'
cursor = '{{colors.terminal_cursor.default.hex}}'
[colors.vi_mode_cursor]
text = '{{colors.background.default.hex}}'
@@ -31,38 +31,38 @@ foreground = '{{colors.surface_variant.default.hex}}'
background = '{{colors.secondary.default.hex}}'
[colors.selection]
text = '{{colors.background.default.hex}}'
background = '{{colors.primary.default.hex}}'
text = '{{colors.terminal_selection_fg.default.hex}}'
background = '{{colors.terminal_selection_bg.default.hex}}'
[colors.normal]
black = '{{colors.surface.default.hex}}'
red = '{{colors.error.default.hex}}'
green = '{{colors.primary.default.hex}}'
yellow = '{{colors.secondary.default.hex}}'
blue = '{{colors.tertiary.default.hex}}'
magenta = '{{colors.primary_fixed_dim.default.hex}}'
cyan = '{{colors.secondary_fixed_dim.default.hex}}'
white = '{{colors.on_surface.default.hex}}'
black = '{{colors.terminal_normal_black.default.hex}}'
red = '{{colors.terminal_normal_red.default.hex}}'
green = '{{colors.terminal_normal_green.default.hex}}'
yellow = '{{colors.terminal_normal_yellow.default.hex}}'
blue = '{{colors.terminal_normal_blue.default.hex}}'
magenta = '{{colors.terminal_normal_magenta.default.hex}}'
cyan = '{{colors.terminal_normal_cyan.default.hex}}'
white = '{{colors.terminal_normal_white.default.hex}}'
[colors.bright]
black = '{{colors.outline.default.hex}}'
red = '{{colors.error.default.hex}}'
green = '{{colors.primary.default.hex}}'
yellow = '{{colors.secondary.default.hex}}'
blue = '{{colors.tertiary.default.hex}}'
magenta = '{{colors.primary_fixed_dim.default.hex}}'
cyan = '{{colors.secondary_fixed_dim.default.hex}}'
white = '{{colors.on_surface.default.hex}}'
black = '{{colors.terminal_bright_black.default.hex}}'
red = '{{colors.terminal_bright_red.default.hex}}'
green = '{{colors.terminal_bright_green.default.hex}}'
yellow = '{{colors.terminal_bright_yellow.default.hex}}'
blue = '{{colors.terminal_bright_blue.default.hex}}'
magenta = '{{colors.terminal_bright_magenta.default.hex}}'
cyan = '{{colors.terminal_bright_cyan.default.hex}}'
white = '{{colors.terminal_bright_white.default.hex}}'
[colors.dim]
black = '{{colors.outline.default.hex}}'
red = '{{colors.error.default.hex}}'
green = '{{colors.primary.default.hex}}'
yellow = '{{colors.secondary.default.hex}}'
blue = '{{colors.tertiary.default.hex}}'
magenta = '{{colors.primary_fixed_dim.default.hex}}'
cyan = '{{colors.secondary_fixed_dim.default.hex}}'
white = '{{colors.on_surface.default.hex}}'
black = '{{colors.terminal_normal_black.default.hex}}'
red = '{{colors.terminal_normal_red.default.hex}}'
green = '{{colors.terminal_normal_green.default.hex}}'
yellow = '{{colors.terminal_normal_yellow.default.hex}}'
blue = '{{colors.terminal_normal_blue.default.hex}}'
magenta = '{{colors.terminal_normal_magenta.default.hex}}'
cyan = '{{colors.terminal_normal_cyan.default.hex}}'
white = '{{colors.terminal_normal_white.default.hex}}'
+17 -18
View File
@@ -73,23 +73,23 @@
(inverse-on-surface "{{colors.on_surface.default.hex}}")
(inverse-primary "{{colors.primary.default.hex}}")
(inverse-surface "{{colors.surface.default.hex}}")
;; Map terminal colors (term0-term15) to available colors
(term0 "{{colors.surface.default.hex}}")
(term1 "{{colors.error.default.hex}}")
(term2 "{{colors.tertiary.default.hex}}")
(term3 "{{colors.secondary.default.hex}}")
(term4 "{{colors.primary.default.hex}}")
(term5 "{{colors.tertiary_container.default.hex}}")
(term6 "{{colors.secondary_container.default.hex}}")
(term7 "{{colors.on_surface.default.hex}}")
(term8 "{{colors.outline.default.hex}}")
(term9 "{{colors.error.default.hex}}")
(term10 "{{colors.tertiary.default.hex}}")
(term11 "{{colors.secondary.default.hex}}")
(term12 "{{colors.primary.default.hex}}")
(term13 "{{colors.tertiary_container.default.hex}}")
(term14 "{{colors.secondary_container.default.hex}}")
(term15 "{{colors.on_surface.default.hex}}"))
;; ANSI terminal colors
(term0 "{{colors.terminal_normal_black.default.hex}}")
(term1 "{{colors.terminal_normal_red.default.hex}}")
(term2 "{{colors.terminal_normal_green.default.hex}}")
(term3 "{{colors.terminal_normal_yellow.default.hex}}")
(term4 "{{colors.terminal_normal_blue.default.hex}}")
(term5 "{{colors.terminal_normal_magenta.default.hex}}")
(term6 "{{colors.terminal_normal_cyan.default.hex}}")
(term7 "{{colors.terminal_normal_white.default.hex}}")
(term8 "{{colors.terminal_bright_black.default.hex}}")
(term9 "{{colors.terminal_bright_red.default.hex}}")
(term10 "{{colors.terminal_bright_green.default.hex}}")
(term11 "{{colors.terminal_bright_yellow.default.hex}}")
(term12 "{{colors.terminal_bright_blue.default.hex}}")
(term13 "{{colors.terminal_bright_magenta.default.hex}}")
(term14 "{{colors.terminal_bright_cyan.default.hex}}")
(term15 "{{colors.terminal_bright_white.default.hex}}"))
(custom-theme-set-faces
'noctalia
@@ -358,4 +358,3 @@
(provide-theme 'noctalia)
;;; noctalia-theme.el ends here
+21 -23
View File
@@ -1,24 +1,22 @@
[colors-dark]
background = {{colors.surface.default.hex_stripped}}
foreground = {{colors.on_surface.default.hex_stripped}}
selection-background = {{colors.tertiary.default.hex_stripped}}
selection-foreground = {{colors.on_tertiary.default.hex_stripped}}
regular0 = {{colors.surface_variant.default.hex_stripped}}
regular1 = {{colors.error.default.hex_stripped}}
regular2 = {{colors.primary.default.hex_stripped}}
regular3 = {{colors.secondary.default.hex_stripped}}
regular4 = {{colors.tertiary.default.hex_stripped}}
regular5 = {{colors.primary_fixed_dim.default.hex_stripped}}
regular6 = {{colors.secondary_fixed_dim.default.hex_stripped}}
regular7 = {{colors.on_surface.default.hex_stripped}}
bright0 = {{colors.on_surface_variant.default.hex_stripped}}
bright1 = {{colors.error.default.hex_stripped}}
bright2 = {{colors.primary.default.hex_stripped}}
bright3 = {{colors.secondary.default.hex_stripped}}
bright4 = {{colors.tertiary.default.hex_stripped}}
bright5 = {{colors.primary_fixed_dim.default.hex_stripped}}
bright6 = {{colors.secondary_fixed_dim.default.hex_stripped}}
bright7 = {{colors.on_surface.default.hex_stripped}}
foreground={{colors.terminal_foreground.default.hex_stripped}}
background={{colors.terminal_background.default.hex_stripped}}
regular0={{colors.terminal_normal_black.default.hex_stripped}}
regular1={{colors.terminal_normal_red.default.hex_stripped}}
regular2={{colors.terminal_normal_green.default.hex_stripped}}
regular3={{colors.terminal_normal_yellow.default.hex_stripped}}
regular4={{colors.terminal_normal_blue.default.hex_stripped}}
regular5={{colors.terminal_normal_magenta.default.hex_stripped}}
regular6={{colors.terminal_normal_cyan.default.hex_stripped}}
regular7={{colors.terminal_normal_white.default.hex_stripped}}
bright0={{colors.terminal_bright_black.default.hex_stripped}}
bright1={{colors.terminal_bright_red.default.hex_stripped}}
bright2={{colors.terminal_bright_green.default.hex_stripped}}
bright3={{colors.terminal_bright_yellow.default.hex_stripped}}
bright4={{colors.terminal_bright_blue.default.hex_stripped}}
bright5={{colors.terminal_bright_magenta.default.hex_stripped}}
bright6={{colors.terminal_bright_cyan.default.hex_stripped}}
bright7={{colors.terminal_bright_white.default.hex_stripped}}
selection-foreground={{colors.terminal_selection_fg.default.hex_stripped}}
selection-background={{colors.terminal_selection_bg.default.hex_stripped}}
cursor={{colors.terminal_cursor_text.default.hex_stripped}} {{colors.terminal_cursor.default.hex_stripped}}
+22 -22
View File
@@ -1,22 +1,22 @@
palette = 0= {{colors.surface_variant.default.hex}}
palette = 1= {{colors.error.default.hex}}
palette = 2= {{colors.primary.default.hex}}
palette = 3= {{colors.secondary.default.hex}}
palette = 4= {{colors.tertiary.default.hex}}
palette = 5= {{colors.primary_fixed_dim.default.hex}}
palette = 6= {{colors.secondary_fixed_dim.default.hex}}
palette = 7= {{colors.on_surface.default.hex}}
palette = 8= {{colors.on_surface_variant.default.hex}}
palette = 9= {{colors.error.default.hex}}
palette = 10= {{colors.primary.default.hex}}
palette = 11= {{colors.secondary.default.hex}}
palette = 12= {{colors.tertiary.default.hex}}
palette = 13= {{colors.primary_fixed_dim.default.hex}}
palette = 14= {{colors.secondary_fixed_dim.default.hex}}
palette = 15= {{colors.on_surface.default.hex}}
background = {{colors.surface.default.hex}}
foreground = {{colors.on_surface.default.hex}}
cursor-color = {{colors.on_surface.default.hex}}
cursor-text = {{colors.surface.default.hex}}
selection-background = {{colors.tertiary.default.hex}}
selection-foreground = {{colors.on_tertiary.default.hex}}
palette = 0={{colors.terminal_normal_black.default.hex}}
palette = 1={{colors.terminal_normal_red.default.hex}}
palette = 2={{colors.terminal_normal_green.default.hex}}
palette = 3={{colors.terminal_normal_yellow.default.hex}}
palette = 4={{colors.terminal_normal_blue.default.hex}}
palette = 5={{colors.terminal_normal_magenta.default.hex}}
palette = 6={{colors.terminal_normal_cyan.default.hex}}
palette = 7={{colors.terminal_normal_white.default.hex}}
palette = 8={{colors.terminal_bright_black.default.hex}}
palette = 9={{colors.terminal_bright_red.default.hex}}
palette = 10={{colors.terminal_bright_green.default.hex}}
palette = 11={{colors.terminal_bright_yellow.default.hex}}
palette = 12={{colors.terminal_bright_blue.default.hex}}
palette = 13={{colors.terminal_bright_magenta.default.hex}}
palette = 14={{colors.terminal_bright_cyan.default.hex}}
palette = 15={{colors.terminal_bright_white.default.hex}}
background = {{colors.terminal_background.default.hex}}
foreground = {{colors.terminal_foreground.default.hex}}
cursor-color = {{colors.terminal_cursor.default.hex}}
cursor-text = {{colors.terminal_cursor_text.default.hex}}
selection-background = {{colors.terminal_selection_bg.default.hex}}
selection-foreground = {{colors.terminal_selection_fg.default.hex}}
+22 -22
View File
@@ -1,26 +1,26 @@
color0 {{colors.surface.default.hex}}
color1 {{colors.error.default.hex}}
color2 {{colors.primary.default.hex}}
color3 {{colors.secondary.default.hex}}
color4 {{colors.tertiary.default.hex}}
color5 {{colors.primary_fixed_dim.default.hex}}
color6 {{colors.secondary_fixed_dim.default.hex}}
color7 {{colors.on_surface.default.hex}}
color8 {{colors.outline.default.hex}}
color9 {{colors.error.default.hex}}
color10 {{colors.primary.default.hex}}
color11 {{colors.secondary.default.hex}}
color12 {{colors.tertiary.default.hex}}
color13 {{colors.primary_fixed_dim.default.hex}}
color14 {{colors.secondary_fixed_dim.default.hex}}
color15 {{colors.on_surface.default.hex}}
color0 {{colors.terminal_normal_black.default.hex}}
color1 {{colors.terminal_normal_red.default.hex}}
color2 {{colors.terminal_normal_green.default.hex}}
color3 {{colors.terminal_normal_yellow.default.hex}}
color4 {{colors.terminal_normal_blue.default.hex}}
color5 {{colors.terminal_normal_magenta.default.hex}}
color6 {{colors.terminal_normal_cyan.default.hex}}
color7 {{colors.terminal_normal_white.default.hex}}
color8 {{colors.terminal_bright_black.default.hex}}
color9 {{colors.terminal_bright_red.default.hex}}
color10 {{colors.terminal_bright_green.default.hex}}
color11 {{colors.terminal_bright_yellow.default.hex}}
color12 {{colors.terminal_bright_blue.default.hex}}
color13 {{colors.terminal_bright_magenta.default.hex}}
color14 {{colors.terminal_bright_cyan.default.hex}}
color15 {{colors.terminal_bright_white.default.hex}}
cursor {{colors.on_surface.default.hex}}
cursor_text_color {{colors.surface.default.hex}}
background {{colors.surface.default.hex}}
foreground {{colors.on_surface.default.hex}}
selection_foreground {{colors.on_surface_variant.default.hex}}
selection_background {{colors.surface_variant.default.hex}}
cursor {{colors.terminal_cursor.default.hex}}
cursor_text_color {{colors.terminal_cursor_text.default.hex}}
background {{colors.terminal_background.default.hex}}
foreground {{colors.terminal_foreground.default.hex}}
selection_foreground {{colors.terminal_selection_fg.default.hex}}
selection_background {{colors.terminal_selection_bg.default.hex}}
active_border_color {{colors.primary.default.hex}}
inactive_border_color {{colors.surface_variant.default.hex}}
url_color {{colors.primary.default.hex}}
+31 -31
View File
@@ -1,41 +1,41 @@
# Noctalia Starship Palette (wallpaper-based)
# Noctalia Starship Palette
# Generated by Noctalia - do not edit manually
[palettes.noctalia]
# Standard colors
blue = "{{colors.primary.default.hex}}"
red = "{{colors.error.default.hex}}"
green = "{{colors.secondary.default.hex}}"
yellow = "{{colors.tertiary.default.hex}}"
cyan = "{{colors.secondary_fixed_dim.default.hex}}"
magenta = "{{colors.primary_fixed_dim.default.hex}}"
white = "{{colors.on_surface.default.hex}}"
black = "{{colors.surface.default.hex}}"
blue = "{{colors.terminal_normal_blue.default.hex}}"
red = "{{colors.terminal_normal_red.default.hex}}"
green = "{{colors.terminal_normal_green.default.hex}}"
yellow = "{{colors.terminal_normal_yellow.default.hex}}"
cyan = "{{colors.terminal_normal_cyan.default.hex}}"
magenta = "{{colors.terminal_normal_magenta.default.hex}}"
white = "{{colors.terminal_normal_white.default.hex}}"
black = "{{colors.terminal_normal_black.default.hex}}"
# Extended palette (Catppuccin-compatible names)
rosewater = "{{colors.tertiary.default.hex}}"
flamingo = "{{colors.tertiary_fixed_dim.default.hex}}"
pink = "{{colors.primary_fixed_dim.default.hex}}"
mauve = "{{colors.inverse_primary.default.hex}}"
maroon = "{{colors.error.default.hex}}"
peach = "{{colors.tertiary_fixed_dim.default.hex}}"
teal = "{{colors.secondary.default.hex}}"
sky = "{{colors.secondary_fixed_dim.default.hex}}"
sapphire = "{{colors.secondary_fixed_dim.default.hex}}"
lavender = "{{colors.inverse_primary.default.hex}}"
rosewater = "{{colors.terminal_bright_yellow.default.hex}}"
flamingo = "{{colors.terminal_bright_red.default.hex}}"
pink = "{{colors.terminal_bright_magenta.default.hex}}"
mauve = "{{colors.terminal_normal_magenta.default.hex}}"
maroon = "{{colors.terminal_bright_red.default.hex}}"
peach = "{{colors.terminal_bright_yellow.default.hex}}"
teal = "{{colors.terminal_normal_cyan.default.hex}}"
sky = "{{colors.terminal_bright_cyan.default.hex}}"
sapphire = "{{colors.terminal_bright_blue.default.hex}}"
lavender = "{{colors.terminal_bright_magenta.default.hex}}"
# Text shades
text = "{{colors.on_surface.default.hex}}"
subtext1 = "{{colors.on_surface_variant.default.hex}}"
subtext0 = "{{colors.outline.default.hex}}"
text = "{{colors.terminal_foreground.default.hex}}"
subtext1 = "{{colors.terminal_normal_white.default.hex}}"
subtext0 = "{{colors.terminal_bright_black.default.hex}}"
# Surface shades
overlay2 = "{{colors.outline.default.hex}}"
overlay1 = "{{colors.on_surface_variant.default.hex}}"
overlay0 = "{{colors.surface_variant.default.hex}}"
surface2 = "{{colors.surface_variant.default.hex}}"
surface1 = "{{colors.surface.default.hex}}"
surface0 = "{{colors.background.default.hex}}"
base = "{{colors.background.default.hex}}"
mantle = "{{colors.surface.default.hex}}"
crust = "{{colors.on_tertiary.default.hex}}"
overlay2 = "{{colors.terminal_bright_black.default.hex}}"
overlay1 = "{{colors.terminal_bright_black.default.hex}}"
overlay0 = "{{colors.terminal_normal_black.default.hex}}"
surface2 = "{{colors.terminal_normal_black.default.hex}}"
surface1 = "{{colors.terminal_normal_black.default.hex}}"
surface0 = "{{colors.terminal_background.default.hex}}"
base = "{{colors.terminal_background.default.hex}}"
mantle = "{{colors.terminal_background.default.hex}}"
crust = "{{colors.terminal_background.default.hex}}"
+76 -23
View File
@@ -1,31 +1,84 @@
[colors]
ansi = [
"{{colors.surface.default.hex}}",
"{{colors.error.default.hex}}",
"{{colors.tertiary.default.hex}}",
"{{colors.secondary.default.hex}}",
"{{colors.primary.default.hex}}",
"{{colors.tertiary_fixed_dim.default.hex}}",
"{{colors.secondary_fixed_dim.default.hex}}",
"{{colors.on_surface.default.hex}}",
"{{colors.terminal_normal_black.default.hex}}",
"{{colors.terminal_normal_red.default.hex}}",
"{{colors.terminal_normal_green.default.hex}}",
"{{colors.terminal_normal_yellow.default.hex}}",
"{{colors.terminal_normal_blue.default.hex}}",
"{{colors.terminal_normal_magenta.default.hex}}",
"{{colors.terminal_normal_cyan.default.hex}}",
"{{colors.terminal_normal_white.default.hex}}",
]
background = "{{colors.surface.default.hex}}"
background = "{{colors.terminal_background.default.hex}}"
brights = [
"{{colors.outline.default.hex}}",
"{{colors.error.default.hex}}",
"{{colors.tertiary.default.hex}}",
"{{colors.secondary.default.hex}}",
"{{colors.primary.default.hex}}",
"{{colors.tertiary_fixed_dim.default.hex}}",
"{{colors.secondary_fixed_dim.default.hex}}",
"{{colors.on_surface.default.hex}}",
"{{colors.terminal_bright_black.default.hex}}",
"{{colors.terminal_bright_red.default.hex}}",
"{{colors.terminal_bright_green.default.hex}}",
"{{colors.terminal_bright_yellow.default.hex}}",
"{{colors.terminal_bright_blue.default.hex}}",
"{{colors.terminal_bright_magenta.default.hex}}",
"{{colors.terminal_bright_cyan.default.hex}}",
"{{colors.terminal_bright_white.default.hex}}",
]
cursor_bg = "{{colors.on_surface.default.hex}}"
cursor_border = "{{colors.on_surface.default.hex}}"
cursor_fg = "{{colors.surface.default.hex}}"
foreground = "{{colors.on_surface.default.hex}}"
selection_bg = "{{colors.surface_variant.default.hex}}"
selection_fg = "{{colors.on_surface_variant.default.hex}}"
compose_cursor = "{{colors.terminal_cursor.default.hex}}"
cursor_bg = "{{colors.terminal_cursor.default.hex}}"
cursor_border = "{{colors.terminal_cursor.default.hex}}"
cursor_fg = "{{colors.terminal_cursor_text.default.hex}}"
foreground = "{{colors.terminal_foreground.default.hex}}"
scrollbar_thumb = "{{colors.terminal_selection_bg.default.hex}}"
selection_bg = "{{colors.terminal_selection_bg.default.hex}}"
selection_fg = "{{colors.terminal_selection_fg.default.hex}}"
split = "{{colors.terminal_bright_black.default.hex}}"
visual_bell = "{{colors.terminal_normal_black.default.hex}}"
[colors.indexed]
16 = "{{colors.secondary.default.hex}}"
17 = "{{colors.terminal_cursor.default.hex}}"
[colors.tab_bar]
background = "{{colors.terminal_background.default.hex | darken 0.1}}"
inactive_tab_edge = "{{colors.terminal_selection_bg.default.hex}}"
[colors.tab_bar.active_tab]
bg_color = "{{colors.primary.default.hex}}"
fg_color = "{{colors.on_primary.default.hex}}"
intensity = "Normal"
italic = false
strikethrough = false
underline = "None"
[colors.tab_bar.inactive_tab]
bg_color = "{{colors.terminal_background.default.hex | darken 0.05}}"
fg_color = "{{colors.terminal_foreground.default.hex}}"
intensity = "Normal"
italic = false
strikethrough = false
underline = "None"
[colors.tab_bar.inactive_tab_hover]
bg_color = "{{colors.terminal_background.default.hex}}"
fg_color = "{{colors.terminal_foreground.default.hex}}"
intensity = "Normal"
italic = false
strikethrough = false
underline = "None"
[colors.tab_bar.new_tab]
bg_color = "{{colors.terminal_selection_bg.default.hex}}"
fg_color = "{{colors.terminal_foreground.default.hex}}"
intensity = "Normal"
italic = false
strikethrough = false
underline = "None"
[colors.tab_bar.new_tab_hover]
bg_color = "{{colors.terminal_bright_black.default.hex}}"
fg_color = "{{colors.terminal_foreground.default.hex}}"
intensity = "Normal"
italic = false
strikethrough = false
underline = "None"
[metadata]
author = "Noctalia"
name = "Noctalia"
+2 -35
View File
@@ -9,39 +9,6 @@ namespace noctalia::theme {
namespace {
constexpr std::uint32_t colorToArgb(const Color& color) {
auto toByte = [](float value) constexpr {
return static_cast<std::uint32_t>(value <= 0.0f ? 0.0f : (value >= 1.0f ? 255.0f : value * 255.0f + 0.5f));
};
return 0xff000000U | (toByte(color.r) << 16U) | (toByte(color.g) << 8U) | toByte(color.b);
}
void setToken(TokenMap& tokens, std::string_view key, const Color& color) {
tokens[std::string(key)] = colorToArgb(color);
}
void applyAnsiColors(TokenMap& tokens, std::string_view prefix, const TerminalAnsiColors& colors) {
setToken(tokens, std::string(prefix) + "_black", colors.black);
setToken(tokens, std::string(prefix) + "_red", colors.red);
setToken(tokens, std::string(prefix) + "_green", colors.green);
setToken(tokens, std::string(prefix) + "_yellow", colors.yellow);
setToken(tokens, std::string(prefix) + "_blue", colors.blue);
setToken(tokens, std::string(prefix) + "_magenta", colors.magenta);
setToken(tokens, std::string(prefix) + "_cyan", colors.cyan);
setToken(tokens, std::string(prefix) + "_white", colors.white);
}
void applyTerminalColors(TokenMap& tokens, const TerminalPalette& terminal) {
applyAnsiColors(tokens, "terminal_normal", terminal.normal);
applyAnsiColors(tokens, "terminal_bright", terminal.bright);
setToken(tokens, "terminal_foreground", terminal.foreground);
setToken(tokens, "terminal_background", terminal.background);
setToken(tokens, "terminal_selection_fg", terminal.selectionFg);
setToken(tokens, "terminal_selection_bg", terminal.selectionBg);
setToken(tokens, "terminal_cursor_text", terminal.cursorText);
setToken(tokens, "terminal_cursor", terminal.cursor);
}
constexpr std::array<BuiltinPalette, 10> kPalettes = {
{
{
@@ -1051,8 +1018,8 @@ namespace noctalia::theme {
GeneratedPalette expandBuiltinPalette(const BuiltinPalette& palette) {
auto generated = expandFixedPalettes(palette.dark, palette.light);
applyTerminalColors(generated.dark, palette.darkTerminal);
applyTerminalColors(generated.light, palette.lightTerminal);
applyTerminalPalette(generated.dark, palette.darkTerminal);
applyTerminalPalette(generated.light, palette.lightTerminal);
return generated;
}
+1 -24
View File
@@ -1,35 +1,12 @@
#pragma once
#include "theme/palette.h"
#include "ui/palette.h"
#include "theme/fixed_palette.h"
#include <span>
#include <string_view>
namespace noctalia::theme {
struct TerminalAnsiColors {
Color black;
Color red;
Color green;
Color yellow;
Color blue;
Color magenta;
Color cyan;
Color white;
};
struct TerminalPalette {
TerminalAnsiColors normal;
TerminalAnsiColors bright;
Color foreground;
Color background;
Color selectionFg;
Color selectionBg;
Color cursorText;
Color cursor;
};
struct BuiltinPalette {
std::string_view name;
Palette dark;
+1
View File
@@ -209,6 +209,7 @@ namespace noctalia::theme {
err = "theme json contained no token maps";
return false;
}
synthesizeTerminalPaletteTokens(palette);
return true;
}
+2
View File
@@ -9,6 +9,7 @@
#include "cpp/cam/hct.h"
#include "theme/color.h"
#include "theme/contrast.h"
#include "theme/fixed_palette.h"
#include "theme/palette.h"
#include "theme/palette_generator.h"
#include "theme/scheme.h"
@@ -1239,6 +1240,7 @@ namespace noctalia::theme {
out.dark["source_color"] = palette[0].toArgb();
out.light["source_color"] = palette[0].toArgb();
}
synthesizeTerminalPaletteTokens(out);
return out;
}
+100
View File
@@ -11,6 +11,9 @@ namespace noctalia::theme {
namespace {
constexpr std::uint32_t kOpaqueBlack = 0xff000000U;
constexpr std::uint32_t kOpaqueWhite = 0xffffffffU;
::Color tokenToColor(const TokenMap& tokens, std::string_view key) {
auto it = tokens.find(std::string(key));
if (it == tokens.end())
@@ -25,6 +28,43 @@ namespace noctalia::theme {
void setToken(TokenMap& dst, std::string_view key, const Color& color) { dst[std::string(key)] = color.toArgb(); }
std::uint32_t colorToArgb(const ::Color& color) {
auto toByte = [](float value) {
return static_cast<std::uint32_t>(value <= 0.0f ? 0.0f : (value >= 1.0f ? 255.0f : value * 255.0f + 0.5f));
};
return kOpaqueBlack | (toByte(color.r) << 16U) | (toByte(color.g) << 8U) | toByte(color.b);
}
void setToken(TokenMap& dst, std::string_view key, const ::Color& color) {
dst[std::string(key)] = colorToArgb(color);
}
bool hasToken(const TokenMap& tokens, std::string_view key) {
return tokens.find(std::string(key)) != tokens.end();
}
std::uint32_t tokenOr(const TokenMap& tokens, std::string_view key, std::uint32_t fallback) {
auto it = tokens.find(std::string(key));
return it == tokens.end() ? fallback : it->second;
}
void setMissingToken(TokenMap& tokens, std::string_view key, std::uint32_t value) {
if (!hasToken(tokens, key)) {
tokens[std::string(key)] = value;
}
}
void applyAnsiColors(TokenMap& tokens, std::string_view prefix, const TerminalAnsiColors& colors) {
setToken(tokens, std::string(prefix) + "_black", colors.black);
setToken(tokens, std::string(prefix) + "_red", colors.red);
setToken(tokens, std::string(prefix) + "_green", colors.green);
setToken(tokens, std::string(prefix) + "_yellow", colors.yellow);
setToken(tokens, std::string(prefix) + "_blue", colors.blue);
setToken(tokens, std::string(prefix) + "_magenta", colors.magenta);
setToken(tokens, std::string(prefix) + "_cyan", colors.cyan);
setToken(tokens, std::string(prefix) + "_white", colors.white);
}
Color interpolateColor(const Color& a, const Color& b, double t) {
auto mix = [t](int lhs, int rhs) { return static_cast<int>(lhs + (rhs - lhs) * t); };
return Color(mix(a.r, b.r), mix(a.g, b.g), mix(a.b, b.b));
@@ -32,6 +72,66 @@ namespace noctalia::theme {
} // namespace
void applyTerminalPalette(TokenMap& tokens, const TerminalPalette& terminal) {
applyAnsiColors(tokens, "terminal_normal", terminal.normal);
applyAnsiColors(tokens, "terminal_bright", terminal.bright);
setToken(tokens, "terminal_foreground", terminal.foreground);
setToken(tokens, "terminal_background", terminal.background);
setToken(tokens, "terminal_selection_fg", terminal.selectionFg);
setToken(tokens, "terminal_selection_bg", terminal.selectionBg);
setToken(tokens, "terminal_cursor_text", terminal.cursorText);
setToken(tokens, "terminal_cursor", terminal.cursor);
}
void synthesizeTerminalPaletteTokens(TokenMap& tokens) {
const std::uint32_t background = tokenOr(tokens, "background", tokenOr(tokens, "surface", kOpaqueBlack));
const std::uint32_t foreground = tokenOr(tokens, "on_surface", kOpaqueWhite);
const std::uint32_t surface = tokenOr(tokens, "surface", background);
const std::uint32_t surfaceVariant = tokenOr(tokens, "surface_variant", surface);
const std::uint32_t onSurfaceVariant = tokenOr(tokens, "on_surface_variant", foreground);
const std::uint32_t outline = tokenOr(tokens, "outline", onSurfaceVariant);
const std::uint32_t error = tokenOr(tokens, "error", foreground);
const std::uint32_t primary = tokenOr(tokens, "primary", foreground);
const std::uint32_t secondary = tokenOr(tokens, "secondary", primary);
const std::uint32_t tertiary = tokenOr(tokens, "tertiary", secondary);
const std::uint32_t primaryFixedDim = tokenOr(tokens, "primary_fixed_dim", primary);
const std::uint32_t secondaryFixedDim = tokenOr(tokens, "secondary_fixed_dim", secondary);
setMissingToken(tokens, "terminal_foreground", foreground);
setMissingToken(tokens, "terminal_background", background);
setMissingToken(tokens, "terminal_cursor", foreground);
setMissingToken(tokens, "terminal_cursor_text", background);
setMissingToken(tokens, "terminal_selection_fg", onSurfaceVariant);
setMissingToken(tokens, "terminal_selection_bg", surfaceVariant);
setMissingToken(tokens, "terminal_normal_black", surfaceVariant);
setMissingToken(tokens, "terminal_normal_red", error);
setMissingToken(tokens, "terminal_normal_green", primary);
setMissingToken(tokens, "terminal_normal_yellow", secondary);
setMissingToken(tokens, "terminal_normal_blue", tertiary);
setMissingToken(tokens, "terminal_normal_magenta", primaryFixedDim);
setMissingToken(tokens, "terminal_normal_cyan", secondaryFixedDim);
setMissingToken(tokens, "terminal_normal_white", foreground);
setMissingToken(tokens, "terminal_bright_black", outline);
setMissingToken(tokens, "terminal_bright_red", error);
setMissingToken(tokens, "terminal_bright_green", primary);
setMissingToken(tokens, "terminal_bright_yellow", secondary);
setMissingToken(tokens, "terminal_bright_blue", tertiary);
setMissingToken(tokens, "terminal_bright_magenta", primaryFixedDim);
setMissingToken(tokens, "terminal_bright_cyan", secondaryFixedDim);
setMissingToken(tokens, "terminal_bright_white", foreground);
}
void synthesizeTerminalPaletteTokens(GeneratedPalette& palette) {
if (!palette.dark.empty()) {
synthesizeTerminalPaletteTokens(palette.dark);
}
if (!palette.light.empty()) {
synthesizeTerminalPaletteTokens(palette.light);
}
}
TokenMap expandFixedPaletteMode(const ::Palette& palette, bool isDark) {
const Color primary = toUiColor(palette.primary);
const Color onPrimary = toUiColor(palette.onPrimary);
+26
View File
@@ -9,8 +9,34 @@ namespace noctalia::theme {
using TokenMap = std::unordered_map<std::string, uint32_t>;
struct TerminalAnsiColors {
::Color black;
::Color red;
::Color green;
::Color yellow;
::Color blue;
::Color magenta;
::Color cyan;
::Color white;
};
struct TerminalPalette {
TerminalAnsiColors normal;
TerminalAnsiColors bright;
::Color foreground;
::Color background;
::Color selectionFg;
::Color selectionBg;
::Color cursorText;
::Color cursor;
};
TokenMap expandFixedPaletteMode(const ::Palette& palette, bool isDark);
GeneratedPalette expandFixedPalettes(const ::Palette& dark, const ::Palette& light);
::Palette mapGeneratedPaletteMode(const TokenMap& tokens);
void applyTerminalPalette(TokenMap& tokens, const TerminalPalette& terminal);
void synthesizeTerminalPaletteTokens(TokenMap& tokens);
void synthesizeTerminalPaletteTokens(GeneratedPalette& palette);
} // namespace noctalia::theme
+2
View File
@@ -10,6 +10,7 @@
#include "cpp/scheme/scheme_rainbow.h"
#include "cpp/scheme/scheme_tonal_spot.h"
#include "cpp/utils/utils.h"
#include "theme/fixed_palette.h"
#include "theme/palette.h"
#include "theme/palette_generator.h"
#include "theme/scheme.h"
@@ -444,6 +445,7 @@ namespace noctalia::theme {
out.light = buildTokenMap(*lightScheme);
out.dark["source_color"] = seed;
out.light["source_color"] = seed;
synthesizeTerminalPaletteTokens(out);
return out;
}
+24 -2
View File
@@ -10,7 +10,7 @@ namespace noctalia::theme {
// and the custom schemes populate the same key set so consumers can treat
// them interchangeably. `source_color` is the seed color used to generate
// the scheme and is exposed for template compatibility.
inline constexpr std::array<std::string_view, 50> kTokens = {
inline constexpr auto kTokens = std::to_array<std::string_view>({
"source_color",
"primary",
"on_primary",
@@ -61,7 +61,29 @@ namespace noctalia::theme {
"inverse_primary",
"background",
"on_background",
};
"terminal_foreground",
"terminal_background",
"terminal_cursor",
"terminal_cursor_text",
"terminal_selection_fg",
"terminal_selection_bg",
"terminal_normal_black",
"terminal_normal_red",
"terminal_normal_green",
"terminal_normal_yellow",
"terminal_normal_blue",
"terminal_normal_magenta",
"terminal_normal_cyan",
"terminal_normal_white",
"terminal_bright_black",
"terminal_bright_red",
"terminal_bright_green",
"terminal_bright_yellow",
"terminal_bright_blue",
"terminal_bright_magenta",
"terminal_bright_cyan",
"terminal_bright_white",
});
inline constexpr size_t kTokenCount = kTokens.size();