[][src]Struct cursive::theme::Palette

pub struct Palette { /* fields omitted */ }

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 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<(), NoSuchColor>
[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]

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]

impl Index<PaletteColor> for Palette[src]

type Output = Color

The returned type after indexing.

impl IndexMut<PaletteColor> for Palette[src]

impl PartialEq<Palette> for Palette[src]

impl StructuralEq for Palette[src]

impl StructuralPartialEq for Palette[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> With for T[src]