Module theme

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

Structs§

ColorPair
Combines a front and back color.
ColorStyle
Possible color style for a cell.
ConcreteStyle
Combine a concrete color and effects.
Effects
A set of effects status.
NoSuchColor
Error parsing a color.
Palette
Color configuration for the application.
Style
Combine a color and effects.
Theme
Represents the style a Cursive application will use.

Enums§

BaseColor
One of the 8 base colors.
BorderStyle
Specifies how some borders should be drawn.
Color
Represents a color used by the theme.
ColorType
Either a color from the palette, or a direct color.
Effect
Text effect
EffectStatus
Describes what to do with an effect.
Error
Possible error returned when loading a theme.
PaletteColor
Color entry in a palette.
PaletteNode
A node in the palette tree.
PaletteStyle
Style entry in a palette.
StyleType
Type of style to apply to some text.

Functions§

load_default
Loads the default theme, and returns its representation.
load_theme_filetoml
Loads a theme from file.
load_tomltoml
Loads a theme string and sets it as active.

Type Aliases§

ConcreteEffects
A concrete set of effects to enable.