support inverse ANSI command (IDEA-149450) appcode/144.2348 clion/144.2345 dbe/144.2344 idea/144.2347 phpstorm/144.2349 pycharm/144.2346 pycharm/144.2351 webstorm/144.2352
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Sun, 20 Dec 2015 23:43:23 +0000 (02:43 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Sun, 20 Dec 2015 23:43:23 +0000 (02:43 +0300)
platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java

index 77e31436930063f94933847aa069567a236d248c..b6e9db8024e69b41e89710107ea7c56c20953774 100644 (file)
@@ -100,6 +100,7 @@ public class ColoredOutputTypeRegistry {
     if (attribute.equals("0")) {
       return ProcessOutputTypes.STDOUT;
     }
+    boolean inverse = false;
     TextAttributes attrs = new TextAttributes();
     final String[] strings = attribute.split(";");
     for (String string : strings) {
@@ -116,6 +117,9 @@ public class ColoredOutputTypeRegistry {
       else if (value == 4) {
         attrs.setEffectType(EffectType.LINE_UNDERSCORE);
       }
+      else if (value == 7) {
+        inverse = true;
+      }
       else if (value == 22) {
         attrs.setFontType(Font.PLAIN);
       }
@@ -156,6 +160,19 @@ public class ColoredOutputTypeRegistry {
       }
       attrs.setEffectColor(foregroundColor);
     }
+    if (inverse) {
+      Color foregroundColor = attrs.getForegroundColor();
+      if (foregroundColor == null) {
+        foregroundColor = getDefaultForegroundColor();
+      }
+      Color backgroundColor = attrs.getBackgroundColor();
+      if (backgroundColor == null) {
+        backgroundColor = getDefaultBackgroundColor();
+      }
+      attrs.setForegroundColor(backgroundColor);
+      attrs.setEffectColor(backgroundColor);
+      attrs.setBackgroundColor(foregroundColor);
+    }
     Key newKey = new Key(completeAttribute);
     ConsoleViewContentType contentType = new ConsoleViewContentType(completeAttribute, attrs);
     ConsoleViewContentType.registerNewConsoleViewType(newKey, contentType);