Search in sources :

Example 66 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class DiffLineMarkerRenderer method paint.

@Override
public void paint(Editor editor, Graphics g, Rectangle range) {
    EditorGutterComponentEx gutter = ((EditorEx) editor).getGutterComponentEx();
    Graphics2D g2 = (Graphics2D) g;
    int x1 = 0;
    int x2 = x1 + gutter.getWidth();
    int y1, y2;
    if (myEmptyRange && myLastLine) {
        y1 = DiffDrawUtil.lineToY(editor, DiffUtil.getLineCount(editor.getDocument()));
        y2 = y1;
    } else {
        int startLine = editor.getDocument().getLineNumber(myHighlighter.getStartOffset());
        int endLine = editor.getDocument().getLineNumber(myHighlighter.getEndOffset()) + 1;
        y1 = DiffDrawUtil.lineToY(editor, startLine);
        y2 = myEmptyRange ? y1 : DiffDrawUtil.lineToY(editor, endLine);
    }
    if (myHideWithoutLineNumbers && !editor.getSettings().isLineNumbersShown()) {
        x1 = gutter.getWhitespaceSeparatorOffset();
    } else {
        int annotationsOffset = gutter.getAnnotationsAreaOffset();
        int annotationsWidth = gutter.getAnnotationsAreaWidth();
        if (annotationsWidth != 0) {
            drawMarker(editor, g2, x1, annotationsOffset, y1, y2, false);
            x1 = annotationsOffset + annotationsWidth;
        }
    }
    if (myIgnoredFoldingOutline) {
        int xOutline = gutter.getWhitespaceSeparatorOffset();
        drawMarker(editor, g2, xOutline, x2, y1, y2, true);
        drawMarker(editor, g2, x1, xOutline, y1, y2, false);
    } else {
        drawMarker(editor, g2, x1, x2, y1, y2, false);
    }
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Example 67 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class DiffLineSeparatorRenderer method paint.

/*
   * Gutter
   */
@Override
public void paint(Editor editor, Graphics g, Rectangle r) {
    if (!myCondition.get())
        return;
    int y = r.y;
    int lineHeight = myEditor.getLineHeight();
    EditorGutterComponentEx gutter = ((EditorEx) editor).getGutterComponentEx();
    int annotationsOffset = gutter.getAnnotationsAreaOffset();
    int annotationsWidth = gutter.getAnnotationsAreaWidth();
    if (annotationsWidth != 0) {
        g.setColor(editor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND));
        g.fillRect(annotationsOffset, y, annotationsWidth, lineHeight);
    }
    draw(g, 0, y, lineHeight, myEditor.getColorsScheme());
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Example 68 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class LineStatusMarkerPopup method createEditorComponent.

@Nullable
private EditorFragmentComponent createEditorComponent(@Nullable FileType fileType, @Nullable List<DiffFragment> wordDiff) {
    if (myRange.getType() == Range.INSERTED)
        return null;
    EditorEx uEditor = (EditorEx) EditorFactory.getInstance().createViewer(myTracker.getVcsDocument(), myTracker.getProject());
    uEditor.setColorsScheme(myEditor.getColorsScheme());
    DiffUtil.setEditorCodeStyle(myTracker.getProject(), uEditor, fileType);
    EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
    uEditor.setHighlighter(highlighterFactory.createEditorHighlighter(myTracker.getProject(), getFileName(myTracker.getDocument())));
    if (wordDiff != null) {
        int vcsStartShift = myTracker.getVcsTextRange(myRange).getStartOffset();
        for (DiffFragment fragment : wordDiff) {
            int vcsStart = vcsStartShift + fragment.getStartOffset1();
            int vcsEnd = vcsStartShift + fragment.getEndOffset1();
            TextDiffType type = getDiffType(fragment);
            DiffDrawUtil.createInlineHighlighter(uEditor, vcsStart, vcsEnd, type);
        }
    }
    EditorFragmentComponent fragmentComponent = EditorFragmentComponent.createEditorFragmentComponent(myEditor.getContentComponent(), uEditor, myRange.getVcsLine1(), myRange.getVcsLine2(), false, false);
    EditorFactory.getInstance().releaseEditor(uEditor);
    return fragmentComponent;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) DiffFragment(com.intellij.diff.fragments.DiffFragment) EditorFragmentComponent(com.intellij.codeInsight.hint.EditorFragmentComponent) TextDiffType(com.intellij.diff.util.TextDiffType) EditorHighlighterFactory(com.intellij.openapi.editor.highlighter.EditorHighlighterFactory) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint) Nullable(org.jetbrains.annotations.Nullable)

Example 69 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class LineStatusMarkerRenderer method getMarkerArea.

@NotNull
public static Rectangle getMarkerArea(@NotNull Editor editor, @NotNull Rectangle r, int line1, int line2) {
    EditorGutterComponentEx gutter = ((EditorEx) editor).getGutterComponentEx();
    // leave 1px for brace highlighters
    int x = r.x + 1;
    int endX = gutter.getWhitespaceSeparatorOffset();
    int y = lineToY(editor, line1);
    int endY = lineToY(editor, line2);
    return new Rectangle(x, y, endX - x, endY - y);
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) EditorEx(com.intellij.openapi.editor.ex.EditorEx) NotNull(org.jetbrains.annotations.NotNull)

Example 70 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class DaemonRespondToChangesTest method typeInAlienEditor.

private static void typeInAlienEditor(Editor alienEditor, char c) {
    TypedAction action = EditorActionManager.getInstance().getTypedAction();
    DataContext dataContext = ((EditorEx) alienEditor).getDataContext();
    action.actionPerformed(alienEditor, c, dataContext);
}
Also used : SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) DataContext(com.intellij.openapi.actionSystem.DataContext) EditorEx(com.intellij.openapi.editor.ex.EditorEx) TypedAction(com.intellij.openapi.editor.actionSystem.TypedAction)

Aggregations

EditorEx (com.intellij.openapi.editor.ex.EditorEx)153 Editor (com.intellij.openapi.editor.Editor)32 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)32 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)28 NotNull (org.jetbrains.annotations.NotNull)23 Document (com.intellij.openapi.editor.Document)22 EditorFactory (com.intellij.openapi.editor.EditorFactory)11 Nullable (org.jetbrains.annotations.Nullable)11 TextRange (com.intellij.openapi.util.TextRange)10 Project (com.intellij.openapi.project.Project)9 IElementType (com.intellij.psi.tree.IElementType)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)7 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)7 PsiFile (com.intellij.psi.PsiFile)7 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)6 EditorGutterComponentEx (com.intellij.openapi.editor.ex.EditorGutterComponentEx)6 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)6 FileType (com.intellij.openapi.fileTypes.FileType)6 Language (com.intellij.lang.Language)5