use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class RainbowColorsInSchemeState method apply.
public void apply(@Nullable EditorColorsScheme scheme) {
if (scheme != null && scheme != myEditedScheme) {
RainbowHighlighter.transferRainbowState(scheme, myEditedScheme);
for (TextAttributesKey key : RainbowHighlighter.RAINBOW_COLOR_KEYS) {
Color color = myEditedScheme.getAttributes(key).getForegroundColor();
if (!color.equals(scheme.getAttributes(key).getForegroundColor())) {
scheme.setAttributes(key, RainbowHighlighter.createRainbowAttribute(color));
}
}
updateRainbowMarkup();
}
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class SimpleEditorPreview method startBlinkingHighlights.
private List<HighlightData> startBlinkingHighlights(final EditorEx editor, final String attrKey, final SyntaxHighlighter highlighter, final boolean show, final Alarm alarm, final int count, final ColorSettingsPage page) {
if (show && count <= 0)
return Collections.emptyList();
removeDecorations(editor);
boolean found = false;
List<HighlightData> highlights = new ArrayList<>();
List<HighlightData> matchingHighlights = new ArrayList<>();
for (HighlightData highlightData : myHighlightData) {
boolean highlight = show && highlightData.getHighlightType().equals(attrKey);
highlightData.addToCollection(highlights, highlight);
if (highlight) {
matchingHighlights.add(highlightData);
found = true;
}
}
if (!found && highlighter != null) {
HighlighterIterator iterator = editor.getHighlighter().createIterator(0);
do {
IElementType tokenType = iterator.getTokenType();
TextAttributesKey[] tokenHighlights = highlighter.getTokenHighlights(tokenType);
for (final TextAttributesKey tokenHighlight : tokenHighlights) {
String type = tokenHighlight.getExternalName();
if (show && type != null && type.equals(attrKey)) {
HighlightData highlightData = new HighlightData(iterator.getStart(), iterator.getEnd(), BLINKING_HIGHLIGHTS_ATTRIBUTES);
highlights.add(highlightData);
matchingHighlights.add(highlightData);
}
}
iterator.advance();
} while (!iterator.atEnd());
}
final Map<TextAttributesKey, String> displayText = ColorSettingsUtil.keyToDisplayTextMap(page);
// sort highlights to avoid overlappings
Collections.sort(highlights, Comparator.comparingInt(HighlightData::getStartOffset));
for (int i = highlights.size() - 1; i >= 0; i--) {
HighlightData highlightData = highlights.get(i);
int startOffset = highlightData.getStartOffset();
HighlightData prevHighlightData = i == 0 ? null : highlights.get(i - 1);
if (prevHighlightData != null && startOffset <= prevHighlightData.getEndOffset() && highlightData.getHighlightType().equals(prevHighlightData.getHighlightType())) {
prevHighlightData.setEndOffset(highlightData.getEndOffset());
} else {
highlightData.addHighlToView(editor, myOptions.getSelectedScheme(), displayText);
}
}
alarm.cancelAllRequests();
alarm.addComponentRequest(() -> startBlinkingHighlights(editor, attrKey, highlighter, !show, alarm, count - 1, page), 400);
return matchingHighlights;
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class SimpleEditorPreview method selectItem.
@Nullable
private static String selectItem(HighlighterIterator itr, SyntaxHighlighter highlighter) {
IElementType tokenType = itr.getTokenType();
if (tokenType == null)
return null;
TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType);
String s = null;
for (int i = highlights.length - 1; i >= 0; i--) {
if (highlights[i] != HighlighterColors.TEXT) {
s = highlights[i].getExternalName();
break;
}
}
return s == null ? HighlighterColors.TEXT.getExternalName() : s;
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class ApplicationInspectionProfileManager method registerProvidedSeverities.
// It should be public to be available from Upsource
public static void registerProvidedSeverities() {
for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
for (HighlightInfoType t : provider.getSeveritiesHighlightInfoTypes()) {
HighlightSeverity highlightSeverity = t.getSeverity(null);
SeverityRegistrar.registerStandard(t, highlightSeverity);
TextAttributesKey attributesKey = t.getAttributesKey();
Icon icon = t instanceof HighlightInfoType.Iconable ? ((HighlightInfoType.Iconable) t).getIcon() : null;
HighlightDisplayLevel.registerSeverity(highlightSeverity, attributesKey, icon);
}
}
}
use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.
the class EclipseColorSchemeImporter method setupMissingColors.
private static void setupMissingColors(@NotNull EditorColorsScheme scheme) {
Color background = scheme.getDefaultBackground();
String defaultSchemeName = ColorUtil.isDark(background) ? "Darcula" : EditorColorsScheme.DEFAULT_SCHEME_NAME;
EditorColorsScheme baseScheme = DefaultColorSchemesManager.getInstance().getScheme(defaultSchemeName);
assert baseScheme != null : "Can not find default scheme '" + defaultSchemeName + "'!";
for (TextAttributesKey attributesKey : ATTRIBUTES_TO_COPY) {
copyAttributes(baseScheme, scheme, attributesKey);
}
for (String keyName : EXTERNAL_ATTRIBUTES) {
TextAttributesKey key = TextAttributesKey.createTextAttributesKey(keyName);
copyAttributes(baseScheme, scheme, key);
}
Color lightForeground = ColorUtil.mix(background, scheme.getDefaultForeground(), 0.5);
scheme.setColor(EditorColors.WHITESPACES_COLOR, lightForeground);
scheme.setColor(EditorColors.INDENT_GUIDE_COLOR, lightForeground);
scheme.setColor(EditorColors.SOFT_WRAP_SIGN_COLOR, lightForeground);
TextAttributes matchedBrace = new TextAttributes();
matchedBrace.setEffectType(EffectType.BOXED);
matchedBrace.setEffectColor(lightForeground);
scheme.setAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES, matchedBrace);
TextAttributes unmatchedBrace = matchedBrace.clone();
unmatchedBrace.setEffectColor(ColorUtil.mix(background, Color.RED, 0.5));
}
Aggregations