Struct pretty_exec_lib::logger::syntax_highlight::Style [−][src]
pub struct Style {
pub foreground: Option<Colour>,
pub background: Option<Colour>,
pub is_bold: bool,
pub is_dimmed: bool,
pub is_italic: bool,
pub is_underline: bool,
pub is_blink: bool,
pub is_reverse: bool,
pub is_hidden: bool,
pub is_strikethrough: bool,
}Expand description
A style is a collection of properties that can format a string using ANSI escape codes.
Examples
use ansi_term::{Style, Colour}; let style = Style::new().bold().on(Colour::Black); println!("{}", style.paint("Bold on black"));
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: boolWhether this style is bold.
is_dimmed: boolWhether this style is dimmed.
is_italic: boolWhether this style is italic.
is_underline: boolWhether this style is underlined.
is_blink: boolWhether this style is blinking.
is_reverse: boolWhether this style has reverse colours.
Whether this style is hidden.
is_strikethrough: boolWhether this style is struckthrough.
Implementations
impl Style[src]
impl Style[src]pub fn prefix(self) -> Prefix[src]
pub fn prefix(self) -> Prefix[src]The prefix bytes for this style. These are the bytes that tell the terminal to use a different colour or font style.
Examples
use ansi_term::{Style, Colour::Blue}; let style = Style::default().bold(); assert_eq!("\x1b[1m", style.prefix().to_string()); let style = Blue.bold(); assert_eq!("\x1b[1;34m", style.prefix().to_string()); let style = Style::default(); assert_eq!("", style.prefix().to_string());
pub fn infix(self, next: Style) -> Infix[src]
pub fn infix(self, next: Style) -> Infix[src]The infix bytes between this style and next style. These are the bytes
that tell the terminal to change the style to next. These may include
a reset followed by the next colour and style, depending on the two styles.
Examples
use ansi_term::{Style, Colour::Green}; let style = Style::default().bold(); assert_eq!("\x1b[32m", style.infix(Green.bold()).to_string()); let style = Green.normal(); assert_eq!("\x1b[1m", style.infix(Green.bold()).to_string()); let style = Style::default(); assert_eq!("", style.infix(style).to_string());
pub fn suffix(self) -> Suffix[src]
pub fn suffix(self) -> Suffix[src]The suffix for this style. These are the bytes that tell the terminal to reset back to its normal colour and font style.
Examples
use ansi_term::{Style, Colour::Green}; let style = Style::default().bold(); assert_eq!("\x1b[0m", style.suffix().to_string()); let style = Green.normal().bold(); assert_eq!("\x1b[0m", style.suffix().to_string()); let style = Style::default(); assert_eq!("", style.suffix().to_string());
impl Style[src]
impl Style[src]pub fn new() -> Style[src]
pub fn new() -> Style[src]Creates a new Style with no properties set.
Examples
use ansi_term::Style; let style = Style::new(); println!("{}", style.paint("hi"));
pub fn bold(&self) -> Style[src]
pub fn bold(&self) -> Style[src]Returns a Style with the bold property set.
Examples
use ansi_term::Style; let style = Style::new().bold(); println!("{}", style.paint("hey"));
pub fn dimmed(&self) -> Style[src]
pub fn dimmed(&self) -> Style[src]Returns a Style with the dimmed property set.
Examples
use ansi_term::Style; let style = Style::new().dimmed(); println!("{}", style.paint("sup"));
pub fn italic(&self) -> Style[src]
pub fn italic(&self) -> Style[src]Returns a Style with the italic property set.
Examples
use ansi_term::Style; let style = Style::new().italic(); println!("{}", style.paint("greetings"));
pub fn underline(&self) -> Style[src]
pub fn underline(&self) -> Style[src]Returns a Style with the underline property set.
Examples
use ansi_term::Style; let style = Style::new().underline(); println!("{}", style.paint("salutations"));
pub fn blink(&self) -> Style[src]
pub fn blink(&self) -> Style[src]Returns a Style with the blink property set.
Examples
use ansi_term::Style; let style = Style::new().blink(); println!("{}", style.paint("wazzup"));
pub fn reverse(&self) -> Style[src]
pub fn reverse(&self) -> Style[src]Returns a Style with the reverse property set.
Examples
use ansi_term::Style; let style = Style::new().reverse(); println!("{}", style.paint("aloha"));
pub fn hidden(&self) -> Style[src]
pub fn hidden(&self) -> Style[src]Returns a Style with the hidden property set.
Examples
use ansi_term::Style; let style = Style::new().hidden(); println!("{}", style.paint("ahoy"));
pub fn strikethrough(&self) -> Style[src]
pub fn strikethrough(&self) -> Style[src]Returns a Style with the strikethrough property set.
Examples
use ansi_term::Style; let style = Style::new().strikethrough(); println!("{}", style.paint("yo"));
pub fn fg(&self, foreground: Colour) -> Style[src]
pub fn fg(&self, foreground: Colour) -> Style[src]Returns a Style with the foreground colour property set.
Examples
use ansi_term::{Style, Colour}; let style = Style::new().fg(Colour::Yellow); println!("{}", style.paint("hi"));
Trait Implementations
impl Debug for Style[src]
impl Debug for Style[src]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()));
impl Default for Style[src]
impl Default for Style[src]pub fn default() -> Style[src]
pub fn default() -> Style[src]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 From<Colour> for Style[src]
impl From<Colour> for Style[src]pub fn from(colour: Colour) -> Style[src]
pub fn from(colour: Colour) -> Style[src]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 Copy for Style[src]
impl StructuralPartialEq for Style[src]
Auto Trait Implementations
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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<X> Pipe for X[src]
impl<X> Pipe for X[src]fn pipe<Return, Function>(self, f: Function) -> Return where
Function: FnOnce(Self) -> Return, [src]
fn pipe<Return, Function>(self, f: Function) -> Return where
Function: FnOnce(Self) -> Return, [src]Apply f to self. Read more
fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return where
Function: FnOnce(&'a Self) -> Return, [src]
fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return where
Function: FnOnce(&'a Self) -> Return, [src]Apply f to &self. Read more
fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return where
Function: FnOnce(&'a mut Self) -> Return, [src]
fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return where
Function: FnOnce(&'a mut Self) -> Return, [src]Apply f to &mut self. Read more
fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: AsRef<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return, [src]
fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: AsRef<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return, [src]Apply f to &self where f takes a single parameter of type Param
and Self implements trait AsRef<Param>. Read more
fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return where
Self: AsMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return, [src]
fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return where
Self: AsMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return, [src]Apply f to &mut self where f takes a single parameter of type Param
and Self implements trait AsMut<Param>. Read more
fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Deref<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return, [src]
fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Deref<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return, [src]Apply f to &self where f takes a single parameter of type Param
and Self implements trait Deref<Param>. Read more
fn pipe_deref_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: DerefMut<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return, [src]
fn pipe_deref_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: DerefMut<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return, [src]Apply f to &mut self where f takes a single parameter of type Param
and Self implements trait DerefMut<Param>. Read more
fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Borrow<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return, [src]
fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Borrow<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return, [src]Apply f to &self where f takes a single parameter of type Param
and Self implements trait Deref<Param>. Read more
fn pipe_borrow_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: BorrowMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return, [src]
fn pipe_borrow_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: BorrowMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return, [src]Apply f to &mut self where f takes a single parameter of type Param
and Self implements trait DerefMut<Param>. Read more
impl<X> Pipe for X[src]
impl<X> Pipe for X[src]impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe 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