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:
- Construct a
Themeobject by setting every field individually. - Get the current theme with
Cursive::current_thememethod and changing the required fields (for example see theme_manual example). - Using a toml file as a theme configuration (for example see theme example).
§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§
pub use crate::style::BaseColor;pub use crate::style::BorderStyle;pub use crate::style::Color;pub use crate::style::ColorPair;pub use crate::style::ColorStyle;pub use crate::style::ColorType;pub use crate::style::ConcreteEffects;pub use crate::style::ConcreteStyle;pub use crate::style::Effect;pub use crate::style::EffectStatus;pub use crate::style::Effects;pub use crate::style::NoSuchColor;pub use crate::style::Palette;pub use crate::style::PaletteColor;pub use crate::style::PaletteNode;pub use crate::style::PaletteStyle;pub use crate::style::Style;pub use crate::style::StyleType;
Structs§
- Represents the style a Cursive application will use.
Enums§
- Possible error returned when loading a theme.
Functions§
- Loads the default theme, and returns its representation.
- load_
theme_ file tomlLoads a theme from file. - load_
toml tomlLoads a theme string and sets it as active.