本文整理汇总了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);
}
}
示例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);
}
});
}
示例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()));
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
}
示例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;
}