Skip to content

Commit

Permalink
Add light colors parsing support
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-Sky committed Oct 1, 2022
1 parent 68cba72 commit 2e4fa2f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ impl Perform for ANSIParser {
4 => attr.effect |= Effect::UNDERLINE,
5 => attr.effect |= Effect::BLINK,
7 => attr.effect |= Effect::REVERSE,
num if num >= 30 && num <= 37 => {
attr.fg = Color::AnsiValue((num - 30) as u8);
}
num @ 30..=37 => attr.fg = Color::AnsiValue((num - 30) as u8),
38 => match iter.next() {
Some(&[2]) => {
// ESC[ 38;2;<r>;<g>;<b> m Select RGB foreground color
Expand Down Expand Up @@ -125,9 +123,7 @@ impl Perform for ANSIParser {
}
},
39 => attr.fg = Color::Default,
num if num >= 40 && num <= 47 => {
attr.bg = Color::AnsiValue((num - 40) as u8);
}
num @ 40..=47 => attr.bg = Color::AnsiValue((num - 40) as u8),
48 => match iter.next() {
Some(&[2]) => {
// ESC[ 48;2;<r>;<g>;<b> m Select RGB background color
Expand Down Expand Up @@ -158,6 +154,8 @@ impl Perform for ANSIParser {
}
},
49 => attr.bg = Color::Default,
num @ 90..=97 => attr.fg = Color::AnsiValue((num - 82) as u8),
num @ 100..=107 => attr.bg = Color::AnsiValue((num - 92) as u8),
_ => {
trace!("ignore CSI {:?} m", params);
}
Expand Down

0 comments on commit 2e4fa2f

Please sign in to comment.