@@ -61,16 +61,25 @@ impl Renderer {
61
61
}
62
62
63
63
/// Default terminal styling
64
+ ///
65
+ /// # Note
66
+ /// Some colors are OS dependant, meaning that the colors will look
67
+ /// different on different operating systems, making testing colored output
68
+ /// difficult.
69
+ /// If you are testing the colored output, you can use the
70
+ /// [`testing-colors` feature](crate#features) to enable colors that are OS
71
+ /// independent.
64
72
pub const fn styled ( ) -> Self {
65
- const BRIGHT_BLUE : Style = if cfg ! ( windows) {
73
+ const USE_WINDOWS_COLORS : bool = cfg ! ( windows) && !cfg ! ( feature = "testing-colors" ) ;
74
+ const BRIGHT_BLUE : Style = if USE_WINDOWS_COLORS {
66
75
AnsiColor :: BrightCyan . on_default ( )
67
76
} else {
68
77
AnsiColor :: BrightBlue . on_default ( )
69
78
} ;
70
79
Self {
71
80
stylesheet : Stylesheet {
72
81
error : AnsiColor :: BrightRed . on_default ( ) . effects ( Effects :: BOLD ) ,
73
- warning : if cfg ! ( windows ) {
82
+ warning : if USE_WINDOWS_COLORS {
74
83
AnsiColor :: BrightYellow . on_default ( )
75
84
} else {
76
85
AnsiColor :: Yellow . on_default ( )
@@ -80,7 +89,7 @@ impl Renderer {
80
89
note : AnsiColor :: BrightGreen . on_default ( ) . effects ( Effects :: BOLD ) ,
81
90
help : AnsiColor :: BrightCyan . on_default ( ) . effects ( Effects :: BOLD ) ,
82
91
line_no : BRIGHT_BLUE . effects ( Effects :: BOLD ) ,
83
- emphasis : if cfg ! ( windows ) {
92
+ emphasis : if USE_WINDOWS_COLORS {
84
93
AnsiColor :: BrightWhite . on_default ( )
85
94
} else {
86
95
Style :: new ( )
0 commit comments