/** * Disables showing of matching characters. */ private void hideMatchingCharacters() { if (fMatchingCharacterPainter != null) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fMatchingCharacterPainter); fMatchingCharacterPainter.deactivate(true); fMatchingCharacterPainter.dispose(); fMatchingCharacterPainter= null; } } }
/** * Enables showing of matching characters. */ private void showMatchingCharacters() { if (fMatchingCharacterPainter == null) { if (fSourceViewer instanceof ITextViewerExtension2) { fMatchingCharacterPainter= new MatchingCharacterPainter(fSourceViewer, fCharacterPairMatcher); fMatchingCharacterPainter.setColor(getColor(fMatchingCharacterPainterColorKey)); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fMatchingCharacterPainter); } } }
/** * Sets whether to highlight the character at caret location or not. * * @param highlightCharacterAtCaretLocation whether to highlight the character at caret location * or not * @since 3.8 */ public void setHighlightCharacterAtCaretLocation(boolean highlightCharacterAtCaretLocation) { handleDrawRequest(null); // see https://bugs.eclipse.org/372515 fHighlightCharacterAtCaretLocation= highlightCharacterAtCaretLocation; }
fMatchingCharacterPainter.setHighlightCharacterAtCaretLocation(isCharacterAtCaretLocationShown()); fMatchingCharacterPainter.paint(IPainter.CONFIGURATION); fMatchingCharacterPainter.setHighlightEnclosingPeerCharacters(areEnclosingPeerCharactersShown()); fMatchingCharacterPainter.paint(IPainter.CONFIGURATION); fMatchingCharacterPainter.setColor(getColor(fMatchingCharacterPainterColorKey)); fMatchingCharacterPainter.paint(IPainter.CONFIGURATION);
/** * 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); } } }
deactivate(false); return; IRegion selection= getSignedSelection(fSourceViewer); IRegion pair; boolean characterPresentAtCaretLocation; if (fCharacterPresentAtCaretLocation && !fHighlightCharacterAtCaretLocation) { fCharacterPresentAtCaretLocation= false; handleDrawRequest(null); deactivate(true); return; deactivate(true); return; handleDrawRequest(null); handleDrawRequest(null); fCharacterPresentAtCaretLocation= characterPresentAtCaretLocation; handleDrawRequest(null); handleDrawRequest(null);
/** * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent) */ @Override public void textChanged(TextEvent event) { if (!fHighlightEnclosingPeerCharacters || !(fMatcher instanceof ICharacterPairMatcherExtension)) return; if (!event.getViewerRedrawState()) return; String text= event.getText(); String replacedText= event.getReplacedText(); ICharacterPairMatcherExtension matcher= (ICharacterPairMatcherExtension)fMatcher; if (searchForCharacters(text, matcher) || searchForCharacters(replacedText, matcher)) paint(IPainter.INTERNAL); }
/** * Sets whether to highlight enclosing peer characters or not. * * @param highlightEnclosingPeerCharcters whether to highlight enclosing peer characters or not * @since 3.8 */ public void setHighlightEnclosingPeerCharacters(boolean highlightEnclosingPeerCharcters) { fHighlightEnclosingPeerCharacters= highlightEnclosingPeerCharcters; installUninstallTextListener(highlightEnclosingPeerCharcters); }
fMatchingCharacterPainter.setHighlightCharacterAtCaretLocation(isCharacterAtCaretLocationShown()); fMatchingCharacterPainter.paint(IPainter.CONFIGURATION); fMatchingCharacterPainter.setHighlightEnclosingPeerCharacters(areEnclosingPeerCharactersShown()); fMatchingCharacterPainter.paint(IPainter.CONFIGURATION); fMatchingCharacterPainter.setColor(getColor(fMatchingCharacterPainterColorKey)); fMatchingCharacterPainter.paint(IPainter.CONFIGURATION);
/** * 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); } } }
deactivate(false); return; IRegion selection= getSignedSelection(fSourceViewer); IRegion pair; boolean characterPresentAtCaretLocation; if (fCharacterPresentAtCaretLocation && !fHighlightCharacterAtCaretLocation) { fCharacterPresentAtCaretLocation= false; handleDrawRequest(null); deactivate(true); return; deactivate(true); return; handleDrawRequest(null); handleDrawRequest(null); fCharacterPresentAtCaretLocation= characterPresentAtCaretLocation; handleDrawRequest(null); handleDrawRequest(null);
/** * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent) */ @Override public void textChanged(TextEvent event) { if (!fHighlightEnclosingPeerCharacters || !(fMatcher instanceof ICharacterPairMatcherExtension)) return; if (!event.getViewerRedrawState()) return; String text= event.getText(); String replacedText= event.getReplacedText(); ICharacterPairMatcherExtension matcher= (ICharacterPairMatcherExtension)fMatcher; if (searchForCharacters(text, matcher) || searchForCharacters(replacedText, matcher)) paint(IPainter.INTERNAL); }
/** * Sets whether to highlight enclosing peer characters or not. * * @param highlightEnclosingPeerCharcters whether to highlight enclosing peer characters or not * @since 3.8 */ public void setHighlightEnclosingPeerCharacters(boolean highlightEnclosingPeerCharcters) { fHighlightEnclosingPeerCharacters= highlightEnclosingPeerCharcters; installUninstallTextListener(highlightEnclosingPeerCharcters); }
/** * Disables showing of matching characters. */ private void hideMatchingCharacters() { if (fMatchingCharacterPainter != null) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fMatchingCharacterPainter); fMatchingCharacterPainter.deactivate(true); fMatchingCharacterPainter.dispose(); fMatchingCharacterPainter= null; } } }
/** * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) */ public void setDocument( IDocument document ) { if ( sourceViewer.getAnnotationModel() == null ) { IAnnotationModel model = new AnnotationModel(); sourceViewer.setDocument( sourceViewer.getDocument(), model ); } // add annotation painter if ( paintManager == null && sourceViewer.getAnnotationModel() instanceof IAnnotationModelExtension ) { AnnotationPainter ap = new AnnotationPainter( sourceViewer, null ); ap.addAnnotationType( "DEFAULT" ); //$NON-NLS-1$ ap.setAnnotationTypeColor( "DEFAULT", BrowserCommonActivator.getDefault().getColor( new RGB( 255, 0, 0 ) ) ); //$NON-NLS-1$ sourceViewer.getAnnotationModel().addAnnotationModelListener( ap ); FilterCharacterPairMatcher cpm = new FilterCharacterPairMatcher( sourceViewer, parser ); MatchingCharacterPainter mcp = new MatchingCharacterPainter( sourceViewer, cpm ); mcp.setColor( BrowserCommonActivator.getDefault().getColor( new RGB( 159, 159, 159 ) ) ); paintManager = new PaintManager( sourceViewer ); paintManager.addPainter( ap ); paintManager.addPainter( mcp ); } }
/** * Sets whether to highlight the character at caret location or not. * * @param highlightCharacterAtCaretLocation whether to highlight the character at caret location * or not * @since 3.8 */ public void setHighlightCharacterAtCaretLocation(boolean highlightCharacterAtCaretLocation) { handleDrawRequest(null); // see https://bugs.eclipse.org/372515 fHighlightCharacterAtCaretLocation= highlightCharacterAtCaretLocation; }
@Override public void dispose() { if (fMatcher != null) { if (fMatcher instanceof ICharacterPairMatcherExtension && fTextListener != null) { installUninstallTextListener(false); } fMatcher.clear(); fMatcher= null; } fColor= null; fTextWidget= null; }