Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("TextViewerDemo");
shell.setBounds(150, 150, 220, 180);
shell.setLayout(new FillLayout());
final TextViewer textViewer = new TextViewer(shell, SWT.MULTI
| SWT.V_SCROLL);
String string = "13213131313\n" + "qwertyuiotyuiop\n"
+ "4444444444444444";
org.eclipse.jface.text.Document document = org.eclipse.jface.text
.Document(string);
textViewer.setDocument(document);
TextPresentation stylePresentation = new TextPresentation();
stylePresentation.addStyleRange(new StyleRange(19, 17, null, null,
SWT.BOLD));
org.eclipse.swt.graphics.Color red = new org.eclipse.swt.graphics.Color(
display, 255, 0, 0);
stylePresentation.addStyleRange(new StyleRange(37, 16, red, null));
textViewer.changeTextPresentation(stylePresentation, true);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
373

被折叠的 条评论
为什么被折叠?



