Beispiel #1
0
        public static void LoadThemesFromString(string data)
        {
            INI tini = new INI();
            tini.NoComments = true;
            tini.Text = data;
            Dict.Clear();
            foreach(string section in tini.Dict.Keys) {
                Theme tt = new Theme();
                tt.Name = section;
                tt.Background      = ToColor(tini.Get("Background"     , section, ""));
                tt.Caret           = ToColor(tini.Get("Caret"          , section, ""));
                tt.Foreground      = ToColor(tini.Get("Foreground"     , section, ""));
                tt.Invisibles      = ToColor(tini.Get("Invisibles"     , section, ""));
                tt.LineHighlight   = ToColor(tini.Get("LineHighlight"  , section, ""));
                tt.ChangedLines    = ToColor(tini.Get("ChangedLines"   , section, ""));
                tt.Selection       = ToColor(tini.Get("Selection"      , section, ""));
                tt.LineNumberColor = ToColor(tini.Get("LineNumberColor", section, ""));
                tt.IndentBackColor = ToColor(tini.Get("IndentBackColor", section, ""));

                tt.StringStyle       = ToStyle2(tini.Get("StringStyle"      , section, ""));
                tt.CommentStyle      = ToStyle2(tini.Get("CommentStyle"     , section, ""));
                tt.NumberStyle       = ToStyle2(tini.Get("NumberStyle"      , section, ""));
                tt.AttributeStyle    = ToStyle2(tini.Get("AttributeStyle"   , section, ""));
                tt.ClassNameStyle    = ToStyle2(tini.Get("ClassNameStyle"   , section, ""));
                tt.KeywordStyle      = ToStyle2(tini.Get("KeywordStyle"     , section, ""));
                tt.CommentTagStyle   = ToStyle2(tini.Get("CommentTagStyle"  , section, ""));
                tt.TagBracketStyle   = ToStyle2(tini.Get("TagBracketStyle"  , section, ""));
                tt.FunctionsStyle    = ToStyle2(tini.Get("FunctionsStyle"   , section, ""));
                tt.VariableStyle     = ToStyle2(tini.Get("VariableStyle"    , section, ""));
                tt.DeclFunctionStyle = ToStyle2(tini.Get("DeclFunctionStyle", section, ""));
                tt.InvisibleStyle    = ToStyle (tini.Get("Invisibles"       , section, ""));
                Dict.Add(section, tt);
            }
        }
Beispiel #2
0
        public static void LoadFromXml(string file)
        {
            Theme t = new Theme();

            YamlObject plist = PlistParser.LoadFromFile(file);
            string themeName = plist["name"];
            if (themeName == "") return;
            YamlObject list = plist.GetObject("settings");
            foreach (YamlObject item in list) {
                string     name     = item["name" ];
                string[]   scope    = item["scope"].Split(',');
                for (int i = 0; i < scope.Length; i++) scope[i] = scope[i].ToLower().Trim();
                YamlObject settings = item.GetObject("settings");
                if ((name=="") && (item["scope"]=="") && (settings.Count > 0)) {
                    t.Background     = ToColor(settings["background"   ]);
                    t.Caret          = ToColor(settings["caret"        ]);
                    t.Foreground     = ToColor(settings["foreground"   ]);
                    t.Invisibles     = ToColor(settings["invisibles"   ]);
                    t.LineHighlight  = ToColor(settings["lineHighlight"]);
                    t.Selection      = ToColor(settings["selection"    ]);
                    t.InvisibleStyle = ToStyle(settings["invisibles"   ]);
                    continue;
                }

                if (InScope(scope, "comment"          )) t.CommentStyle    = ToStyleFromSettings(settings);
                if (InScope(scope, "string"           )) t.StringStyle     = ToStyleFromSettings(settings);
                if (InScope(scope, "constant.numeric" )) t.NumberStyle     = ToStyleFromSettings(settings);
                if (InScope(scope, "keyword"          )) t.KeywordStyle    = ToStyleFromSettings(settings);
                if (InScope(scope, "entity.name.class")) t.ClassNameStyle  = ToStyleFromSettings(settings);
                if (InScope(scope, "declaration.class")) t.ClassNameStyle  = ToStyleFromSettings(settings);
                if (InScope(scope, "support.class"    )) t.ClassNameStyle  = ToStyleFromSettings(settings);
                if (InScope(scope, "meta.tag"         )) t.TagBracketStyle = ToStyleFromSettings(settings);
                if (InScope(scope, "entity.name.tag"  )) t.TagNameStyle    = ToStyleFromSettings(settings);
                if (InScope(scope, "variable"         )) t.VariableStyle   = ToStyleFromSettings(settings);
                if (InScope(scope, "attribute-name"   )) t.AttributeStyle  = ToStyleFromSettings(settings);
                if (InScope(scope, "support.function" )) t.FunctionsStyle  = ToStyleFromSettings(settings);
                if (InScope(scope, "support.constant" )) t.ConstantsStyle  = ToStyleFromSettings(settings);
                if (InScope(scope, "entity.name.function")) t.DeclFunctionStyle = ToStyleFromSettings(settings);

            }
            Dict[themeName] = t;
        }
