[−][src]Struct tui::style::Style
Style let you control the main characteristics of the displayed elements.
Examples
Style::default() .fg(Color::Black) .bg(Color::Green) .add_modifier(Modifier::ITALIC | Modifier::BOLD);
Fields
fg: Option<Color>
bg: Option<Color>
add_modifier: Modifier
sub_modifier: Modifier
Implementations
impl Style
[src]
pub fn fg(self, color: Color) -> Style
[src]
Changes the foreground color.
Examples
let style = Style::default().fg(Color::Blue); let diff = Style::default().fg(Color::Red); assert_eq!(style.patch(diff), Style::default().fg(Color::Red));
pub fn bg(self, color: Color) -> Style
[src]
Changes the background color.
Examples
let style = Style::default().bg(Color::Blue); let diff = Style::default().bg(Color::Red); assert_eq!(style.patch(diff), Style::default().bg(Color::Red));
pub fn add_modifier(self, modifier: Modifier) -> Style
[src]
Changes the text emphasis.
When applied, it adds the given modifier to the Style
modifiers.
Examples
let style = Style::default().add_modifier(Modifier::BOLD); let diff = Style::default().add_modifier(Modifier::ITALIC); let patched = style.patch(diff); assert_eq!(patched.add_modifier, Modifier::BOLD | Modifier::ITALIC); assert_eq!(patched.sub_modifier, Modifier::empty());
pub fn remove_modifier(self, modifier: Modifier) -> Style
[src]
Changes the text emphasis.
When applied, it removes the given modifier from the Style
modifiers.
Examples
let style = Style::default().add_modifier(Modifier::BOLD | Modifier::ITALIC); let diff = Style::default().remove_modifier(Modifier::ITALIC); let patched = style.patch(diff); assert_eq!(patched.add_modifier, Modifier::BOLD); assert_eq!(patched.sub_modifier, Modifier::ITALIC);
pub fn patch(self, other: Style) -> Style
[src]
Results in a combined style that is equivalent to applying the two individual styles to a style one after the other.
Examples
let style_1 = Style::default().fg(Color::Yellow); let style_2 = Style::default().bg(Color::Red); let combined = style_1.patch(style_2); assert_eq!( Style::default().patch(style_1).patch(style_2), Style::default().patch(combined));
Trait Implementations
impl Clone for Style
[src]
impl Copy for Style
[src]
impl Debug for Style
[src]
impl Default for Style
[src]
impl PartialEq<Style> for Style
[src]
impl StructuralPartialEq for Style
[src]
Auto Trait Implementations
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,