Style

Struct Style 

Source
pub struct Style {
    pub effects: Effects,
    pub color: ColorStyle,
}
Expand description

Combine a color and effects.

Represents any transformation that can be applied to text.

This is a “abstract” style, which can depend on the current theme, or on the previously active style.

Fields§

§effects: Effects

Effects to apply.

§color: ColorStyle

Color style to apply.

Implementations§

Source§

impl Style

Source

pub const fn none() -> Style

Returns a new Style that doesn’t apply anything.

Same as Style::inherit_parent().

Source

pub fn merge(styles: &[Style]) -> Style

Returns a new Style by merging all given styles.

Will use the last non-None color, and will combine all effects.

Source

pub fn combine<S>(self, other: S) -> Style
where S: Into<Style>,

Returns a combination of self and other.

Source

pub const fn from_color_style(color: ColorStyle) -> Style

Create a new Style from a single ColorStyle and no effect.

Source

pub const fn inherit_parent() -> Style

Uses ColorType::InheritParent for both front and background.

Source

pub const fn terminal_default() -> Style

Style set by terminal before entering a Cursive program.

Source

pub const fn background() -> Style

Application background, where no view is present.

Source

pub const fn shadow() -> Style

Color used by view shadows. Only background matters.

Source

pub const fn view() -> Style

Style used for views.

Source

pub const fn primary() -> Style

Main text with default background.

Source

pub const fn secondary() -> Style

Secondary text color, with default background.

Source

pub const fn tertiary() -> Style

Tertiary text color, with default background.

Source

pub const fn title_primary() -> Style

Title text color with default background.

Source

pub const fn title_secondary() -> Style

Alternative color for a title.

Source

pub const fn highlight() -> Style

Returns a highlight style.

Source

pub const fn highlight_inactive() -> Style

Returns an inactive highlight style.

Source

pub fn resolve( &self, palette: &Palette, previous: ConcreteStyle, ) -> ConcreteStyle

Resolve a style to a concrete style.

Trait Implementations§

Source§

impl AsRef<Style> for Style

Source§

fn as_ref(&self) -> &Style

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Style

Source§

fn default() -> Style

Returns the “default value” for a type. Read more
Source§

impl From<Color> for Style

Source§

fn from(color: Color) -> Style

Converts to this type from the input type.
Source§

impl From<ColorPair> for Style

Source§

fn from(color: ColorPair) -> Style

Converts to this type from the input type.
Source§

impl From<ColorStyle> for Style

Source§

fn from(color: ColorStyle) -> Style

Converts to this type from the input type.
Source§

impl From<ColorType> for Style

Source§

fn from(color: ColorType) -> Style

Converts to this type from the input type.
Source§

impl From<Effect> for Style

Source§

fn from(effect: Effect) -> Style

Converts to this type from the input type.
Source§

impl From<Effects> for Style

Source§

fn from(effects: Effects) -> Style

Converts to this type from the input type.
Source§

impl From<PaletteColor> for Style

Source§

fn from(color: PaletteColor) -> Style

Converts to this type from the input type.
Source§

impl From<Style> for StyleType

Source§

fn from(style: Style) -> StyleType

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a Style> for Style

Creates a new Style by merging all given styles.

Will use the last non-None color, and will combine all effects.

Source§

fn from_iter<I>(iter: I) -> Style
where I: IntoIterator<Item = &'a Style>,

Creates a value from an iterator. Read more
Source§

impl<T> FromIterator<T> for Style
where T: Into<Style>,

Creates a new Style by merging all given styles.

Will use the last non-None color, and will combine all effects.

Source§

fn from_iter<I>(iter: I) -> Style
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

impl FromStr for Style

Source§

type Err = NoSuchColor

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Style, <Style as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Style

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Style

Source§

fn eq(&self, other: &Style) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Resolvable for Style

Source§

fn from_config(config: &Value, context: &Context) -> Result<Style, Error>
where Style: Sized,

Build from a config (a JSON value). Read more
Source§

fn from_any(any: Box<dyn Any>) -> Option<Self>
where Self: Sized + Any,

Build from an Any variable. Read more
Source§

impl Copy for Style

Source§

impl Eq for Style

Source§

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnwindSafe for Style

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F>(self, f: F) -> U
where F: FnOnce(Self) -> U,

Calls the given closure and return the result. Read more
Source§

fn with<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.