update code and new tag color
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / editors / PHPConfiguration.java
1 package net.sourceforge.phpeclipse.editors;
2
3 import org.eclipse.jface.text.IDocument;
4 import org.eclipse.jface.text.ITextDoubleClickStrategy;
5 import org.eclipse.jface.text.TextAttribute;
6 import org.eclipse.jface.text.presentation.IPresentationReconciler;
7 import org.eclipse.jface.text.presentation.PresentationReconciler;
8 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
9 import org.eclipse.jface.text.rules.Token;
10 import org.eclipse.jface.text.source.ISourceViewer;
11 import org.eclipse.jface.text.source.SourceViewerConfiguration;
12
13 public class PHPConfiguration extends SourceViewerConfiguration
14 {
15         private PHPScanner scanner;
16         private ColorManager colorManager;
17
18         public PHPConfiguration(ColorManager colorManager)
19         {
20                 this.colorManager = colorManager;
21         }
22         public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
23         {
24                 return new String[] {
25                         IDocument.DEFAULT_CONTENT_TYPE,
26                         PHPPartitionScanner.HTML_COMMENT,
27                         PHPPartitionScanner.HTML_TAG };
28         }
29
30         protected PHPScanner getXMLScanner()
31         {
32                 if (scanner == null)
33                 {
34                         scanner = new PHPScanner(colorManager);
35                         scanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(IPHPColorConstants.DEFAULT))));
36                 }
37                 return scanner;
38         
39         
40         }
41         
42         
43
44
45         public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
46         {
47                 PresentationReconciler reconciler = new PresentationReconciler();
48
49                 DefaultDamagerRepairer dr =
50                 new DefaultDamagerRepairer(getXMLScanner());
51                 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
52                 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
53
54                 return reconciler;
55         }
56         
57         
58         
59
60 }
61