pub trait Theme {
// Required methods
fn fg(&self, color: &str, text: &str) -> String;
fn bg(&self, color: &str, text: &str) -> String;
fn bold(&self, text: &str) -> String;
fn italic(&self, text: &str) -> String;
fn inverse(&self, text: &str) -> String;
// Provided methods
fn fg_key(&self, key: ThemeKey, text: &str) -> String { ... }
fn bg_key(&self, key: ThemeKey, text: &str) -> String { ... }
fn fg_ansi(&self, _color: &str) -> &str { ... }
fn fg_ansi_key(&self, key: ThemeKey) -> &str { ... }
}Expand description
Theme trait for components that need color styling.
Implementations provide foreground and background color functions that take text and return ANSI-styled strings.
Required Methods§
Sourcefn fg(&self, color: &str, text: &str) -> String
fn fg(&self, color: &str, text: &str) -> String
Apply a foreground color to text.
color is a color name (e.g., “accent”, “text”, “success”, “error”, “muted”).
Provided Methods§
Sourcefn fg_key(&self, key: ThemeKey, text: &str) -> String
fn fg_key(&self, key: ThemeKey, text: &str) -> String
Apply a foreground color from a ThemeKey.
Sourcefn bg_key(&self, key: ThemeKey, text: &str) -> String
fn bg_key(&self, key: ThemeKey, text: &str) -> String
Apply a background color from a ThemeKey.
Sourcefn fg_ansi(&self, _color: &str) -> &str
fn fg_ansi(&self, _color: &str) -> &str
Return the ANSI escape code for a named color (without text). Default implementation returns empty string — override in concrete themes.
Sourcefn fg_ansi_key(&self, key: ThemeKey) -> &str
fn fg_ansi_key(&self, key: ThemeKey) -> &str
Return the ANSI escape code for a ThemeKey color (without text).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".