Hiding text in Editor [message #890010] |
Wed, 20 June 2012 14:51 |
Ali Pang Messages: 1 Registered: June 2012 |
Junior Member |
|
|
Hey!
I'm trying to create an editor where I'm hiding certain patterns, e.g. I'd like to display the document
as
i.e. hiding the pattern @1000. This might appear multiple times within a line.
I've managed to get what I want using a ProjectionDocument, but this messes up my syntax highlighting etc (still appears, but with incorrect offsets.). I'm probably setting things up wrong. Are there any code examples of doing something similar somewhere?
To clarify, I do _not_ want this to behave as the java code folding, with expansion/collapsing. I'd simply like some text completely hidden from view.
Thanks for any help! My code so far has been to simply try to create an extension of FileDocumentProvider, but this appears not to be enough.
public class MyDocumentProvider extends FileDocumentProvider {
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = super.createDocument(element);
ProjectionDocumentManager pMan = new ProjectionDocumentManager();
ProjectionDocument pDoc = (ProjectionDocument) pMan.createSlaveDocument(document);
// just remove the first 10 characters for testing
try {
pDoc.addMasterDocumentRange(10, document.getLength() - 10);
} catch (BadLocationException e)
{
e.printStackTrace();
}
// set up scanners
if (pDoc != null) {
IDocumentPartitioner partitioner =
new FastPartitioner(
new MyPartitionScanner(),
new String[]
{
MyPartitionScanner.COMMENT_CONTENT,
MYPartitionScanner.STRING_CONTENT
});
partitioner.connect(pDoc);
pDoc.setDocumentPartitioner(partitioner);
}
return pDoc;
}
}
Any help on how to set this up properly much appreciated.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03313 seconds