pub struct SimpleColor { /* private fields */ }Expand description
A simple color type representing the 16 basic terminal colors (8 basic colors + bright variants).
These colors are also available as associated BasicColor constants in the Color enum, which
can be turned into a SimpleColor value:
use fluent_ansi::{prelude::*, color::{BasicColor, SimpleColor}};
assert_eq!(Color::RED.to_simple_color(), SimpleColor::new(BasicColor::Red));
assert_eq!(Color::RED.bright(), SimpleColor::new_bright(BasicColor::Red));See Wikipedia’s article on 3-bit and 4-bit colors ANSI escape codes.
Implementations§
Source§impl SimpleColor
impl SimpleColor
Sourcepub const fn new(basic_color: BasicColor) -> Self
pub const fn new(basic_color: BasicColor) -> Self
Creates a new simple, non-bright color.
Sourcepub const fn new_bright(basic_color: BasicColor) -> Self
pub const fn new_bright(basic_color: BasicColor) -> Self
Creates a new bright simple color.
Sourcepub const fn get_basic_color(self) -> BasicColor
pub const fn get_basic_color(self) -> BasicColor
Returns the basic color of this simple color.
Source§impl SimpleColor
impl SimpleColor
Sourcepub fn for_fg(self) -> TargetedColor
pub fn for_fg(self) -> TargetedColor
Associate this color with the foreground plane.
Sourcepub fn for_bg(self) -> TargetedColor
pub fn for_bg(self) -> TargetedColor
Associate this color with the background plane.
Sourcepub fn for_underline(self) -> TargetedColor
pub fn for_underline(self) -> TargetedColor
Associate this color with the underline effect.
Sourcepub fn for_target(self, target: ColorTarget) -> TargetedColor
pub fn for_target(self, target: ColorTarget) -> TargetedColor
Associate this color with the specified color target.
Source§impl SimpleColor
impl SimpleColor
Sourcepub fn underline(self) -> Style
pub fn underline(self) -> Style
An alias for Self::solid_underline().
Sourcepub fn solid_underline(self) -> Style
pub fn solid_underline(self) -> Style
Sets the solid underline effect.
Sourcepub fn curly_underline(self) -> Style
pub fn curly_underline(self) -> Style
Sets the curly underline effect.
Sourcepub fn dotted_underline(self) -> Style
pub fn dotted_underline(self) -> Style
Sets the dotted underline effect.
Sourcepub fn dashed_underline(self) -> Style
pub fn dashed_underline(self) -> Style
Sets the dashed underline effect.
Sourcepub fn strikethrough(self) -> Style
pub fn strikethrough(self) -> Style
Sets the strikethrough effect.
Sourcepub fn double_underline(self) -> Style
pub fn double_underline(self) -> Style
Sets the double underline effect.
Sourcepub fn underline_effect(self, underline_effect: UnderlineEffect) -> Style
pub fn underline_effect(self, underline_effect: UnderlineEffect) -> Style
Sets the underline effect.
Sourcepub fn underline_color(self, color: impl Into<Color>) -> Style
pub fn underline_color(self, color: impl Into<Color>) -> Style
Sets the underline color.
Sourcepub fn color(self, targeted_color: impl Into<TargetedColor>) -> Style
pub fn color(self, targeted_color: impl Into<TargetedColor>) -> Style
Sets the given color in a target.
Sourcepub fn add(self, element: impl StylingElement<Style>) -> Style
pub fn add(self, element: impl StylingElement<Style>) -> Style
Adds the given element to the style.
Sourcepub fn applied_to<C: Display>(self, content: C) -> Styled<C>
pub fn applied_to<C: Display>(self, content: C) -> Styled<C>
Applies the styling to the given content, returning a Styled<C> instance.
Source§impl SimpleColor
impl SimpleColor
Sourcepub fn to_targeted_color(self) -> TargetedColor
pub fn to_targeted_color(self) -> TargetedColor
Converts the type into a TargetedColor
Trait Implementations§
Source§impl Clone for SimpleColor
impl Clone for SimpleColor
Source§fn clone(&self) -> SimpleColor
fn clone(&self) -> SimpleColor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more