Class AnsiConsole

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.io.PrintStream err
      Deprecated.
      this field will be made private in a future release, use err() instead
      static java.lang.String JANSI_COLORS
      The default color support that Jansi will use, can be either 16, 256 or truecolor.
      static java.lang.String JANSI_COLORS_16
      Force the use of 16 colors.
      static java.lang.String JANSI_COLORS_256
      Force the use of 256 colors.
      static java.lang.String JANSI_COLORS_TRUECOLOR
      Force the use of 24-bit colors.
      static java.lang.String JANSI_EAGER
      Deprecated.
      this property has been added but only for backward compatibility.
      static java.lang.String JANSI_ERR_COLORS
      Jansi colors specific to the standard error stream.
      static java.lang.String JANSI_ERR_MODE
      Jansi mode specific to the standard error stream.
      static java.lang.String JANSI_FORCE
      Deprecated.
      use JANSI_MODE instead
      static java.lang.String JANSI_GRACEFUL
      If the jansi.graceful system property is set to false, any exception that occurs during the initialization will cause the library to report this exception and fail.
      static java.lang.String JANSI_MODE
      The default mode which Jansi will use, can be either force, strip or default (the default).
      static java.lang.String JANSI_MODE_DEFAULT
      Jansi mode value that output sequences if on a terminal, else strip them.
      static java.lang.String JANSI_MODE_FORCE
      Jansi mode value to force ansi sequences to the stream even if it's not a terminal.
      static java.lang.String JANSI_MODE_STRIP
      Jansi mode value to strip all ansi sequences.
      static java.lang.String JANSI_NORESET
      If the jansi.noreset system property is set to true, the attributes won't be reset when the streams are uninstalled.
      static java.lang.String JANSI_OUT_COLORS
      Jansi colors specific to the standard output stream.
      static java.lang.String JANSI_OUT_MODE
      Jansi mode specific to the standard output stream.
      static java.lang.String JANSI_PASSTHROUGH
      Deprecated.
      use JANSI_MODE instead
      static java.lang.String JANSI_STRIP
      Deprecated.
      use JANSI_MODE instead
      static java.io.PrintStream out
      Deprecated.
      this field will be made private in a future release, use out() instead
      static java.io.PrintStream system_err
      Deprecated.
      this field will be made private in a future release, use sysErr() instead
      static java.io.PrintStream system_out
      Deprecated.
      this field will be made private in a future release, use sysOut() instead
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static AnsiPrintStream 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 int getTerminalWidth()
      Try to find the width of the console for this process.
      static boolean isInstalled()
      check if the streams have been installed or not
      static AnsiPrintStream 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 java.io.PrintStream sysErr()
      Access to the original System.err stream before ansi streams were installed.
      static java.io.PrintStream sysOut()
      Access to the original System.out stream before ansi streams were installed.
      static void systemInstall()
      Install AnsiConsole.out() to System.out and AnsiConsole.err() to System.err.
      static void systemUninstall()
      undo a previous systemInstall().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JANSI_MODE

        public static final java.lang.String JANSI_MODE
        The default mode which Jansi will use, can be either force, strip or default (the default). If this property is set, it will override jansi.passthrough, jansi.strip and jansi.force properties.
        See Also:
        Constant Field Values
      • JANSI_MODE_FORCE

        public static final java.lang.String JANSI_MODE_FORCE
        Jansi mode value to force ansi sequences to the stream even if it's not a terminal.
        See Also:
        Constant Field Values
      • JANSI_COLORS

        public static final java.lang.String JANSI_COLORS
        The default color support that Jansi will use, can be either 16, 256 or truecolor. If not set, JANSI will try to autodetect the number of colors supported by the terminal by checking the COLORTERM and TERM variables.
        See Also:
        Constant Field Values
      • JANSI_COLORS_16

        public static final java.lang.String JANSI_COLORS_16
        Force the use of 16 colors. When using a 256-indexed color, or an RGB color, the color will be rounded to the nearest one from the 16 palette.
        See Also:
        Constant Field Values
      • JANSI_COLORS_256

        public static final java.lang.String JANSI_COLORS_256
        Force the use of 256 colors. When using an RGB color, the color will be rounded to the nearest one from the standard 256 palette.
        See Also:
        Constant Field Values
      • JANSI_PASSTHROUGH

        @Deprecated
        public static final java.lang.String JANSI_PASSTHROUGH
        Deprecated.
        use JANSI_MODE instead
        If the jansi.passthrough system property is set to true, will not perform any transformation and any ansi sequence will be conveyed without any modification.
        See Also:
        Constant Field Values
      • JANSI_STRIP

        @Deprecated
        public static final java.lang.String JANSI_STRIP
        Deprecated.
        use JANSI_MODE instead
        If the jansi.strip system property is set to true, and jansi.passthrough is not enabled, all ansi sequences will be stripped before characters are written to the output streams.
        See Also:
        Constant Field Values
      • JANSI_FORCE

        @Deprecated
        public static final java.lang.String JANSI_FORCE
        Deprecated.
        use JANSI_MODE instead
        If the jansi.force system property is set to true, and neither jansi.passthrough nor jansi.strip are set, then ansi sequences will be printed to the output stream. This forces the behavior which is by default dependent on the output stream being a real console: if the output stream is redirected to a file or through a system pipe, ansi sequences are disabled by default.
        See Also:
        Constant Field Values
      • JANSI_EAGER

        @Deprecated
        public static final java.lang.String JANSI_EAGER
        Deprecated.
        this property has been added but only for backward compatibility.
        If the jansi.eager system property is set to true, the system streams will be eagerly initialized, else the initialization is delayed until out(), err() or systemInstall() is called.
        Since:
        2.1
        See Also:
        Constant Field Values
      • JANSI_NORESET

        public static final java.lang.String JANSI_NORESET
        If the jansi.noreset system property is set to true, the attributes won't be reset when the streams are uninstalled.
        See Also:
        Constant Field Values
      • JANSI_GRACEFUL

        public static final java.lang.String JANSI_GRACEFUL
        If the jansi.graceful system property is set to false, any exception that occurs during the initialization will cause the library to report this exception and fail. The default behavior is to behave gracefully and fall back to pure emulation on posix systems.
        See Also:
        Constant Field Values
      • system_out

        @Deprecated
        public static java.io.PrintStream system_out
        Deprecated.
        this field will be made private in a future release, use sysOut() instead
      • out

        @Deprecated
        public static java.io.PrintStream out
        Deprecated.
        this field will be made private in a future release, use out() instead
      • system_err

        @Deprecated
        public static java.io.PrintStream system_err
        Deprecated.
        this field will be made private in a future release, use sysErr() instead
      • err

        @Deprecated
        public static java.io.PrintStream err
        Deprecated.
        this field will be made private in a future release, use err() instead
    • Method Detail

      • getTerminalWidth

        public static int getTerminalWidth()
        Try to find the width of the console for this process. Both output and error streams will be checked to determine the width. A value of 0 is returned if the width can not be determined.
        Since:
        2.2
      • out

        public static AnsiPrintStream 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.
      • sysOut

        public static java.io.PrintStream sysOut()
        Access to the original System.out stream before ansi streams were installed.
        Returns:
        the originial System.out print stream
      • err

        public static AnsiPrintStream 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.
      • sysErr

        public static java.io.PrintStream sysErr()
        Access to the original System.err stream before ansi streams were installed.
        Returns:
        the originial System.err print stream
      • systemInstall

        public static void systemInstall()
        Install AnsiConsole.out() to System.out and AnsiConsole.err() to System.err.
        See Also:
        systemUninstall()
      • isInstalled

        public static boolean isInstalled()
        check if the streams have been installed or not