static ThemeSetting GetSetting(List <ThemeSetting> settings, string scope, bool exact = true)
        {
            ThemeSetting result = null;
            string       cs     = null;
            int          d      = 0;
            var          stack  = new ScopeStack(scope);

            foreach (var s in settings.Skip(1))
            {
                if (s.Scopes.Any(a => EditorTheme.IsCompatibleScope(a, stack, ref cs, ref d)))
                {
                    result = s;
                }
            }
            return(result);
        }
示例#2
0
 bool IsValidScope(ThemeSetting setting, ScopeStack scopeStack, ref string compatibleScope, ref int depth)
 {
     if (setting.Scopes.Count == 0)
     {
         compatibleScope = "";
         depth           = int.MaxValue - 1;
         return(true);
     }
     foreach (var s in setting.Scopes)
     {
         if (IsCompatibleScope(s, scopeStack, ref compatibleScope, ref depth))
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
 bool IsValidScope(ThemeSetting setting, ScopeStack scopeStack, ref string compatibleScope, ref int depth)
 {
     if (setting.Scopes.Count == 0)
     {
         compatibleScope = "";
         depth           = int.MaxValue - 1;
         return(true);
     }
     for (int i = 0; i < setting.Scopes.Count; i++)
     {
         var s = setting.Scopes[i];
         if (IsCompatibleScope(s, scopeStack, ref compatibleScope, ref depth))
         {
             return(true);
         }
     }
     return(false);
 }
        static ThemeSetting CalculateMissingDefaultColors(ThemeSetting themeSetting)
        {
            var settings        = (Dictionary <string, string>)themeSetting.Settings;
            var bgColor         = HslColor.Parse(settings [EditorThemeColors.Background]);
            var darkModificator = HslColor.Brightness(bgColor) < 0.5 ? 1 : -1;

            // do some better best-fit calculations
            if (!settings.ContainsKey(EditorThemeColors.LineNumbersBackground))
            {
                settings [EditorThemeColors.LineNumbersBackground] = bgColor.AddLight(0.01 * darkModificator).ToPangoString();
            }
            if (!settings.ContainsKey(EditorThemeColors.IndicatorMarginSeparator))
            {
                settings [EditorThemeColors.IndicatorMarginSeparator] = bgColor.AddLight(0.03 * darkModificator).ToPangoString();
            }
            if (!settings.ContainsKey(EditorThemeColors.LineNumbers))
            {
                settings [EditorThemeColors.LineNumbers] = HslColor.Parse(settings [EditorThemeColors.Foreground]).AddLight(-0.1 * darkModificator).ToPangoString();
            }
            if (!settings.ContainsKey(EditorThemeColors.IndicatorMargin))
            {
                settings [EditorThemeColors.IndicatorMargin] = bgColor.AddLight(0.02 * darkModificator).ToPangoString();
            }

            // copy all missing settings from main template theme
            var templateTheme = SyntaxHighlightingService.GetEditorTheme(darkModificator == 1 ? EditorTheme.DefaultDarkThemeName : EditorTheme.DefaultThemeName);

            foreach (var kv in templateTheme.Settings[0].Settings)
            {
                if (settings.ContainsKey(kv.Key))
                {
                    continue;
                }
                settings.Add(kv.Key, kv.Value);
            }

            return(new ThemeSetting(themeSetting.Name, themeSetting.Scopes, settings));
        }