pub struct Text { /* private fields */ }Expand description
Styled text.
Implementations§
Source§impl Text
impl Text
Sourcepub fn new(cm: ColorMode) -> Self
pub fn new(cm: ColorMode) -> Self
Examples found in repository?
examples/switch.rs (line 10)
5fn main() {
6 let args = std::env::args().collect::<Vec<String>>();
7 let color_mode = if args.len() != 2 { ColorMode::default() } else { ColorMode::new(&args[1]) };
8 println!(
9 "{}",
10 Text::new(color_mode)
11 .s("Switching colors:\n")
12 .black()
13 .s(" 0 ")
14 .red()
15 .s(" 1 ")
16 .green()
17 .s(" 2 ")
18 .yellow()
19 .s(" 3 ")
20 .blue()
21 .s(" 4 ")
22 .magenta()
23 .s(" 5 ")
24 .cyan()
25 .s(" 6 ")
26 .white()
27 .s(" 7 ")
28 .reset()
29 );
30}Sourcepub fn auto() -> Self
pub fn auto() -> Self
Examples found in repository?
More examples
examples/basic.rs (line 22)
19fn main() {
20 println!(
21 "{}",
22 Text::auto()
23 .s("Foreground colors:\n")
24 .black()
25 .s(" 0 ")
26 .red()
27 .s(" 1 ")
28 .green()
29 .s(" 2 ")
30 .yellow()
31 .s(" 3 ")
32 .blue()
33 .s(" 4 ")
34 .magenta()
35 .s(" 5 ")
36 .cyan()
37 .s(" 6 ")
38 .white()
39 .s(" 7 ")
40 .reset()
41 );
42}Sourcepub fn on() -> Self
pub fn on() -> Self
Examples found in repository?
examples/always.rs (line 20)
17fn main() {
18 println!(
19 "{}",
20 Text::on()
21 .s("Always colored:\n")
22 .black()
23 .s(" 0 ")
24 .red()
25 .s(" 1 ")
26 .green()
27 .s(" 2 ")
28 .yellow()
29 .s(" 3 ")
30 .blue()
31 .s(" 4 ")
32 .magenta()
33 .s(" 5 ")
34 .cyan()
35 .s(" 6 ")
36 .white()
37 .s(" 7 ")
38 .reset()
39 );
40}Sourcepub fn off() -> Self
pub fn off() -> Self
Examples found in repository?
examples/never.rs (line 20)
17fn main() {
18 println!(
19 "{}",
20 Text::off()
21 .s("Never colored:\n")
22 .black()
23 .s(" 0 ")
24 .red()
25 .s(" 1 ")
26 .green()
27 .s(" 2 ")
28 .yellow()
29 .s(" 3 ")
30 .blue()
31 .s(" 4 ")
32 .magenta()
33 .s(" 5 ")
34 .cyan()
35 .s(" 6 ")
36 .white()
37 .s(" 7 ")
38 .reset()
39 );
40}Trait Implementations§
Source§impl AddAssign<&Text> for Text
impl AddAssign<&Text> for Text
Source§fn add_assign(&mut self, rhs: &Text)
fn add_assign(&mut self, rhs: &Text)
Performs the
+= operation. Read moreSource§impl AddAssign<&str> for Text
impl AddAssign<&str> for Text
Source§fn add_assign(&mut self, rhs: &str)
fn add_assign(&mut self, rhs: &str)
Performs the
+= operation. Read moreSource§impl AddAssign for Text
impl AddAssign for Text
Source§fn add_assign(&mut self, rhs: Text)
fn add_assign(&mut self, rhs: Text)
Performs the
+= operation. Read moreSource§impl StyledText for Text
impl StyledText for Text
Source§fn plural<T: Display>(self, s: T, n: usize) -> Self
fn plural<T: Display>(self, s: T, n: usize) -> Self
Adds
s suffix to the content when the number is not 1.Source§fn align_left<T: Display>(self, s: T, width: usize) -> Self
fn align_left<T: Display>(self, s: T, width: usize) -> Self
Adds the content aligned left with specified width.
Source§fn align_right<T: Display>(self, s: T, width: usize) -> Self
fn align_right<T: Display>(self, s: T, width: usize) -> Self
Adds the content aligned right with specified width.
Source§fn align_center<T: Display>(self, s: T, width: usize) -> Self
fn align_center<T: Display>(self, s: T, width: usize) -> Self
Adds the content centered with specified width.
Source§fn pad<T: Display>(self, ch: char, padding: usize, s: T) -> Self
fn pad<T: Display>(self, ch: char, padding: usize, s: T) -> Self
Pads the content with specified character.
Source§fn pad_left<T: Display>(self, ch: char, s: T, width: usize) -> Self
fn pad_left<T: Display>(self, ch: char, s: T, width: usize) -> Self
Pads the content aligned the left with specified width.
Source§fn pad_right<T: Display>(self, ch: char, s: T, width: usize) -> Self
fn pad_right<T: Display>(self, ch: char, s: T, width: usize) -> Self
Pads the content aligned right with specified width.
Source§fn pad_center<T: Display>(self, ch: char, s: T, width: usize) -> Self
fn pad_center<T: Display>(self, ch: char, s: T, width: usize) -> Self
Pads the content centered with specified width.
Source§fn choose<T: Display>(
self,
condition: bool,
when_true: T,
when_false: T,
) -> Self
fn choose<T: Display>( self, condition: bool, when_true: T, when_false: T, ) -> Self
Adds new content based on the condition.
Source§fn bright_black(self) -> Self
fn bright_black(self) -> Self
Sets the foreground color to bright black.
Source§fn bright_red(self) -> Self
fn bright_red(self) -> Self
Sets the foreground color to bright red.
Source§fn bright_green(self) -> Self
fn bright_green(self) -> Self
Sets the foreground color to bright green.
Source§fn bright_yellow(self) -> Self
fn bright_yellow(self) -> Self
Sets the foreground color to bright yellow.
Source§fn bright_blue(self) -> Self
fn bright_blue(self) -> Self
Sets the foreground color to bright blue.
Source§fn bright_magenta(self) -> Self
fn bright_magenta(self) -> Self
Sets the foreground color to bright magenta.
Source§fn bright_cyan(self) -> Self
fn bright_cyan(self) -> Self
Sets the foreground color to bright cyan.
Source§fn bright_white(self) -> Self
fn bright_white(self) -> Self
Sets the foreground color to bright white.
Source§fn bg_bright_black(self) -> Self
fn bg_bright_black(self) -> Self
Sets the background color to bright black.
Source§fn bg_bright_red(self) -> Self
fn bg_bright_red(self) -> Self
Sets the background color to bright red.
Source§fn bg_bright_green(self) -> Self
fn bg_bright_green(self) -> Self
Sets the background color to bright green.
Source§fn bg_bright_yellow(self) -> Self
fn bg_bright_yellow(self) -> Self
Sets the background color to bright yellow.
Source§fn bg_bright_blue(self) -> Self
fn bg_bright_blue(self) -> Self
Sets the background color to bright blue.
Source§fn bg_magenta(self) -> Self
fn bg_magenta(self) -> Self
Sets the background color to magenta.
Source§fn bg_bright_magenta(self) -> Self
fn bg_bright_magenta(self) -> Self
Sets the background color to bright magenta.
Source§fn bg_bright_cyan(self) -> Self
fn bg_bright_cyan(self) -> Self
Sets the background color to bright cyan.
Source§fn bg_bright_white(self) -> Self
fn bg_bright_white(self) -> Self
Sets the background color to bright white.
Source§fn bright_color(self, c: Color) -> Self
fn bright_color(self, c: Color) -> Self
Sets the bright color by color enumeration.
Source§fn bg_bright_color(self, c: Color) -> Self
fn bg_bright_color(self, c: Color) -> Self
Sets the background bright color by color enumeration.
Source§fn bright_color_8(self, c: u8) -> Self
fn bright_color_8(self, c: u8) -> Self
Sets the bright color by color index.
Source§fn bg_color_8(self, c: u8) -> Self
fn bg_color_8(self, c: u8) -> Self
Sets the background color by color index.
Source§fn bg_bright_color_8(self, c: u8) -> Self
fn bg_bright_color_8(self, c: u8) -> Self
Sets the background bright color by color index.
fn color_256(self, c: u8) -> Self
fn bg_color_256(self, c: u8) -> Self
fn color_rgb(self, c: RgbColor) -> Self
fn bg_color_rgb(self, c: RgbColor) -> Self
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more