Module cursive_core::theme

source ·
Expand description

Theming support for a consistent UI.

A Theme object defines the color palette an application will use, as well as various options to style views.

There are several ways to set a theme for the application:

§Configuring theme with toml

This requires the toml feature to be enabled.

[dependencies]
cursive = { version = "*", features = ["toml"] }

To use the theme in your application, load it with Cursive::load_toml method (or use theme::load_theme_file to acquire the theme object).

let mut siv = Cursive::new();
// Embed the theme with the binary.
siv.load_toml(include_str!("<path_to_theme_file>.toml")).unwrap();

Here are the possible entries (all fields are optional):

# Every field in a theme file is optional.

# First come some various options
shadow = false  # Don't draw shadows around stacked views
borders = "simple"  # Alternatives are "none" and "outset"

# Here we define the color palette.
[colors]
    background = "black"
    # If the value is an array, the first valid color will be used.
    # If the terminal doesn't support custom color,
    # non-base colors will be skipped.
    shadow     = ["#000000", "black"]
    view       = "#d3d7cf"

    # Array and simple values have the same effect.
    primary   = ["#111111"]
    secondary = "#EEEEEE"
    tertiary  = "#444444"

    # Hex values can use lower or uppercase.
    # (base color MUST be lowercase)
    title_primary   = "#ff5555"
    title_secondary = "#ffff55"

    # Lower precision values can use only 3 digits.
    highlight          = "#F00"
    highlight_inactive = "#5555FF"

§Re-exports from style

For backward-compatibility, this module re-exports most of the crate::style module. These re-exports are deprecated and will be removed in a future version.

Re-exports§

Structs§

  • Represents the style a Cursive application will use.

Enums§

  • Possible error returned when loading a theme.

Functions§