Struct cursive_core::theme::Palette [−][src]
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
impl Palette
[src]
pub fn custom<'a>(&'a self, key: &str) -> Option<&'a Color>
[src]
Returns a custom color from this palette.
Returns None
if the given key was not found.
pub fn merge(&self, namespace: &str) -> Palette
[src]
Returns a new palette where the given namespace has been merged.
All values in the namespace will override previous values.
pub fn set_color(&mut self, key: &str, color: Color)
[src]
Sets the color for the given key.
This will update either the basic palette or the custom values.
pub fn set_basic_color(&mut self, key: &str, color: Color) -> Result<(), ()>
[src]
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>
)
[src]
&mut self,
key: &str,
namespace: HashMap<String, PaletteNode, RandomState>
)
Adds a color namespace to this palette.
Trait Implementations
impl Clone for Palette
[src]
impl Debug for Palette
[src]
impl Default for Palette
[src]
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)
impl Eq for Palette
[src]
impl Extend<(PaletteColor, Color)> for Palette
[src]
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (PaletteColor, Color)>,
[src]
T: IntoIterator<Item = (PaletteColor, Color)>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl Index<PaletteColor> for Palette
[src]
type Output = Color
The returned type after indexing.
fn index(&self, palette_color: PaletteColor) -> &Color
[src]
impl IndexMut<PaletteColor> for Palette
[src]
fn index_mut(&mut self, palette_color: PaletteColor) -> &mut Color
[src]
impl PartialEq<Palette> for Palette
[src]
impl StructuralEq for Palette
[src]
impl StructuralPartialEq for Palette
[src]
Auto Trait Implementations
impl RefUnwindSafe for Palette
[src]
impl Send for Palette
[src]
impl Sync for Palette
[src]
impl Unpin for Palette
[src]
impl UnwindSafe for Palette
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,