Exemplo n.º 1
0
 public static void LoadStylesAndModes(Assembly assembly)
 {
     foreach (string resource in assembly.GetManifestResourceNames())
     {
         if (!resource.EndsWith(".xml"))
         {
             continue;
         }
         if (resource.EndsWith("SyntaxMode.xml"))
         {
             using (Stream stream = assembly.GetManifestResourceStream(resource))
                 using (XmlTextReader reader = new XmlTextReader(stream)) {
                     string mimeTypes             = Scan(reader, SyntaxMode.MimeTypesAttribute);
                     ResourceXmlProvider provider = new ResourceXmlProvider(assembly, resource);
                     foreach (string mimeType in mimeTypes.Split(';'))
                     {
                         syntaxModeLookup [mimeType] = provider;
                     }
                 }
         }
         else if (resource.EndsWith("Style.xml"))
         {
             using (Stream stream = assembly.GetManifestResourceStream(resource))
                 using (XmlTextReader reader = new XmlTextReader(stream)) {
                     string styleName = Scan(reader, Style.NameAttribute);
                     styleLookup [styleName] = new ResourceXmlProvider(assembly, resource);
                 }
         }
     }
 }
Exemplo n.º 2
0
        public DSyntaxMode()
        {
            var matches = new List<Mono.TextEditor.Highlighting.Match>();

            var provider = new ResourceXmlProvider(
                typeof(DSyntaxMode).Assembly,
                typeof(DSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("DSyntaxHighlightingMode")));
            using (XmlReader reader = provider.Open())
            {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                this.rules = new List<Rule>(baseMode.Rules);
                this.keywords = new List<Keywords>(baseMode.Keywords);
                this.spans = new List<Span>(baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
                matches.AddRange(baseMode.Matches);
                this.prevMarker = baseMode.PrevMarker;
                this.SemanticRules = new List<SemanticRule>(baseMode.SemanticRules);
                this.keywordTable = baseMode.keywordTable;
                this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
                this.properties = baseMode.Properties;
            }

            // D Number literals
            matches.Add(workaroundMatchCtor("constant.digit", @"(?<!\w)(0((x|X)[0-9a-fA-F_]+|(b|B)[0-1_]+)|([0-9]+[_0-9]*)[L|U|u|f|i]*)"));

            // extern linkages attributes
            //matches.Add(workaroundMatchCtor("constant.digit", "(?<=extern[\\s]*\\()[\\s]*(C(\\+\\+)?|D|Windows|System|Pascal|Java)[\\s]*(?=\\))"));

            // version checks
            //matches.Add(workaroundMatchCtor("constant.digit", @"(?<=version[\s]*\()[\s]*(DigitalMars|GNU|LDC|Windows|OSX|linux|FreeBSD|OpenBSD|BSD|Solaris|Posix|D_Version2)[\s]*(?=\))"));

            // type declaration names
            //matches.Add(workaroundMatchCtor("keyword.semantic.type", @"(?<=(class|struct|union|interface|template)[\s]+)[\w]+"));

            this.matches = matches.ToArray();
        }
		public AspNetSyntaxMode ()
		{
			ResourceXmlProvider provider = new ResourceXmlProvider (typeof(IXmlProvider).Assembly, "AspNetSyntaxMode.xml");
			using (XmlReader reader = provider.Open ()) {
				SyntaxMode baseMode = SyntaxMode.Read (reader);
				this.rules = new List<Rule> (baseMode.Rules);
				this.keywords = new List<Keywords> (baseMode.Keywords);
				this.spans = baseMode.Spans;
				this.matches = baseMode.Matches;
				this.prevMarker = baseMode.PrevMarker;
				this.SemanticRules = new List<SemanticRule> (baseMode.SemanticRules);
				this.table = baseMode.Table;
			}
		}
Exemplo n.º 4
0
		public JaySyntaxMode ()
		{
			ResourceXmlProvider provider = new ResourceXmlProvider (typeof(IXmlProvider).Assembly, typeof(IXmlProvider).Assembly.GetManifestResourceNames ().First (s => s.Contains ("JaySyntaxMode")));
			using (XmlReader reader = provider.Open ()) {
				SyntaxMode baseMode = SyntaxMode.Read (reader);
				this.rules = new List<Rule> (baseMode.Rules);
				this.keywords = new List<Keywords> (baseMode.Keywords);
				this.spans = new List<Span> (baseMode.Spans).ToArray ();
				this.matches = baseMode.Matches;
				this.prevMarker = baseMode.PrevMarker;
				this.SemanticRules = new List<SemanticRule> (baseMode.SemanticRules);
				this.table = baseMode.Table;
				this.properties = baseMode.Properties;
			}
		}
Exemplo n.º 5
0
        public JaySyntaxMode()
        {
            ResourceXmlProvider provider = new ResourceXmlProvider(typeof(IXmlProvider).Assembly, typeof(IXmlProvider).Assembly.GetManifestResourceNames().First(s => s.Contains("JaySyntaxMode")));

            using (XmlReader reader = provider.Open()) {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                this.rules         = new List <Rule> (baseMode.Rules);
                this.keywords      = new List <Keywords> (baseMode.Keywords);
                this.spans         = new List <Span> (baseMode.Spans).ToArray();
                this.matches       = baseMode.Matches;
                this.prevMarker    = baseMode.PrevMarker;
                this.SemanticRules = new List <SemanticRule> (baseMode.SemanticRules);
                this.table         = baseMode.Table;
                this.properties    = baseMode.Properties;
            }
        }
Exemplo n.º 6
0
        public FSharpSyntaxMode()
        {
            ResourceXmlProvider provider = new ResourceXmlProvider (typeof(IXmlProvider).Assembly, "FSharpSyntaxMode.xml");
            using (XmlReader reader = provider.Open ()) {
                SyntaxMode baseMode = SyntaxMode.Read (reader);
                this.rules = new List<Rule> (baseMode.Rules);
                this.keywords = new List<Keywords> (baseMode.Keywords);
                this.spans = baseMode.Spans;
                this.matches = baseMode.Matches;
                this.prevMarker = baseMode.PrevMarker;
                this.SemanticRules = new List<SemanticRule> (baseMode.SemanticRules);
                this.table = baseMode.Table;
                this.properties = baseMode.Properties;
            }

            AddSemanticRule ("Comment", new HighlightUrlSemanticRule ("comment"));
            AddSemanticRule ("XmlDocumentation", new HighlightUrlSemanticRule ("comment"));
            AddSemanticRule ("String", new HighlightUrlSemanticRule ("string"));
            AddSemanticRule (new HighlightFSharpSemanticRule ());
        }
		public CSharpSyntaxMode ()
		{
			ResourceXmlProvider provider = new ResourceXmlProvider (typeof(IXmlProvider).Assembly, typeof(IXmlProvider).Assembly.GetManifestResourceNames ().First (s => s.Contains ("CSharpSyntaxMode")));
			using (XmlReader reader = provider.Open ()) {
				SyntaxMode baseMode = SyntaxMode.Read (reader);
				this.rules = new List<Rule> (baseMode.Rules);
				this.keywords = new List<Keywords> (baseMode.Keywords);
				this.spans = new List<Span> (baseMode.Spans.Where (span => span.Begin.Pattern != "#")).ToArray ();
				this.matches = baseMode.Matches;
				this.prevMarker = baseMode.PrevMarker;
				this.SemanticRules = new List<SemanticRule> (baseMode.SemanticRules);
				this.table = baseMode.Table;
				this.properties = baseMode.Properties;
			}
			
			AddSemanticRule ("Comment", new HighlightUrlSemanticRule ("comment"));
			AddSemanticRule ("XmlDocumentation", new HighlightUrlSemanticRule ("comment"));
			AddSemanticRule ("String", new HighlightUrlSemanticRule ("string"));
			AddSemanticRule (new HighlightCSharpSemanticRule ());
		}
Exemplo n.º 8
0
		public static void LoadStylesAndModes (Assembly assembly)
		{
			foreach (string resource in assembly.GetManifestResourceNames ()) {
				if (!resource.EndsWith (".xml")) 
					continue;
				if (resource.EndsWith ("SyntaxMode.xml")) {
					using (Stream stream = assembly.GetManifestResourceStream (resource)) 
					using (XmlTextReader reader =  new XmlTextReader (stream)) {
						string mimeTypes = Scan (reader, SyntaxMode.MimeTypesAttribute);
						ResourceXmlProvider provider = new ResourceXmlProvider (assembly, resource);
						foreach (string mimeType in mimeTypes.Split (';')) {
							syntaxModeLookup [mimeType] = provider;
						}
					}
				} else if (resource.EndsWith ("Style.xml")) {
					using (Stream stream = assembly.GetManifestResourceStream (resource)) 
					using (XmlTextReader reader = new XmlTextReader (stream)) {
						string styleName = Scan (reader, ColorScheme.NameAttribute);
						styleLookup [styleName] = new ResourceXmlProvider (assembly, resource);
					}
				}
			}
		}