Example #1
0
        public static ColorScheme LoadFrom(XmlReader reader)
        {
            var result = new ColorScheme();

            XmlReadHelper.ReadList(reader, "EditorStyle", delegate()
            {
                switch (reader.LocalName)
                {
                case "EditorStyle":
                    result.Name        = reader.GetAttribute(NameAttribute);
                    result.Description = reader.GetAttribute("_description");
                    return(true);

                case "Color":
                    result.customPalette [reader.GetAttribute("name")] = reader.GetAttribute("value");
                    return(true);

                case "Style":
                    ReadStyleTree(reader, result, null, null, null, null);
                    return(true);
                }
                return(false);
            });
            result.GetChunkStyle(DefaultString).ChunkProperties |= ChunkProperties.TransparentBackground;
            return(result);
        }
Example #2
0
        public static Rule Read(SyntaxMode mode, XmlReader reader, bool ignoreCaseDefault)
        {
            Rule result = new Rule();

            result.Name         = reader.GetAttribute("name");
            result.DefaultColor = reader.GetAttribute("color");
            result.IgnoreCase   = ignoreCaseDefault;
            if (!String.IsNullOrEmpty(reader.GetAttribute("ignorecase")))
            {
                result.IgnoreCase = Boolean.Parse(reader.GetAttribute("ignorecase"));
            }
            List <Match>  matches        = new List <Match> ();
            List <Span>   spanList       = new List <Span> ();
            List <Marker> prevMarkerList = new List <Marker> ();

            XmlReadHelper.ReadList(reader, Node, delegate() {
                switch (reader.LocalName)
                {
                case Node:
                    return(true);
                }
                return(result.ReadNode(reader, matches, spanList, prevMarkerList));
            });
            result.matches    = matches.ToArray();
            result.spans      = spanList.ToArray();
            result.prevMarker = prevMarkerList.ToArray();
            return(result);
        }
Example #3
0
        static void ReadStyleTree(XmlReader reader, ColorScheme result, string curName, string curWeight, string curColor, string curBgColor)
        {
            string name    = reader.GetAttribute("name");
            string weight  = reader.GetAttribute("weight") ?? curWeight;
            string color   = reader.GetAttribute("color");
            string bgColor = reader.GetAttribute("bgColor");
            string fullName;

            if (String.IsNullOrEmpty(curName))
            {
                fullName = name;
            }
            else
            {
                fullName = curName + "." + name;
            }
            if (!String.IsNullOrEmpty(color))
            {
                result.SetChunkStyle(fullName, weight, color, bgColor);
            }
            XmlReadHelper.ReadList(reader, "Style", delegate()
            {
                switch (reader.LocalName)
                {
                case "Style":
                    ReadStyleTree(reader, result, fullName, weight, color, bgColor);
                    return(true);
                }
                return(false);
            });
        }
Example #4
0
        public static Keywords Read(XmlReader reader, bool ignoreCaseDefault)
        {
            Keywords result = new Keywords();

            result.Color = reader.GetAttribute("color");
            if (!String.IsNullOrEmpty(reader.GetAttribute("ignorecase")))
            {
                result.IgnoreCase = Boolean.Parse(reader.GetAttribute("ignorecase"));
            }
            else
            {
                result.IgnoreCase = ignoreCaseDefault;
            }

            XmlReadHelper.ReadList(reader, Node, delegate() {
                switch (reader.LocalName)
                {
                case "Word":
                    result.words.Add(reader.ReadElementString());
                    return(true);
                }
                ;
                return(false);
            });
            return(result);
        }
Example #5
0
        public static SyntaxMode Read(XmlReader reader)
        {
            SyntaxMode    result         = new SyntaxMode();
            List <Match>  matches        = new List <Match> ();
            List <Span>   spanList       = new List <Span> ();
            List <Marker> prevMarkerList = new List <Marker> ();

            XmlReadHelper.ReadList(reader, Node, delegate() {
                switch (reader.LocalName)
                {
                case Node:
                    string extends = reader.GetAttribute("extends");
                    if (!String.IsNullOrEmpty(extends))
                    {
                        result = (SyntaxMode)SyntaxModeService.GetSyntaxMode(extends).MemberwiseClone();
                    }
                    result.Name     = reader.GetAttribute("name");
                    result.MimeType = reader.GetAttribute(MimeTypesAttribute);
                    if (!String.IsNullOrEmpty(reader.GetAttribute("ignorecase")))
                    {
                        result.IgnoreCase = Boolean.Parse(reader.GetAttribute("ignorecase"));
                    }
                    return(true);

                case Rule.Node:
                    result.rules.Add(Rule.Read(result, reader, result.IgnoreCase));
                    return(true);
                }
                return(result.ReadNode(reader, matches, spanList, prevMarkerList));
            });
            result.spans      = spanList.ToArray();
            result.prevMarker = prevMarkerList.ToArray();
            result.matches    = matches.ToArray();
            return(result);
        }
Example #6
0
		public static Match Read (XmlReader reader)
		{
			string expression = reader.GetAttribute ("expression");
			if (!string.IsNullOrEmpty (expression)) {
				var result = new Match ();

				result.Pattern = "\\G" + expression;
				result.regex   = new System.Text.RegularExpressions.Regex (result.Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);

				XmlReadHelper.ReadList (reader, Node, delegate () {
					switch (reader.LocalName) {
					case "Group":
						result.Groups.Add (reader.GetAttribute ("color"));
						return true;
					}
					return false;
				});

				return result;
			}

			string color   = reader.GetAttribute ("color");
			string pattern = reader.ReadElementString ();
			Match result2   = pattern == "CSharpNumber" ? new CSharpNumberMatch () : new Match ();
			result2.Color   = color;
			result2.Pattern = "\\G" + pattern;
			result2.regex   = new System.Text.RegularExpressions.Regex (result2.Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
			return result2;
		}
Example #7
0
        public static Span Read(XmlReader reader)
        {
            Span result = new Span();

            result.Rule      = reader.GetAttribute("rule");
            result.Color     = reader.GetAttribute("color");
            result.TagColor  = reader.GetAttribute("tagColor");
            result.NextColor = reader.GetAttribute("nextColor");

            result.Escape = reader.GetAttribute("escape");

            string stopateol = reader.GetAttribute("stopateol");

            if (!String.IsNullOrEmpty(stopateol))
            {
                result.StopAtEol = Boolean.Parse(stopateol);
            }

            if (reader.LocalName == AltNode)
            {
                AddFlags(result.BeginFlags, reader.GetAttribute("flags"));
                result.Continuation = reader.GetAttribute("continuation");
                result.Begin        = new Regex(reader.ReadElementString());
                result.StopAtEol    = true;
            }
            else
            {
                XmlReadHelper.ReadList(reader, Node, delegate() {
                    switch (reader.LocalName)
                    {
                    case "Begin":
                        AddFlags(result.BeginFlags, reader.GetAttribute("flags"));
                        result.Begin = new Regex(reader.ReadElementString());
                        return(true);

                    case "End":
                        AddFlags(result.EndFlags, reader.GetAttribute("flags"));
                        result.End = new Regex(reader.ReadElementString());
                        return(true);

                    case "Exit":
                        AddFlags(result.ExitFlags, reader.GetAttribute("flags"));
                        result.Exit = new Regex(reader.ReadElementString());
                        return(true);
                    }
                    return(false);
                });
            }
            return(result);
        }