Package org.fusesource.jansi
Class AnsiConsole
- java.lang.Object
-
- org.fusesource.jansi.AnsiConsole
-
public class AnsiConsole extends java.lang.ObjectProvides 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
jansiand is loaded using HawtJNI RuntimeLibrary- Since:
- 1.0
- See Also:
systemInstall(),wrapPrintStream(PrintStream, int) for more details on ANSI mode selection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classAnsiConsole.JansiOutputTypeType of output installed by AnsiConsole.
-
Field Summary
Fields Modifier and Type Field Description static java.io.PrintStreamerrprivate static intinstalled(package private) static booleanIS_CYGWIN(package private) static booleanIS_MINGW_XTERM(package private) static booleanIS_WINDOWS(package private) static AnsiConsole.JansiOutputTypeJANSI_STDERR_TYPE(package private) static AnsiConsole.JansiOutputTypeJANSI_STDOUT_TYPEprivate static AnsiConsole.JansiOutputTypejansiOutputTypestatic java.io.PrintStreamoutstatic java.io.PrintStreamsystem_errstatic java.io.PrintStreamsystem_out
-
Constructor Summary
Constructors Modifier Constructor Description privateAnsiConsole()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.io.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 java.io.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 voidsystemInstall()InstallAnsiConsole.outtoSystem.outandAnsiConsole.errtoSystem.err.static voidsystemUninstall()undo a previoussystemInstall().static java.io.OutputStreamwrapErrorOutputStream(java.io.OutputStream stream)Deprecated.static java.io.OutputStreamwrapOutputStream(java.io.OutputStream stream)Deprecated.static java.io.OutputStreamwrapOutputStream(java.io.OutputStream stream, int fileno)Deprecated.static java.io.PrintStreamwrapPrintStream(java.io.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 java.io.PrintStreamwrapSystemErr(java.io.PrintStream ps)static java.io.PrintStreamwrapSystemOut(java.io.PrintStream ps)
-
-
-
Field Detail
-
system_out
public static final java.io.PrintStream system_out
-
out
public static final java.io.PrintStream out
-
system_err
public static final java.io.PrintStream system_err
-
err
public static final java.io.PrintStream 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
private static AnsiConsole.JansiOutputType jansiOutputType
-
JANSI_STDOUT_TYPE
static final AnsiConsole.JansiOutputType JANSI_STDOUT_TYPE
-
JANSI_STDERR_TYPE
static final AnsiConsole.JansiOutputType JANSI_STDERR_TYPE
-
installed
private static int installed
-
-
Method Detail
-
wrapOutputStream
@Deprecated public static java.io.OutputStream wrapOutputStream(java.io.OutputStream stream)
Deprecated.
-
wrapSystemOut
public static java.io.PrintStream wrapSystemOut(java.io.PrintStream ps)
-
wrapErrorOutputStream
@Deprecated public static java.io.OutputStream wrapErrorOutputStream(java.io.OutputStream stream)
Deprecated.
-
wrapSystemErr
public static java.io.PrintStream wrapSystemErr(java.io.PrintStream ps)
-
wrapOutputStream
@Deprecated public static java.io.OutputStream wrapOutputStream(java.io.OutputStream stream, int fileno)Deprecated.
-
wrapPrintStream
public static java.io.PrintStream wrapPrintStream(java.io.PrintStream ps, int fileno)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
public 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.- Returns:
- a PrintStream which is ANSI aware.
- See Also:
wrapPrintStream(PrintStream, int)
-
err
public 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.- Returns:
- a PrintStream which is ANSI aware.
- See Also:
wrapPrintStream(PrintStream, int)
-
systemInstall
public static void systemInstall()
InstallAnsiConsole.outtoSystem.outandAnsiConsole.errtoSystem.err.- See Also:
systemUninstall()
-
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.
-
-