示例#1
0
        private void BindConfigToForm()
        {
            this.comboBoxLanguage.Items.Clear();
            this.comboBoxLexer.Items.Clear();
            this.comboBoxLanguage.Sorted = true;
            this.comboBoxLexer.Sorted    = true;
            foreach (string language in this.configuration.LanguageNames)
            {
                this.comboBoxLanguage.Items.Add(language);
                this.comboBoxSample.Items.Add(language);

                ILanguageConfig lc = this.configuration.Languages[language];
                if (!comboBoxLexer.Items.Contains(lc.Lexer.LexerName))
                {
                    comboBoxLexer.Items.Add(lc.Lexer.LexerName);
                }
            }

            this.radioButtonGlobal.Checked = true;

            this.lexerType = Utilities.GetLexerEnumFromLexerType(this.configuration.LanguageDefaults.Lexer.Type);
            this.styles    = this.configuration.LanguageDefaults.Styles;

            BindStylesToForm(lexerType, styles);
        }
示例#2
0
        private static void ApplyLanguageProperty(Queue <string> keyQueue, string val)
        {
            if (keyQueue.Count > 1)
            {
                string          langName = keyQueue.Dequeue();
                ILanguageConfig langConf = config.Languages[langName];

                ApplyLanguageProperty(langConf, keyQueue, val);
            }
        }
示例#3
0
        private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.radioButtonLanguage.Checked)
            {
                if ((comboBoxLanguage.SelectedIndex) < 0 && (comboBoxLanguage.Items.Count > 0))
                {
                    comboBoxLanguage.SelectedIndex = 0;
                }
                else if (comboBoxLanguage.SelectedIndex >= 0)
                {
                    ILanguageConfig lang = Configuration.Languages[comboBoxLanguage.SelectedItem.ToString()];
                    this.comboBoxLexer.SelectedIndex = this.comboBoxLexer.Items.IndexOf(lang.Lexer.LexerName);

                    this.lexerType = Utilities.GetLexerEnumFromLexerType(lang.Lexer.Type);
                    this.styles    = lang.Styles;
                    BindStylesToForm(lexerType, styles);
                }
            }
        }
