public class AnsiConsole
extends java.lang.Object
implements java.io.Closeable
Each method in this class calls Workaround.enableLibraryLoad()
before delegating to the corresponding method in the
org.fusesource.jansi.AnsiConsole class.
This works around a problem in Jansi's
org.fusesource.hawtjni.runtime.Library
that prevents the native libraries embedded in the Jansi JAR in
/META-INF/native/* from being loaded
when running in a GraalVM native image.
Usage: use this class as a drop-in replacement for
org.fusesource.jansi.AnsiConsole.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Calls
systemUninstall() if running on a Windows OS, otherwise does nothing. |
static java.io.PrintStream |
err()
If the standard out natively supports ANSI escape codes, then this just
returns System.err, otherwise it will provide an ANSI aware PrintStream
which strips out the ANSI escape sequences or which implement the escape
sequences.
|
static java.io.PrintStream |
out()
If the standard out natively supports ANSI escape codes, then this just
returns System.out, otherwise it will provide an ANSI aware PrintStream
which strips out the ANSI escape sequences or which implement the escape
sequences.
|
static void |
systemInstall()
Install
AnsiConsole.out to System.out and
AnsiConsole.err to System.err. |
static void |
systemUninstall()
undo a previous
systemInstall(). |
static AnsiConsole |
windowsInstall()
Calls
systemInstall() if running on a Windows OS, otherwise does nothing. |
static java.io.OutputStream |
wrapErrorOutputStream(java.io.OutputStream stream)
Deprecated.
|
static java.io.OutputStream |
wrapOutputStream(java.io.OutputStream stream)
Deprecated.
|
static java.io.OutputStream |
wrapOutputStream(java.io.OutputStream stream,
int fileno)
Deprecated.
|
static java.io.PrintStream |
wrapPrintStream(java.io.PrintStream ps,
int fileno)
Wrap PrintStream applying rules in following order:
if
jansi.passthrough is true, don't wrap but just passthrough (console is
expected to natively support ANSI escape codes),
if jansi.strip is true, just strip ANSI escape codes inconditionally,
if OS is Windows and terminal is not Cygwin or Mingw, wrap as WindowsAnsiPrintStream to process ANSI escape codes,
if file descriptor is a terminal (see isatty(int)) or jansi.force is true,
just passthrough,
else strip ANSI escape codes (not a terminal).
|
static java.io.PrintStream |
wrapSystemErr(java.io.PrintStream ps) |
static java.io.PrintStream |
wrapSystemOut(java.io.PrintStream ps) |
public static void systemInstall()
AnsiConsole.out to System.out and
AnsiConsole.err to System.err.systemUninstall()public static void systemUninstall()
systemInstall(). If systemInstall() was called
multiple times, systemUninstall() must be called the same number of times before
it is actually uninstalled.@Deprecated public static java.io.OutputStream wrapOutputStream(java.io.OutputStream stream)
public static java.io.PrintStream wrapSystemOut(java.io.PrintStream ps)
@Deprecated public static java.io.OutputStream wrapErrorOutputStream(java.io.OutputStream stream)
public static java.io.PrintStream wrapSystemErr(java.io.PrintStream ps)
@Deprecated
public static java.io.OutputStream wrapOutputStream(java.io.OutputStream stream,
int fileno)
public static java.io.PrintStream wrapPrintStream(java.io.PrintStream ps,
int fileno)
jansi.passthrough is true, don't wrap but just passthrough (console is
expected to natively support ANSI escape codes),jansi.strip is true, just strip ANSI escape codes inconditionally,isatty(int)) or jansi.force is true,
just passthrough,ps - original PrintStream to wrapfileno - file descriptorpublic static java.io.PrintStream out()
wrapPrintStream(PrintStream, int)public static java.io.PrintStream err()
wrapPrintStream(PrintStream, int)public static AnsiConsole windowsInstall()
systemInstall() if running on a Windows OS, otherwise does nothing.Closeable instancepublic void close()
systemUninstall() if running on a Windows OS, otherwise does nothing.close in interface java.io.Closeableclose in interface java.lang.AutoCloseable