import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.link.LinkedModeModel;
import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ST;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.IUpdate;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
import org.eclipse.ui.texteditor.TextNavigationAction;
import org.simantics.scl.ui.editor.SCLSourceViewerConfigurationNew;
import org.simantics.scl.ui.editor.completion.SCLTextEditorEnvironment;
import com.ibm.icu.text.BreakIterator;
public class SCLModuleEditor2 extends TextEditor {
+
+ private static final char[] CHARS = new char[] { '(', ')', '{', '}', '[', ']', '<', '>' };
+
+ private static final String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
+ private static final String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
+ private static final String HIGHLIGHT_BRACKET_AT_CARET_LOCATION = "highlightBracketAtCaretLocation"; //$NON-NLS-1$
+ private static final String ENCLOSING_BRACKETS = "enclosingBrackets"; //$NON-NLS-1$
+
private boolean disposed = false;
protected ResourceManager resourceManager;
+ private DefaultCharacterPairMatcher matcher;
public SCLModuleEditor2() {
super();
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
super.init(site, input);
+ getPreferenceStore().setValue(MATCHING_BRACKETS, true);
+ getPreferenceStore().setValue(MATCHING_BRACKETS_COLOR, "192,192,192"); //$NON-NLS-1$
+ getPreferenceStore().setValue(HIGHLIGHT_BRACKET_AT_CARET_LOCATION, true);
+ getPreferenceStore().setValue(ENCLOSING_BRACKETS, true);
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
- getEditorSite().getService(IContextService.class).activateContext("org.simantics.scl.ui.editor");
+ getEditorSite().getService(IContextService.class).activateContext("org.simantics.scl.ui.editor"); //$NON-NLS-1$
updatePartName();
}
protected void updatePartName() {
setPartName(getEditorInput().getName());
}
+
+ @Override
+ protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
+ matcher = new DefaultCharacterPairMatcher(CHARS);
+ support.setCharacterPairMatcher(matcher);
+ support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR, HIGHLIGHT_BRACKET_AT_CARET_LOCATION, ENCLOSING_BRACKETS);
+ super.configureSourceViewerDecorationSupport(support);
+ }
@Override
public void dispose() {
disposed = true;
super.dispose();
resourceManager.dispose();
+ if (matcher != null) matcher.dispose();
}
public boolean isDisposed() {