void CreateDefaultHighlightingStrategy()
        {
            DefaultHighlightingStrategy defaultHighlightingStrategy = new DefaultHighlightingStrategy();

            defaultHighlightingStrategy.Extensions = new string[] {};
            defaultHighlightingStrategy.Rules.Add(new HighlightRuleSet());
            highlightingDefs["Default"] = defaultHighlightingStrategy;
        }
        IHighlightingStrategy LoadDefinition(DictionaryEntry entry)
        {
            SyntaxMode syntaxMode = (SyntaxMode)entry.Key;
            ISyntaxModeFileProvider syntaxModeFileProvider = (ISyntaxModeFileProvider)entry.Value;

            DefaultHighlightingStrategy highlightingStrategy = HighlightingDefinitionParser.Parse(syntaxMode, syntaxModeFileProvider.GetSyntaxModeFile(syntaxMode));

            highlightingDefs[syntaxMode.Name] = highlightingStrategy;
            highlightingStrategy.ResolveReferences();

            return(highlightingStrategy);
        }
Exemplo n.º 3
0
        private static void AddDocument()
        {
            Netron.Neon.TextEditor.Document.DefaultDocument defaultDocument1 =
                new Netron.Neon.TextEditor.Document.DefaultDocument();
            Netron.Neon.TextEditor.Document.DefaultFormattingStrategy defaultFormattingStrategy1 =
                new Netron.Neon.TextEditor.Document.DefaultFormattingStrategy();
            Netron.Neon.TextEditor.Document.DefaultHighlightingStrategy defaultHighlightingStrategy1 =
                new Netron.Neon.TextEditor.Document.DefaultHighlightingStrategy();
            Netron.Neon.TextEditor.Document.GapTextBufferStrategy gapTextBufferStrategy1 =
                new Netron.Neon.TextEditor.Document.GapTextBufferStrategy();
            Netron.Neon.TextEditor.Document.DefaultTextEditorProperties defaultTextEditorProperties1 =
                new Netron.Neon.TextEditor.Document.DefaultTextEditorProperties();
            defaultDocument1.FormattingStrategy     = defaultFormattingStrategy1;
            defaultHighlightingStrategy1.Extensions = new string[0];
            defaultDocument1.HighlightingStrategy   = defaultHighlightingStrategy1;
            defaultDocument1.ReadOnly           = false;
            defaultDocument1.TextBufferStrategy = gapTextBufferStrategy1;
            defaultDocument1.TextContent        = "";
            defaultTextEditorProperties1.AllowCaretBeyondEOL    = false;
            defaultTextEditorProperties1.AutoInsertCurlyBracket = true;
            defaultTextEditorProperties1.BracketMatchingStyle   = Netron.Neon.TextEditor.Document.BracketMatchingStyle.After;
            defaultTextEditorProperties1.ConvertTabsToSpaces    = false;
            defaultTextEditorProperties1.CreateBackupCopy       = false;
            defaultTextEditorProperties1.DocumentSelectionMode  = Netron.Neon.TextEditor.Document.DocumentSelectionMode.Normal;
            defaultTextEditorProperties1.EnableFolding          = true;
//            defaultTextEditorProperties1.Encoding = ((System.Text.Encoding)(resources.GetObject("defaultTextEditorProperties1.Encoding")));
            defaultTextEditorProperties1.Font                 = new System.Drawing.Font("Courier New", 10F);
            defaultTextEditorProperties1.HideMouseCursor      = false;
            defaultTextEditorProperties1.IndentStyle          = Netron.Neon.TextEditor.Document.IndentStyle.None;
            defaultTextEditorProperties1.IsIconBarVisible     = true;
            defaultTextEditorProperties1.LineTerminator       = "\r\n";
            defaultTextEditorProperties1.LineViewerStyle      = Netron.Neon.TextEditor.Document.LineViewerStyle.FullRow;
            defaultTextEditorProperties1.MouseWheelScrollDown = true;
            defaultTextEditorProperties1.MouseWheelTextZoom   = true;
            defaultTextEditorProperties1.ShowEOLMarker        = true;
            defaultTextEditorProperties1.ShowHorizontalRuler  = false;
            defaultTextEditorProperties1.ShowInvalidLines     = false;
            defaultTextEditorProperties1.ShowLineNumbers      = true;
            defaultTextEditorProperties1.ShowMatchingBracket  = false;
            defaultTextEditorProperties1.ShowSpaces           = true;
            defaultTextEditorProperties1.ShowTabs             = true;
            defaultTextEditorProperties1.ShowVerticalRuler    = true;
            defaultTextEditorProperties1.TabIndent            = 4;
            defaultTextEditorProperties1.UseAntiAliasedFont   = false;
            defaultTextEditorProperties1.VerticalRulerRow     = 80;
            defaultDocument1.TextEditorProperties             = defaultTextEditorProperties1;
        }
Exemplo n.º 4
0
        public static DefaultHighlightingStrategy Parse(SyntaxMode syntaxMode, XmlTextReader xmlTextReader)
        {
            try {
                XmlValidatingReader validatingReader = new XmlValidatingReader(xmlTextReader);
                Stream shemaStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Netron.Neon.Actinium.TextEditor.syntaxmodes.Mode.xsd");
                validatingReader.Schemas.Add("", new XmlTextReader(shemaStream));
                validatingReader.ValidationType          = ValidationType.Schema;
                validatingReader.ValidationEventHandler += new ValidationEventHandler(ValidationHandler);


                XmlDocument doc = new XmlDocument();
                doc.Load(validatingReader);

                DefaultHighlightingStrategy highlighter = new DefaultHighlightingStrategy(doc.DocumentElement.Attributes["name"].InnerText);

                if (doc.DocumentElement.Attributes["extensions"] != null)
                {
                    highlighter.Extensions = doc.DocumentElement.Attributes["extensions"].InnerText.Split(new char[] { ';', '|' });
                }

                XmlElement environment = doc.DocumentElement["Environment"];
                if (environment != null)
                {
                    foreach (XmlNode node in environment.ChildNodes)
                    {
                        if (node is XmlElement)
                        {
                            XmlElement el = (XmlElement)node;
                            highlighter.SetColorFor(el.Name, el.HasAttribute("bgcolor") ? new HighlightBackground(el) : new HighlightColor(el));
                        }
                    }
                }

                // parse properties
                if (doc.DocumentElement["Properties"] != null)
                {
                    foreach (XmlElement propertyElement in doc.DocumentElement["Properties"].ChildNodes)
                    {
                        highlighter.Properties[propertyElement.Attributes["name"].InnerText] = propertyElement.Attributes["value"].InnerText;
                    }
                }

                if (doc.DocumentElement["Digits"] != null)
                {
                    highlighter.DigitColor = new HighlightColor(doc.DocumentElement["Digits"]);
                }

                XmlNodeList nodes = doc.DocumentElement.GetElementsByTagName("RuleSet");
                foreach (XmlElement element in nodes)
                {
                    highlighter.AddRuleSet(new HighlightRuleSet(element));
                }

                xmlTextReader.Close();

                if (errors != null)
                {
                    ReportErrors(syntaxMode.FileName);
                    errors = null;
                    return(null);
                }
                else
                {
                    return(highlighter);
                }
            } catch (Exception e) {
                MessageBox.Show("Could not load mode definition file.\n" + e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return(null);
            }
        }