From ee406d47fa4c2f777b7888023373386513d435a4 Mon Sep 17 00:00:00 2001 From: Timon_Post Date: Sat, 4 May 2019 13:03:18 +0200 Subject: [PATCH] fmt --- crossterm_style/examples/style.rs | 9 +++++---- crossterm_style/src/winapi_color.rs | 10 ++++++---- docs/CHANGELOG.md | 6 ++++++ docs/know_problems.md | 2 +- examples/style.rs | 8 +++++--- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crossterm_style/examples/style.rs b/crossterm_style/examples/style.rs index 857d3c5..8de4e73 100644 --- a/crossterm_style/examples/style.rs +++ b/crossterm_style/examples/style.rs @@ -388,10 +388,11 @@ pub fn print_supported_colors() { } } -fn main() { - println!("{}", Colored::Bg(Color::Red)); - println!("{}", Colored::Fg(Color::Blue)); - +pub fn reset_fg_and_bg() { println!("{}", Colored::Fg(Color::Reset)); println!("{}", Colored::Bg(Color::Reset)); } + +fn main() { + print_all_background_colors_with_method() +} diff --git a/crossterm_style/src/winapi_color.rs b/crossterm_style/src/winapi_color.rs index e02078f..ee0c84d 100644 --- a/crossterm_style/src/winapi_color.rs +++ b/crossterm_style/src/winapi_color.rs @@ -119,8 +119,9 @@ impl ITerminalColor for WinApiColor { // init the original color in case it is not set. let mut original_color = original_console_color(); - const mask: u16 = BG_INTENSITY | BG_RED | BG_GREEN | BG_BLUE; - original_color &= !(mask); + const REMOVE_BG_MASK: u16 = BG_INTENSITY | BG_RED | BG_GREEN | BG_BLUE; + // remove all background values from the original color, we don't want to reset those. + original_color &= !(REMOVE_BG_MASK); original_color } @@ -153,8 +154,9 @@ impl ITerminalColor for WinApiColor { // init the original color in case it is not set. let mut original_color = original_console_color(); - const mask: u16 = FG_INTENSITY | FG_RED | FG_GREEN | FG_BLUE; - original_color &= !(mask); + const REMOVE_FG_MASK: u16 = FG_INTENSITY | FG_RED | FG_GREEN | FG_BLUE; + // remove all foreground values from the original color, we don't want to reset those. + original_color &= !(REMOVE_FG_MASK); 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.*/ diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index da8d0cb..939c97f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,9 @@ +# Changes crossterm_input 0.9.4 +- Reset foreground and background color individually. [PR](https://github.com/TimonPost/crossterm/pull/138) +- Backtap input support. [PR](https://github.com/TimonPost/crossterm/pull/129) +- Corrected white/grey and added dark grey. +- Fixed getting cursor position with raw screen enabled. [PR](https://github.com/TimonPost/crossterm/pull/134) + # Changes crossterm_input 0.9.3 - Removed println from `SyncReader` diff --git a/docs/know_problems.md b/docs/know_problems.md index adb6135..7bc8eb0 100644 --- a/docs/know_problems.md +++ b/docs/know_problems.md @@ -4,7 +4,7 @@ And I don't think it has to do anything with crossterm but it has to do whit how # Winapi-problems - Power shell does not interpreter 'DarkYellow' and is instead using gray instead, cmd is working perfectly fine. - Power shell inserts an '\n' (enter) when the program starts, this enter is the one you pressed when running the command. -- After the program ran, power shell will reset the background color. +- After the program ran, power shell will reset the background and foreground colors. # UNIX-terminals The Arc and Manjaro KDE Konsole's are not seeming to resize the terminal instead they are resizing the buffer. \ No newline at end of file diff --git a/examples/style.rs b/examples/style.rs index fa3503e..c1508c6 100644 --- a/examples/style.rs +++ b/examples/style.rs @@ -405,7 +405,9 @@ pub fn print_supported_colors() { } } -fn main() { - print_all_background_colors_with_method(); - print_all_foreground_colors_with_method(); +pub fn reset_fg_and_bg() { + println!("{}", Colored::Fg(Color::Reset)); + println!("{}", Colored::Bg(Color::Reset)); } + +fn main() {}