public static void Populate(IScintillaConfig scintillaConfig, ConfigResource resource)
 {
     config = scintillaConfig;
     if (config != null)
     {
         PropertiesReader.Read(resource, PropertyRead);
     }
 }
 public static void Populate(IScintillaConfig scintillaConfig, ConfigResource resource)
 {
     config = scintillaConfig;
     if (config != null)
     {
         PropertiesReader.Read(resource, PropertyRead);
     }
 }
 public static void Populate(IScintillaConfig scintillaConfig, FileInfo file)
 {
     config = scintillaConfig;
     if (config != null)
     {
         PropertiesReader.Read(new ConfigResource(file), PropertyRead);
     }
 }
 public static void Populate(IScintillaConfig scintillaConfig, FileInfo file)
 {
     config = scintillaConfig;
     if (config != null)
     {
         PropertiesReader.Read(new ConfigResource(file), PropertyRead);
     }
 }
        public LexerConfigCollection(IScintillaConfig parent, IScintillaConfigProvider provider)
        {
            if (provider == null)
                throw new Exception("IScintillaConfigProvider must be provided to the LexerConfigCollection constructor!");
            if (parent == null)
                throw new Exception("The ScintillaConfig must be provided in the LexerConfigCollection constructor!");

            this.parent = parent;
            this.provider = provider;
        }
        public LanguageConfigCollection(IScintillaConfig parent, IScintillaConfigProvider provider, ILexerConfigCollection lexers)
        {
            if (provider == null)
                throw new Exception("IScintillaConfigProvider must be provided in the LanguageConfigCollection constructor!");
            if (lexers == null)
                throw new Exception("The LexerConfigCollection must be provided in the LanguageConfigCollection constructor!");
            if (parent == null)
                throw new Exception("The ScintillaConfig must be provided in the LanguageConfigCollection constructor!");

            this.parent = parent;
            this.provider = provider;
            this.lexers = lexers;
        }
Example #7
0
        public LexerConfigCollection(IScintillaConfig parent, IScintillaConfigProvider provider)
        {
            if (provider == null)
            {
                throw new Exception("IScintillaConfigProvider must be provided to the LexerConfigCollection constructor!");
            }
            if (parent == null)
            {
                throw new Exception("The ScintillaConfig must be provided in the LexerConfigCollection constructor!");
            }

            this.parent   = parent;
            this.provider = provider;
        }
Example #8
0
        public LanguageConfigCollection(IScintillaConfig parent, IScintillaConfigProvider provider, ILexerConfigCollection lexers)
        {
            if (provider == null)
            {
                throw new Exception("IScintillaConfigProvider must be provided in the LanguageConfigCollection constructor!");
            }
            if (lexers == null)
            {
                throw new Exception("The LexerConfigCollection must be provided in the LanguageConfigCollection constructor!");
            }
            if (parent == null)
            {
                throw new Exception("The ScintillaConfig must be provided in the LanguageConfigCollection constructor!");
            }

            this.parent   = parent;
            this.provider = provider;
            this.lexers   = lexers;
        }
Example #9
0
 public LanguageConfig(IScintillaConfig scintillaConf, string name)
 {
     this.scintillaConf = scintillaConf;
     this.name          = name;
 }
