Search in sources :

Example 26 with RangeHighlighter

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

the class SimpleDiffChange method createOperation.

//
// Helpers
//
@NotNull
private MyGutterOperation createOperation(@NotNull Side side) {
    int offset = side.getStartOffset(myFragment);
    EditorEx editor = myViewer.getEditor(side);
    RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE);
    return new MyGutterOperation(side, highlighter);
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) EditorEx(com.intellij.openapi.editor.ex.EditorEx) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with RangeHighlighter

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

the class SimpleOnesideDiffViewer method onDispose.

@Override
@CalledInAwt
protected void onDispose() {
    for (RangeHighlighter highlighter : myHighlighters) {
        highlighter.dispose();
    }
    myHighlighters.clear();
    super.onDispose();
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 28 with RangeHighlighter

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

the class UnifiedDiffChange method createOperation.

@NotNull
private MyGutterOperation createOperation(@NotNull Side sourceSide) {
    int offset = myEditor.getDocument().getLineStartOffset(myLine1);
    RangeHighlighter highlighter = myEditor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE);
    return new MyGutterOperation(sourceSide, highlighter);
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with RangeHighlighter

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

the class UnifiedEditorRangeHighlighter method apply.

public void apply(@Nullable Project project, @NotNull Document document) {
    MarkupModel model = DocumentMarkupModel.forDocument(document, project, true);
    for (Element piece : myPieces) {
        RangeHighlighterEx delegate = piece.getDelegate();
        if (!delegate.isValid())
            continue;
        RangeHighlighter highlighter = model.addRangeHighlighter(piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getTextAttributes(), delegate.getTargetArea());
        highlighter.setEditorFilter(delegate.getEditorFilter());
        highlighter.setCustomRenderer(delegate.getCustomRenderer());
        highlighter.setErrorStripeMarkColor(delegate.getErrorStripeMarkColor());
        highlighter.setErrorStripeTooltip(delegate.getErrorStripeTooltip());
        highlighter.setGutterIconRenderer(delegate.getGutterIconRenderer());
        highlighter.setLineMarkerRenderer(delegate.getLineMarkerRenderer());
        highlighter.setLineSeparatorColor(delegate.getLineSeparatorColor());
        highlighter.setThinErrorStripeMark(delegate.isThinErrorStripeMark());
        highlighter.setLineSeparatorPlacement(delegate.getLineSeparatorPlacement());
        highlighter.setLineSeparatorRenderer(delegate.getLineSeparatorRenderer());
    }
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) RangeHighlighterEx(com.intellij.openapi.editor.ex.RangeHighlighterEx) DocumentMarkupModel(com.intellij.openapi.editor.impl.DocumentMarkupModel) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel)

Example 30 with RangeHighlighter

use of com.intellij.openapi.editor.markup.RangeHighlighter 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)

Aggregations

RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)102 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)29 TextRange (com.intellij.openapi.util.TextRange)23 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)18 Editor (com.intellij.openapi.editor.Editor)17 ArrayList (java.util.ArrayList)16 NotNull (org.jetbrains.annotations.NotNull)15 Project (com.intellij.openapi.project.Project)13 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)10 MarkupModel (com.intellij.openapi.editor.markup.MarkupModel)10 Document (com.intellij.openapi.editor.Document)9 RelativePoint (com.intellij.ui.awt.RelativePoint)8 Nullable (org.jetbrains.annotations.Nullable)8 EditorEx (com.intellij.openapi.editor.ex.EditorEx)7 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)7 PsiElement (com.intellij.psi.PsiElement)6 EditorWindow (com.intellij.injected.editor.EditorWindow)4 Result (com.intellij.openapi.application.Result)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)4 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)4