[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] Re: Hiding certain portions of text

Donny Kurniawan wrote:

Hello,

I want to create an editor that can hide certain portions of text.
For example: I want to hide all comments in a C program.

printf("1");
// Hide Me A
printf("2");
// Hide Me B
printf("3");

I just want to hide the comments in the file without actually removing the comments in the underlying file.

I know it's possible since Eclipse Text Folding / Projection is able to hide/show portions of the document.

Yes, this is possible. Take a look at ProjectionViewer and its supporting classes like ProjectionSupport, ProjectionAnnotation etc. As a code example you can either use the Java or the Ant Editor.


Dani


Browsing the APIs, I found about ITextViewer.setVisibleRegion(int start, int length). Is there a similar method that accepts an array of text regions?


If it's not supported by the Eclipse Text infrastructure, what is the best way to implement this?


Thanks,
Best regards.