pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub underline_color: Option<Color>,
pub add_modifier: Modifier,
pub sub_modifier: Modifier,
}Expand description
A complete style specification for text or widgets.
Styles can be composed and merged, with later values taking precedence.
§Example
use tuxtui_core::style::{Color, Style, Modifier};
let style = Style::default()
.fg(Color::Blue)
.bg(Color::Black)
.add_modifier(Modifier::BOLD);Fields§
§fg: Option<Color>Foreground color
bg: Option<Color>Background color
underline_color: Option<Color>Available on crate feature
underline-color only.Underline color (if underline-color feature enabled)
add_modifier: ModifierText modifiers
sub_modifier: ModifierModifiers to remove
Implementations§
Source§impl Style
impl Style
Sourcepub const fn underline_color(self, color: Color) -> Self
Available on crate feature underline-color only.
pub const fn underline_color(self, color: Color) -> Self
underline-color only.Set the underline color (requires underline-color feature).
Sourcepub const fn add_modifier(self, modifier: Modifier) -> Self
pub const fn add_modifier(self, modifier: Modifier) -> Self
Add modifiers.
Sourcepub const fn remove_modifier(self, modifier: Modifier) -> Self
pub const fn remove_modifier(self, modifier: Modifier) -> Self
Remove modifiers.
Sourcepub const fn patch(self, other: Self) -> Self
pub const fn patch(self, other: Self) -> Self
Patch this style with another, taking non-None values from other.
§Example
use tuxtui_core::style::{Color, Style};
let base = Style::default().fg(Color::Red);
let patch = Style::default().bg(Color::Blue);
let merged = base.patch(patch);
assert_eq!(merged.fg, Some(Color::Red));
assert_eq!(merged.bg, Some(Color::Blue));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>,
Deserialize this value from the given Serde deserializer. Read more
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 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
Mutably borrows from an owned value. Read more
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.