colors
Colors can be specified as named colors, hex strings (#RRGGBB), or
tables with foreground, background, and modifier fields.
struct ColorValue
pub struct ColorValueA resolved color and text modifier specification.
| Field | Type | Description |
|---|---|---|
bg |
Option<Color> | Background color, if set. |
bold |
bool | Whether bold weight is enabled. |
dim |
bool | Whether dim/faint rendering is enabled. |
fg |
Option<Color> | Foreground color, if set. |
italic |
bool | Whether italic style is enabled. |
underline |
bool | Whether underline decoration is enabled. |
Implements Clone, Debug, PartialEq, Deserialize<'de>, Serialize.
ColorValue::bg
pub fn bg(&self) -> &Option<Color>Background color, if set.
| Parameter | Type | Description |
|---|---|---|
| returns | &Option<Color> |
ColorValue::bold
pub fn bold(&self) -> &boolWhether bold weight is enabled.
| Parameter | Type | Description |
|---|---|---|
| returns | &bool |
ColorValue::dim
pub fn dim(&self) -> &boolWhether dim/faint rendering is enabled.
| Parameter | Type | Description |
|---|---|---|
| returns | &bool |
ColorValue::fg
pub fn fg(&self) -> &Option<Color>Foreground color, if set.
| Parameter | Type | Description |
|---|---|---|
| returns | &Option<Color> |
ColorValue::italic
pub fn italic(&self) -> &boolWhether italic style is enabled.
| Parameter | Type | Description |
|---|---|---|
| returns | &bool |
ColorValue::underline
pub fn underline(&self) -> &boolWhether underline decoration is enabled.
| Parameter | Type | Description |
|---|---|---|
| returns | &bool |
ColorValue::apply_to
pub fn apply_to(&self, style: Style) -> StyleApplies this value’s colors and modifiers to the given Style.
Only the colors and modifiers that are set change; the rest of style stays as it was.
| Parameter | Type | Description |
|---|---|---|
style |
Style | the style to layer this value on |
| returns | Style | style with this value’s foreground, background and modifiers applied. |
struct Settings
pub struct SettingsTwo-tier color configuration: semantic palette slots and per-token overrides.
The palette map accepts Palette keys with color-only values.
The overrides map accepts theme token keys with full ColorValue format.
| Field | Type | Description |
|---|---|---|
overrides |
HashMap<String, ColorValue> | Per-token style overrides keyed by dot-separated token name. |
palette |
HashMap<String, Color> | Palette-level color overrides keyed by slot name (e.g. "primary"). |
Implements Clone, Debug, Default, PartialEq, Deserialize<'de>, Serialize.
Settings::overrides
pub fn overrides(&self) -> &HashMap<String, ColorValue>Per-token style overrides keyed by dot-separated token name.
| Parameter | Type | Description |
|---|---|---|
| returns | &HashMap<String, ColorValue> |
Settings::palette
pub fn palette(&self) -> &HashMap<String, Color>Palette-level color overrides keyed by slot name (e.g. "primary").
| Parameter | Type | Description |
|---|---|---|
| returns | &HashMap<String, Color> |
Settings::iter
pub fn iter(&self) -> impl Iterator<Item = (&String, &ColorValue)>Iterates over all configured token override entries.
| Parameter | Type | Description |
|---|---|---|
| returns | impl Iterator<Item = (&String, &ColorValue)> | An iterator of (token name, value) pairs from the overrides map, in no fixed order. |
fn color_to_string
fn color_to_string(color: Color) -> StringConverts a Color back to its canonical string representation.
| Parameter | Type | Description |
|---|---|---|
color |
Color | the color to name |
| returns | String | The lowercase color name, or #RRGGBB in uppercase hex for an RGB color. Colors with no name here, such as 256-color indexes, become "white". |
fn parse_color
fn parse_color(s: &str) -> Result<Color, String>Parses a color string, dispatching to hex or named-color parsing.
| Parameter | Type | Description |
|---|---|---|
s |
&str | a #RRGGBB hex string or a color name |
| returns | Result<Color, String> | The color, or an error message when the string is neither a valid hex color nor a known name. |
fn parse_hex_color
fn parse_hex_color(hex: &str) -> Result<Color, String>Parses a 6-digit hex color string (without the # prefix) into an RGB Color.
| Parameter | Type | Description |
|---|---|---|
hex |
&str | six hex digits, in either case |
| returns | Result<Color, String> | The RGB color, or an error message when the string is not exactly six ASCII hex digits. A sign such as +f and non-ASCII characters are rejected. |
fn parse_named_color
fn parse_named_color(name: &str) -> Result<Color, String>Maps a case-insensitive color name (e.g. "bright_cyan") to a Color.
| Parameter | Type | Description |
|---|---|---|
name |
&str | one of the 16 ANSI color names, such as red or bright_cyan |
| returns | Result<Color, String> | The color, or an error message for an unknown name. |