Example #10
0
        /// <summary>
        /// Apply the lexer style according to the scite config files
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateScintillaConfig(IScintillaConfig config)
        {
            string key, val, lang;
            int?   valInt;
            bool?  valBool;

            foreach (string ext in extentionLanguages.Keys)
            {
                config.ExtensionLanguages[ext] = extentionLanguages[ext];
            }

            // Menu Items in the format: (menuString|fileExtension|key|)*
            key = "menu.language";
            if (properties.ContainsKey(key))
            {
                val = this.Evaluate(properties[key]);
                string[] menuItems = val.Split('|');
                for (int i = 2; i < menuItems.Length; i += 3)
                {
                    lang = this.GetLanguageFromExtension(menuItems[i - 1]);

                    MenuItemConfig menuItem = new MenuItemConfig();
                    menuItem.Text         = menuItems[i - 2];
                    menuItem.Value        = (lang == null) ? menuItems[i - 1] : lang;
                    menuItem.ShortcutKeys = GetKeys(menuItems[i]);

                    config.LanguageMenuItems.Add(menuItem);
                }
            }

            /*
             * braces.check
             * braces.sloppy
             * indent.auto
             * indent.automatic
             * indent.opening
             * indent.closing
             * indent.maintain.filepattern
             * statement.indent.filepattern
             * statement.end.filepattern
             * statement.lookback.filepattern
             * block.start.filepattern
             * block.end.filepattern
             *
             * api.filepattern
             * autocomplete.choose.single
             * autocomplete.lexer.ignorecase
             * autocomplete.lexer.start.characters
             * autocomplete.*.start.characters
             * autocomplete.lexer.fillups
             * autocomplete.*.fillups
             * autocompleteword.automatic
             *
             * calltip.lexer.ignorecase
             * calltip.*.ignorecase
             * calltip.lexer.word.characters
             * calltip.*.word.characters
             * calltip.lexer.parameters.start
             * calltip.lexer.parameters.end
             * calltip.lexer.parameters.separators
             * calltip.*.parameters.start
             * calltip.*.parameters.end
             * calltip.*.parameters.separators
             * calltip.lexer.end.definition
             * calltip.*.end.definition
             */

            valInt = GetInt("code.page");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.CodePage = valInt.Value;
            }

            valInt = GetInt("selection.alpha");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.SelectionAlpha = valInt;
            }

            config.LanguageDefaults.SelectionBackColor = GetColor("selection.back", config.LanguageDefaults.SelectionBackColor);

            config.FileOpenFilter = GetString("open.filter", config.FileOpenFilter);

            config.DefaultFileExtention = GetString("default.file.ext", config.DefaultFileExtention);

            valInt = GetInt("tabsize");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.TabSize = valInt;
            }

            valInt = GetInt("indent.size");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.IndentSize = valInt;
            }

            valBool = GetBool("styling.within.preprocessor");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.StylingWithinPreprocessor = valBool.Value;
            }

            valBool = GetBool("fold");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.Fold = valBool.Value;
            }

            valBool = GetBool("fold.compact");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.FoldCompact = valBool.Value;
            }

            valBool = GetBool("fold.symbols");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.FoldSymbols = valBool.Value;
            }

            valBool = GetBool("fold.comment");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.FoldComment = valBool.Value;
            }

            valBool = GetBool("fold.on.open");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.FoldOnOpen = valBool.Value;
            }

            valBool = GetBool("fold.at.else");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.FoldAtElse = valBool.Value;
            }

            valBool = GetBool("fold.preprocessor");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.FoldPreprocessor = valBool.Value;
            }

            valBool = GetBool("fold.html");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.HtmlFold = valBool.Value;
            }

            valBool = GetBool("fold.html.preprocessor");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.HtmlFoldPreprocessor = valBool.Value;
            }

            valInt = GetInt("fold.flags");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.FoldFlags = valInt;
            }

            valInt = GetInt("fold.margin.width");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.FoldMarginWidth = valInt;
            }

            config.LanguageDefaults.FoldMarginColor = GetColor("fold.margin.colour", config.LanguageDefaults.FoldMarginColor);

            config.LanguageDefaults.FoldMarginHighlightColor = GetColor("fold.margin.highlight.colour", config.LanguageDefaults.FoldMarginHighlightColor);

            valBool = GetBool("html.tags.case.sensitive");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.HtmlTagsCaseSensitive = valBool.Value;
            }

            valBool = GetBool("fold.comment.python");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.PythonFoldComment = valBool.Value;
            }

            valBool = GetBool("fold.quotes.python");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.PythonFoldQuotes = valBool.Value;
            }

            valInt = GetInt("tab.timmy.whinge.level");
            if (valInt.HasValue)
            {
                config.LanguageDefaults.PythonWhingeLevel = valInt.Value;
            }

            valBool = GetBool("sql.backslash.escapes");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.SqlBackslashEscapes = valBool.Value;
            }

            valBool = GetBool("lexer.sql.backticks.identifier");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.SqlBackticksIdentifier = valBool.Value;
            }

            valBool = GetBool("fold.sql.only.begin");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.SqlFoldOnlyBegin = valBool.Value;
            }

            valBool = GetBool("fold.perl.pod");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.PerlFoldPod = valBool.Value;
            }

            valBool = GetBool("fold.perl.package");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.PerlFoldPackage = valBool.Value;
            }

            valBool = GetBool("nsis.ignorecase");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.NsisIgnoreCase = valBool.Value;
            }

            valBool = GetBool("nsis.uservars");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.NsisUserVars = valBool.Value;
            }

            valBool = GetBool("nsis.foldutilcmd");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.NsisFoldUtilCommand = valBool.Value;
            }

            valBool = GetBool("lexer.cpp.allow.dollars");
            if (valBool.HasValue)
            {
                config.LanguageDefaults.CppAllowDollars = valBool.Value;
            }
            return(true);
        }
