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.
Structs§
- Combines a front and back color.
- Possible color style for a cell.
- Combine a concrete color and effects.
- A set of effects status.
- Error parsing a color.
- Color configuration for the application.
- Combine a color and effects.
- Represents the style a Cursive application will use.
Enums§
- One of the 8 base colors.
- Specifies how some borders should be drawn.
- Represents a color used by the theme.
- Either a color from the palette, or a direct color.
- Text effect
- Describes what to do with an effect.
- Possible error returned when loading a theme.
- Color entry in a palette.
- A node in the palette tree.
- Style entry in a palette.
- Type of style to apply to some text.
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.
Type Aliases§
- A concrete set of effects to enable.