Search in sources :

Example 46 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class IterationState method getBreakAttributes.

public TextAttributes getBreakAttributes() {
    TextAttributes attributes = new TextAttributes();
    setAttributes(attributes, true);
    return attributes;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 47 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class EditorColorsSchemeImplTest method testSaveNoInheritanceAndDefaults.

public void testSaveNoInheritanceAndDefaults() {
    TextAttributes declarationAttrs = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME).getAttributes(DefaultLanguageHighlighterColors.IDENTIFIER).clone();
    Pair<EditorColorsScheme, TextAttributes> result = doTestWriteRead(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION, declarationAttrs);
    TextAttributes fallbackAttrs = result.first.getAttributes(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION.getFallbackAttributeKey());
    assertThat(result.second).isEqualTo(fallbackAttrs);
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 48 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class DocumentMarkupModelTest method testInfoTestAttributes.

public void testInfoTestAttributes() throws Exception {
    LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<>();
    extension.language = "TEXT";
    extension.implementationClass = TestAnnotator.class.getName();
    PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, myFixture.getTestRootDisposable());
    myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
    EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()) {

        {
            initFonts();
        }
    };
    scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
    ((EditorEx) myFixture.getEditor()).setColorsScheme(scheme);
    myFixture.doHighlighting();
    MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
    RangeHighlighter[] highlighters = model.getAllHighlighters();
    assertThat(highlighters).hasSize(1);
    TextAttributes attributes = highlighters[0].getTextAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.getBackgroundColor()).isNull();
    assertThat(attributes.getForegroundColor()).isNull();
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Annotator(com.intellij.lang.annotation.Annotator) EditorColorsSchemeImpl(com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl) DefaultColorsScheme(com.intellij.openapi.editor.colors.impl.DefaultColorsScheme) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel)

Example 49 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class EditorPaintingTest method testCaretRowWinsOverSyntaxEvenInPresenceOfHighlighter.

public void testCaretRowWinsOverSyntaxEvenInPresenceOfHighlighter() throws Exception {
    initText("foo");
    setUniformEditorHighlighter(new TextAttributes(null, Color.red, null, null, Font.PLAIN));
    addRangeHighlighter(0, 3, 0, null, Color.blue);
    checkResult();
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 50 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class EditorColorsSchemeImplTest method testUpgradeFromVer141.

public void testUpgradeFromVer141() throws Exception {
    TextAttributesKey constKey = DefaultLanguageHighlighterColors.CONSTANT;
    TextAttributesKey fallbackKey = constKey.getFallbackAttributeKey();
    assertNotNull(fallbackKey);
    EditorColorsScheme scheme = loadScheme("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<scheme name=\"Test\" version=\"141\" parent_scheme=\"Default\">\n" + "<attributes>" + "   <option name=\"TEXT\">\n" + "      <value>\n" + "           option name=\"FOREGROUND\" value=\"ffaaaa\" />\n" + "      </value>\n" + "   </option>" + "</attributes>" + "</scheme>\n");
    TextAttributes constAttrs = scheme.getAttributes(constKey);
    TextAttributes fallbackAttrs = scheme.getAttributes(fallbackKey);
    assertNotSame(fallbackAttrs, constAttrs);
    assertEquals(Font.BOLD | Font.ITALIC, constAttrs.getFontType());
    TextAttributes classAttrs = scheme.getAttributes(DefaultLanguageHighlighterColors.CLASS_NAME);
    TextAttributes classFallbackAttrs = scheme.getAttributes(DefaultLanguageHighlighterColors.CLASS_NAME.getFallbackAttributeKey());
    assertSame(classFallbackAttrs, classAttrs);
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Aggregations

TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)205 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)40 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)31 NotNull (org.jetbrains.annotations.NotNull)29 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)28 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)26 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)26 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)23 TextRange (com.intellij.openapi.util.TextRange)21 Nullable (org.jetbrains.annotations.Nullable)21 ArrayList (java.util.ArrayList)19 Editor (com.intellij.openapi.editor.Editor)18 Project (com.intellij.openapi.project.Project)17 PsiElement (com.intellij.psi.PsiElement)12 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 JBColor (com.intellij.ui.JBColor)10 Document (com.intellij.openapi.editor.Document)9 ContainerUtil (com.intellij.util.containers.ContainerUtil)9 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)8