Struct cursive::theme::Palette [−][src]
pub struct Palette { /* fields omitted */ }
Expand description
Color configuration for the application.
Assign each color role an actual color.
It implements Index
and IndexMut
to access and modify this mapping:
It also implements Extend
to update a batch of colors at
once.
Example
use cursive_core::theme::{BaseColor::*, Color::*, PaletteColor::*};
let mut palette = Palette::default();
assert_eq!(palette[Background], Dark(Blue));
palette[Shadow] = Light(Red);
assert_eq!(palette[Shadow], Light(Red));
let colors = vec![(Shadow, Dark(Green)), (Primary, Light(Blue))];
palette.extend(colors);
assert_eq!(palette[Shadow], Dark(Green));
assert_eq!(palette[Primary], Light(Blue));
Implementations
Returns a custom color from this palette.
Returns None
if the given key was not found.
Returns a new palette where the given namespace has been merged.
All values in the namespace will override previous values.
Sets the color for the given key.
This will update either the basic palette or the custom values.
Sets a basic color from its name.
Returns Err(())
if key
is not a known PaletteColor
.
pub fn add_namespace(
&mut self,
key: &str,
namespace: HashMap<String, PaletteNode, RandomState>
)
pub fn add_namespace(
&mut self,
key: &str,
namespace: HashMap<String, PaletteNode, RandomState>
)
Adds a color namespace to this palette.
Trait Implementations
Returns the default palette for a cursive application.
Background
=>Dark(Blue)
Shadow
=>Dark(Black)
View
=>Dark(White)
Primary
=>Dark(Black)
Secondary
=>Dark(Blue)
Tertiary
=>Light(White)
TitlePrimary
=>Dark(Red)
TitleSecondary
=>Dark(Yellow)
Highlight
=>Dark(Red)
HighlightInactive
=>Dark(Blue)
HighlightText
=>Dark(White)
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Performs the mutable indexing (container[index]
) operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Palette
impl UnwindSafe for Palette
Blanket Implementations
Mutably borrows from an owned value. Read more
Calls the given closure and return the result. Read more
Calls the given closure on self
.