/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.build;

import com.intellij.build.events.BuildEvent;
import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

/**
 * @author Vladislav.Soroka
 */
public class BuildTextConsoleView extends ConsoleViewImpl implements BuildConsoleView {
  private final String myId;

  public BuildTextConsoleView(@NotNull Project project, boolean viewer, String id) {
    super(project, viewer);
    myId = id;
  }

  @Override
  public String getViewId() {
    return myId;
  }

  @Override
  public void onEvent(BuildEvent event) {
    print(event.getMessage(), ConsoleViewContentType.SYSTEM_OUTPUT);
  }
}


@@ -720,16 +720,131 @@
 ewImpl;%0A
+import com.intellij.execution.process.AnsiEscapeDecoder;%0Aimport com.intellij.execution.process.ProcessOutputTypes;%0A
 import c
@@ -937,16 +937,54 @@
 roject;%0A
+import com.intellij.openapi.util.Key;%0A
 import o
@@ -1143,38 +1143,158 @@
 View
- %7B%0A  private final String myId
+, AnsiEscapeDecoder.ColoredTextAcceptor %7B%0A  private final String myId;%0A  private final AnsiEscapeDecoder myAnsiEscapeDecoder = new AnsiEscapeDecoder()
 ;%0A%0A 
@@ -1551,70 +1551,263 @@
     
-print(event.getMessage(), ConsoleViewContentType.SYSTEM_OUTPUT
+myAnsiEscapeDecoder.escapeText(event.getMessage(), ProcessOutputTypes.STDOUT, this);%0A  %7D%0A%0A  @Override%0A  public void coloredTextAvailable(@NotNull String text, @NotNull Key attributes) %7B%0A    print(text, ConsoleViewContentType.getConsoleViewType(attributes)
 );%0A 

Build text console view ANSI colors support