@@ -110,16 +110,25 @@ public static boolean supportsUnicode(Appendable output) {
110
110
}
111
111
112
112
static boolean checkAnsiColourSupport (String varName ) {
113
- return envVarIn (varName ,
114
- "screen" , "xterm" , "vt100" ,
115
- "vt220" , "rxvt" , "color" ,
116
- "ansi" , "cygwin" , "linux" );
113
+ return envVarMatches (varName ,
114
+ t -> t .startsWith ("screen" )
115
+ || t .startsWith ("xterm" )
116
+ || t .startsWith ("vt100" )
117
+ || t .startsWith ("vt220" )
118
+ || t .startsWith ("rxvt" )
119
+ || t .contains ("color" )
120
+ || t .contains ("ansi" )
121
+ || t .contains ("cygwin" )
122
+ || t .contains ("linux" ));
117
123
}
118
124
119
125
static boolean check256ColourSupport (String varName ) {
120
126
return envVarMatches (varName , t -> t .endsWith ("256" ) || t .endsWith ("256color" ));
121
127
}
122
128
129
+ /*
130
+ * A port of the logic from https://docs.rs/supports-color/2.0.0/supports_color/
131
+ */
123
132
public static ColourSupport colourSupport (Appendable output ) {
124
133
if (envVarNotEquals ("NO_COLOR" , "" ) || envVarEquals ("TERM" , "dumb" ) || !isAtty (output )) {
125
134
return ColourSupport .NONE ;
0 commit comments