public static @NotNull SimpleTextAttributes fromTextAttributes(TextAttributes attributes) {
    if (attributes == null) return REGULAR_ATTRIBUTES;

    Color fgColor = attributes.getForegroundColor();
    if (fgColor == null) fgColor = REGULAR_ATTRIBUTES.getFgColor();
    Color bgColor = attributes.getBackgroundColor();

    int style = attributes.getFontType();
    if (attributes.getEffectColor() != null) {
      EffectType effectType = attributes.getEffectType();
      if (effectType == EffectType.STRIKEOUT) {
        style |= STYLE_STRIKEOUT;
      }
      else if (effectType == EffectType.WAVE_UNDERSCORE) {
        style |= STYLE_WAVED;
      }
      else if (effectType == EffectType.LINE_UNDERSCORE) {
        style |= STYLE_UNDERLINE;
      }
      else if (effectType == EffectType.BOLD_DOTTED_LINE) {
        style |= STYLE_BOLD_DOTTED_LINE;
      }
      else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
        style |= STYLE_BOLD_UNDERLINE;
      }
      else if (effectType == EffectType.SEARCH_MATCH) {
        style |= STYLE_SEARCH_MATCH;
      }
      else {
        // not supported
      }
    }
    //noinspection MagicConstant
    return new SimpleTextAttributes(bgColor, fgColor, attributes.getEffectColor(), style);
  }
public static @NotNull SimpleTextAttributes fromTextAttributes(TextAttributes attributes)