Trait ascii_forge::prelude::Stylize
source · pub trait Stylize: Sized {
type Styled: AsRef<ContentStyle> + AsMut<ContentStyle>;
Show 64 methods
// Required method
fn stylize(self) -> Self::Styled;
// Provided methods
fn with(self, color: Color) -> Self::Styled { ... }
fn on(self, color: Color) -> Self::Styled { ... }
fn underline(self, color: Color) -> Self::Styled { ... }
fn attribute(self, attr: Attribute) -> Self::Styled { ... }
fn reset(self) -> Self::Styled { ... }
fn bold(self) -> Self::Styled { ... }
fn underlined(self) -> Self::Styled { ... }
fn reverse(self) -> Self::Styled { ... }
fn dim(self) -> Self::Styled { ... }
fn italic(self) -> Self::Styled { ... }
fn negative(self) -> Self::Styled { ... }
fn slow_blink(self) -> Self::Styled { ... }
fn rapid_blink(self) -> Self::Styled { ... }
fn hidden(self) -> Self::Styled { ... }
fn crossed_out(self) -> Self::Styled { ... }
fn black(self) -> Self::Styled { ... }
fn on_black(self) -> Self::Styled { ... }
fn underline_black(self) -> Self::Styled { ... }
fn dark_grey(self) -> Self::Styled { ... }
fn on_dark_grey(self) -> Self::Styled { ... }
fn underline_dark_grey(self) -> Self::Styled { ... }
fn red(self) -> Self::Styled { ... }
fn on_red(self) -> Self::Styled { ... }
fn underline_red(self) -> Self::Styled { ... }
fn dark_red(self) -> Self::Styled { ... }
fn on_dark_red(self) -> Self::Styled { ... }
fn underline_dark_red(self) -> Self::Styled { ... }
fn green(self) -> Self::Styled { ... }
fn on_green(self) -> Self::Styled { ... }
fn underline_green(self) -> Self::Styled { ... }
fn dark_green(self) -> Self::Styled { ... }
fn on_dark_green(self) -> Self::Styled { ... }
fn underline_dark_green(self) -> Self::Styled { ... }
fn yellow(self) -> Self::Styled { ... }
fn on_yellow(self) -> Self::Styled { ... }
fn underline_yellow(self) -> Self::Styled { ... }
fn dark_yellow(self) -> Self::Styled { ... }
fn on_dark_yellow(self) -> Self::Styled { ... }
fn underline_dark_yellow(self) -> Self::Styled { ... }
fn blue(self) -> Self::Styled { ... }
fn on_blue(self) -> Self::Styled { ... }
fn underline_blue(self) -> Self::Styled { ... }
fn dark_blue(self) -> Self::Styled { ... }
fn on_dark_blue(self) -> Self::Styled { ... }
fn underline_dark_blue(self) -> Self::Styled { ... }
fn magenta(self) -> Self::Styled { ... }
fn on_magenta(self) -> Self::Styled { ... }
fn underline_magenta(self) -> Self::Styled { ... }
fn dark_magenta(self) -> Self::Styled { ... }
fn on_dark_magenta(self) -> Self::Styled { ... }
fn underline_dark_magenta(self) -> Self::Styled { ... }
fn cyan(self) -> Self::Styled { ... }
fn on_cyan(self) -> Self::Styled { ... }
fn underline_cyan(self) -> Self::Styled { ... }
fn dark_cyan(self) -> Self::Styled { ... }
fn on_dark_cyan(self) -> Self::Styled { ... }
fn underline_dark_cyan(self) -> Self::Styled { ... }
fn white(self) -> Self::Styled { ... }
fn on_white(self) -> Self::Styled { ... }
fn underline_white(self) -> Self::Styled { ... }
fn grey(self) -> Self::Styled { ... }
fn on_grey(self) -> Self::Styled { ... }
fn underline_grey(self) -> Self::Styled { ... }
}
Expand description
Provides a set of methods to set attributes and colors.
§Examples
use crossterm::style::Stylize;
println!("{}", "Bold text".bold());
println!("{}", "Underlined text".underlined());
println!("{}", "Negative text".negative());
println!("{}", "Red on blue".red().on_blue());
Required Associated Types§
sourcetype Styled: AsRef<ContentStyle> + AsMut<ContentStyle>
type Styled: AsRef<ContentStyle> + AsMut<ContentStyle>
This type with styles applied.
Required Methods§
Provided Methods§
sourcefn underlined(self) -> Self::Styled
fn underlined(self) -> Self::Styled
Applies the Underlined
attribute to the text.
sourcefn slow_blink(self) -> Self::Styled
fn slow_blink(self) -> Self::Styled
Applies the SlowBlink
attribute to the text.
sourcefn rapid_blink(self) -> Self::Styled
fn rapid_blink(self) -> Self::Styled
Applies the RapidBlink
attribute to the text.
Applies the Hidden
attribute to the text.
sourcefn crossed_out(self) -> Self::Styled
fn crossed_out(self) -> Self::Styled
Applies the CrossedOut
attribute to the text.
sourcefn underline_black(self) -> Self::Styled
fn underline_black(self) -> Self::Styled
Sets the underline color to Black
.
sourcefn on_dark_grey(self) -> Self::Styled
fn on_dark_grey(self) -> Self::Styled
Sets the background color to DarkGrey
.
sourcefn underline_dark_grey(self) -> Self::Styled
fn underline_dark_grey(self) -> Self::Styled
Sets the underline color to DarkGrey
.
sourcefn underline_red(self) -> Self::Styled
fn underline_red(self) -> Self::Styled
Sets the underline color to Red
.
sourcefn on_dark_red(self) -> Self::Styled
fn on_dark_red(self) -> Self::Styled
Sets the background color to DarkRed
.
sourcefn underline_dark_red(self) -> Self::Styled
fn underline_dark_red(self) -> Self::Styled
Sets the underline color to DarkRed
.
sourcefn green(self) -> Self::Styled
fn green(self) -> Self::Styled
Sets the foreground color to Green
.
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
fn run(&mut self, window: &mut Window) -> Result<SceneResult, Box<dyn Error>> {
// Set up a scene
let mut ui_buffer = Buffer::new((6, 3));
let chars = ['┌', '─', '┐', '│', ' ', '│', '└', '─', '┘'];
let nine_slice = ui::NineSlice::new(chars, (6, 3));
// Render Some elements to the buffer.
render!(ui_buffer, [
vec2(0, 0) => nine_slice,
vec2(1, 1) => "QUIT".green()
]);
// Loop the current scene.
loop {
window.update()?;
// Renders some elements to the window.
render!(window, [
vec2(0, 0) => format!("{:?}", cursor::position()?),
vec2(window.size().x / 2, window.size().y / 4) => ui_buffer,
]);
// If the `q` key was pressed, quit the application by returning no scene.
if window.code(KeyCode::Char('q')) {
return Ok(None);
}
// If the buffer was clicked on, quit.
if window.mouse(MouseEventKind::Down(MouseButton::Left))?
&& window.hover(
vec2(window.size().x / 2, window.size().y / 4),
ui_buffer.size(),
)?
{
return Ok(None);
}
}
}
sourcefn underline_green(self) -> Self::Styled
fn underline_green(self) -> Self::Styled
Sets the underline color to Green
.
sourcefn dark_green(self) -> Self::Styled
fn dark_green(self) -> Self::Styled
Sets the foreground color to DarkGreen
.
sourcefn on_dark_green(self) -> Self::Styled
fn on_dark_green(self) -> Self::Styled
Sets the background color to DarkGreen
.
sourcefn underline_dark_green(self) -> Self::Styled
fn underline_dark_green(self) -> Self::Styled
Sets the underline color to DarkGreen
.
sourcefn underline_yellow(self) -> Self::Styled
fn underline_yellow(self) -> Self::Styled
Sets the underline color to Yellow
.
sourcefn dark_yellow(self) -> Self::Styled
fn dark_yellow(self) -> Self::Styled
Sets the foreground color to DarkYellow
.
sourcefn on_dark_yellow(self) -> Self::Styled
fn on_dark_yellow(self) -> Self::Styled
Sets the background color to DarkYellow
.
sourcefn underline_dark_yellow(self) -> Self::Styled
fn underline_dark_yellow(self) -> Self::Styled
Sets the underline color to DarkYellow
.
sourcefn underline_blue(self) -> Self::Styled
fn underline_blue(self) -> Self::Styled
Sets the underline color to Blue
.
sourcefn on_dark_blue(self) -> Self::Styled
fn on_dark_blue(self) -> Self::Styled
Sets the background color to DarkBlue
.
sourcefn underline_dark_blue(self) -> Self::Styled
fn underline_dark_blue(self) -> Self::Styled
Sets the underline color to DarkBlue
.
sourcefn on_magenta(self) -> Self::Styled
fn on_magenta(self) -> Self::Styled
Sets the background color to Magenta
.
sourcefn underline_magenta(self) -> Self::Styled
fn underline_magenta(self) -> Self::Styled
Sets the underline color to Magenta
.
sourcefn dark_magenta(self) -> Self::Styled
fn dark_magenta(self) -> Self::Styled
Sets the foreground color to DarkMagenta
.
sourcefn on_dark_magenta(self) -> Self::Styled
fn on_dark_magenta(self) -> Self::Styled
Sets the background color to DarkMagenta
.
sourcefn underline_dark_magenta(self) -> Self::Styled
fn underline_dark_magenta(self) -> Self::Styled
Sets the underline color to DarkMagenta
.
sourcefn underline_cyan(self) -> Self::Styled
fn underline_cyan(self) -> Self::Styled
Sets the underline color to Cyan
.
sourcefn on_dark_cyan(self) -> Self::Styled
fn on_dark_cyan(self) -> Self::Styled
Sets the background color to DarkCyan
.
sourcefn underline_dark_cyan(self) -> Self::Styled
fn underline_dark_cyan(self) -> Self::Styled
Sets the underline color to DarkCyan
.
sourcefn underline_white(self) -> Self::Styled
fn underline_white(self) -> Self::Styled
Sets the underline color to White
.
sourcefn underline_grey(self) -> Self::Styled
fn underline_grey(self) -> Self::Styled
Sets the underline color to Grey
.