Java Code Examples for com.intellij.openapi.editor.markup.TextAttributes#merge()

The following examples show how to use com.intellij.openapi.editor.markup.TextAttributes#merge() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LexerEditorHighlighter.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
TextAttributes convertAttributes(@Nonnull TextAttributesKey[] keys) {
  TextAttributes resultAttributes = new TextAttributes();
  boolean firstPass = true;
  for (TextAttributesKey key : keys) {
    TextAttributes attributesByKey = myScheme.getAttributes(key);
    if (attributesByKey == null) {
      continue;
    }
    if (firstPass) {
      resultAttributes.copyFrom(attributesByKey);
      firstPass = false;
    }
    else {
      resultAttributes = TextAttributes.merge(resultAttributes, attributesByKey);
    }
  }
  return resultAttributes;
}
 
Example 2
Source File: ChunkExtractor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void addChunk(@Nonnull CharSequence chars,
                             int start,
                             int end,
                             @Nonnull TextAttributes originalAttrs,
                             boolean bold,
                             @javax.annotation.Nullable UsageType usageType,
                             @Nonnull List<TextChunk> result) {
  if (start >= end) return;

  TextAttributes attrs = bold ? TextAttributes.merge(originalAttrs, new TextAttributes(null, null, null, null, Font.BOLD)) : originalAttrs;
  result.add(new TextChunk(attrs, StringFactory.createShared(CharArrayUtil.fromSequence(chars, start, end)), usageType));
}
 
Example 3
Source File: ChunkExtractor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private TextAttributes convertAttributes(@Nonnull TextAttributesKey[] keys) {
  TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT);

  for (TextAttributesKey key : keys) {
    TextAttributes attrs2 = myColorsScheme.getAttributes(key);
    if (attrs2 != null) {
      attrs = TextAttributes.merge(attrs, attrs2);
    }
  }

  attrs = attrs.clone();
  return attrs;
}
 
Example 4
Source File: TextDiffType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public TextAttributes getTextAttributes(@Nonnull Editor editor) {
  TextAttributes originalAttrs = getTextAttributes(editor.getColorsScheme());
  if (originalAttrs == null) {
    return null;
  }
  TextAttributes overridingAttributes = new TextAttributes();
  if (myApplied) {
    overridingAttributes.setBackgroundColor(((EditorEx)editor).getBackgroundColor());
  }
  else if (myInlineWrapper) {
    overridingAttributes.setBackgroundColor(getBgColorForFragmentContainingInlines((EditorEx)editor));
  }
  return TextAttributes.merge(originalAttrs, overridingAttributes);
}