utilprint

Crates.ioutilprint
lib.rsutilprint
version0.1.4
sourcesrc
created_at2024-07-26 13:36:01.730807
updated_at2024-07-29 11:54:05.219212
descriptionA utility crate for easily using colors or unicode in your terminal printing
homepagehttps://github.com/Coffee-Nerd/utilprint
repositoryhttps://github.com/Coffee-Nerd/utilprint
max_upload_size
id1316111
size17,247
Jeffrey Johnston (Coffee-Nerd)

documentation

https://docs.rs/utilprint

README

UtilPrint

Crates.io Documentation License

UtilPrint is a minimalist Rust crate designed to simplify the process of adding color and Unicode characters, such as emojis, to your terminal output.

It provides a fast and easy-to-use interface for enhancing your console applications with visually appealing elements. This is how it looks in a few different terminals. The aesthetics will depend on your terminal settings and support.

240727_00h54m57s_screenshot

Features

  • Easy to Use: UtilPrint offers a straightforward API that makes it simple to integrate color and Unicode characters into your terminal output.
  • Minimalistic: The crate is designed to be lightweight and unobtrusive, focusing on providing essential functionality without unnecessary complexity.
  • Fast: UtilPrint is optimized for performance, ensuring that adding color and emojis to your terminal output doesn't slow down your application.
  • Unicode Support: Easily incorporate Unicode characters, including emojis, into your terminal output to create more engaging and expressive console applications.

Installation

Add utilprint to your Cargo.toml:

[dependencies]
utilprint = "0.1.3"

Usage Here's a quick example of how to use UtilPrint to add color and an emoji to your terminal output:

use utilprint::utilprint;

fn main() {
    utilprint("@x226He@x190ll@x155o @x119W@x120or@x084l@x085d, @x050t@x051his @x045is@x075 U@x069t@x105il@x099P@x135ri@x165nt@x201, let@x200's m@x205ake t@x204he@x210 w@x209or@x215ld co@x220lorf@x226ul!@w Here is a #2615, @ua Euro #20AC @Rs@ry@Rm@rb@Ro@rl@u, @Mand p@mu@Mr@mp@Ml@me @Mt@me@Mx@mt");
}

This will print "Hello World, this is UtilPrint, let's make the world Colorful!"

In rainbow colors, and then it includes more text in different colors, and some unicode characters, like an emoji. Here is a ☕, a Euro € symbol, and purple text

That is a complex example, but you may think that isn't that easy to read, and you may want to use just one color, or a specific set of colors. For this I have implemented many different cool methods.

utilprint("I wonder what cool things we are going to make with UtilPrint?!".pastelbow());

image

As you can see, this is now printing in our custom colorset, called pastelbow!

utilprint("I really like rainbows, they are beautiful and awesome!".rainbow());

image

This would also create a more traditional rainbow colored text!

utilprint("This should be red!".red());

image

We can also use very simple coloration, with simply using the .red() method.

And of course we love unicode, and emojis! You can see a nice list of unicode symbols here...

https://www.compart.com/en/unicode/category/So

Currently we support unicode in the form of #0000, where the four zeroes can be any combination of numbers and letters...

utilprint("I love to drink #2615 every single day, because it makes me #263A #2705");

image

Here you can see we have our coffee, our smiley face, and our checkmark!

Color Codes

UtilPrint uses simple color codes to specify colors:

@d: Black
@r: Red
@g: Green
@y: Yellow
@b: Blue
@m: Magenta
@c: Cyan
@w: White
@D: Gray (Bright Black)
@R: Bright Red
@G: Bright Green
@Y: Bright Yellow
@B: Bright Blue
@M: Bright Magenta
@C: Bright Cyan
@W: Bright White
@u: Reset color
For Xterm 256 colors, use @xNNN where NNN is the color number.

Unicode Characters
To add Unicode characters, use #NNNN where NNNN is the Unicode code. For example, #1F600 for a smiley face.

Contributing

Contributions are welcome! Please feel free to submit pull requests, report bugs, or suggest new features.

License

This project uses an MIT license. Feel free to use this, but credit me!

KNOWN BUGS

Using a method like .rainbow(), or any non single color method like .red() will result in your emojis being lost, and the unicode not being consumed. This is in the works to be fixed.

UtilPrint is licensed under the MIT License. Have fun using or modifying it! If you want to credit me, that would be great!

Commit count: 0

cargo fmt