1 use std::fmt::Display;
2 
3 use super::StyledContent;
4 
5 /// Provides a set of methods to set the colors.
6 ///
7 /// Every method with the `on_` prefix sets the background color. All other methods set
8 /// the foreground color.
9 ///
10 /// Method names correspond to the [`Color`](enum.Color.html) enum variants.
11 ///
12 /// # Examples
13 ///
14 /// ```no_run
15 /// use crossterm::style::Colorize;
16 ///
17 /// let styled_text = "Red foreground color on blue background.".red().on_blue();
18 /// println!("{}", styled_text);
19 /// ```
20 pub trait Colorize<D: Display + Clone> {
black(self) -> StyledContent<D>21     fn black(self) -> StyledContent<D>;
dark_grey(self) -> StyledContent<D>22     fn dark_grey(self) -> StyledContent<D>;
red(self) -> StyledContent<D>23     fn red(self) -> StyledContent<D>;
dark_red(self) -> StyledContent<D>24     fn dark_red(self) -> StyledContent<D>;
green(self) -> StyledContent<D>25     fn green(self) -> StyledContent<D>;
dark_green(self) -> StyledContent<D>26     fn dark_green(self) -> StyledContent<D>;
yellow(self) -> StyledContent<D>27     fn yellow(self) -> StyledContent<D>;
dark_yellow(self) -> StyledContent<D>28     fn dark_yellow(self) -> StyledContent<D>;
blue(self) -> StyledContent<D>29     fn blue(self) -> StyledContent<D>;
dark_blue(self) -> StyledContent<D>30     fn dark_blue(self) -> StyledContent<D>;
magenta(self) -> StyledContent<D>31     fn magenta(self) -> StyledContent<D>;
dark_magenta(self) -> StyledContent<D>32     fn dark_magenta(self) -> StyledContent<D>;
cyan(self) -> StyledContent<D>33     fn cyan(self) -> StyledContent<D>;
dark_cyan(self) -> StyledContent<D>34     fn dark_cyan(self) -> StyledContent<D>;
white(self) -> StyledContent<D>35     fn white(self) -> StyledContent<D>;
grey(self) -> StyledContent<D>36     fn grey(self) -> StyledContent<D>;
37 
on_black(self) -> StyledContent<D>38     fn on_black(self) -> StyledContent<D>;
on_dark_grey(self) -> StyledContent<D>39     fn on_dark_grey(self) -> StyledContent<D>;
on_red(self) -> StyledContent<D>40     fn on_red(self) -> StyledContent<D>;
on_dark_red(self) -> StyledContent<D>41     fn on_dark_red(self) -> StyledContent<D>;
on_green(self) -> StyledContent<D>42     fn on_green(self) -> StyledContent<D>;
on_dark_green(self) -> StyledContent<D>43     fn on_dark_green(self) -> StyledContent<D>;
on_yellow(self) -> StyledContent<D>44     fn on_yellow(self) -> StyledContent<D>;
on_dark_yellow(self) -> StyledContent<D>45     fn on_dark_yellow(self) -> StyledContent<D>;
on_blue(self) -> StyledContent<D>46     fn on_blue(self) -> StyledContent<D>;
on_dark_blue(self) -> StyledContent<D>47     fn on_dark_blue(self) -> StyledContent<D>;
on_magenta(self) -> StyledContent<D>48     fn on_magenta(self) -> StyledContent<D>;
on_dark_magenta(self) -> StyledContent<D>49     fn on_dark_magenta(self) -> StyledContent<D>;
on_cyan(self) -> StyledContent<D>50     fn on_cyan(self) -> StyledContent<D>;
on_dark_cyan(self) -> StyledContent<D>51     fn on_dark_cyan(self) -> StyledContent<D>;
on_white(self) -> StyledContent<D>52     fn on_white(self) -> StyledContent<D>;
on_grey(self) -> StyledContent<D>53     fn on_grey(self) -> StyledContent<D>;
54 }
55 
56 /// Provides a set of methods to set the text attributes.
57 ///
58 /// Method names correspond to the [`Attribute`](enum.Attribute.html) enum variants.
59 ///
60 /// # Examples
61 ///
62 /// ```no_run
63 /// use crossterm::style::Styler;
64 ///
65 /// println!("{}", "Bold text".bold());
66 /// println!("{}", "Underlined text".underlined());
67 /// println!("{}", "Negative text".negative());
68 /// ```
69 pub trait Styler<D: Display + Clone> {
reset(self) -> StyledContent<D>70     fn reset(self) -> StyledContent<D>;
bold(self) -> StyledContent<D>71     fn bold(self) -> StyledContent<D>;
underlined(self) -> StyledContent<D>72     fn underlined(self) -> StyledContent<D>;
reverse(self) -> StyledContent<D>73     fn reverse(self) -> StyledContent<D>;
dim(self) -> StyledContent<D>74     fn dim(self) -> StyledContent<D>;
italic(self) -> StyledContent<D>75     fn italic(self) -> StyledContent<D>;
negative(self) -> StyledContent<D>76     fn negative(self) -> StyledContent<D>;
slow_blink(self) -> StyledContent<D>77     fn slow_blink(self) -> StyledContent<D>;
rapid_blink(self) -> StyledContent<D>78     fn rapid_blink(self) -> StyledContent<D>;
hidden(self) -> StyledContent<D>79     fn hidden(self) -> StyledContent<D>;
crossed_out(self) -> StyledContent<D>80     fn crossed_out(self) -> StyledContent<D>;
81 }
82