Skip to content

mercur3/colored-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

colored-text

About

A lightweight library for printing colored text on an UNIX terminal environment.

Usage

use colored_text::{esthetics, ColoredString};

let x = ColoredText::text("Hello, World")
    .style(esthetics::Style::Underline)     // define underline style
    .color(esthetics::Color::Cyan);         // use cyan color

println!("{}", x);

Notes

It is possible to inject a string that will produce non desirable behaviour.

use colored_text::{esthetics, ColoredString};

let c = ColoredText::text("\x1b[9;31mabc")  // overwrites esthetics::Style:Normal and esthetics::Color::White
    .style(esthetics::Style::Normal)
    .color(esthetics::Color::White);