| 
| Newlines disappear in SourceViewer [message #202253] | Thu, 26 February 2004 09:09 |  | 
| Eclipse User  |  |  |  |  | Originally posted by: titi-r5.bluewin.ch 
 Hi newsgroup !
 
 I want to display some xml file in a view (not an editor) with syntax
 coloring.
 
 So I created a view containing a SourceViewer and copied the code from
 the XML editor template. When I display a file in this view, the syntax
 coloring is ok, but the whole text is on one single line...
 
 I tried to change viewer style to SWT.WRAP, but this is not what I want.
 I want the viewer to keep the original whitespace, newlines, ...
 
 I thought it had something to do with IWhitespaceDetector and rules,
 scanner, ... But I really don't know how to make it behave the way I
 want it.
 
 
 Here is my createPartControl method:
 
 public void createPartControl(Composite parent) {
 viewer = new SourceViewer(parent, new VerticalRuler(10),
 SWT.H_SCROLL | SWT.V_SCROLL);
 viewer.configure(new XMIConfiguration(colorManager));
 viewer.setEditable(false);
 
 IDocument doc = new Document();
 IDocumentPartitioner partitioner = new DefaultPartitioner(
 new XMIPartitionScanner(), new String[] {
 XMIPartitionScanner.XML_TAG,
 XMIPartitionScanner.XML_COMMENT});
 partitioner.connect(doc);
 doc.setDocumentPartitioner(partitioner);
 
 viewer.setDocument(doc);
 
 String contents = ... // the contents of the file to display
 doc.set(contents);
 }
 
 The XMIConfiguration is the one provided by the XML editor template.
 
 By the way, is there an article explaining the use of SourceViewer,
 rules, scanners... ?
 
 Thanks in advance
 
 Thierry Monney
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03843 seconds