Tca-Types
Core type definitions for Terminal Colors Architecture (TCA).
Defines the Theme struct that TOML theme files deserialize into, color reference resolution, hex utilities, built-in themes, and a cycling cursor for navigating sets of themes.
Installation
Loading a Theme
From a TOML String
use Theme;
let theme: Theme = from_str?;
From a File or Theme Name (Requires fs Feature)
use Theme;
// Exact file path
let theme = from_name;
// Theme name or slug — resolves user themes then built-ins
let theme = from_name;
let theme = from_name;
// Auto-detect from terminal dark/light mode
let theme = from_name;
From Built-in Themes (no Files Needed)
use BuiltinTheme;
let theme = TokyoNight.theme;
let theme = Nord.theme;
let theme = default.theme; // Dracula (dark)
let theme = default_light.theme; // SolarizedLight
Loading a Collection of Themes
use ;
// All user-installed themes from XDG data dir
let themes = all_user_themes;
// Built-ins merged with user themes (user overrides built-in on name match)
let themes = all_themes;
// All themes from a specific directory
let themes = all_from_dir;
// Iterate over all built-ins
for builtin in iter
Theme Cursor
ThemeCursor<T> is a cycling cursor for navigating a collection of themes. peek() shows the current theme; next() and prev() move the cursor (both wrap).
use ;
// From built-in themes
let mut cursor = with_builtins;
// From user themes
let mut cursor = with_user_themes;
// Built-ins + user themes merged
let mut cursor = with_all_themes;
// From an explicit list
let mut cursor = new;
// Navigate
let current: &Theme = cursor.peek.unwrap;
let next: &Theme = cursor.next.unwrap; // advances, wraps at end
let prev: &Theme = cursor.prev.unwrap; // retreats, wraps at start
// Inspect without moving
println!;
println!;
// Iterate all themes without cycling
for theme in cursor.themes
Resolving Color References
let theme: Theme = from_str?;
// Resolve any reference format 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")
let hex = theme.resolve; // None
Hex Utilities
use hex_to_rgb;
let = hex_to_rgb?; // (255, 85, 51)
let = hex_to_rgb?; // also works without #
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 Reference Formats
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
| Variant | Slug | Style |
|---|---|---|
CatppuccinMocha |
catppuccin-mocha |
dark |
Cyberpunk |
cyberpunk |
dark |
Dracula |
dracula |
dark |
EverforestDark |
everforest-dark |
dark |
GruvboxDark |
gruvbox-dark |
dark |
Mono |
mono |
dark |
Nord |
nord |
dark |
OneDark |
one-dark |
dark |
RosePine |
rose-pine |
dark |
SolarizedLight |
solarized-light |
light |
TokyoNight |
tokyo-night |
dark |
Features
| Feature | Default | Description |
|---|---|---|
fs |
enabled | File I/O, Theme::from_name, all_themes, ThemeCursor::with_user_themes / with_all_themes |
# Without file I/O (built-ins and TOML parsing still available)
= { = "0.4", = false }
License
MIT