Commit 4d7a4607 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Added syntex highlighting support for Ttcn3SourceViewControl


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 8ce057cf
......@@ -9,8 +9,12 @@ package org.eclipse.titan.designer.editors.controls;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
......@@ -26,6 +30,8 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.titan.designer.editors.ColorManager;
import org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner;
/**
* A custom TTCN3 source viewer control for the TTCN3 editor
......@@ -97,12 +103,29 @@ public class Ttcn3SourceViewControl implements IInformationControl, IInformation
}
viewer.setText(information);
// StyleRange range = new StyleRange();
// range.start = 0;
// range.length = 4;
// range.fontStyle = SWT.BOLD;
// range.foreground = viewer.getDisplay().getSystemColor(SWT.COLOR_GREEN);
// viewer.setStyleRange(range);
IDocument doc = new Document(information);
CodeScanner scanner = new CodeScanner(new ColorManager());
scanner.setRange(doc, 0, information.length());
IToken token;
for (;;) {
token = scanner.nextToken();
if (token.isEOF())
break;
int len = scanner.getTokenLength();
int offs = scanner.getTokenOffset();
StyleRange range = new StyleRange();
range.start = offs;
range.length = len;
if (token.getData() instanceof TextAttribute) {
TextAttribute attrib = (TextAttribute)token.getData();
//range.fontStyle = attrib.getFont()
range.foreground = attrib.getForeground();
}
viewer.setStyleRange(range);
}
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment