Search in sources :

Example 1 with MatchingCharacterPainter

use of org.eclipse.jface.text.source.MatchingCharacterPainter in project eclipse.platform.text by eclipse.

the class BracketMatchingReconciler method install.

@Override
public void install(ITextViewer textViewer) {
    if (textViewer instanceof ITextViewerExtension2 && textViewer instanceof SourceViewer) {
        fSourceViewer = (SourceViewer) textViewer;
        fMatchingCharacterPainter = new MatchingCharacterPainter(fSourceViewer, fCharacterPairMatcher);
        fMatchingCharacterPainter.setColor(new Color(Display.getCurrent(), fBoxingRGB));
        fMatchingCharacterPainter.setHighlightCharacterAtCaretLocation(true);
        fMatchingCharacterPainter.setHighlightEnclosingPeerCharacters(true);
        fSourceViewer.addPainter(fMatchingCharacterPainter);
    }
}
Also used : MatchingCharacterPainter(org.eclipse.jface.text.source.MatchingCharacterPainter) ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Color(org.eclipse.swt.graphics.Color)

Example 2 with MatchingCharacterPainter

use of org.eclipse.jface.text.source.MatchingCharacterPainter in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method showMatchingCharacters.

/**
 * Enables showing of matching characters.
 */
private void showMatchingCharacters() {
    if (fMatchingCharacterPainter == null) {
        if (fSourceViewer instanceof ITextViewerExtension2) {
            fMatchingCharacterPainter = new MatchingCharacterPainter(fSourceViewer, fCharacterPairMatcher);
            fMatchingCharacterPainter.setColor(getColor(fMatchingCharacterPainterColorKey));
            fMatchingCharacterPainter.setHighlightCharacterAtCaretLocation(isCharacterAtCaretLocationShown());
            fMatchingCharacterPainter.setHighlightEnclosingPeerCharacters(areEnclosingPeerCharactersShown());
            ITextViewerExtension2 extension = (ITextViewerExtension2) fSourceViewer;
            extension.addPainter(fMatchingCharacterPainter);
        }
    }
}
Also used : MatchingCharacterPainter(org.eclipse.jface.text.source.MatchingCharacterPainter) ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2)

Aggregations

ITextViewerExtension2 (org.eclipse.jface.text.ITextViewerExtension2)2 MatchingCharacterPainter (org.eclipse.jface.text.source.MatchingCharacterPainter)2 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 Color (org.eclipse.swt.graphics.Color)1