當前位置: 首頁>>代碼示例>>Java>>正文


Java TextAttributes類代碼示例

本文整理匯總了Java中com.intellij.openapi.editor.markup.TextAttributes的典型用法代碼示例。如果您正苦於以下問題:Java TextAttributes類的具體用法?Java TextAttributes怎麽用?Java TextAttributes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextAttributes類屬於com.intellij.openapi.editor.markup包,在下文中一共展示了TextAttributes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateGherkinRunIcons

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
public void generateGherkinRunIcons(Document rootDocument, Editor rootEditor) {
    for (int i = 0; i < rootDocument.getLineCount(); i++) {
        int startOffset = rootDocument.getLineStartOffset(i);
        int endOffset = rootDocument.getLineEndOffset(i);

        String lineText = rootDocument.getText(new TextRange(startOffset, endOffset)).trim();

        Icon icon;
        if (lineText.matches(SCENARIO_REGEX)) {
            icon = GherkinIconRenderer.SCENARIO_ICON;
        } else if (lineText.matches(FEATURE_REGEX)) {
            icon = GherkinIconRenderer.FEATURE_ICON;
        } else {
            // System.out.println();
             continue;
        }
        GherkinIconRenderer gherkinIconRenderer = new GherkinIconRenderer(rootEditor.getProject(), fileName);
        gherkinIconRenderer.setLine(i);
        gherkinIconRenderer.setIcon(icon);

        RangeHighlighter rangeHighlighter = createRangeHighlighter(rootDocument, rootEditor, i, i, new TextAttributes());
        rangeHighlighter.setGutterIconRenderer(gherkinIconRenderer);
    }
}
 
開發者ID:KariiO,項目名稱:Gherkin-TS-Runner,代碼行數:25,代碼來源:GherkinIconUtils.java

示例2: highlightLine

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
private void highlightLine(int index, NamedTextAttr namedTextAttr) {
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        try {
            MarkupModelEx markupModel = myEditor.getMarkupModel();
            final Document doc = markupModel.getDocument();
            final int lineStartOffset = doc.getLineStartOffset(index);
            final int lineEndOffset = doc.getLineEndOffset(index);
            // IDEA-53203: add ERASE_MARKER for manually defined attributes
            markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                    HighlighterLayer.SELECTION - 1, TextAttributes.ERASE_MARKER,
                    HighlighterTargetArea.EXACT_RANGE);
            RangeHighlighter rangeHighlight =
                    markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                            HighlighterLayer.SELECTION - 1, namedTextAttr,
                            HighlighterTargetArea.EXACT_RANGE);
            rangeHighlight.setErrorStripeMarkColor(namedTextAttr.getErrorStripeColor());
            rangeHighlight.setErrorStripeTooltip(namedTextAttr.getName());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
}
 
開發者ID:huoguangjin,項目名稱:MultiHighlight,代碼行數:23,代碼來源:ColorPreviewPanel.java

示例3: reset

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
@Override
public void reset(@NotNull TextAttributes ta) {
    myCbBold.setEnabled(true);
    myCbItalic.setEnabled(true);

    int fontType = ta.getFontType();
    myCbBold.setSelected(BitUtil.isSet(fontType, Font.BOLD));
    myCbItalic.setSelected(BitUtil.isSet(fontType, Font.ITALIC));

    resetColorChooser(myCbForeground, myForegroundChooser, ta.getForegroundColor());
    resetColorChooser(myCbBackground, myBackgroundChooser, ta.getBackgroundColor());
    resetColorChooser(myCbErrorStripe, myErrorStripeColorChooser, ta.getErrorStripeColor());

    Color effectColor = ta.getEffectColor();
    resetColorChooser(myCbEffects, myEffectsColorChooser, effectColor);

    if (effectColor == null) {
        myEffectsCombo.setEnabled(false);
    } else {
        myEffectsCombo.setEnabled(true);
        myEffectsModel.setSelectedItem(
                ContainerUtil.reverseMap(myEffectsMap).get(ta.getEffectType()));
    }
}
 
開發者ID:huoguangjin,項目名稱:MultiHighlight,代碼行數:25,代碼來源:ColorChooserPanel.java

