pub struct Paint<T> {
pub item: T,
pub style: Style,
}Expand description
A structure encapsulating an item and styling.
Fields§
§item: T§style: StyleImplementations§
Source§impl<T> Paint<T>
impl<T> Paint<T>
Sourcepub const fn new(item: T) -> Paint<T>
pub const fn new(item: T) -> Paint<T>
Constructs a new Paint structure encapsulating item with no set
styling.
Sourcepub const fn wrapping(item: T) -> Paint<T>
pub const fn wrapping(item: T) -> Paint<T>
Constructs a new wrapping Paint structure encapsulating item with
default styling.
A wrapping Paint 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.
Sourcepub const fn rgb(r: u8, g: u8, b: u8, item: T) -> Paint<T>
pub const fn rgb(r: u8, g: u8, b: u8, item: T) -> Paint<T>
Constructs a new Paint structure encapsulating item with the
foreground color set to the RGB color r, g, b.
Sourcepub const fn fixed(color: u8, item: T) -> Paint<T>
pub const fn fixed(color: u8, item: T) -> Paint<T>
Constructs a new Paint structure encapsulating item with the
foreground color set to the fixed 8-bit color color.
pub const fn red(item: T) -> Paint<T>
pub const fn black(item: T) -> Paint<T>
pub const fn yellow(item: T) -> Paint<T>
pub const fn green(item: T) -> Paint<T>
pub const fn cyan(item: T) -> Paint<T>
pub const fn blue(item: T) -> Paint<T>
pub const fn magenta(item: T) -> Paint<T>
pub const fn white(item: T) -> Paint<T>
Sourcepub fn with_style(self, style: Style) -> Paint<T>
pub fn with_style(self, style: Style) -> Paint<T>
Sets the style of self to style.
Sourcepub const fn wrap(self) -> Paint<T>
pub const fn wrap(self) -> Paint<T>
Makes self a wrapping Paint.
A wrapping Paint 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
pub fn blink(self) -> Self
Source§impl Paint<()>
impl Paint<()>
Sourcepub fn is_enabled() -> bool
pub fn is_enabled() -> bool
Returns true if coloring is enabled and false otherwise.
Sourcepub fn set_terminal(tf: TerminalFile)
pub fn set_terminal(tf: TerminalFile)
Set the terminal we are writing to. This influences the logic that checks whether or not to include colors.