TextModifier

Trait TextModifier 

Source
pub trait TextModifier {
Show 13 methods // Required methods fn color(&self, color: Color) -> String; fn background_color(&self, color: Color) -> String; fn fg(&self, color: Color) -> String; fn bg(&self, color: Color) -> String; fn bold(&self) -> String; fn dim(&self) -> String; fn italic(&self) -> String; fn underline(&self) -> String; fn blink(&self) -> String; fn reverse(&self) -> String; fn hidden(&self) -> String; fn strikethrough(&self) -> String; fn bright(&self) -> String;
}
Expand description

Trait for applying colors and text styling to strings.

This trait provides methods to colorize text (foreground and background) and apply various text styles like bold, italic, underline, etc. All methods return a new String with ANSI escape codes applied.

§Examples

use tinterm::{TextModifier, Color};

// Basic coloring
let red_text = "Hello".color(Color::RED);
let blue_bg = "World".bg(Color::BLUE);

// Text styling
let bold_text = "Important".bold();
let italic_text = "Emphasis".italic();

// Method chaining
let styled = "Fancy Text".bold().color(Color::GREEN);

Required Methods§

Source

fn color(&self, color: Color) -> String

Source

fn background_color(&self, color: Color) -> String

Source

fn fg(&self, color: Color) -> String

Source

fn bg(&self, color: Color) -> String

Source

fn bold(&self) -> String

Source

fn dim(&self) -> String

Source

fn italic(&self) -> String

Source

fn underline(&self) -> String

Source

fn reverse(&self) -> String

Source

fn hidden(&self) -> String

Source

fn strikethrough(&self) -> String

Source

fn bright(&self) -> String

Implementations on Foreign Types§

Source§

impl TextModifier for str

Source§

fn color(&self, color: Color) -> String

Source§

fn background_color(&self, color: Color) -> String

Source§

fn fg(&self, color: Color) -> String

Source§

fn bg(&self, color: Color) -> String

Source§

fn bold(&self) -> String

Source§

fn dim(&self) -> String

Source§

fn italic(&self) -> String

Source§

fn underline(&self) -> String

Source§

fn reverse(&self) -> String

Source§

fn hidden(&self) -> String

Source§

fn strikethrough(&self) -> String

Source§

fn bright(&self) -> String

Implementors§