Crate rat_theme4

Crate rat_theme4 

Source
Expand description

SalsaTheme provides a styling system for ratatui apps.

It has a flat mapping from style-name to either a ratatui Style or to one of the composite styles used by rat-widget.

And it contains the underlying color Palette.

§Naming styles

  • It has an extension trait for Style that adds constants for known styles. In the same manner you can add your application specific styles and have them with code completion.

  • For rat-widget composite style it defines an anchor struct WidgetStyle that performs the same purpose.

§Usage


// ratatui Style
let s: Style = theme.style(Style::SELECT);

// composite style
Checkbox::new()
    .styles(theme.style(WidgetStyle::CHECKBOX))
    .render(area, buf, &mut state);

§Palette

Palette holds the color definitions and aliases for the colors. This is the part of the theme that can be persisted. It can be stored/loaded from file or put into a static.

With create_palette_theme the theme can be reconstructed.


let mut f = File::open("dark_palettes/base16.pal").expect("pal-file");
let pal = load_palette(f).expect("valid_pal-file");
let theme = match create_palette_theme(pal) {
    Ok(r) => r,
    Err(p) => panic!("unsupported theme {:?}", p.theme),
};

let s: Style = theme.style(Style::INPUT);

Modules§

palette
Palette is the color palette for salsa-themes.
palettes
Currently shipped palettes.
theme
SalsaTheme is the main structure for themes.
themes

Structs§

LoadPaletteErr
WidgetStyle
Anchor struct for the names of composite styles used by rat-widget’s.

Traits§

RatWidgetColor
Extension trait for Color that defines standard names used by rat-theme to define color-aliases.
StyleName
Extension trait for Style that defines some standard names used by rat-theme/rat-widget

Functions§

create_paletteDeprecated
Create one of the predefined themes as a Palette.
create_palette_theme
Create the Theme based on the given Palette.
create_salsa_palette
Create one of the predefined themes as a Palette.
create_salsa_theme
Create one of the predefined themes.
create_themeDeprecated
load_palette
Load a .pal file as a Palette.
log_style_define
Log style definition. May help debugging styling problems …
salsa_palettesDeprecated
All predefined rat-salsa themes.
salsa_themes
All predefined rat-salsa themes.
store_palette
Stora a Palette as a .pal file.