[][src]Struct unsegen::base::style::StyleModifier

pub struct StyleModifier { /* fields omitted */ }

Defines a set of modifications on a style. Multiple modifiers can be combined before applying them to a style.

Implementations

impl StyleModifier[src]

pub fn new() -> Self[src]

Construct a new (not actually) modifier, that leaves all style properties unchanged.

pub fn fg_color(self, fg_color: Color) -> Self[src]

Make the modifier change the foreground color to the specified value.

pub fn bg_color(self, bg_color: Color) -> Self[src]

Make the modifier change the background color to the specified value.

pub fn format(self, format: TextFormatModifier) -> Self[src]

Make the modifier change the textformat of the style to the specified value.

pub fn bold<M: Into<BoolModifyMode>>(self, val: M) -> Self[src]

Make the modifier change the bold property of the textformat of the style to the specified value.

This is a shortcut for using format using a TextFormatModifier that changes the bold property.

Examples:

use unsegen::base::{StyleModifier, TextFormatModifier};

let s1 = StyleModifier::new().bold(true);
let s2 = StyleModifier::new().format(TextFormatModifier::new().bold(true));

assert_eq!(s1, s2);

pub fn italic<M: Into<BoolModifyMode>>(self, val: M) -> Self[src]

Make the modifier change the italic property of the textformat of the style to the specified value.

This is a shortcut for using format using a TextFormatModifier that changes the italic property.

Examples:

use unsegen::base::{StyleModifier, TextFormatModifier};

let s1 = StyleModifier::new().italic(true);
let s2 = StyleModifier::new().format(TextFormatModifier::new().italic(true));

assert_eq!(s1, s2);

pub fn invert<M: Into<BoolModifyMode>>(self, val: M) -> Self[src]

Make the modifier change the invert property of the textformat of the style to the specified value.

This is a shortcut for using format using a TextFormatModifier that changes the invert property.

Examples:

use unsegen::base::{StyleModifier, TextFormatModifier};

let s1 = StyleModifier::new().invert(true);
let s2 = StyleModifier::new().format(TextFormatModifier::new().invert(true));

assert_eq!(s1, s2);

pub fn underline<M: Into<BoolModifyMode>>(self, val: M) -> Self[src]

Make the modifier change the underline property of the textformat of the style to the specified value.

This is a shortcut for using format using a TextFormatModifier that changes the underline property.

Examples:

use unsegen::base::{StyleModifier, TextFormatModifier};

let s1 = StyleModifier::new().underline(true);
let s2 = StyleModifier::new().format(TextFormatModifier::new().underline(true));

assert_eq!(s1, s2);

pub fn on_top_of(self, other: StyleModifier) -> Self[src]

Combine the current value with that of the argument so that the application of the returned value is always equivalent to first applying other and then applying self to some Style.

Examples:

use unsegen::base::*;

let mut s1 = Style::default();
let mut s2 = s1;

let m1 =
StyleModifier::new().fg_color(Color::Red).italic(BoolModifyMode::Toggle).bold(true).underline(false);
let m2 = StyleModifier::new().bg_color(Color::Blue).italic(true).bold(false);

m1.on_top_of(m2).modify(&mut s1);

m2.modify(&mut s2);
m1.modify(&mut s2);

assert_eq!(s1, s2);

pub fn apply_to_default(self) -> Style[src]

Apply the modifier to a default (i.e., empty) Style. In a way, this converts the StyleModifier to a Style.

Examples:

use unsegen::base::*;

let m = StyleModifier::new().fg_color(Color::Red).italic(true);
let mut style = Style::default();

assert_eq!(m.apply(style), m.apply_to_default());

pub fn apply(self, style: Style) -> Style[src]

Apply this modifier to a given style and return the result. This is essentially a convenience wrapper around modify, which clones the Style.

Examples:

use unsegen::base::*;

let m = StyleModifier::new().fg_color(Color::Red).italic(BoolModifyMode::Toggle);
let mut style = Style::default();
let style2 = m.apply(style);
m.modify(&mut style);

assert_eq!(style, style2);

pub fn modify(self, style: &mut Style)[src]

Modify the given style according to the properties of this modifier.

Trait Implementations

impl Clone for StyleModifier[src]

impl Copy for StyleModifier[src]

impl Debug for StyleModifier[src]

impl Default for StyleModifier[src]

impl Eq for StyleModifier[src]

impl PartialEq<StyleModifier> for StyleModifier[src]

impl StructuralEq for StyleModifier[src]

impl StructuralPartialEq for StyleModifier[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.