Struct cursive_core::theme::ColorStyle
source · Expand description
Possible color style for a cell.
Represents a color pair role to use when printing something.
The current theme will assign each role a foreground and background color.
The Default
value is to inherit the parent’s colors.
Fields§
§front: ColorType
Color used for the foreground (the text itself).
back: ColorType
Color used for the background.
Implementations§
source§impl ColorStyle
impl ColorStyle
sourcepub fn new<F, B>(front: F, back: B) -> Selfwhere
F: Into<ColorType>,
B: Into<ColorType>,
pub fn new<F, B>(front: F, back: B) -> Selfwhere
F: Into<ColorType>,
B: Into<ColorType>,
Creates a new color style, using the given values for front and back.
Examples
use cursive::theme::ColorStyle;
// `BaseColor` implements `Into<ColorStyle>`
use cursive::theme::BaseColor::*;
let red_on_black = ColorStyle::new(Red, Black);
// So does `Color`.
let red_on_black = ColorStyle::new(Red.light(), Black.dark());
// Or `PaletteColor`.
use cursive::theme::PaletteColor::*;
let primary = ColorStyle::new(Primary, View);
sourcepub fn front<F>(front: F) -> Selfwhere
F: Into<ColorType>,
pub fn front<F>(front: F) -> Selfwhere
F: Into<ColorType>,
Uses the given color as front, inherits the parent background color.
Examples
use cursive::theme::{BaseColor::*, ColorStyle, ColorType};
let color = ColorStyle::front(Red.dark());
assert_eq!(color, ColorStyle::new(Red.dark(), ColorType::InheritParent));
sourcepub fn back<B>(back: B) -> Selfwhere
B: Into<ColorType>,
pub fn back<B>(back: B) -> Selfwhere
B: Into<ColorType>,
Uses the given color as background, inherits the parent front color.
Examples
use cursive::theme::{BaseColor::*, ColorStyle, ColorType};
let color = ColorStyle::back(Black.dark());
assert_eq!(
color,
ColorStyle::new(ColorType::InheritParent, Black.dark())
);
sourcepub fn invert(self) -> Self
pub fn invert(self) -> Self
Returns an inverted color style, with the front and back colors swapped.
Examples
use cursive::theme::BaseColor::*;
use cursive::theme::ColorStyle;
let red_on_black = ColorStyle::new(Red.dark(), Black.dark());
let black_on_red = red_on_black.invert();
assert_eq!(black_on_red, ColorStyle::new(Black.dark(), Red.dark()));
sourcepub fn inherit_parent() -> Self
pub fn inherit_parent() -> Self
Uses ColorType::InheritParent
for both front and background.
sourcepub fn terminal_default() -> Self
pub fn terminal_default() -> Self
Style set by terminal before entering a Cursive program.
sourcepub fn background() -> Self
pub fn background() -> Self
Application background, where no view is present.
sourcepub fn title_primary() -> Self
pub fn title_primary() -> Self
Title text color with default background.
sourcepub fn title_secondary() -> Self
pub fn title_secondary() -> Self
Alternative color for a title.
sourcepub fn highlight_inactive() -> Self
pub fn highlight_inactive() -> Self
Highlight color for inactive views (not in focus).
sourcepub fn merge(old: Self, new: Self) -> Self
pub fn merge(old: Self, new: Self) -> Self
Merge the color type new
over the color type old
.
This merges the front and back color types of a
and b
.
sourcepub fn resolve(&self, palette: &Palette, previous: ColorPair) -> ColorPair
pub fn resolve(&self, palette: &Palette, previous: ColorPair) -> ColorPair
Return the color pair that this style represents.
Trait Implementations§
source§impl Clone for ColorStyle
impl Clone for ColorStyle
source§fn clone(&self) -> ColorStyle
fn clone(&self) -> ColorStyle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more