Beispiel #3
0
        public static void LoadThemesFromString(string data)
        {
            INI tini = new INI {
                NoComments = true,
                Text       = data
            };
            Dict.Clear();
            foreach(string section in tini.Dict.Keys) {
                // ReSharper disable once UseObjectOrCollectionInitializer
                Theme tt = new Theme();
                tt.Name = section;
                tt.Background      = ToColor(tini.Get("Background"     , section, ""));
                tt.Caret           = ToColor(tini.Get("Caret"          , section, ""));
                tt.Foreground      = ToColor(tini.Get("Foreground"     , section, ""));
                tt.Invisibles      = ToColor(tini.Get("Invisibles"     , section, ""));
                tt.LineHighlight   = ToColor(tini.Get("LineHighlight"  , section, ""));
                tt.ChangedLines    = ToColor(tini.Get("ChangedLines"   , section, ""));
                tt.Selection       = ToColor(tini.Get("Selection"      , section, ""));
                tt.SelectionBorder = ToColor(tini.Get("SelectionBorder", section, ""));
                tt.SelectionForegr = ToColor(tini.Get("SelectionForegr", section, ""));
                tt.LineNumberColor = ToColor(tini.Get("LineNumberColor", section, ""));
                tt.IndentBackColor = ToColor(tini.Get("IndentBackColor", section, ""));

                tt.StringStyle       = ToStyle2(tini.Get("StringStyle"      , section, ""));
                tt.CommentStyle      = ToStyle2(tini.Get("CommentStyle"     , section, ""));
                tt.NumberStyle       = ToStyle2(tini.Get("NumberStyle"      , section, ""));
                tt.AttributeStyle    = ToStyle2(tini.Get("AttributeStyle"   , section, ""));
                tt.ClassNameStyle    = ToStyle2(tini.Get("ClassNameStyle"   , section, ""));
                tt.KeywordStyle      = ToStyle2(tini.Get("KeywordStyle"     , section, ""));
                tt.CommentTagStyle   = ToStyle2(tini.Get("CommentTagStyle"  , section, ""));
                tt.TagBracketStyle   = ToStyle2(tini.Get("TagBracketStyle"  , section, ""));
                tt.FunctionsStyle    = ToStyle2(tini.Get("FunctionsStyle"   , section, ""));
                tt.VariableStyle     = ToStyle2(tini.Get("VariableStyle"    , section, ""));
                tt.DeclFunctionStyle = ToStyle2(tini.Get("DeclFunctionStyle", section, ""));
                tt.PunctuationStyle  = ToStyle2(tini.Get("PunctuationStyle" , section, ""));
                tt.InvisibleStyle    = ToStyle (tini.Get("Invisibles"       , section, ""));
                tt.TypesStyle        = ToStyle2(tini.Get("TypesStyle"       , section, ""));
                Dict.Add(section, tt);
            }
        }