Example #11
0
 public LexerConfig(IScintillaConfig scintillaConf, int lexer)
 {
     this.scintillaConf = scintillaConf;
     this.lexerType = (Lexer)lexer;
     lexerName = GetLexerName(lexerType);
 }
Example #12
0
 public LanguageConfig(IScintillaConfig scintillaConf, string name)
 {
     this.scintillaConf = scintillaConf;
     this.name = name;
 }
Example #13
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 PopulateScintillaConfig(IScintillaConfig config)
 {
     ScintillaPropertiesHelper.Populate(config, GetResource("global.properties"));
     return(true);
 }
 public bool PopulateScintillaConfig(IScintillaConfig config)
 {
     ScintillaPropertiesHelper.Populate(config, GetResource("global.properties"));
     return true;
 }
Example #16
0
        /// <summary>
        /// Apply the lexer style according to the scite config files
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateScintillaConfig(IScintillaConfig config, string filepattern)
        {
            string key, val, lang;
            int? valInt;
            bool? valBool;

            // Menu Items in the format: (menuString|fileExtension|key|)*
            key = "menu.language";
            if (properties.ContainsKey(key))
            {
                val = this.Evaluate(properties[key]);
                string[] menuItems = val.Split('|');
                for (int i = 2; i < menuItems.Length; i += 3)
                {
                    lang = this.GetLanguageFromExtension(menuItems[i - 1]);

                    MenuItemConfig menuItem = new MenuItemConfig();
                    menuItem.Text = menuItems[i - 2];
                    menuItem.Value = (lang == null) ? menuItems[i - 1] : lang;
                    menuItem.ShortcutKeys = GetKeys(menuItems[i]);

                    config.LanguageMenuItems.Add(menuItem);
                }
            }

            valInt = GetInt("code.page");
            if (valInt.HasValue) config.CodePage = valInt.Value;

            valInt = GetInt("selection.alpha");
            if (valInt.HasValue) config.SelectionAlpha = valInt;

            config.SelectionBackColor = GetColor("selection.back", config.SelectionBackColor);

            config.FileOpenFilter = GetString("open.filter", config.FileOpenFilter);

            config.DefaultFileExtention = GetString("default.file.ext", config.DefaultFileExtention);

			valInt = GetInt("tab.size", filepattern);
			if(!valInt.HasValue)
			{
				valInt = GetInt("tabsize");
				if (valInt.HasValue) config.TabSize = valInt;
			}

            valInt = GetInt("indent.size", filepattern);
            if (valInt.HasValue) config.IndentSize = valInt;

			valBool = GetBool("use.tabs", filepattern);
			if (valBool.HasValue) config.UseTabs = valBool;

            valBool = GetBool("fold");
            if (valBool.HasValue) config.Fold = valBool.Value;

            valBool = GetBool("fold.compact");
            if (valBool.HasValue) config.FoldCompact = valBool.Value;

            valBool = GetBool("fold.symbols");
            if (valBool.HasValue) config.FoldSymbols = valBool.Value;

            valBool = GetBool("fold.comment");
            if (valBool.HasValue) config.FoldComment = valBool.Value;

            valBool = GetBool("fold.on.open");
            if (valBool.HasValue) config.FoldOnOpen = valBool.Value;

            valBool = GetBool("fold.preprocessor");
            if (valBool.HasValue) config.FoldPreprocessor = valBool.Value;

            valBool = GetBool("fold.html");
            if (valBool.HasValue) config.FoldHTML = valBool.Value;

            valBool = GetBool("fold.html.preprocessor");
            if (valBool.HasValue) config.FoldHTMLPreprocessor = valBool.Value;

            valInt = GetInt("fold.flags");
            if (valInt.HasValue) config.FoldFlags = valInt;

            valInt = GetInt("fold.margin.width");
            if (valInt.HasValue) config.FoldMarginWidth = valInt;

            config.FoldMarginColor = GetColor("fold.margin.colour", config.FoldMarginColor);

            config.FoldMarginHighlightColor = GetColor("fold.margin.highlight.colour", config.FoldMarginHighlightColor);

            //tabsize=8
            //indent.size=8
            //default.file.ext=.cxx
            //open.filter
            //code.page
            //selection.alpha=30
            //selection.back=#000000
            //fold=1
            //fold.compact=1
            //fold.flags=16
            //fold.symbols=1
            //#fold.on.open=1
            //fold.comment=1
            //fold.preprocessor=1
            // there are a ton of generic scintilla properties - we will eventually implement them here
            //#fold.margin.width=16
            //#fold.margin.colour=#FF0000
            //#fold.margin.highlight.colour=#0000FF

            //fold.quotes.python
            //fold.perl.package
            //fold.perl.pod
            return true;
        }
