Package org.fusesource.jansi
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 enum
Type of output installed by AnsiConsole. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PrintStream
private 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.JansiOutputType
private static AnsiConsole.JansiOutputType
static final PrintStream
static final PrintStream
static final PrintStream
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 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
InstallAnsiConsole.out
toSystem.out
andAnsiConsole.err
toSystem.err
.static void
undo a previoussystemInstall()
.static OutputStream
wrapErrorOutputStream
(OutputStream stream) Deprecated.static OutputStream
wrapOutputStream
(OutputStream stream) Deprecated.static OutputStream
wrapOutputStream
(OutputStream stream, int fileno) Deprecated.static PrintStream
wrapPrintStream
(PrintStream ps, int fileno) Wrap PrintStream applying rules in following order: ifjansi.passthrough
istrue
, don't wrap but just passthrough (console is expected to natively support ANSI escape codes), ifjansi.strip
istrue
, 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.force
istrue
, just passthrough, else strip ANSI escape codes (not a terminal).static PrintStream
static 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.passthrough
istrue
, don't wrap but just passthrough (console is expected to natively support ANSI escape codes), - if
jansi.strip
istrue
, 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.force
istrue
, 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.out
toSystem.out
andAnsiConsole.err
toSystem.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.
-