How to add columns in SourceViewer at right side? [message #1060416] |
Fri, 24 May 2013 10:31  |
Eclipse User |
|
|
|
Hi,
I have some special requirement to the text editor. I want to show the source code (C, C++) in editor with line number, hot-spots (overview ruler) and some colums at the right side of the text. These columns will have some information about corresponding line. Something like attached screen-shot. How can I do this? I found org.eclipse.ui.workbench.texteditor.rulerColumns; which can be used for line based information but the problem is it adds the column to the ruler i.e. at left hand side of text and I want it right side. Also the overview ruler is outside the scroll bar hence can not be used. Could you please help me to acheive this requirement?
For this I have implemented extension point "org.eclipse.ui.editors". And override createPartControl() method of EditorPart (pasting code below); where I am creating SourceViewer control and rulers.
------------------------------
public void createPartControl(Composite parent) {
final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
sashForm.setLayout(new RowLayout());
CompositeRuler lineNumRuler = new CompositeRuler();
LineNumberRulerColumn lineCol = new LineNumberRulerColumn();
lineNumRuler.addDecorator(0, lineCol);
OverviewRuler overviewRuler = new OverviewRuler(null, 10, null);
SourceViewer viewer = new SourceViewer(sashForm, lineNumRuler,
overviewRuler, true, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI
| SWT.BORDER | SWT.FULL_SELECTION);
AnnotationRulerColumn col = new AnnotationRulerColumn(10);
viewer.addVerticalRulerColumn(col);
Document document = new Document("My C code here");
viewer.setDocument(document);
}
------------------------------------
--
God bless you and all,
Ramesh
Attachment: editor.png
(Size: 32.47KB, Downloaded 216 times)
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03668 seconds