Example #17
0
        /// <summary>
        /// Apply the lexer style according to the scite config files
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateScintillaConfig(IScintillaConfig config)
        {
            string key, val, lang;
            int?   valInt;
            bool?  valBool;

            // Menu Items in the format: (menuString|fileExtension|key|)*
            key = "menu.language";
            if (properties.ContainsKey(key))
            {
                val = this.Evaluate(properties[key]);
                string[] menuItems = val.Split('|');
                for (int i = 2; i < menuItems.Length; i += 3)
                {
                    lang = this.GetLanguageFromExtension(menuItems[i - 1]);

                    MenuItemConfig menuItem = new MenuItemConfig();
                    menuItem.Text         = menuItems[i - 2];
                    menuItem.Value        = (lang == null) ? menuItems[i - 1] : lang;
                    menuItem.ShortcutKeys = GetKeys(menuItems[i]);

                    config.LanguageMenuItems.Add(menuItem);
                }
            }

            valInt = GetInt("code.page");
            if (valInt.HasValue)
            {
                config.CodePage = valInt.Value;
            }

            valInt = GetInt("selection.alpha");
            if (valInt.HasValue)
            {
                config.SelectionAlpha = valInt;
            }

            config.SelectionBackColor = GetColor("selection.back", config.SelectionBackColor);

            config.FileOpenFilter = GetString("open.filter", config.FileOpenFilter);

            config.DefaultFileExtention = GetString("default.file.ext", config.DefaultFileExtention);

            valInt = GetInt("tabsize");
            if (valInt.HasValue)
            {
                config.TabSize = valInt;
            }

            valInt = GetInt("indent.size");
            if (valInt.HasValue)
            {
                config.IndentSize = valInt;
            }

            valBool = GetBool("fold");
            if (valBool.HasValue)
            {
                config.Fold = valBool.Value;
            }

            valBool = GetBool("fold.compact");
            if (valBool.HasValue)
            {
                config.FoldCompact = valBool.Value;
            }

            valBool = GetBool("fold.symbols");
            if (valBool.HasValue)
            {
                config.FoldSymbols = valBool.Value;
            }

            valBool = GetBool("fold.comment");
            if (valBool.HasValue)
            {
                config.FoldComment = valBool.Value;
            }

            valBool = GetBool("fold.on.open");
            if (valBool.HasValue)
            {
                config.FoldOnOpen = valBool.Value;
            }

            valBool = GetBool("fold.preprocessor");
            if (valBool.HasValue)
            {
                config.FoldPreprocessor = valBool.Value;
            }

            valBool = GetBool("fold.html");
            if (valBool.HasValue)
            {
                config.FoldHTML = valBool.Value;
            }

            valBool = GetBool("fold.html.preprocessor");
            if (valBool.HasValue)
            {
                config.FoldHTMLPreprocessor = valBool.Value;
            }

            valInt = GetInt("fold.flags");
            if (valInt.HasValue)
            {
                config.FoldFlags = valInt;
            }

            valInt = GetInt("fold.margin.width");
            if (valInt.HasValue)
            {
                config.FoldMarginWidth = valInt;
            }

            config.FoldMarginColor = GetColor("fold.margin.colour", config.FoldMarginColor);

            config.FoldMarginHighlightColor = GetColor("fold.margin.highlight.colour", config.FoldMarginHighlightColor);

            //tabsize=8
            //indent.size=8
            //default.file.ext=.cxx
            //open.filter
            //code.page
            //selection.alpha=30
            //selection.back=#000000
            //fold=1
            //fold.compact=1
            //fold.flags=16
            //fold.symbols=1
            //#fold.on.open=1
            //fold.comment=1
            //fold.preprocessor=1
            // there are a ton of generic scintilla properties - we will eventually implement them here
            //#fold.margin.width=16
            //#fold.margin.colour=#FF0000
            //#fold.margin.highlight.colour=#0000FF

            //fold.quotes.python
            //fold.perl.package
            //fold.perl.pod
            return(true);
        }
