fix(terminal): support bright colors (#256)
* fix(terminal): support bright colors * style(fmt): make it uglier because rustfmt
This commit is contained in:
parent
bb87cbdd28
commit
1c71d16eb5
1 changed files with 64 additions and 0 deletions
|
|
@ -37,6 +37,14 @@ pub enum NamedColor {
|
||||||
Magenta,
|
Magenta,
|
||||||
Cyan,
|
Cyan,
|
||||||
White,
|
White,
|
||||||
|
BrightBlack,
|
||||||
|
BrightRed,
|
||||||
|
BrightGreen,
|
||||||
|
BrightYellow,
|
||||||
|
BrightBlue,
|
||||||
|
BrightMagenta,
|
||||||
|
BrightCyan,
|
||||||
|
BrightWhite,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NamedColor {
|
impl NamedColor {
|
||||||
|
|
@ -50,6 +58,14 @@ impl NamedColor {
|
||||||
NamedColor::Magenta => format!("{}", 35),
|
NamedColor::Magenta => format!("{}", 35),
|
||||||
NamedColor::Cyan => format!("{}", 36),
|
NamedColor::Cyan => format!("{}", 36),
|
||||||
NamedColor::White => format!("{}", 37),
|
NamedColor::White => format!("{}", 37),
|
||||||
|
NamedColor::BrightBlack => format!("{}", 90),
|
||||||
|
NamedColor::BrightRed => format!("{}", 91),
|
||||||
|
NamedColor::BrightGreen => format!("{}", 92),
|
||||||
|
NamedColor::BrightYellow => format!("{}", 93),
|
||||||
|
NamedColor::BrightBlue => format!("{}", 94),
|
||||||
|
NamedColor::BrightMagenta => format!("{}", 95),
|
||||||
|
NamedColor::BrightCyan => format!("{}", 96),
|
||||||
|
NamedColor::BrightWhite => format!("{}", 97),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn to_background_ansi_code(&self) -> String {
|
fn to_background_ansi_code(&self) -> String {
|
||||||
|
|
@ -62,6 +78,14 @@ impl NamedColor {
|
||||||
NamedColor::Magenta => format!("{}", 45),
|
NamedColor::Magenta => format!("{}", 45),
|
||||||
NamedColor::Cyan => format!("{}", 46),
|
NamedColor::Cyan => format!("{}", 46),
|
||||||
NamedColor::White => format!("{}", 47),
|
NamedColor::White => format!("{}", 47),
|
||||||
|
NamedColor::BrightBlack => format!("{}", 100),
|
||||||
|
NamedColor::BrightRed => format!("{}", 101),
|
||||||
|
NamedColor::BrightGreen => format!("{}", 102),
|
||||||
|
NamedColor::BrightYellow => format!("{}", 103),
|
||||||
|
NamedColor::BrightBlue => format!("{}", 104),
|
||||||
|
NamedColor::BrightMagenta => format!("{}", 105),
|
||||||
|
NamedColor::BrightCyan => format!("{}", 106),
|
||||||
|
NamedColor::BrightWhite => format!("{}", 107),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,6 +407,46 @@ impl CharacterStyles {
|
||||||
params_used += 1; // even if it's a bug, let's not create an endless loop, eh?
|
params_used += 1; // even if it's a bug, let's not create an endless loop, eh?
|
||||||
}
|
}
|
||||||
[49, ..] => *self = self.background(Some(AnsiCode::Reset)),
|
[49, ..] => *self = self.background(Some(AnsiCode::Reset)),
|
||||||
|
[90, ..] => {
|
||||||
|
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlack)))
|
||||||
|
}
|
||||||
|
[91, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightRed))),
|
||||||
|
[92, ..] => {
|
||||||
|
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightGreen)))
|
||||||
|
}
|
||||||
|
[93, ..] => {
|
||||||
|
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightYellow)))
|
||||||
|
}
|
||||||
|
[94, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlue))),
|
||||||
|
[95, ..] => {
|
||||||
|
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta)))
|
||||||
|
}
|
||||||
|
[96, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightCyan))),
|
||||||
|
[97, ..] => {
|
||||||
|
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightWhite)))
|
||||||
|
}
|
||||||
|
[100, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlack)))
|
||||||
|
}
|
||||||
|
[101, ..] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightRed))),
|
||||||
|
[102, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightGreen)))
|
||||||
|
}
|
||||||
|
[103, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightYellow)))
|
||||||
|
}
|
||||||
|
[104, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlue)))
|
||||||
|
}
|
||||||
|
[105, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta)))
|
||||||
|
}
|
||||||
|
[106, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightCyan)))
|
||||||
|
}
|
||||||
|
[107, ..] => {
|
||||||
|
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightWhite)))
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// if this happens, it's a bug
|
// if this happens, it's a bug
|
||||||
let _ = debug_log_to_file(format!("unhandled csi m code {:?}", ansi_params));
|
let _ = debug_log_to_file(format!("unhandled csi m code {:?}", ansi_params));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue