A simple text formatting crate for Rust TUI applications.
Either install via running cargo add textfmt or by manually adding an entry to
your Cargo.toml file.
Begin by storing text in a String or &str, then call .into() to convert it
into a FmtText structure. As of versions ≥ v1.1.0, you can also directly call formatting
options on a String or &str to automatically cast it to a FmtText object.
use textfmt::*;
fn main() {
// type declaration allows for `.into()` calls on both `String` and `&str`
let fmt_str: FmtText = "foo".into();
// This first makes the text blue, then prints it; the text does not remain
// blue after this call.
fmt_str.blue()
.println();
// Alternatively, using no variables...
FmtText::from("bar")
.red()
.bold()
.println();
// as of v1.1.0, you can also implicitly cast `String`s and `&str`s via
// importing the `textfmt::FmtString` trait
"baz".cyan()
.italic()
.underline()
.println();
}This project keeps track of changes via the CHANGELOG.md file. Reference it for details.
See the CONTRIBUTING.md file for details.
This crate is licensed under the MIT license or the Apache 2.0 license.
See the LICENSE file for more details.