[−][src]Struct ansi_term::Style
A style is a collection of properties that can format a string using ANSI escape codes.
Fields
foreground: Option<Colour>
The style's foreground colour, if it has one.
background: Option<Colour>
The style's background colour, if it has one.
is_bold: bool
Whether this style is bold.
is_dimmed: bool
Whether this style is dimmed.
is_italic: bool
Whether this style is italic.
is_underline: bool
Whether this style is underlined.
is_blink: bool
Whether this style is blinking.
is_reverse: bool
Whether this style has reverse colours.
Whether this style is hidden.
is_strikethrough: bool
Whether this style is struckthrough.
Methods
impl Style
[src]
impl Style
pub fn prefix(self) -> Prefix
[src]
pub fn prefix(self) -> Prefix
The prefix for this style.
pub fn infix(self, other: Style) -> Infix
[src]
pub fn infix(self, other: Style) -> Infix
The infix between this style and another.
pub fn suffix(self) -> Suffix
[src]
pub fn suffix(self) -> Suffix
The suffix for this style.
impl Style
[src]
impl Style
pub fn new() -> Style
[src]
pub fn new() -> Style
Creates a new Style with no differences.
pub fn bold(&self) -> Style
[src]
pub fn bold(&self) -> Style
Returns a Style
with the bold property set.
pub fn dimmed(&self) -> Style
[src]
pub fn dimmed(&self) -> Style
Returns a Style
with the dimmed property set.
pub fn italic(&self) -> Style
[src]
pub fn italic(&self) -> Style
Returns a Style
with the italic property set.
pub fn underline(&self) -> Style
[src]
pub fn underline(&self) -> Style
Returns a Style
with the underline property set.
pub fn blink(&self) -> Style
[src]
pub fn blink(&self) -> Style
Returns a Style
with the blink property set.
pub fn reverse(&self) -> Style
[src]
pub fn reverse(&self) -> Style
Returns a Style
with the reverse property set.
Returns a Style
with the hidden property set.
pub fn strikethrough(&self) -> Style
[src]
pub fn strikethrough(&self) -> Style
Returns a Style
with the hidden property set.
pub fn fg(&self, foreground: Colour) -> Style
[src]
pub fn fg(&self, foreground: Colour) -> Style
Returns a Style
with the foreground colour property set.
pub fn on(&self, background: Colour) -> Style
[src]
pub fn on(&self, background: Colour) -> Style
Returns a Style
with the background colour property set.
pub fn is_plain(self) -> bool
[src]
pub fn is_plain(self) -> bool
Return true if this Style
has no actual styles, and can be written
without any control characters.
impl Style
[src]
impl Style
pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(
self,
input: I
) -> ANSIGenericString<'a, S> where
I: Into<Cow<'a, S>>,
<S as ToOwned>::Owned: Debug,
[src]
pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(
self,
input: I
) -> ANSIGenericString<'a, S> where
I: Into<Cow<'a, S>>,
<S as ToOwned>::Owned: Debug,
Paints the given text with this colour, returning an ANSI string.
Trait Implementations
impl Clone for Style
[src]
impl Clone for Style
fn clone(&self) -> Style
[src]
fn clone(&self) -> Style
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)
Performs copy-assignment from source
. Read more
impl Copy for Style
[src]
impl Copy for Style
impl From<Colour> for Style
[src]
impl From<Colour> for Style
fn from(colour: Colour) -> Style
[src]
fn from(colour: Colour) -> Style
You can turn a Colour
into a Style
with the foreground colour set
with the From
trait.
use ansi_term::{Style, Colour}; let green_foreground = Style::default().fg(Colour::Green); assert_eq!(green_foreground, Colour::Green.normal()); assert_eq!(green_foreground, Colour::Green.into()); assert_eq!(green_foreground, Style::from(Colour::Green));
impl Default for Style
[src]
impl Default for Style
fn default() -> Style
[src]
fn default() -> Style
Returns a style with no properties set. Formatting text using this style returns the exact same text.
use ansi_term::Style; assert_eq!(None, Style::default().foreground); assert_eq!(None, Style::default().background); assert_eq!(false, Style::default().is_bold); assert_eq!("txt", Style::default().paint("txt").to_string());
impl PartialEq<Style> for Style
[src]
impl PartialEq<Style> for Style
fn eq(&self, other: &Style) -> bool
[src]
fn eq(&self, other: &Style) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Style) -> bool
[src]
fn ne(&self, other: &Style) -> bool
This method tests for !=
.
impl Debug for Style
[src]
impl Debug for Style
Styles have a special Debug
implementation that only shows the fields that
are set. Fields that haven’t been touched aren’t included in the output.
This behaviour gets bypassed when using the alternate formatting mode
format!("{:#?}")
.
use ansi_term::Colour::{Red, Blue}; assert_eq!("Style { fg(Red), on(Blue), bold, italic }", format!("{:?}", Red.on(Blue).bold().italic()));
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more