Search in sources :

Example 1 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class XmlTagInplaceRenamer method addHighlights.

private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) {
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
    final HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject());
    for (final TextRange range : ranges) {
        highlightManager.addOccurrenceHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, 0, highlighters, null);
    }
    for (RangeHighlighter highlighter : highlighters) {
        highlighter.setGreedyToLeft(true);
        highlighter.setGreedyToRight(true);
    }
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) TextRange(com.intellij.openapi.util.TextRange) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 2 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class GroovyRefactoringUtil method highlightOccurrences.

public static void highlightOccurrences(Project project, @Nullable Editor editor, PsiElement[] elements) {
    if (editor == null)
        return;
    ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
    HighlightManager highlightManager = HighlightManager.getInstance(project);
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    if (elements.length > 0) {
        highlightManager.addOccurrenceHighlights(editor, elements, attributes, false, highlighters);
    }
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 3 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class PythonHighlightingTest method testMagicMethods.

// PY-19927
public void testMagicMethods() {
    EditorColorsManager manager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = (EditorColorsScheme) manager.getGlobalScheme().clone();
    manager.addColorsScheme(scheme);
    EditorColorsManager.getInstance().setGlobalScheme(scheme);
    TextAttributesKey xKey = TextAttributesKey.find("PY.PREDEFINED_DEFINITION");
    TextAttributes xAttributes = new TextAttributes(Color.green, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
    scheme.setAttributes(xKey, xAttributes);
    doTest();
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Example 4 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class PythonHighlightingTest method testBuiltins.

public void testBuiltins() {
    EditorColorsManager manager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = (EditorColorsScheme) manager.getGlobalScheme().clone();
    manager.addColorsScheme(scheme);
    EditorColorsManager.getInstance().setGlobalScheme(scheme);
    TextAttributesKey xKey;
    TextAttributes xAttributes;
    xKey = TextAttributesKey.find("PY.BUILTIN_NAME");
    xAttributes = new TextAttributes(Color.green, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
    scheme.setAttributes(xKey, xAttributes);
    xKey = TextAttributesKey.find("PY.PREDEFINED_USAGE");
    xAttributes = new TextAttributes(Color.yellow, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
    scheme.setAttributes(xKey, xAttributes);
    doTest();
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Example 5 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class PythonHighlightingTest method testYieldInNestedFunction.

public void testYieldInNestedFunction() {
    // highlight func declaration first, lest we get an "Extra fragment highlighted" error.
    EditorColorsManager manager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = (EditorColorsScheme) manager.getGlobalScheme().clone();
    manager.addColorsScheme(scheme);
    EditorColorsManager.getInstance().setGlobalScheme(scheme);
    TextAttributesKey xKey = TextAttributesKey.find("PY.FUNC_DEFINITION");
    TextAttributes xAttributes = new TextAttributes(Color.red, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
    scheme.setAttributes(xKey, xAttributes);
    doTest();
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Aggregations

EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)43 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)37 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)22 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)14 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)9 Editor (com.intellij.openapi.editor.Editor)7 Project (com.intellij.openapi.project.Project)7 TextRange (com.intellij.openapi.util.TextRange)7 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)6 ArrayList (java.util.ArrayList)6 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)4 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)3 WindowManager (com.intellij.openapi.wm.WindowManager)3 PsiElement (com.intellij.psi.PsiElement)3 Nullable (org.jetbrains.annotations.Nullable)3 FindManager (com.intellij.find.FindManager)2 FindModel (com.intellij.find.FindModel)2 Application (com.intellij.openapi.application.Application)2 Document (com.intellij.openapi.editor.Document)2 StatusBar (com.intellij.openapi.wm.StatusBar)2