Skip to main content

Theme

Trait Theme 

Source
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§

Source

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”).

Source

fn bg(&self, color: &str, text: &str) -> String

Apply a background color to text.

Source

fn bold(&self, text: &str) -> String

Apply bold styling.

Source

fn italic(&self, text: &str) -> String

Apply italic styling (used for thinking blocks, matching pi).

Source

fn inverse(&self, text: &str) -> String

Apply reverse/inverse video styling (used for intra-line diff highlighting).

Provided Methods§

Source

fn fg_key(&self, key: ThemeKey, text: &str) -> String

Apply a foreground color from a ThemeKey.

Source

fn bg_key(&self, key: ThemeKey, text: &str) -> String

Apply a background color from a ThemeKey.

Source

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.

Source

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".

Implementors§