示例4: actionPerformed

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
    
    final HighlightManager highlightManager = HighlightManager.getInstance(project);
    final RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) highlightManager).getHighlighters(editor);
    for (RangeHighlighter highlighter : highlighters) {
        final TextAttributes ta = highlighter.getTextAttributes();
        if (ta != null && ta instanceof NamedTextAttr
                && highlighter.getLayer() == HighlighterLayer.SELECTION - 1) {
            highlightManager.removeSegmentHighlighter(editor, highlighter);
        }
    }
}
 
開發者ID:huoguangjin,項目名稱:MultiHighlight,代碼行數:17,代碼來源:MultiHighlightClearAction.java

示例5: create

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
@Override
protected Key create(List<TextAttributesKey> keys) {
  StringBuilder keyName = new StringBuilder("ConsoleViewUtil_");
  for (TextAttributesKey key : keys) {
    keyName.append("_").append(key.getExternalName());
  }
  final Key newKey = new Key(keyName.toString());
  textAttributeKeys.put(newKey, keys);
  ConsoleViewContentType contentType = new ConsoleViewContentType(keyName.toString(), HighlighterColors.TEXT) {
    @Override
    public TextAttributes getAttributes() {
      return mergedTextAttributes.get(newKey);
    }
  };

  registerNewConsoleViewType(newKey, contentType);
  return newKey;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:ConsoleViewUtil.java

示例6: getTextAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
@Nullable
@Override
public TextAttributes getTextAttributes(@NotNull EditorColorsScheme scheme, @NotNull ArrangementSettingsToken token, boolean selected) {
  if (selected) {
    TextAttributes attributes = new TextAttributes();
    attributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
    attributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
    return attributes;
  }
  else if (SUPPORTED_TYPES.contains(token)) {
    return getAttributes(scheme, JavaHighlightingColors.KEYWORD);
  }
  else if (SUPPORTED_MODIFIERS.contains(token)) {
    getAttributes(scheme, JavaHighlightingColors.KEYWORD);
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:JavaRearranger.java

示例7: isInherited

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
public boolean isInherited(TextAttributesKey key) {
  TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
  if (fallbackKey != null) {
    if (myParentScheme instanceof AbstractColorsScheme) {
      TextAttributes ownAttrs = ((AbstractColorsScheme)myParentScheme).getDirectlyDefinedAttributes(key);
      if (ownAttrs != null) {
        return ownAttrs.isFallbackEnabled();
      }
    }
    TextAttributes attributes = getAttributes(key);
    if (attributes != null) {
      TextAttributes fallbackAttributes = getAttributes(fallbackKey);
      return attributes == fallbackAttributes;
    }
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:ColorAndFontOptions.java

示例8: highlightAllOccurrences

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
/**
 * @return List of highlighters
 */
public static List<RangeHighlighter> highlightAllOccurrences(Project project, PsiElement[] occurrences, Editor editor) {
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (occurrences.length > 1) {
    for (PsiElement occurrence : occurrences) {
      final RangeMarker rangeMarker = occurrence.getUserData(ElementToWorkOn.TEXT_RANGE);
      if (rangeMarker != null && rangeMarker.isValid()) {
        highlightManager
          .addRangeHighlight(editor, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), attributes, true, highlighters);
      }
      else {
        final TextRange textRange = occurrence.getTextRange();
        highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, highlighters);
      }
    }
  }
  return highlighters;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:RefactoringUtil.java

示例9: equals

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
private static boolean equals(TextAttributes attributes1, TextAttributes attributes2) {
  if (attributes2 == null) {
    return attributes1 == null;
  }
  if(attributes1 == null) {
    return false;
  }
  if(!Comparing.equal(attributes1.getForegroundColor(), attributes2.getForegroundColor())) {
    return false;
  }
  if(attributes1.getFontType() != attributes2.getFontType()) {
    return false;
  }
  if(!Comparing.equal(attributes1.getBackgroundColor(), attributes2.getBackgroundColor())) {
    return false;
  }
  if(!Comparing.equal(attributes1.getEffectColor(), attributes2.getEffectColor())) {
    return false;
  }
  return true;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:HTMLTextPainter.java

示例10: testScopeBased

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
  scopeManager.addScope(xScope);
  scopeManager.addScope(utilScope);

  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);
  TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

  TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
  TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
  scheme.setAttributes(utilKey, utilAttributes);

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:AdvHighlightingTest.java

示例11: update

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
@Override
public void update(PresentationData presentation) {
  String newName = getValue().getName();
  int nameEndOffset = newName.length();
  int todoItemCount = getTodoItemCount(getValue());
  int fileCount = getFileCount(getValue());
  newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
  myHighlightedRegions.clear();

  TextAttributes textAttributes = new TextAttributes();

  if (CopyPasteManager.getInstance().isCutElement(getValue())) {
    textAttributes.setForegroundColor(CopyPasteManager.CUT_COLOR);
  }
  myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));

  EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
  myHighlightedRegions.add(
    new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
  presentation.setIcon(ModuleType.get(getValue()).getIcon());
  presentation.setPresentableText(newName);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:ModuleToDoNode.java

示例12: getAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
@Override
public TextAttributes getAttributes(TextAttributesKey key) {
  if (key != null) {
    TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
    TextAttributes attributes = getDirectlyDefinedAttributes(key);
    if (fallbackKey == null) {
      if (containsValue(attributes)) return attributes;
    }
    else {
      if (containsValue(attributes) && !attributes.isFallbackEnabled()) return attributes;
      attributes = getFallbackAttributes(fallbackKey);
      if (containsValue(attributes)) return attributes;
    }
  }
  return myParentScheme.getAttributes(key);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:EditorColorsSchemeImpl.java

示例13: flashUsageScriptaculously

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
private static void flashUsageScriptaculously(@NotNull final Usage usage) {
  if (!(usage instanceof UsageInfo2UsageAdapter)) {
    return;
  }
  UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage;

  Editor editor = usageInfo.openTextEditor(true);
  if (editor == null) return;
  TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);

  RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6);
  List<Segment> segments = new ArrayList<Segment>();
  CommonProcessors.CollectProcessor<Segment> processor = new CommonProcessors.CollectProcessor<Segment>(segments);
  usageInfo.processRangeMarkers(processor);
  rangeBlinker.resetMarkers(segments);
  rangeBlinker.startBlinking();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:SearchForUsagesRunnable.java

示例14: renderElement

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
public void renderElement(LookupElement element, LookupElementPresentation presentation) {
  Suggestion suggestion = (Suggestion) element.getObject();
  if (suggestion.icon != null) {
    presentation.setIcon(suggestion.icon);
  }

  presentation.setStrikeout(suggestion.deprecationLevel != null);
  if (suggestion.deprecationLevel != null) {
    if (suggestion.deprecationLevel == SpringConfigurationMetadataDeprecationLevel.error) {
      presentation.setItemTextForeground(RED);
    } else {
      presentation.setItemTextForeground(YELLOW);
    }
  }

  String lookupString = element.getLookupString();
  presentation.setItemText(lookupString);
  if (!lookupString.equals(suggestion.suggestion)) {
    presentation.setItemTextBold(true);
  }

  String shortDescription;
  if (suggestion.defaultValue != null) {
    shortDescription = shortenTextWithEllipsis(suggestion.defaultValue, 60, 0, true);
    TextAttributes attrs =
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(SCALAR_TEXT);
    presentation.setTailText("=" + shortDescription, attrs.getForegroundColor());
  }

  if (suggestion.description != null) {
    presentation.appendTailText(
        " (" + Util.getFirstSentenceWithoutDot(suggestion.description) + ")", true);
  }

  if (suggestion.shortType != null) {
    presentation.setTypeText(suggestion.shortType);
  }
}
 
開發者ID:1tontech,項目名稱:intellij-spring-assistant,代碼行數:39,代碼來源:Suggestion.java

示例15: getNormalAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //導入依賴的package包/類
private static TextAttributes getNormalAttributes() {
    TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.INLINED_VALUES);
    if (attributes == null || attributes.getForegroundColor() == null) {
        return new TextAttributes(new JBColor(Gray._135, new Color(0x3d8065)), null, null, null, Font.ITALIC);
    }
    return attributes;
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:8,代碼來源:RmlEditorLinePainter.java


注:本文中的com.intellij.openapi.editor.markup.TextAttributes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。