https://github.com/stevencyb/rcolors
A simple terminal colorization/style tool written in Rust.
https://github.com/stevencyb/rcolors
color rust terminal
Last synced: 3 months ago
JSON representation
A simple terminal colorization/style tool written in Rust.
- Host: GitHub
- URL: https://github.com/stevencyb/rcolors
- Owner: StevenCyb
- License: mit
- Created: 2024-09-03T17:59:49.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-04T13:39:17.000Z (almost 2 years ago)
- Last Synced: 2025-09-27T21:44:58.789Z (9 months ago)
- Topics: color, rust, terminal
- Language: Rust
- Homepage:
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RColors
[](https://crates.io/crates/rcolors)

[](https://github.com/StevenCyb/rcolors/actions/workflows/tests.yml)
[](https://github.com/StevenCyb/rcolors/actions/workflows/lint.yml)
[](https://github.com/StevenCyb/rcolors/actions/workflows/rustfmt.yml)
[](https://github.com/StevenCyb/rcolors/actions/workflows/release.yml)
RColor lets you use styled outputs in terms of [ANSI Escape
Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Rust.

## Usage
### Using Macros
The following colors are supported by macros: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan` and `white`.
```rust
use rcolors::*;
fn main() {
// like `print` but with color suffix
print_red!("This is red print! ");
// like `println` but with color suffix
println_red!("This is red println!");
// like `format`
let x = red!("This is a value");
println!("{}", x);
}
```
### Using Builder
The builder makes it easier to build complex colored text sections.
Unlike the macros, the builder also offers style ANSI codes.
E.g.:
```rust
fn main() {
Builder::new()
.bold().fg_yellow().text("Language: ").reset()
.fg_cyan().italic().text("Rust\n").reset()
.bold().fg_yellow().text("Username: ").reset()
.fg_cyan().italic().text("root\n").reset()
.bold().fg_yellow().text("Password: ").reset()
.fg_cyan().italic().text("********\n")
// .print();
// .println();
.as_string();
}
```