pub struct Style { /* private fields */ }Expand description
A terminal style.
Supports foreground color, background color, attributes, and an optional
hyperlink. Attributes use a three-state system: set to true, set to
false, or not set (None).
Implementations§
Source§impl Style
impl Style
Sourcepub fn underline2(self, value: bool) -> Self
pub fn underline2(self, value: bool) -> Self
Builder: set double underline.
Sourcepub fn without_color(&self) -> Self
pub fn without_color(&self) -> Self
Return a copy with foreground and background colors stripped.
Sourcepub fn background_style(&self) -> Self
pub fn background_style(&self) -> Self
Return a style with the background color set to the foreground color, useful for background-only rendering.
Sourcepub fn transparent_background(&self) -> bool
pub fn transparent_background(&self) -> bool
Returns true if the background is not set (transparent).
Sourcepub fn from_str(definition: &str) -> Self
pub fn from_str(definition: &str) -> Self
Builder: set style from a string (e.g. “bold red on blue”).
Sourcepub fn is_plain(&self) -> bool
pub fn is_plain(&self) -> bool
Returns true if this style has no colors, attributes, or link set.
Sourcepub fn get_italic(&self) -> Option<bool>
pub fn get_italic(&self) -> Option<bool>
Check if the italic attribute is explicitly set to true.
Sourcepub fn combine(&self, other: &Style) -> Style
pub fn combine(&self, other: &Style) -> Style
Merge two styles: self is the base, other overrides.
Sourcepub fn reset_ansi(&self) -> &'static str
pub fn reset_ansi(&self) -> &'static str
Return the ANSI reset sequence needed to turn off this style.
Sourcepub fn chain(&self, other: &Style) -> Style
pub fn chain(&self, other: &Style) -> Style
Create a chain-of-styles fallback. When self has a value set, use it;
otherwise fall through to other.
Sourcepub fn clear_meta_and_links(&mut self) -> &mut Self
pub fn clear_meta_and_links(&mut self) -> &mut Self
Clear the meta field and link field, returning self for chaining.
Sourcepub fn from_color(color: Color) -> Self
pub fn from_color(color: Color) -> Self
Create a style with just a foreground color set.
Sourcepub fn get_html_style(&self, _theme: Option<&ExportTheme>) -> String
pub fn get_html_style(&self, _theme: Option<&ExportTheme>) -> String
Generate CSS style string for HTML export.
Sourcepub fn normalize(&self) -> Style
pub fn normalize(&self) -> Style
Return a “normalized” style: remove negative (explicitly false) attributes that just reset inherited ones. Only keep explicitly true attributes and colors.
Sourcepub fn pick_first(&self) -> Option<&'static str>
pub fn pick_first(&self) -> Option<&'static str>
Return the “first” significant color name for display purposes (fg color name, or bg color name, or None).
Sourcepub fn test(&self, text: Option<&str>) -> String
pub fn test(&self, text: Option<&str>) -> String
Render a test/demo string. If text is None, use “Lorem ipsum”.
Sourcepub fn update_link(&mut self, url: Option<String>) -> &mut Self
pub fn update_link(&mut self, url: Option<String>) -> &mut Self
Update or clear the link, returning self for chaining.
Sourcepub fn set_meta(&mut self, meta: Option<Vec<u8>>) -> &mut Self
pub fn set_meta(&mut self, meta: Option<Vec<u8>>) -> &mut Self
Set metadata, returning self for chaining.
Sourcepub fn on(self, color: impl Into<Option<Color>>) -> Self
pub fn on(self, color: impl Into<Option<Color>>) -> Self
Alias for bgcolor() (Python rich has both .on() and .bgcolor()).
Sourcepub fn bgcolor_ref(&self) -> Option<&Color>
pub fn bgcolor_ref(&self) -> Option<&Color>
Get a reference to the background color.
Trait Implementations§
impl Eq 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 UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more