Struct unsegen::base::style::StyleModifier [−][src]
pub struct StyleModifier { /* fields omitted */ }
Expand description
Defines a set of modifications on a style. Multiple modifiers can be combined before applying them to a style.
Implementations
impl StyleModifier
[src]
impl StyleModifier
[src]pub fn new() -> Self
[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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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);
Trait Implementations
impl Clone for StyleModifier
[src]
impl Clone for StyleModifier
[src]fn clone(&self) -> StyleModifier
[src]
fn clone(&self) -> StyleModifier
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl Debug for StyleModifier
[src]
impl Debug for StyleModifier
[src]impl Default for StyleModifier
[src]
impl Default for StyleModifier
[src]fn default() -> StyleModifier
[src]
fn default() -> StyleModifier
[src]Returns the “default value” for a type. Read more
impl PartialEq<StyleModifier> for StyleModifier
[src]
impl PartialEq<StyleModifier> for StyleModifier
[src]fn eq(&self, other: &StyleModifier) -> bool
[src]
fn eq(&self, other: &StyleModifier) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &StyleModifier) -> bool
[src]
fn ne(&self, other: &StyleModifier) -> bool
[src]This method tests for !=
.
impl Copy for StyleModifier
[src]
impl Eq for StyleModifier
[src]
impl StructuralEq for StyleModifier
[src]
impl StructuralPartialEq for StyleModifier
[src]
Auto Trait Implementations
impl RefUnwindSafe for StyleModifier
impl Send for StyleModifier
impl Sync for StyleModifier
impl Unpin for StyleModifier
impl UnwindSafe for StyleModifier
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more