Exemplo n.º 1
0
        FontColorStyle GetColor(ScopeStack scopeStack)
        {
            HslColor foreground;
            HslColor background;
            string   fontStyle;

            settings [0].TryGetColor(EditorThemeColors.Foreground, out foreground);
            settings [0].TryGetColor(EditorThemeColors.Background, out background);
            settings [0].TryGetSetting("fontStyle", out fontStyle);

            string found      = null;
            int    foundDepth = int.MaxValue;

            if (scopeStack.Count > 1)
            {
                if (scopeStack.Peek() == scopeStack.FirstElement)
                {
                    return(new FontColorStyle(foreground, background, fontStyle));
                }
            }

            for (int i = 1; i < settings.Count; ++i)
            {
                var    setting         = settings[i];
                string compatibleScope = null;
                int    depth           = 0;
                if (IsValidScope(setting, scopeStack, ref compatibleScope, ref depth))
                {
                    if (found != null && (depth > foundDepth || depth == foundDepth && found.Length >= compatibleScope.Length))
                    {
                        continue;
                    }
                    HslColor tryC;
                    if (setting.TryGetColor(EditorThemeColors.Foreground, out tryC))
                    {
                        found      = compatibleScope;
                        foreground = tryC;
                        foundDepth = depth;
                    }
                    if (setting.TryGetColor(EditorThemeColors.Background, out tryC))
                    {
                        background = tryC;
                    }
                    string tryS;
                    if (setting.TryGetSetting("fontStyle", out tryS))
                    {
                        fontStyle = tryS;
                    }
                }
            }
            return(new FontColorStyle(foreground, background, fontStyle));
        }
            public override Tuple <bool, ScopeStack> MatchesStack(ScopeStack scopeStack, ref string matchExpr)
            {
                if (scopeStack.IsEmpty)
                {
                    return(mismatch);
                }
                bool found = scopeStack.Peek().StartsWith(scope, StringComparison.Ordinal);

                if (found)
                {
                    matchExpr = scope;
                    return(Tuple.Create(found, scopeStack.Pop()));
                }
                return(mismatch);
            }
Exemplo n.º 3
0
            public override (bool, ScopeStack) MatchesStack(ScopeStack scopeStack, ref string matchExpr)
            {
                if (scopeStack.IsEmpty)
                {
                    return(mismatch);
                }
                var  top   = scopeStack.Peek();
                bool found = top == scope || top.Length > scope.Length && top[scope.Length] == '.' && top.StartsWith(scope, StringComparison.Ordinal);

                if (found)
                {
                    matchExpr = scope;
                    return(found, scopeStack.Pop());
                }
                return(mismatch);
            }