Search in sources :

Example 1 with AnsiEscapeDecoder

use of com.intellij.execution.process.AnsiEscapeDecoder in project intellij-community by JetBrains.

the class Printer method printWithAnsiColoring.

default default void printWithAnsiColoring(@NotNull String text, @NotNull Key processOutputType) {
    AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
    decoder.escapeText(text, ProcessOutputTypes.STDOUT, new AnsiEscapeDecoder.ColoredTextAcceptor() {

        @Override
        public void coloredTextAvailable(@NotNull String text, @NotNull Key attributes) {
            ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(attributes);
            if (contentType == null || contentType == ConsoleViewContentType.NORMAL_OUTPUT) {
                contentType = ConsoleViewContentType.getConsoleViewType(processOutputType);
            }
            print(text, contentType);
        }
    });
}
Also used : AnsiEscapeDecoder(com.intellij.execution.process.AnsiEscapeDecoder) Key(com.intellij.openapi.util.Key) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Example 2 with AnsiEscapeDecoder

use of com.intellij.execution.process.AnsiEscapeDecoder in project intellij-community by JetBrains.

the class Printer method printWithAnsiColoring.

default default void printWithAnsiColoring(@NotNull String text, @NotNull ConsoleViewContentType contentType) {
    AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
    decoder.escapeText(text, ProcessOutputTypes.STDOUT, new AnsiEscapeDecoder.ColoredTextAcceptor() {

        @Override
        public void coloredTextAvailable(@NotNull String text, @NotNull Key attributes) {
            ConsoleViewContentType viewContentType = ConsoleViewContentType.getConsoleViewType(attributes);
            if (viewContentType == null) {
                viewContentType = contentType;
            }
            print(text, viewContentType);
        }
    });
}
Also used : AnsiEscapeDecoder(com.intellij.execution.process.AnsiEscapeDecoder) Key(com.intellij.openapi.util.Key) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Aggregations

AnsiEscapeDecoder (com.intellij.execution.process.AnsiEscapeDecoder)2 ConsoleViewContentType (com.intellij.execution.ui.ConsoleViewContentType)2 Key (com.intellij.openapi.util.Key)2