IDEA-149450 ANSI escapes not interpreted as expected appcode/144.2326 clion/144.2323 dbe/144.2322 idea/144.2324 phpstorm/144.2329 pycharm/144.2325 pycharm/144.2328 rubymine/144.2327 webstorm/144.2330
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Sat, 19 Dec 2015 19:48:20 +0000 (22:48 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Sat, 19 Dec 2015 19:48:20 +0000 (22:48 +0300)
platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java

index 6e84402ae9e2225055b8e0fdec41c496dcf8db1e..f99fab3b3ee3333b11d7d25755d77491d6c80c0c 100644 (file)
@@ -18,11 +18,13 @@ package com.intellij.execution.process;
 import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.openapi.editor.markup.EffectType;
 import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.ObjectUtils;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
@@ -92,7 +94,9 @@ public class ColoredOutputTypeRegistry {
     if (attribute.startsWith("\u001B[")) {
       attribute = attribute.substring(2);
     }
-    else attribute = StringUtil.trimStart(attribute, "[");
+    else {
+      attribute = StringUtil.trimStart(attribute, "[");
+    }
     attribute = StringUtil.trimEnd(attribute, "m");
     if (attribute.equals("0")) {
       return ProcessOutputTypes.STDOUT;
@@ -135,7 +139,7 @@ public class ColoredOutputTypeRegistry {
         //TODO: 256 colors background
       }
       else if (value == 49) {
-        attrs.setBackgroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY));
+        attrs.setBackgroundColor(getDefaultBackgroundColor());
       }
       else if (value >= 90 && value <= 97) {
         attrs.setForegroundColor(
@@ -163,6 +167,13 @@ public class ColoredOutputTypeRegistry {
     return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(colorKey).getForegroundColor();
   }
 
+  @NotNull
+  private static Color getDefaultBackgroundColor() {
+    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
+    Color color = scheme.getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
+    return ObjectUtils.notNull(color, scheme.getDefaultBackground());
+  }
+
   public static TextAttributesKey getAnsiColorKey(int value) {
     if (value >= 16) {
       return ConsoleViewContentType.NORMAL_OUTPUT_KEY;