Class AnsiConsole
java.lang.Object
org.fusesource.jansi.AnsiConsole
Provides consistent access to an ANSI aware console PrintStream or an ANSI codes stripping PrintStream
if not on a terminal (see
Jansi native
CLibrary isatty(int)).
The native library used is named jansi and is loaded using HawtJNI Runtime
Library
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumType of output installed by AnsiConsole. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PrintStreamprivate static int(package private) static final boolean(package private) static final boolean(package private) static final boolean(package private) static final AnsiConsole.JansiOutputType(package private) static final AnsiConsole.JansiOutputTypeprivate static AnsiConsole.JansiOutputTypestatic final PrintStreamstatic final PrintStreamstatic final PrintStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PrintStreamerr()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 PrintStreamout()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 voidInstallAnsiConsole.outtoSystem.outandAnsiConsole.errtoSystem.err.static voidundo a previoussystemInstall().static OutputStreamwrapErrorOutputStream(OutputStream stream) Deprecated.static OutputStreamwrapOutputStream(OutputStream stream) Deprecated.static OutputStreamwrapOutputStream(OutputStream stream, int fileno) Deprecated.static PrintStreamwrapPrintStream(PrintStream ps, int fileno) Wrap PrintStream applying rules in following order: ifjansi.passthroughistrue, don't wrap but just passthrough (console is expected to natively support ANSI escape codes), ifjansi.stripistrue, 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 (seeisatty(int)) orjansi.forceistrue, just passthrough, else strip ANSI escape codes (not a terminal).static PrintStreamstatic PrintStream
-
Field Details
-
system_out
-
out
-
system_err
-
err
-
IS_WINDOWS
static final boolean IS_WINDOWS -
IS_CYGWIN
static final boolean IS_CYGWIN -
IS_MINGW_XTERM
static final boolean IS_MINGW_XTERM -
jansiOutputType
-
JANSI_STDOUT_TYPE
-
JANSI_STDERR_TYPE
-
installed
private static int installed
-
-
Constructor Details
-
AnsiConsole
private AnsiConsole()
-
-
Method Details
-
wrapOutputStream
Deprecated. -
wrapSystemOut
-
wrapErrorOutputStream
Deprecated. -
wrapSystemErr
-
wrapOutputStream
Deprecated. -
wrapPrintStream
Wrap PrintStream applying rules in following order:- if
jansi.passthroughistrue, don't wrap but just passthrough (console is expected to natively support ANSI escape codes), - if
jansi.stripistrue, 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)) orjansi.forceistrue, just passthrough, - else strip ANSI escape codes (not a terminal).
- Parameters:
ps- original PrintStream to wrapfileno- file descriptor- Returns:
- wrapped PrintStream depending on OS and system properties
- Since:
- 1.17
- if
-
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.- Returns:
- a PrintStream which is ANSI aware.
- See Also:
-
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.- Returns:
- a PrintStream which is ANSI aware.
- See Also:
-
systemInstall
public static void systemInstall()InstallAnsiConsole.outtoSystem.outandAnsiConsole.errtoSystem.err.- See Also:
-
systemUninstall
public static void systemUninstall()undo a previoussystemInstall(). IfsystemInstall()was called multiple times,systemUninstall()must be called the same number of times before it is actually uninstalled.
-