fix: use short forms for colors below 8 (#31)

closes #30
This commit is contained in:
Silas Groh 2023-06-02 13:57:08 +02:00 committed by GitHub
parent 280ed71ec1
commit 7a898206fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ pub struct Color(pub Option<u8>);
impl Display for Color {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0 {
Some(color @ 0..=7) => write!(f, "\x1b[3{color}m"),
Some(color) => write!(f, "\x1b[38;5;{color}m"),
None => write!(f, "\x1b[39m"),
}