pub struct StyleBuilder { /* private fields */ }Expand description
A helper struct for creating the Style object
Implementations§
Source§impl StyleBuilder
impl StyleBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new StyleBuilder struct for creating styles
Sets the hidden property to true
Sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Sets the strikethrough property to true
Examples found in repository?
3fn main() {
4 // You can either color the text directly with the Color enumeration
5 println!(
6 "{}Cyan colored \"Hello World!\"{}",
7 Color::Cyan.open(),
8 Color::Cyan.close()
9 );
10
11 // or you can use the builder function from within the Style stuct
12 // to create a style that can be used for more than one instance of
13 // a string and you wouldn't need to have an open and close function
14 // prepended and appended to every text you type like the above example
15
16 let style = Style::builder().red().strikethrough().build();
17
18 println!("{}", style.stylize("Hello World in red with strikethrough"));
19
20 println!("This is in red: {}", Color::Red.paint("a red string"));
21}Sourcepub fn red(self) -> Self
pub fn red(self) -> Self
Sets the text color to red
Examples found in repository?
3fn main() {
4 // You can either color the text directly with the Color enumeration
5 println!(
6 "{}Cyan colored \"Hello World!\"{}",
7 Color::Cyan.open(),
8 Color::Cyan.close()
9 );
10
11 // or you can use the builder function from within the Style stuct
12 // to create a style that can be used for more than one instance of
13 // a string and you wouldn't need to have an open and close function
14 // prepended and appended to every text you type like the above example
15
16 let style = Style::builder().red().strikethrough().build();
17
18 println!("{}", style.stylize("Hello World in red with strikethrough"));
19
20 println!("This is in red: {}", Color::Red.paint("a red string"));
21}Sourcepub fn black_bright(self) -> Self
pub fn black_bright(self) -> Self
Sets the text color to a bright black (gray)
Sourcepub fn red_bright(self) -> Self
pub fn red_bright(self) -> Self
Sets the text color to a bright red
Sourcepub fn green_bright(self) -> Self
pub fn green_bright(self) -> Self
Sets the text color to a bright green
Sourcepub fn yellow_bright(self) -> Self
pub fn yellow_bright(self) -> Self
Sets the text color to a bright yellow
Sourcepub fn blue_bright(self) -> Self
pub fn blue_bright(self) -> Self
Sets the text color to a bright blue
Sourcepub fn magenta_bright(self) -> Self
pub fn magenta_bright(self) -> Self
Sets the text color to a bright magenta
Sourcepub fn cyan_bright(self) -> Self
pub fn cyan_bright(self) -> Self
Sets the text color to a bright cyan
Sourcepub fn white_bright(self) -> Self
pub fn white_bright(self) -> Self
Sets the text color to a bright white
Sourcepub fn bg_magenta(self) -> Self
pub fn bg_magenta(self) -> Self
Sets the text’s bckground color to magenta
Sourcepub fn bg_black_bright(self) -> Self
pub fn bg_black_bright(self) -> Self
Sets the text’s bckground color to a bright black (gray)
Sourcepub fn bg_red_bright(self) -> Self
pub fn bg_red_bright(self) -> Self
Sets the text’s bckground color to a bright red
Sourcepub fn bg_green_bright(self) -> Self
pub fn bg_green_bright(self) -> Self
Sets the text’s bckground color to a bright green
Sourcepub fn bg_yellow_bright(self) -> Self
pub fn bg_yellow_bright(self) -> Self
Sets the text’s bckground color to a bright yellow
Sourcepub fn bg_blue_bright(self) -> Self
pub fn bg_blue_bright(self) -> Self
Sets the text’s bckground color to a bright blue
Sourcepub fn bg_magenta_bright(self) -> Self
pub fn bg_magenta_bright(self) -> Self
Sets the text’s bckground color to a bright magenta
Sourcepub fn bg_cyan_bright(self) -> Self
pub fn bg_cyan_bright(self) -> Self
Sets the text’s bckground color to a bright cyan
Sourcepub fn bg_white_bright(self) -> Self
pub fn bg_white_bright(self) -> Self
Sets the text’s bckground color to a bright white
Sourcepub fn build(self) -> Style
pub fn build(self) -> Style
Builds a Style struct from a the current instance of
the StyleBuilder struct
Examples found in repository?
3fn main() {
4 // You can either color the text directly with the Color enumeration
5 println!(
6 "{}Cyan colored \"Hello World!\"{}",
7 Color::Cyan.open(),
8 Color::Cyan.close()
9 );
10
11 // or you can use the builder function from within the Style stuct
12 // to create a style that can be used for more than one instance of
13 // a string and you wouldn't need to have an open and close function
14 // prepended and appended to every text you type like the above example
15
16 let style = Style::builder().red().strikethrough().build();
17
18 println!("{}", style.stylize("Hello World in red with strikethrough"));
19
20 println!("This is in red: {}", Color::Red.paint("a red string"));
21}