14 releases

0.0.13 Nov 17, 2020
0.0.12 Nov 2, 2020
0.0.11 Oct 19, 2020
0.0.4 Sep 27, 2020

#955 in Command-line interface

Download history 19/week @ 2024-07-26 2/week @ 2024-08-02 17/week @ 2024-09-20 1/week @ 2024-09-27

173 downloads per month
Used in qutonium

MIT license

57KB
2K SLoC

qute

github crates.io docs.rs Crates.io


designify your terminal with a large ansi colors palette 🎨

Examples — API — Goals — License

a nice ANSI escape codes API to use ansi color in a elegant way that support 8 color, 16 color, 88 color, 256 color and 16 millions color mode. You can manage the color mode by yourself, you got the control dude!

Examples

snippet

extern crate qute;

use qute::prelude::*;

fn main () {
  let quted = qute!("my string").background_black().white();

  println!("{}", quted);
}
extern crate qute;

use qute::prelude::*;

fn main () {
  let quted = style!({
    value: "my string";
    color: "purple";
    background: "black";
    font-weight: none;
  });

  println!("{}", quted);
}

cargo

example command
256 cargo run --example hello_colors
basic cargo run --example basic
css cargo run --example css
rgb cargo run --example rgb

Usage

Add the following to your Cargo.toml:

[dependencies]
qute = "0.0.13"

Now you can use the crate in your code

extern crate qute;

API

the qute! macro contains all method to designify your terminal as you want. Select Graphic Rendition are parameters applied into the escape sequence format string. See the SGR table below

Modifier

no params

returns

self { Designer }: the current instance

color snippet preview
bold qute!("my string").bold()
dim qute!("my string").dim()
underlined qute!("my string").underline()
blink qute!("my string").blink()
reverse qute!("my string").reverse()
hidden qute!("my string").hidden()
strikethrough qute!("my string").strikethrough()

Foreground

no params

returns

self { Designer }: the current instance

color snippet preview
black qute!("my string").black()
red qute!("my string").red()
green qute!("my string").green()
yellow qute!("my string").yellow()
blue qute!("my string").blue()
magenta qute!("my string").magenta()
cyan qute!("my string").cyan()
gray qute!("my string").gray()
light_red qute!("my string").light_red()
light_green qute!("my string").light_green()
light_yellow qute!("my string").light_yellow()
light_blue qute!("my string").light_blue()
light_magenta qute!("my string").light_magenta()
light_cyan qute!("my string").light_cyan()
white qute!("my string").white()

Background

no params

returns

self { Designer }: the current instance

color snippet preview
black qute!("my string").background_black()
red qute!("my string").background_red()
green qute!("my string").background_green()
yellow qute!("my string").background_yellow()
blue qute!("my string").background_blue()
magenta qute!("my string").background_magenta()
cyan qute!("my string").background_cyan()
gray qute!("my string").background_gray()
light_red qute!("my string").background_light_red()
light_green qute!("my string").background_light_green()
light_yellow qute!("my string").background_light_yellow()
light_blue qute!("my string").background_light_blue()
light_magenta qute!("my string").background_light_magenta()
light_cyan qute!("my string").background_light_cyan()
white qute!("my string").background_white()

256 Colors

params

n { u8 }: the color number - from 0 to 255

returns

self { Designer }: the current instance

mode snippet preview
foreground qute!("my string").set_color(231)
background qute!("my string").set_background(220)

RGB

params

r { u8 }: the standard red g { u8 }: the standard green b { u8 }: the standard blue

returns

self { Designer }: the current instance

mode snippet preview
foreground qute!("my string").set_rgb_color(255, 255, 255)
background qute!("my string").set_rgb_background(128, 128, 128)

CSS

CSS colors keyword are supported. See the complete list here

params

keyword { String }: the css color keyword

returns

self { Designer }: the current instance

mode snippet preview
foreground qute!("my string").set_css_color("lime")
background qute!("my string").set_css_background("aquamarine")

Goals

  • support modifiers
  • support vga
  • support rgb
  • support css colors keywords
  • unit testing (wip)
  • support hexa
  • support hsl
  • force color
  • convert to css
  • cross platform
  • documentation

License

Copyright Šī¸ 2020 Qurity

Released under the MIT license

No runtime deps