fmt
This commit is contained in:
parent
51c0ab6012
commit
e1a46d5fb5
@ -44,7 +44,8 @@ pub fn pos_raw() -> io::Result<(u16, u16)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read rows and cols through a ad-hoc integer parsing function
|
// Read rows and cols through a ad-hoc integer parsing function
|
||||||
let read_num: fn() -> Result<(i32, char), Error> = || -> Result<(i32, char), Error> {
|
let read_num: fn() -> Result<(i32, char) -> Result<(i32, char), Error> =
|
||||||
|
|| -> Result<(i32, char), Error> {
|
||||||
let mut num = 0;
|
let mut num = 0;
|
||||||
let mut c: char;
|
let mut c: char;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ impl ITerminalColor for AnsiColor {
|
|||||||
if new_color == Color::Reset {
|
if new_color == Color::Reset {
|
||||||
ansi_value.push_str("39");
|
ansi_value.push_str("39");
|
||||||
return ansi_value;
|
return ansi_value;
|
||||||
}else {
|
} else {
|
||||||
ansi_value.push_str("38;");
|
ansi_value.push_str("38;");
|
||||||
color = new_color;
|
color = new_color;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ impl ITerminalColor for AnsiColor {
|
|||||||
if new_color == Color::Reset {
|
if new_color == Color::Reset {
|
||||||
ansi_value.push_str("49");
|
ansi_value.push_str("49");
|
||||||
return ansi_value;
|
return ansi_value;
|
||||||
}else {
|
} else {
|
||||||
ansi_value.push_str("48;");
|
ansi_value.push_str("48;");
|
||||||
color = new_color;
|
color = new_color;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ impl ITerminalColor for AnsiColor {
|
|||||||
rgb_val = format!("5;{}", val);
|
rgb_val = format!("5;{}", val);
|
||||||
rgb_val.as_str()
|
rgb_val.as_str()
|
||||||
}
|
}
|
||||||
_ => ""
|
_ => "",
|
||||||
};
|
};
|
||||||
|
|
||||||
ansi_value.push_str(color_val);
|
ansi_value.push_str(color_val);
|
||||||
|
@ -31,17 +31,16 @@ pub struct TerminalColor {
|
|||||||
impl TerminalColor {
|
impl TerminalColor {
|
||||||
/// Create new instance whereon color related actions can be performed.
|
/// Create new instance whereon color related actions can be performed.
|
||||||
pub fn new() -> TerminalColor {
|
pub fn new() -> TerminalColor {
|
||||||
// #[cfg(windows)]
|
#[cfg(windows)]
|
||||||
// let color = if supports_ansi() {
|
let color = if supports_ansi() {
|
||||||
// Box::from(AnsiColor::new()) as Box<(dyn ITerminalColor + Sync + Send)>
|
Box::from(AnsiColor::new()) as Box<(dyn ITerminalColor + Sync + Send)>
|
||||||
// } else {
|
} else {
|
||||||
// WinApiColor::new() as Box<(dyn ITerminalColor + Sync + Send)>
|
WinApiColor::new() as Box<(dyn ITerminalColor + Sync + Send)>
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// #[cfg(unix)]
|
#[cfg(unix)]
|
||||||
// let color = AnsiColor::new();
|
let color = AnsiColor::new();
|
||||||
|
|
||||||
let color = WinApiColor::new() as Box<(dyn ITerminalColor + Sync + Send)>;
|
|
||||||
TerminalColor { color }
|
TerminalColor { color }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ impl ITerminalColor for WinApiColor {
|
|||||||
const mask: u16 = FG_INTENSITY | FG_RED | FG_GREEN | FG_BLUE;
|
const mask: u16 = FG_INTENSITY | FG_RED | FG_GREEN | FG_BLUE;
|
||||||
original_color &= !(mask);
|
original_color &= !(mask);
|
||||||
original_color
|
original_color
|
||||||
},
|
}
|
||||||
/* WinApi will be used for systems that do not support ANSI, those are windows version less then 10. RGB and 255 (AnsiBValue) colors are not supported in that case.*/
|
/* WinApi will be used for systems that do not support ANSI, those are windows version less then 10. RGB and 255 (AnsiBValue) colors are not supported in that case.*/
|
||||||
Color::Rgb { r: _, g: _, b: _ } => 0,
|
Color::Rgb { r: _, g: _, b: _ } => 0,
|
||||||
Color::AnsiValue(_val) => 0,
|
Color::AnsiValue(_val) => 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user