pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub modifiers: Modifiers,
pub underline_color: Option<Color>,
pub underline_style: UnderlineStyle,
}Expand description
Visual style for a terminal cell (foreground, background, modifiers).
Styles are applied to text via the builder methods on Context widget
calls (e.g., .bold(), .fg(Color::Cyan)). All fields are optional;
None means “inherit from the terminal default.”
§Example
use slt::{Style, Color};
let style = Style::new().fg(Color::Cyan).bold();Fields§
§fg: Option<Color>Foreground color, or None to use the terminal default.
bg: Option<Color>Background color, or None to use the terminal default.
modifiers: ModifiersText modifiers (bold, italic, underline, etc.).
underline_color: Option<Color>Underline color, or None to use the same color as the foreground.
Emitted as SGR 58 when set and SGR 59 (reset to foreground) when
cleared. Requires a terminal that supports separate underline colors.
underline_style: UnderlineStyleUnderline rendering style (straight, curly, dotted, etc.).
Defaults to UnderlineStyle::Straight. Non-straight styles are
emitted as CSI 4:Nm and require terminal support.
Implementations§
Source§impl Style
impl Style
Sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Add the strikethrough modifier.
Sourcepub const fn underline_color(self, color: Color) -> Self
pub const fn underline_color(self, color: Color) -> Self
Set a separate underline color.
Setting this implies the Modifiers::UNDERLINE bit so the
underline is actually rendered. Emitted as SGR 58.
§Example
use slt::{Color, Modifiers, Style};
let s = Style::new().underline_color(Color::Red);
assert!(s.modifiers.contains(Modifiers::UNDERLINE));Sourcepub const fn underline_style(self, style: UnderlineStyle) -> Self
pub const fn underline_style(self, style: UnderlineStyle) -> Self
Set the underline rendering style (straight, curly, dotted, etc.).
Setting a style implies the Modifiers::UNDERLINE bit so the
underline is actually rendered. Emitted as CSI 4:Nm.
§Example
use slt::{Modifiers, Style, UnderlineStyle};
let s = Style::new().underline_style(UnderlineStyle::Curly);
assert!(s.modifiers.contains(Modifiers::UNDERLINE));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Style
impl<'de> Deserialize<'de> for Style
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for Style
impl Eq for Style
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 UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.