@@ -48,6 +48,12 @@ public class AnsiConsole {
48
48
49
49
static final boolean IS_WINDOWS = System .getProperty ("os.name" ).toLowerCase (Locale .ENGLISH ).contains ("win" );
50
50
51
+ /**
52
+ * <a href="https://conemu.github.io">ConEmu</a> ANSI X3.64 support enabled,
53
+ * used by <a href="https://cmder.net/">cmder</a>
54
+ */
55
+ static final boolean IS_CON_EMU_ANSI = "ON" .equals (System .getenv ("ConEmuANSI" ));
56
+
51
57
static final boolean IS_CYGWIN = IS_WINDOWS
52
58
&& System .getenv ("PWD" ) != null
53
59
&& System .getenv ("PWD" ).startsWith ("/" )
@@ -124,9 +130,10 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen
124
130
return new AnsiOutputStream (stream );
125
131
}
126
132
127
- if (IS_WINDOWS && !IS_CYGWIN && ! IS_MINGW_XTERM ) {
133
+ if (IS_WINDOWS && !( IS_CON_EMU_ANSI || IS_CYGWIN || IS_MINGW_XTERM ) ) {
128
134
129
- // On windows we know the console does not interpret ANSI codes..
135
+ // On Windows, when no ANSI-capable terminal is used, we know the console does not natively interpret ANSI
136
+ // codes but we can use jansi-native Kernel32 API for console
130
137
try {
131
138
jansiOutputType = JansiOutputType .WINDOWS ;
132
139
return new WindowsAnsiOutputStream (stream , fileno == STDOUT_FILENO );
@@ -140,7 +147,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen
140
147
return new AnsiOutputStream (stream );
141
148
}
142
149
143
- // We must be on some Unix variant, including Cygwin or MSYS(2) on Windows...
150
+ // We must be on some Unix variant or ANSI-enabled ConEmu, Cygwin or MSYS(2) on Windows...
144
151
try {
145
152
// If the jansi.force property is set, then we force to output
146
153
// the ansi escapes for piping it into ansi color aware commands (e.g. less -r)
@@ -202,9 +209,10 @@ public static PrintStream wrapPrintStream(final PrintStream ps, int fileno) {
202
209
return new AnsiPrintStream (ps );
203
210
}
204
211
205
- if (IS_WINDOWS && !IS_CYGWIN && ! IS_MINGW_XTERM ) {
212
+ if (IS_WINDOWS && !( IS_CON_EMU_ANSI || IS_CYGWIN || IS_MINGW_XTERM ) ) {
206
213
207
- // On windows we know the console does not interpret ANSI codes..
214
+ // On Windows, when no ANSI-capable terminal is used, we know the console does not natively interpret ANSI
215
+ // codes but we can use jansi-native Kernel32 API for console
208
216
try {
209
217
jansiOutputType = JansiOutputType .WINDOWS ;
210
218
return new WindowsAnsiPrintStream (ps , fileno == STDOUT_FILENO );
@@ -218,7 +226,7 @@ public static PrintStream wrapPrintStream(final PrintStream ps, int fileno) {
218
226
return new AnsiPrintStream (ps );
219
227
}
220
228
221
- // We must be on some Unix variant, including Cygwin or MSYS(2) on Windows...
229
+ // We must be on some Unix variant or ANSI-enabled ConEmu, Cygwin or MSYS(2) on Windows...
222
230
try {
223
231
// If the jansi.force property is set, then we force to output
224
232
// the ansi escapes for piping it into ansi color aware commands (e.g. less -r)
0 commit comments