tca-types
Core type definitions for Terminal Colors Architecture (TCA).
Overview
Defines the Theme struct that TOML theme files deserialize into, plus color reference resolution and hex utilities. Used as the serialization layer by tca-loader and tca-ratatui.
Installation
Usage
use Theme;
// Deserialize from TOML
let theme: Theme = from_str?;
// Resolve color references to #RRGGBB
let hex = theme.resolve; // Some("#24283b")
let hex = theme.resolve; // Some("#f7768e")
let hex = theme.resolve; // Some("#f7768e")
let hex = theme.resolve; // Some("#ff0000")
// Hex parsing
use hex_to_rgb;
let = hex_to_rgb?; // (255, 85, 51)
Type structure
Theme
├── meta (required) — name, slug, author, version, description, dark
├── ansi (required) — 16 direct #RRGGBB values: black … bright_white
├── semantic (required) — error, warning, info, success, highlight, link
├── ui (required) — bg, fg, border, cursor, selection (each with sub-fields)
├── palette (optional) — named color ramps, e.g. neutral = ["#111", "#222", …]
└── base16 (optional) — base00–base0F mappings
Color references
Fields outside [ansi] may use any of these formats:
| Format | Example | Resolves via |
|---|---|---|
| Direct hex | #ff0000 |
returned as-is |
| ANSI reference | ansi.bright_red |
[ansi] section |
| Palette reference | palette.neutral.2 |
[palette] section (0-based) |
| Base16 reference | base16.base08 |
[base16] section (recursive) |
[ansi] values must always be direct #RRGGBB hex — references are not allowed there.
Built-in themes
BuiltinTheme provides 11 embedded themes (no files needed):
use BuiltinTheme;
let theme = Dracula.theme;
let theme = TokyoNight.theme;
let theme = default.theme; // Dracula
License
MIT