#color-string #color #string #graphics #background-color #filesize

coloured-strings

这个Crate使字符串着色变得简单且轻量(< 3.0 kb)!

9个版本

0.1.10 2023年3月19日
0.1.9 2023年2月12日
0.1.7 2023年1月25日

#164 in 图形API

每月39次下载

MIT许可协议

10KB
54

coloured-strings

横幅 这是一个Rust crate,允许使用最小的文件大小将着色字符串打印到终端。

注意:此版本为了支持真彩色,文件大小略有增加。如果不需要rgb颜色,请下载之前的版本。

  colour("this is a green string", "green");
  colour("this is a red string", "r");
  colour("this is a string with a strikethrough", "s");
  colour(&colour("this string has white text and a blue background", w")[..], "b-bl"));
  custom_colour("A custom string!", true, 255, 100, 200);

使用方法

运行 cargo add coloured-strings 之后,在你的文件中写入以下内容 use coloured_strings

示例

use coloured_strings::*;

fn main() {
    println!("{}", colour("I love coloured text!", "brightgreen");
}

当前颜色

   // normal colours
    "black" | "b"
    "red" | "r"
    "green" | "g"
    "yellow" | "y"
    "blue" | "bl"
    "magenta" | "m"
    "cyan" | "c"
    "white"| "w"

    // bright colours
    "brightblack" | "bb"
    "brightred" | "br"
    "brightgreen" | "bg"
    "brightyellow" | "by"
    "brightblue" | "bbl"
    "brightmagenta" | "bm"
    "brightcyan" | "bc"
    "brightwhite" | "bw"

    //background colours
    "backgroundred" | "b-r"
    "backgroundgreen" | "b-g"
    "backgroundyellow" | "b-y"
    "backgroundblue" | "b-b"
    "backgroundmagenta" | "b-m"
    "backgroundcyan" | "b-c"
    "bacgroundwhite" | "b-w"

    //bright background colours
    "backgroundbrightblack" | "b-bb"
    "backgroundbrightred" | "b-br"
    "backgroundbrightgreen" | "b-bg"
    "backgroundbrightyellow" | "b-by"
    "backgroundbrightblue" | "b-bbl"
    "backgroundbrightmagenta" | "b-bm"
    "backgroundbrightcyan" | "b-bc"
    "backgroundbrightwhite" | "b-bw"

   // other styles
    "clear" | "cl"
    "dimmed" | "d"
    "italic" | "i"  
    "underline" | "u"
    "blink" | "bli"  
    "reversed" | "re"
    "hidden" | "h"
    "strikethrough" | "s"

无运行时依赖