fn ansi_code()

in reverie-process/src/pid.rs [96:121]


    fn ansi_code(&self) -> Option<&'static str> {
        if colored::control::SHOULD_COLORIZE.should_colorize() {
            // Why not just use `colored::Colorize` you ask? It allocates a
            // string in order to create the color code. Since we may log a lot
            // of output that may contain a lot of PIDs, we don't want that to
            // slow us down.
            Some(match self.0.as_raw() % 14 {
                0 => "\x1b[0;31m",  // Red
                1 => "\x1b[0;32m",  // Green
                2 => "\x1b[0;33m",  // Yellow
                3 => "\x1b[0;34m",  // Blue
                4 => "\x1b[0;35m",  // Magenta
                5 => "\x1b[0;36m",  // Cyan
                6 => "\x1b[0;37m",  // White
                7 => "\x1b[1;31m",  // Bright red
                8 => "\x1b[1;32m",  // Bright green
                9 => "\x1b[01;33m", // Bright yellow
                10 => "\x1b[1;34m", // Bright blue
                11 => "\x1b[1;35m", // Bright magenta
                12 => "\x1b[1;36m", // Bright cyan
                _ => "\x1b[1;37m",  // Bright white
            })
        } else {
            None
        }
    }