private static void ApplyGeneralProperty(string key, string var)
        {
            string val = Evaluate(var);

            switch (key)
            {
            case "menu-language":
                string[] menuItems = val.Split('|');
                for (int i = 2; i < menuItems.Length; i += 3)
                {
                    MenuItemConfig menuItem = new MenuItemConfig();
                    menuItem.Text         = menuItems[i - 2];
                    menuItem.Value        = menuItems[i - 1];
                    menuItem.ShortcutKeys = GetKeys(menuItems[i]);

                    config.LanguageMenuItems.Add(menuItem);
                }
                break;

            case "language-names":
                config.LanguageNames.AddRange(val.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                break;

            case "extension-languages":
                PropertiesReader.GetKeyValuePairs(val, config.ExtensionLanguages);
                break;

            case "open-filter":
                config.FileOpenFilter = val;
                break;

            case "default-file-ext":
                config.DefaultFileExtention = val;
                break;

            default:
                config.Properties[key] = Evaluate(val);
                break;
            }
        }
Example #2
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;
        }
        private static void ApplyGeneralProperty(string key, string var)
        {
            string val = Evaluate(var);
            switch (key)
            {
                case "menu-language":
                    string[] menuItems = val.Split('|');
                    for (int i = 2; i < menuItems.Length; i += 3)
                    {
                        MenuItemConfig menuItem = new MenuItemConfig();
                        menuItem.Text = menuItems[i - 2];
                        menuItem.Value = menuItems[i - 1];
                        menuItem.ShortcutKeys = GetKeys(menuItems[i]);

                        config.LanguageMenuItems.Add(menuItem);
                    }
                    break;
                case "language-names":
                    config.LanguageNames.AddRange(val.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                    break;
                case "extension-languages":
                    PropertiesReader.GetKeyValuePairs(val, config.ExtensionLanguages);
                    break;
                case "open-filter":
                    config.FileOpenFilter = val;
                    break;
                case "default-file-ext":
                    config.DefaultFileExtention = val;
                    break;
                default:
                    config.Properties[key] = Evaluate(val);
                    break;
            }
        }
        /// <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;
        }