reujab / silver

A cross-shell customizable powerline-like prompt with icons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for high intensity colors

kamiyaa opened this issue · comments

https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

ESC[ 38;5;⟨n⟩ m Select foreground color
ESC[ 48;5;⟨n⟩ m Select background color
  0-  7:  standard colors (as in ESC [ 30–37 m)
  8- 15:  high intensity colors (as in ESC [ 90–97 m)
 16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
232-255:  grayscale from black to white in 24 steps

Currently, only 0-7 can be used.
Would be nice to be able to use 8-15 as well.

Maybe something like:

fn code(color: &str) -> Option<String> {
    match color {
        "none" => Some("0".to_owned()),
        "black" => Some("30".to_owned()),
        "red" => Some("31".to_owned()),
        "green" => Some("32".to_owned()),
        "yellow" => Some("33".to_owned()),
        "blue" => Some("34".to_owned()),
        "magenta" => Some("35".to_owned()),
        "cyan" => Some("36".to_owned()),
        "white" => Some("37".to_owned()),
        "lightblack" => Some("90".to_owned()),
        "lightred" => Some("91".to_owned()),
        "lightgreen" => Some("92".to_owned()),
        "lightyellow" => Some("93".to_owned()),
        "lightblue" => Some("94".to_owned()),
        "lightmagenta" => Some("95".to_owned()),
        "lightcyan" => Some("96".to_owned()),
        "lightwhite" => Some("97".to_owned()),
        _ => None,
    }
}