Class AnsiConsole

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  AnsiConsole.JansiOutputType
      Type of output installed by AnsiConsole.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private AnsiConsole()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      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 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • installed

        private static int installed
    • Constructor Detail

      • AnsiConsole

        private AnsiConsole()
    • 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.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).
        Parameters:
        ps - original PrintStream to wrap
        fileno - file descriptor
        Returns:
        wrapped PrintStream depending on OS and system properties
        Since:
        1.17
      • 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()
        Install AnsiConsole.out to System.out and AnsiConsole.err to System.err.
        See Also:
        systemUninstall()