Skip to content

uptudev/textfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

textfmt

A simple text formatting crate for Rust TUI applications.

Contents

Installation

Either install via running cargo add textfmt or by manually adding an entry to your Cargo.toml file.

Usage

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

Changelog

This project keeps track of changes via the CHANGELOG.md file. Reference it for details.

Contributing

See the CONTRIBUTING.md file for details.

License

This crate is licensed under the MIT license or the Apache 2.0 license.

See the LICENSE file for more details.

About

A simple text formatting crate for Rust TUI applications.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors