From 8b40dbd6fb35610b04fbeb0e8aa3844715dc729c Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Sat, 19 Dec 2015 22:48:20 +0300 Subject: [PATCH] IDEA-149450 ANSI escapes not interpreted as expected --- .../process/ColoredOutputTypeRegistry.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java b/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java index 6e84402ae9e2..f99fab3b3ee3 100644 --- a/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java +++ b/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java @@ -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; -- 2.23.3