Ejemplo n.º 1
0
        public KeywordClass GetKeywordClass(string keywordName)
        {
            KeywordClass result = null;

            if (MasterScintilla == this)
            {
                // check the children first (from the end)
                for (int i = includedFiles.Length - 1; i > -1; i--)
                {
                    Scintilla child = (Scintilla)(includedFiles[i]);
                    result = child.GetKeywordClass(keywordName);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }
            //other wise just check here.
            for (int i = keywordclass.Length - 1; i > -1; i--)
            {
                if (keywordclass[i].name.Equals(keywordName))
                {
                    result = keywordclass[i];
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void Configure(ScintillaControl scintilla, string language)
        {
            if (language == null || language.Equals(""))
            {
                return;
            }

            Language lang = this.GetLanguage(language);

            if (lang == null)
            {
                return;
            }

            scintilla.StyleClearAll();
            System.Type enumtype = typeof(Enums.Lexer);
            try
            {
                scintilla.Lexer = (int)Enum.Parse(typeof(Enums.Lexer), lang.lexer.name, true);
            }
            catch (Exception)
            {
                // try by key instead
                scintilla.Lexer = lang.lexer.key;
            }
            if (lang.lexer.stylebits > 0)
            {
                scintilla.StyleBits = lang.lexer.stylebits;
            }

            for (int j = 0; j < lang.usestyles.Length; j++)
            {
                UseStyle usestyle = lang.usestyles[j];

                if (usestyle.HasForegroundColor)
                {
                    scintilla.StyleSetFore(usestyle.key, usestyle.ForegroundColor);
                }
                if (usestyle.HasBackgroundColor)
                {
                    scintilla.StyleSetBack(usestyle.key, usestyle.BackgroundColor);
                }
                if (usestyle.HasFontName)
                {
                    scintilla.StyleSetFont(usestyle.key, usestyle.FontName);
                }
                if (usestyle.HasFontSize)
                {
                    scintilla.StyleSetSize(usestyle.key, usestyle.FontSize);
                }
                if (usestyle.HasBold)
                {
                    scintilla.StyleSetBold(usestyle.key, usestyle.IsBold);
                }
                if (usestyle.HasItalics)
                {
                    scintilla.StyleSetItalic(usestyle.key, usestyle.IsItalics);
                }
                if (usestyle.HasEolFilled)
                {
                    scintilla.StyleSetEOLFilled(usestyle.key, usestyle.IsEolFilled);
                }
            }

            // clear the keywords lists
            for (int j = 0; j < 9; j++)
            {
                scintilla.KeyWords(j, "");
            }

            for (int j = 0; j < lang.usekeywords.Length; j++)
            {
                UseKeyword   usekeyword = lang.usekeywords[j];
                KeywordClass kc         = this.GetKeywordClass(usekeyword.cls);
                if (kc != null)
                {
                    scintilla.KeyWords(usekeyword.key, kc.val);
                }
            }
        }