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);