#[repr(C, packed(1))]pub struct Style { /* private fields */ }
Expand description
Represents a set of styling options.
Implementations§
Source§impl Style
impl Style
Sourcepub const fn new(color: Color) -> Style
pub const fn new(color: Color) -> Style
Default style with the foreground set to color
and no other set
properties.
Sourcepub fn merge(self, other: Style) -> Style
pub fn merge(self, other: Style) -> Style
Merge styles with other. This is an additive process, so colors will only be changed if they aren’t set on the receiver object.
Sourcepub const fn wrap(self) -> Style
pub const fn wrap(self) -> Style
Sets self
to be wrapping.
A wrapping Style
converts all color resets written out by the internal
value to the styling of itself. This allows for seamless color wrapping
of other colored text.
§Performance
In order to wrap an internal value, the internal value must first be written out to a local buffer and examined. As a result, displaying a wrapped value is likely to result in a heap allocation and copy.
pub fn bold(self) -> Self
pub fn dim(self) -> Self
pub fn italic(self) -> Self
pub fn underline(self) -> Self
pub fn invert(self) -> Self
pub fn strikethrough(self) -> Self
Sourcepub fn paint<T>(self, item: T) -> Paint<T>
pub fn paint<T>(self, item: T) -> Paint<T>
Constructs a new Paint
structure that encapsulates item
with the
style set to self
.
Sourcepub const fn is_wrapping(&self) -> bool
pub const fn is_wrapping(&self) -> bool
Returns true
if self
is wrapping.
Sourcepub fn fmt_prefix(&self, f: &mut dyn Write) -> Result
pub fn fmt_prefix(&self, f: &mut dyn Write) -> Result
Writes the ANSI code prefix for the currently set styles.
This method is intended to be used inside of fmt::Display
and
fmt::Debug
implementations for custom or specialized use-cases. Most
users should use Paint
for all painting needs.
This method writes the ANSI code prefix irrespective of whether painting
is currently enabled or disabled. To write the prefix only if painting
is enabled, condition a call to this method on Paint::is_enabled()
.
Sourcepub fn fmt_suffix(&self, f: &mut dyn Write) -> Result
pub fn fmt_suffix(&self, f: &mut dyn Write) -> Result
Writes the ANSI code suffix for the currently set styles.
This method is intended to be used inside of fmt::Display
and
fmt::Debug
implementations for custom or specialized use-cases. Most
users should use Paint
for all painting needs.
This method writes the ANSI code suffix irrespective of whether painting
is currently enabled or disabled. To write the suffix only if painting
is enabled, condition a call to this method on Paint::is_enabled()
.