pub struct Style { /* private fields */ }Expand description
A structure representing text styling with effects and colors.
Implementations§
Source§impl Style
impl Style
Sourcepub fn set_effect(self, effect: impl Into<Effect>, value: bool) -> Self
pub fn set_effect(self, effect: impl Into<Effect>, value: bool) -> Self
Sets the given effect to the specified value.
Sourcepub fn get_effect(&self, effect: impl Into<Effect>) -> bool
pub fn get_effect(&self, effect: impl Into<Effect>) -> bool
Gets whether the given effect is set.
Sourcepub fn get_effects(&self) -> GetEffects ⓘ
pub fn get_effects(&self) -> GetEffects ⓘ
Returns an iterator over the effects that are currently set.
Sourcepub fn set_underline_effect(
self,
underline_effect: Option<UnderlineEffect>,
) -> Self
pub fn set_underline_effect( self, underline_effect: Option<UnderlineEffect>, ) -> Self
Sets the underline effect.
Sourcepub fn get_underline_effect(&self) -> Option<UnderlineEffect>
pub fn get_underline_effect(&self) -> Option<UnderlineEffect>
Gets the underline effect.
Sourcepub fn set_color(
self,
target: ColorTarget,
color: Option<impl Into<Color>>,
) -> Self
pub fn set_color( self, target: ColorTarget, color: Option<impl Into<Color>>, ) -> Self
Sets the color for the given color target.
To clear the color for some color target, the color type must be specified in the None value.
To help with that, the Color::none() method can be used:
style.set_color(ColorTarget::Foreground, None::<Color>);
// or
style.set_color(ColorTarget::Foreground, Color::none());Sourcepub fn get_color(&self, target: ColorTarget) -> Option<Color>
pub fn get_color(&self, target: ColorTarget) -> Option<Color>
Gets the color for the given color target.
Sourcepub fn set<A: StylingAttribute<Self>>(self, attr: A, value: A::Value) -> Self
pub fn set<A: StylingAttribute<Self>>(self, attr: A, value: A::Value) -> Self
Sets the given attribute to the specified value.
Sourcepub fn get<A: StylingAttribute<Self>>(&self, attr: A) -> A::Value
pub fn get<A: StylingAttribute<Self>>(&self, attr: A) -> A::Value
Gets the value of the given attribute.
Sourcepub fn remove<A: StylingAttribute<Self>>(self, attr: A) -> Self
pub fn remove<A: StylingAttribute<Self>>(self, attr: A) -> Self
Clears the given attribute.
Source§impl Style
impl Style
Sourcepub fn underline(self) -> Style
pub fn underline(self) -> Style
An alias for Self::solid_underline().
Sourcepub fn solid_underline(self) -> Style
pub fn solid_underline(self) -> Style
Sets the solid underline effect.
Sourcepub fn curly_underline(self) -> Style
pub fn curly_underline(self) -> Style
Sets the curly underline effect.
Sourcepub fn dotted_underline(self) -> Style
pub fn dotted_underline(self) -> Style
Sets the dotted underline effect.
Sourcepub fn dashed_underline(self) -> Style
pub fn dashed_underline(self) -> Style
Sets the dashed underline effect.
Sourcepub fn strikethrough(self) -> Style
pub fn strikethrough(self) -> Style
Sets the strikethrough effect.
Sourcepub fn double_underline(self) -> Style
pub fn double_underline(self) -> Style
Sets the double underline effect.
Sourcepub fn underline_effect(self, underline_effect: UnderlineEffect) -> Style
pub fn underline_effect(self, underline_effect: UnderlineEffect) -> Style
Sets the underline effect.
Sourcepub fn underline_color(self, color: impl Into<Color>) -> Style
pub fn underline_color(self, color: impl Into<Color>) -> Style
Sets the underline color.
Sourcepub fn color(self, targeted_color: impl Into<TargetedColor>) -> Style
pub fn color(self, targeted_color: impl Into<TargetedColor>) -> Style
Sets the given color in a target.
Sourcepub fn add(self, element: impl StylingElement<Style>) -> Style
pub fn add(self, element: impl StylingElement<Style>) -> Style
Adds the given element to the style.
Sourcepub fn applied_to<C: Display>(self, content: C) -> Styled<C>
pub fn applied_to<C: Display>(self, content: C) -> Styled<C>
Applies the styling to the given content, returning a Styled<C> instance.