Enable component type SCL script editor to visualize maching brackets and apply code color highlighting
Normal SCL script editors have proper SCL code color highlighting and matching bracket visualization (<> [] () {}
).
Neither of these work in component type SCL script editors or procedural component type substructure-code script editors which since they don't share the same SCL editor base class (SCLModuleEditor2
vs. SCLModuleEditor
).
Code coloring comes from the IDocumentProvider
applied to the editor (SCLModuleEditor2DocumentProvider
vs ComponentTypeScriptDocumentProvider
). This code needs to be applied to the IDocument
produced by createDocument
:
IDocumentPartitioner partitioner = new FastPartitioner(new SCLPartitionScanner(), SCLPartitionScanner.PARTITION_TYPES);
partitioner.connect(doc);
doc.setDocumentPartitioner(partitioner);
To get the matching bracket visualization, the editor needs to apply this code from SCLModuleEditor2
:
@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);
}
Edited by Tuukka Lehtonen