Use 8-color mode when possible.
This commit is contained in:
parent
b288548756
commit
cd59514615
|
@ -96,6 +96,13 @@ pub trait TermWrite {
|
|||
/// Set foreground color.
|
||||
fn color(&mut self, color: Color) -> io::Result<usize> {
|
||||
let ansi = color.to_ansi_val();
|
||||
if ansi <= 7 {
|
||||
self.csi(&[
|
||||
b'3',
|
||||
b'0' + ansi,
|
||||
b'm',
|
||||
])
|
||||
} else {
|
||||
self.csi(&[
|
||||
b'3',
|
||||
b'8',
|
||||
|
@ -108,9 +115,18 @@ pub trait TermWrite {
|
|||
b'm',
|
||||
])
|
||||
}
|
||||
}
|
||||
/// Set background color.
|
||||
fn bg_color(&mut self, color: Color) -> io::Result<usize> {
|
||||
let ansi = color.to_ansi_val();
|
||||
|
||||
if ansi <= 7 {
|
||||
self.csi(&[
|
||||
b'4',
|
||||
b'0' + ansi,
|
||||
b'm',
|
||||
])
|
||||
} else {
|
||||
self.csi(&[
|
||||
b'4',
|
||||
b'8',
|
||||
|
@ -123,6 +139,7 @@ pub trait TermWrite {
|
|||
b'm',
|
||||
])
|
||||
}
|
||||
}
|
||||
/// Set rendition mode (SGR).
|
||||
fn style(&mut self, mode: Style) -> io::Result<usize> {
|
||||
self.rendition(mode as u8)
|
||||
|
|
Loading…
Reference in New Issue