Example #18
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);
        }
Example #19
0
 public LexerConfig(IScintillaConfig scintillaConf, int lexer)
 {
     this.scintillaConf = scintillaConf;
     this.lexerType     = (Lexer)lexer;
     lexerName          = GetLexerName(lexerType);
 }
Example #20
0
        /// <summary>
        /// Apply the lexer style according to the scite config files
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateScintillaConfig(IScintillaConfig config)
        {
            string key, val, lang;
            int? valInt;
            bool? valBool;

            foreach (string ext in extentionLanguages.Keys)
            {
                config.ExtensionLanguages[ext] = extentionLanguages[ext];
            }

            // Menu Items in the format: (menuString|fileExtension|key|)*
            key = "menu.language";
            if (properties.ContainsKey(key))
            {
                val = this.Evaluate(properties[key]);
                string[] menuItems = val.Split('|');
                for (int i = 2; i < menuItems.Length; i += 3)
                {
                    lang = this.GetLanguageFromExtension(menuItems[i - 1]);

                    MenuItemConfig menuItem = new MenuItemConfig();
                    menuItem.Text = menuItems[i - 2];
                    menuItem.Value = (lang == null) ? menuItems[i - 1] : lang;
                    menuItem.ShortcutKeys = GetKeys(menuItems[i]);

                    config.LanguageMenuItems.Add(menuItem);
                }
            }
            /*
            braces.check
            braces.sloppy
            indent.auto
            indent.automatic
            indent.opening
            indent.closing
            indent.maintain.filepattern 
            statement.indent.filepattern
            statement.end.filepattern
            statement.lookback.filepattern
            block.start.filepattern
            block.end.filepattern 
            * 
            api.filepattern 
            autocomplete.choose.single
            autocomplete.lexer.ignorecase
            autocomplete.lexer.start.characters
            autocomplete.*.start.characters 
            autocomplete.lexer.fillups
            autocomplete.*.fillups 
            autocompleteword.automatic
            * 
            calltip.lexer.ignorecase
            calltip.*.ignorecase 
            calltip.lexer.word.characters
            calltip.*.word.characters 
            calltip.lexer.parameters.start
            calltip.lexer.parameters.end
            calltip.lexer.parameters.separators
            calltip.*.parameters.start
            calltip.*.parameters.end
            calltip.*.parameters.separators 
            calltip.lexer.end.definition
            calltip.*.end.definition 
            */

            valInt = GetInt("code.page");
            if (valInt.HasValue) config.LanguageDefaults.CodePage = valInt.Value;

            valInt = GetInt("selection.alpha");
            if (valInt.HasValue) config.LanguageDefaults.SelectionAlpha = valInt;

            config.LanguageDefaults.SelectionBackColor = GetColor("selection.back", config.LanguageDefaults.SelectionBackColor);

            config.FileOpenFilter = GetString("open.filter", config.FileOpenFilter);

            config.DefaultFileExtention = GetString("default.file.ext", config.DefaultFileExtention);

            valInt = GetInt("tabsize");
            if (valInt.HasValue) config.LanguageDefaults.TabSize = valInt;

            valInt = GetInt("indent.size");
            if (valInt.HasValue) config.LanguageDefaults.IndentSize = valInt;

            valBool = GetBool("styling.within.preprocessor");
            if (valBool.HasValue) config.LanguageDefaults.StylingWithinPreprocessor = valBool.Value;

            valBool = GetBool("fold");
            if (valBool.HasValue) config.LanguageDefaults.Fold = valBool.Value;

            valBool = GetBool("fold.compact");
            if (valBool.HasValue) config.LanguageDefaults.FoldCompact = valBool.Value;

            valBool = GetBool("fold.symbols");
            if (valBool.HasValue) config.LanguageDefaults.FoldSymbols = valBool.Value;

            valBool = GetBool("fold.comment");
            if (valBool.HasValue) config.LanguageDefaults.FoldComment = valBool.Value;

            valBool = GetBool("fold.on.open");
            if (valBool.HasValue) config.LanguageDefaults.FoldOnOpen = valBool.Value;

            valBool = GetBool("fold.at.else");
            if (valBool.HasValue) config.LanguageDefaults.FoldAtElse = valBool.Value;

            valBool = GetBool("fold.preprocessor");
            if (valBool.HasValue) config.LanguageDefaults.FoldPreprocessor = valBool.Value;

            valBool = GetBool("fold.html");
            if (valBool.HasValue) config.LanguageDefaults.HtmlFold = valBool.Value;

            valBool = GetBool("fold.html.preprocessor");
            if (valBool.HasValue) config.LanguageDefaults.HtmlFoldPreprocessor = valBool.Value;

            valInt = GetInt("fold.flags");
            if (valInt.HasValue) config.LanguageDefaults.FoldFlags = valInt;

            valInt = GetInt("fold.margin.width");
            if (valInt.HasValue) config.LanguageDefaults.FoldMarginWidth = valInt;

            config.LanguageDefaults.FoldMarginColor = GetColor("fold.margin.colour", config.LanguageDefaults.FoldMarginColor);

            config.LanguageDefaults.FoldMarginHighlightColor = GetColor("fold.margin.highlight.colour", config.LanguageDefaults.FoldMarginHighlightColor);

            valBool = GetBool("html.tags.case.sensitive");
            if (valBool.HasValue) config.LanguageDefaults.HtmlTagsCaseSensitive = valBool.Value;

            valBool = GetBool("fold.comment.python");
            if (valBool.HasValue) config.LanguageDefaults.PythonFoldComment = valBool.Value;

            valBool = GetBool("fold.quotes.python");
            if (valBool.HasValue) config.LanguageDefaults.PythonFoldQuotes = valBool.Value;

            valInt = GetInt("tab.timmy.whinge.level");
            if (valInt.HasValue) config.LanguageDefaults.PythonWhingeLevel = valInt.Value;

            valBool = GetBool("sql.backslash.escapes");
            if (valBool.HasValue) config.LanguageDefaults.SqlBackslashEscapes = valBool.Value;

            valBool = GetBool("lexer.sql.backticks.identifier");
            if (valBool.HasValue) config.LanguageDefaults.SqlBackticksIdentifier = valBool.Value;

            valBool = GetBool("fold.sql.only.begin");
            if (valBool.HasValue) config.LanguageDefaults.SqlFoldOnlyBegin = valBool.Value;

            valBool = GetBool("fold.perl.pod");
            if (valBool.HasValue) config.LanguageDefaults.PerlFoldPod = valBool.Value;

            valBool = GetBool("fold.perl.package");
            if (valBool.HasValue) config.LanguageDefaults.PerlFoldPackage = valBool.Value;

            valBool = GetBool("nsis.ignorecase");
            if (valBool.HasValue) config.LanguageDefaults.NsisIgnoreCase = valBool.Value;

            valBool = GetBool("nsis.uservars");
            if (valBool.HasValue) config.LanguageDefaults.NsisUserVars = valBool.Value;

            valBool = GetBool("nsis.foldutilcmd");
            if (valBool.HasValue) config.LanguageDefaults.NsisFoldUtilCommand = valBool.Value;

            valBool = GetBool("lexer.cpp.allow.dollars");
            if (valBool.HasValue) config.LanguageDefaults.CppAllowDollars = valBool.Value;
            return true;
        }