示例#4
0
        private static void ApplyKeywords(ILanguageConfig langConf, Queue <string> keyQueue, string var)
        {
            int styleIndex;

            if (keyQueue.Count == 1)
            {
                string strIndex = keyQueue.Dequeue();
                if (!int.TryParse(strIndex, out styleIndex))
                {
                    styleIndex = 0;
                }
            }
            else
            {
                styleIndex = 0;
            }

            langConf.KeywordLists[styleIndex] = Evaluate(var);
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateLanguageConfig(ILanguageConfig config, ILexerConfigCollection lexers)
        {
            bool   success = true;
            string key, s,
                   language = config.Name.ToLower(),
                   extList  = GetExtensionListFromLanguage(language);

            if (extList == null)
            {
                extList = "*." + language;
                languageExtentions[language] = extList;
            }

            config.ExtensionList = extList;

            key = string.Format("lexer.{0}", extList);
            if (properties.ContainsKey(key))
            {
                config.Lexer = lexers[this.Evaluate(properties[key])];
            }

            if (config.Lexer == null)
            {
                success = false;
            }

            /*--------------------------------------- keywords ---------------------------------------
            *  Most of the lexers differentiate between names and keywords and use the keywords variables to do so.
            *  To avoid repeating the keyword list for each file extension, where several file extensions are
            *  used for one language, a keywordclass variable is defined in the distributed properties file
            *  although this is just a convention. Some lexers define a second set of keywords which will be
            *  displayed in a different style to the first set of keywords. This is used in the HTML lexer
            *  to display JavaScript keywords in a different style to HTML tags and attributes.
            *  ----------------------------------------------------------------------------------------*/
            for (int i = 0; i <= 8; i++)
            {
                s   = (i == 0) ? string.Empty : i.ToString();
                key = string.Format("keywords{0}.{1}", s, extList);
                s   = GetString(key);
                if (s != null)
                {
                    config.KeywordLists[i] = s;
                }
            }

            /*--------------------------------------- word characters ---------------------------------------
             * Defines which characters can be parts of words. The default value here is all the alphabetic and
             * numeric characters and the underscore which is a reasonable value for languages such as C++.
             * ----------------------------------------------------------------------------------------*/
            key = string.Format("word.characters.{0}", extList);
            config.WordCharacters = GetString(key);

            /*--------------------------------------- whitespace characters ---------------------------------------
             * Defines which characters are considered whitespace. The default value is that initially set up by Scintilla,
             * which is space and all chars less than 0x20. Setting this property allows you to force Scintilla to consider other
             * characters as whitespace (e.g. punctuation) during such activities as cursor navigation (ctrl+left/right).
             * ----------------------------------------------------------------------------------------*/
            key = string.Format("whitespace.characters.{0}", extList);
            config.WhitespaceCharacters = GetString(key);

            return(success);
        }
示例#6
0
        public void Configure(ScintillaControl scintilla, string language)
        {
            scintilla.StyleClearAll();
            scintilla.DisableMarginClickFold();

            IScintillaConfig conf = this;
            ILanguageConfig  lang = conf.Languages[language];

            if (lang != null)
            {
                lang = lang.CombinedLanguageConfig;
                if (lang.CodePage.HasValue)
                {
                    scintilla.CodePage = lang.CodePage.Value;
                }
                if (lang.SelectionAlpha.HasValue)
                {
                    scintilla.SelectionAlpha = lang.SelectionAlpha.Value;
                }
                if (lang.SelectionBackColor != Color.Empty)
                {
                    scintilla.SetSelectionBackground(true, lang.SelectionBackColor);
                }
                if (lang.TabSize.HasValue)
                {
                    scintilla.TabWidth = lang.TabSize.Value;
                }
                if (lang.IndentSize.HasValue)
                {
                    scintilla.Indent = lang.IndentSize.Value;
                }

                // Enable line numbers
                scintilla.MarginWidthN(0, 40);

                bool enableFolding = false;
                if (lang.Fold.HasValue)
                {
                    enableFolding = lang.Fold.Value;
                }
                if (enableFolding)
                {
                    // Lexer specific properties
                    scintilla.Property("fold", "1");
                    if (lang.FoldAtElse.HasValue)
                    {
                        scintilla.Property("fold.at.else", (lang.FoldAtElse.Value ? "1" : "0"));
                    }
                    if (lang.FoldCompact.HasValue)
                    {
                        scintilla.Property("fold.compact", (lang.FoldCompact.Value ? "1" : "0"));
                    }
                    if (lang.FoldComment.HasValue)
                    {
                        scintilla.Property("fold.comment", (lang.FoldComment.Value ? "1" : "0"));
                    }
                    if (lang.FoldPreprocessor.HasValue)
                    {
                        scintilla.Property("fold.preprocessor", (lang.FoldPreprocessor.Value ? "1" : "0"));
                    }
                    if (lang.StylingWithinPreprocessor.HasValue)
                    {
                        scintilla.Property("styling.within.preprocessor", (lang.PythonFoldQuotes.Value ? "1" : "0"));
                    }

                    if (lang.HtmlFold.HasValue)
                    {
                        scintilla.Property("fold.html", (lang.HtmlFold.Value ? "1" : "0"));
                    }
                    if (lang.HtmlFoldPreprocessor.HasValue)
                    {
                        scintilla.Property("fold.html.preprocessor", (lang.HtmlFoldPreprocessor.Value ? "1" : "0"));
                    }
                    if (lang.HtmlTagsCaseSensitive.HasValue)
                    {
                        scintilla.Property("html.tags.case.sensitive", (lang.HtmlTagsCaseSensitive.Value ? "1" : "0"));
                    }

                    if (lang.PythonFoldComment.HasValue)
                    {
                        scintilla.Property("fold.comment.python", (lang.PythonFoldComment.Value ? "1" : "0"));
                    }
                    if (lang.PythonFoldQuotes.HasValue)
                    {
                        scintilla.Property("fold.quotes.python", (lang.PythonFoldQuotes.Value ? "1" : "0"));
                    }
                    if (lang.PythonWhingeLevel.HasValue)
                    {
                        scintilla.Property("tab.timmy.whinge.level", lang.PythonWhingeLevel.Value.ToString());
                    }

                    if (lang.SqlBackslashEscapes.HasValue)
                    {
                        scintilla.Property("sql.backslash.escapes", (lang.SqlBackslashEscapes.Value ? "1" : "0"));
                    }
                    if (lang.SqlBackticksIdentifier.HasValue)
                    {
                        scintilla.Property("lexer.sql.backticks.identifier", (lang.SqlBackticksIdentifier.Value ? "1" : "0"));
                    }
                    if (lang.SqlFoldOnlyBegin.HasValue)
                    {
                        scintilla.Property("fold.sql.only.begin", (lang.SqlFoldOnlyBegin.Value ? "1" : "0"));
                    }

                    if (lang.PerlFoldPod.HasValue)
                    {
                        scintilla.Property("fold.perl.pod", (lang.PerlFoldPod.Value ? "1" : "0"));
                    }
                    if (lang.PerlFoldPackage.HasValue)
                    {
                        scintilla.Property("fold.perl.package", (lang.PerlFoldPackage.Value ? "1" : "0"));
                    }

                    if (lang.NsisIgnoreCase.HasValue)
                    {
                        scintilla.Property("nsis.ignorecase", (lang.NsisIgnoreCase.Value ? "1" : "0"));
                    }
                    if (lang.NsisUserVars.HasValue)
                    {
                        scintilla.Property("nsis.uservars", (lang.NsisUserVars.Value ? "1" : "0"));
                    }
                    if (lang.NsisFoldUtilCommand.HasValue)
                    {
                        scintilla.Property("nsis.foldutilcmd", (lang.NsisFoldUtilCommand.Value ? "1" : "0"));
                    }
                    if (lang.CppAllowDollars.HasValue)
                    {
                        scintilla.Property("lexer.cpp.allow.dollars", (lang.CppAllowDollars.Value ? "1" : "0"));
                    }

                    //for HTML lexer: "asp.default.language"
                    //enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };

                    scintilla.MarginWidthN(1, 0);
                    scintilla.MarginTypeN(1, MarginType.Symbol);
                    scintilla.MarginMaskN(1, unchecked ((int)0xFE000000));
                    scintilla.MarginSensitiveN(1, true);

                    if (lang.FoldMarginWidth.HasValue)
                    {
                        scintilla.MarginWidthN(1, lang.FoldMarginWidth.Value);
                    }
                    else
                    {
                        scintilla.MarginWidthN(1, 20);
                    }

                    if (lang.FoldMarginColor != Color.Empty)
                    {
                        scintilla.SetFoldMarginColor(true, lang.FoldMarginColor);
                    }
                    if (lang.FoldMarginHighlightColor != Color.Empty)
                    {
                        scintilla.SetFoldMarginHiColor(true, lang.FoldMarginHighlightColor);
                    }
                    if (lang.FoldFlags.HasValue)
                    {
                        scintilla.SetFoldFlags(lang.FoldFlags.Value);
                    }

                    scintilla.MarkerDefine(MarkerOutline.Folder, MarkerSymbol.Plus);
                    scintilla.MarkerDefine(MarkerOutline.FolderOpen, MarkerSymbol.Minus);
                    scintilla.MarkerDefine(MarkerOutline.FolderEnd, MarkerSymbol.Empty);
                    scintilla.MarkerDefine(MarkerOutline.FolderMidTail, MarkerSymbol.Empty);
                    scintilla.MarkerDefine(MarkerOutline.FolderOpenMid, MarkerSymbol.Minus);
                    scintilla.MarkerDefine(MarkerOutline.FolderSub, MarkerSymbol.Empty);
                    scintilla.MarkerDefine(MarkerOutline.FolderTail, MarkerSymbol.Empty);

                    scintilla.EnableMarginClickFold();
                }

                if (!string.IsNullOrEmpty(lang.WhitespaceCharacters))
                {
                    scintilla.WhitespaceChars(lang.WhitespaceCharacters);
                }

                if (!string.IsNullOrEmpty(lang.WordCharacters))
                {
                    scintilla.WordChars(lang.WordCharacters);
                }

                ILexerConfig lexer = lang.Lexer;
                if (lexer != null)
                {
                    scintilla.Lexer = lexer.LexerID;
                    //scintilla.LexerLanguage(lang.Name);
                }

                SortedDictionary <int, ILexerStyle> styles = lang.Styles;
                foreach (ILexerStyle style in styles.Values)
                {
                    if (style.ForeColor != Color.Empty)
                    {
                        scintilla.StyleSetFore(style.StyleIndex, style.ForeColor);
                    }

                    if (style.BackColor != Color.Empty)
                    {
                        scintilla.StyleSetBack(style.StyleIndex, style.BackColor);
                    }

                    if (!string.IsNullOrEmpty(style.FontName))
                    {
                        scintilla.StyleSetFont(style.StyleIndex, style.FontName);
                    }

                    if (style.FontSize.HasValue)
                    {
                        scintilla.StyleSetSize(style.StyleIndex, style.FontSize.Value);
                    }

                    if (style.Bold.HasValue)
                    {
                        scintilla.StyleSetBold(style.StyleIndex, style.Bold.Value);
                    }

                    if (style.Italics.HasValue)
                    {
                        scintilla.StyleSetItalic(style.StyleIndex, style.Italics.Value);
                    }

                    if (style.EOLFilled.HasValue)
                    {
                        scintilla.StyleSetEOLFilled(style.StyleIndex, style.EOLFilled.Value);
                    }

                    scintilla.StyleSetCase(style.StyleIndex, style.CaseVisibility);
                }
                scintilla.StyleBits = scintilla.StyleBitsNeeded;

                for (int j = 0; j < 9; j++)
                {
                    if (lang.KeywordLists.ContainsKey(j))
                    {
                        scintilla.KeyWords(j, lang.KeywordLists[j]);
                    }
                    else
                    {
                        scintilla.KeyWords(j, string.Empty);
                    }
                }
            }

            scintilla.Colorize(0, scintilla.Length);
        }
 public bool PopulateLanguageConfig(ILanguageConfig config, ILexerConfigCollection lexers)
 {
     ScintillaPropertiesHelper.Populate(config.ScintillaConfig, GetResource("lang." + config.Name.ToLower() + ".properties"));
     return true;
 }
 public bool PopulateLanguageConfig(ILanguageConfig config, ILexerConfigCollection lexers)
 {
     ScintillaPropertiesHelper.Populate(config.ScintillaConfig, GetResource("lang." + config.Name.ToLower() + ".properties"));
     return(true);
 }
示例#9
0
        private static void ApplyLanguageProperty(ILanguageConfig langConf, Queue <string> keyQueue, string val)
        {
            if (keyQueue.Count > 0)
            {
                string key = keyQueue.Dequeue();

                switch (key)
                {
                case "style":
                    ApplyStyle(langConf.Lexer.Type, langConf.Styles, keyQueue, val);
                    break;

                case "keywords":
                    ApplyKeywords(langConf, keyQueue, val);
                    break;

                case "lexer":
                    langConf.Lexer = config.Lexers[Evaluate(val)];
                    break;

                case "word-characters":
                    langConf.WordCharacters = Evaluate(val);
                    break;

                case "whitespace-characters":
                    langConf.WhitespaceCharacters = Evaluate(val);
                    break;

                case "code-page":
                    langConf.CodePage = GetInt(val);
                    break;

                case "selection-alpha":
                    langConf.SelectionAlpha = GetInt(val);
                    break;

                case "selection-back":
                    langConf.SelectionBackColor = GetColor(val, Color.Empty);
                    break;

                case "tabsize":
                    langConf.TabSize = GetInt(val);
                    break;

                case "indent-size":
                    langConf.IndentSize = GetInt(val);
                    break;

                case "fold":
                    langConf.Fold = GetBool(val);
                    break;

                case "fold-compact":
                    langConf.FoldCompact = GetBool(val);
                    break;

                case "fold-symbols":
                    langConf.FoldSymbols = GetBool(val);
                    break;

                case "fold-comment":
                    langConf.FoldComment = GetBool(val);
                    break;

                case "fold-on-open":
                    langConf.FoldOnOpen = GetBool(val);
                    break;

                case "fold-preprocessor":
                    langConf.FoldPreprocessor = GetBool(val);
                    break;

                case "fold-html":
                    langConf.HtmlFold = GetBool(val);
                    break;

                case "fold-html-preprocessor":
                    langConf.HtmlFoldPreprocessor = GetBool(val);
                    break;

                case "fold-flags":
                    langConf.FoldFlags = GetInt(val);
                    break;

                case "fold-margin-width":
                    langConf.FoldMarginWidth = GetInt(val);
                    break;

                case "fold-margin-color":
                    langConf.FoldMarginColor = GetColor(val, Color.Empty);
                    break;

                case "fold-margin-highlight-color":
                    langConf.FoldMarginHighlightColor = GetColor(val, Color.Empty);
                    break;

                default:
                    config.Properties[key] = Evaluate(val);
                    break;
                }
            }
        }
        private static void ApplyKeywords(ILanguageConfig langConf, Queue<string> keyQueue, string var)
        {
            int styleIndex;
            if (keyQueue.Count == 1)
            {
                string strIndex = keyQueue.Dequeue();
                if (!int.TryParse(strIndex, out styleIndex))
                {
                    styleIndex = 0;
                }
            }
            else
            {
                styleIndex = 0;
            }

            langConf.KeywordLists[styleIndex] = Evaluate(var);
        }
        private static void ApplyLanguageProperty(ILanguageConfig langConf, Queue<string> keyQueue, string val)
        {
            if (keyQueue.Count > 0)
            {
                string key = keyQueue.Dequeue();

                switch (key)
                {
                    case "style":
                        ApplyStyle(langConf.Lexer.Type, langConf.Styles, keyQueue, val);
                        break;
                    case "keywords":
                        ApplyKeywords(langConf, keyQueue, val);
                        break;
                    case "lexer":
                        langConf.Lexer = config.Lexers[Evaluate(val)];
                        break;
                    case "word-characters":
                        langConf.WordCharacters = Evaluate(val);
                        break;
                    case "whitespace-characters":
                        langConf.WhitespaceCharacters = Evaluate(val);
                        break;
                    case "code-page":
                        langConf.CodePage = GetInt(val);
                        break;
                    case "selection-alpha":
                        langConf.SelectionAlpha = GetInt(val);
                        break;
                    case "selection-back":
                        langConf.SelectionBackColor = GetColor(val, Color.Empty);
                        break;
                    case "tabsize":
                        langConf.TabSize = GetInt(val);
                        break;
                    case "indent-size":
                        langConf.IndentSize = GetInt(val);
                        break;
                    case "fold":
                        langConf.Fold = GetBool(val);
                        break;
                    case "fold-compact":
                        langConf.FoldCompact = GetBool(val);
                        break;
                    case "fold-symbols":
                        langConf.FoldSymbols = GetBool(val);
                        break;
                    case "fold-comment":
                        langConf.FoldComment = GetBool(val);
                        break;
                    case "fold-on-open":
                        langConf.FoldOnOpen = GetBool(val);
                        break;
                    case "fold-preprocessor":
                        langConf.FoldPreprocessor = GetBool(val);
                        break;
                    case "fold-html":
                        langConf.HtmlFold = GetBool(val);
                        break;
                    case "fold-html-preprocessor":
                        langConf.HtmlFoldPreprocessor = GetBool(val);
                        break;
                    case "fold-flags":
                        langConf.FoldFlags = GetInt(val);
                        break;
                    case "fold-margin-width":
                        langConf.FoldMarginWidth = GetInt(val);
                        break;
                    case "fold-margin-color":
                        langConf.FoldMarginColor = GetColor(val, Color.Empty);
                        break;
                    case "fold-margin-highlight-color":
                        langConf.FoldMarginHighlightColor = GetColor(val, Color.Empty);
                        break;
                    default:
                        config.Properties[key] = Evaluate(val);
                        break;
                }
            }
        }
示例#12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateLanguageConfig(ILanguageConfig config, ILexerConfigCollection lexers)
        {
            bool success = true;
            string key, s, 
                language = config.Name.ToLower(),
                extList = GetExtensionListFromLanguage(language);

            if (extList == null)
            {
                extList = "*." + language;
                languageExtentions[language] = extList;
            }

            config.ExtensionList = extList;

            key = string.Format("lexer.{0}", extList);
            if (properties.ContainsKey(key))
            {
                config.Lexer = lexers[this.Evaluate(properties[key])];
            }

            if (config.Lexer == null) success = false;

            /*--------------------------------------- keywords ---------------------------------------
            Most of the lexers differentiate between names and keywords and use the keywords variables to do so. 
            To avoid repeating the keyword list for each file extension, where several file extensions are 
            used for one language, a keywordclass variable is defined in the distributed properties file 
            although this is just a convention. Some lexers define a second set of keywords which will be 
            displayed in a different style to the first set of keywords. This is used in the HTML lexer 
            to display JavaScript keywords in a different style to HTML tags and attributes.
            ----------------------------------------------------------------------------------------*/
            for (int i = 0; i <= 8; i++)
            {
                s = (i == 0) ? string.Empty : i.ToString();
                key = string.Format("keywords{0}.{1}", s, extList);
                s = GetString(key);
                if (s != null) config.KeywordLists[i] = s;
            }

            /*--------------------------------------- word characters ---------------------------------------
            Defines which characters can be parts of words. The default value here is all the alphabetic and  
            numeric characters and the underscore which is a reasonable value for languages such as C++. 
            ----------------------------------------------------------------------------------------*/
            key = string.Format("word.characters.{0}", extList);
            config.WordCharacters = GetString(key);

            /*--------------------------------------- whitespace characters ---------------------------------------
            Defines which characters are considered whitespace. The default value is that initially set up by Scintilla, 
            which is space and all chars less than 0x20. Setting this property allows you to force Scintilla to consider other 
            characters as whitespace (e.g. punctuation) during such activities as cursor navigation (ctrl+left/right).  
            ----------------------------------------------------------------------------------------*/
            key = string.Format("whitespace.characters.{0}", extList);
            config.WhitespaceCharacters = GetString(key);

            return success;
        }
示例#13
0
        public void Configure(ScintillaNet.Scintilla scintilla, string language)
        {
            scintilla.Styles.ClearAll();
            scintilla.Folding.IsEnabled = false;

            IScintillaConfig conf = this;
            ILanguageConfig  lang = conf.Languages[language];

            if (lang != null)
            {
                lang = lang.CombinedLanguageConfig;

                //CauseError;
                //FIND THE MAP FOR THE NEXT 2 LINES
                if (lang.CodePage.HasValue)
                {
                    scintilla.NativeInterface.SetCodePage(lang.CodePage.Value);
                }
                //if (lang.SelectionAlpha.HasValue) scintilla.Selection.ForeColor = lang.SelectionAlpha.Value;
                if (lang.SelectionBackColor != Color.Empty)
                {
                    scintilla.Selection.BackColor = lang.SelectionBackColor;
                }
                if (lang.TabSize.HasValue)
                {
                    scintilla.Indentation.TabWidth = lang.TabSize.Value;
                }
                if (lang.IndentSize.HasValue)
                {
                    scintilla.Indentation.IndentWidth = lang.IndentSize.Value;
                }

                // Enable line numbers
                scintilla.Margins.Margin0.Width = 40;

                bool enableFolding = false;
                if (lang.Fold.HasValue)
                {
                    enableFolding = lang.Fold.Value;
                }
                if (enableFolding)
                {
                    // Lexer specific properties
                    scintilla.PropertyBag.Add("fold", "1");

                    //CAUSE ERROR;
                    //this Is TO CAUSE AN ERROR TO REMIND ME TO CHECK ALL OF THESE ELEMENTS!!!;

                    if (lang.FoldAtElse.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.at.else", (lang.FoldAtElse.Value ? "1" : "0"));
                    }
                    if (lang.FoldCompact.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.compact", (lang.FoldCompact.Value ? "1" : "0"));
                    }
                    if (lang.FoldComment.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.comment", (lang.FoldComment.Value ? "1" : "0"));
                    }
                    if (lang.FoldPreprocessor.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.preprocessor", (lang.FoldPreprocessor.Value ? "1" : "0"));
                    }
                    if (lang.StylingWithinPreprocessor.HasValue)
                    {
                        scintilla.PropertyBag.Add("styling.within.preprocessor", (lang.PythonFoldQuotes.Value ? "1" : "0"));
                    }

                    if (lang.HtmlFold.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.html", (lang.HtmlFold.Value ? "1" : "0"));
                    }
                    if (lang.HtmlFoldPreprocessor.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.html.preprocessor", (lang.HtmlFoldPreprocessor.Value ? "1" : "0"));
                    }
                    if (lang.HtmlTagsCaseSensitive.HasValue)
                    {
                        scintilla.PropertyBag.Add("html.tags.case.sensitive", (lang.HtmlTagsCaseSensitive.Value ? "1" : "0"));
                    }

                    if (lang.PythonFoldComment.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.comment.python", (lang.PythonFoldComment.Value ? "1" : "0"));
                    }
                    if (lang.PythonFoldQuotes.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.quotes.python", (lang.PythonFoldQuotes.Value ? "1" : "0"));
                    }
                    if (lang.PythonWhingeLevel.HasValue)
                    {
                        scintilla.PropertyBag.Add("tab.timmy.whinge.level", lang.PythonWhingeLevel.Value.ToString());
                    }

                    if (lang.SqlBackslashEscapes.HasValue)
                    {
                        scintilla.PropertyBag.Add("sql.backslash.escapes", (lang.SqlBackslashEscapes.Value ? "1" : "0"));
                    }
                    if (lang.SqlBackticksIdentifier.HasValue)
                    {
                        scintilla.PropertyBag.Add("lexer.sql.backticks.identifier", (lang.SqlBackticksIdentifier.Value ? "1" : "0"));
                    }
                    if (lang.SqlFoldOnlyBegin.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.sql.only.begin", (lang.SqlFoldOnlyBegin.Value ? "1" : "0"));
                    }

                    if (lang.PerlFoldPod.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.perl.pod", (lang.PerlFoldPod.Value ? "1" : "0"));
                    }
                    if (lang.PerlFoldPackage.HasValue)
                    {
                        scintilla.PropertyBag.Add("fold.perl.package", (lang.PerlFoldPackage.Value ? "1" : "0"));
                    }

                    if (lang.NsisIgnoreCase.HasValue)
                    {
                        scintilla.PropertyBag.Add("nsis.ignorecase", (lang.NsisIgnoreCase.Value ? "1" : "0"));
                    }
                    if (lang.NsisUserVars.HasValue)
                    {
                        scintilla.PropertyBag.Add("nsis.uservars", (lang.NsisUserVars.Value ? "1" : "0"));
                    }
                    if (lang.NsisFoldUtilCommand.HasValue)
                    {
                        scintilla.PropertyBag.Add("nsis.foldutilcmd", (lang.NsisFoldUtilCommand.Value ? "1" : "0"));
                    }
                    if (lang.CppAllowDollars.HasValue)
                    {
                        scintilla.PropertyBag.Add("lexer.cpp.allow.dollars", (lang.CppAllowDollars.Value ? "1" : "0"));
                    }

                    //for HTML lexer: "asp.default.language"
                    //enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };

                    scintilla.Margins.Margin1.Width       = 0;
                    scintilla.Margins.Margin1.Type        = MarginType.Symbol;
                    scintilla.Margins.Margin1.Mask        = unchecked ((int)0xFE000000);
                    scintilla.Margins.Margin1.IsClickable = true;

                    if (lang.FoldMarginWidth.HasValue)
                    {
                        scintilla.Margins.Margin1.Width = lang.FoldMarginWidth.Value;
                    }
                    else
                    {
                        scintilla.Margins.Margin1.Width = 20;
                    }

                    //if (lang.FoldMarginColor != Color.Empty)
                    //    scintilla.Margins.SetFoldMarginColor(true, lang.FoldMarginColor);
                    //if (lang.FoldMarginHighlightColor != Color.Empty)
                    //    scintilla.SetFoldMarginHiColor(true, lang.FoldMarginHighlightColor);
                    //if (lang.FoldFlags.HasValue)
                    //    scintilla.SetFoldFlags(lang.FoldFlags.Value);

                    scintilla.Markers.Folder.Symbol            = MarkerSymbol.Plus;
                    scintilla.Markers.FolderOpen.Symbol        = MarkerSymbol.Minus;
                    scintilla.Markers.FolderEnd.Symbol         = MarkerSymbol.Empty;
                    scintilla.Markers.FolderOpenMidTail.Symbol = MarkerSymbol.Empty;
                    scintilla.Markers.FolderOpenMid.Symbol     = MarkerSymbol.Minus;
                    scintilla.Markers.FolderSub.Symbol         = MarkerSymbol.Empty;
                    scintilla.Markers.FolderTail.Symbol        = MarkerSymbol.Empty;

                    //scintilla.EnableMarginClickFold();
                }

                if (!string.IsNullOrEmpty(lang.WhitespaceCharacters))
                {
                    scintilla.Lexing.WhitespaceChars = lang.WhitespaceCharacters;
                }

                if (!string.IsNullOrEmpty(lang.WordCharacters))
                {
                    scintilla.Lexing.WordChars = lang.WordCharacters;
                }

                ILexerConfig lexer = lang.Lexer;

                scintilla.Lexing.Lexer     = Utilities.LexerLookupByID(lexer.LexerID);
                scintilla.Lexing.LexerName = lang.Name;

                SortedDictionary <int, ILexerStyle> styles = lang.Styles;
                foreach (ILexerStyle style in styles.Values)
                {
                    if (style.ForeColor != Color.Empty)
                    {
                        scintilla.Styles[style.StyleIndex].ForeColor = style.ForeColor;
                    }

                    if (style.BackColor != Color.Empty)
                    {
                        scintilla.Styles[style.StyleIndex].BackColor = style.BackColor;
                    }

                    if (!string.IsNullOrEmpty(style.FontName))
                    {
                        scintilla.Styles[style.StyleIndex].FontName = style.FontName;
                    }

                    if (style.FontSize.HasValue)
                    {
                        scintilla.Styles[style.StyleIndex].Size = style.FontSize.Value;
                    }

                    if (style.Bold.HasValue)
                    {
                        scintilla.Styles[style.StyleIndex].Bold = style.Bold.Value;
                    }

                    if (style.Italics.HasValue)
                    {
                        scintilla.Styles[style.StyleIndex].Italic = style.Italics.Value;
                    }

                    if (style.EOLFilled.HasValue)
                    {
                        scintilla.Styles[style.StyleIndex].IsSelectionEolFilled = style.EOLFilled.Value;
                    }

                    scintilla.Styles[style.StyleIndex].Case = style.CaseVisibility;
                }


                for (int j = 0; j < 9; j++)
                {
                    if (lang.KeywordLists.ContainsKey(j))
                    {
                        scintilla.Lexing.SetKeywords(j, lang.KeywordLists[j]);
                    }
                    else
                    {
                        scintilla.Lexing.SetKeywords(j, string.Empty);
                    }
                }
            }

            scintilla.Lexing.Colorize(0, scintilla.Text.Length);
        }