示例#1
0
 private List <ICompletionListItem> HandleSelectorCompletion(LocalContext context)
 {
     return(htmlTags);
 }
示例#2
0
 private List <ICompletionListItem> HandlePropertyCompletion(LocalContext context)
 {
     return(blockLevel);
 }
示例#3
0
 private List <ICompletionListItem> HandlePrefixCompletion(LocalContext context)
 {
     return(prefixes);
 }
示例#4
0
 private List <ICompletionListItem> HandlePseudoCompletion(LocalContext context)
 {
     return(pseudos);
 }
示例#5
0
        private LocalContext GetContext(ScintillaControl sci, int position)
        {
            var ctx   = new LocalContext(sci);
            int i     = position - 1;
            int style = sci.StyleAt(i - 1);

            if (style == (int)CSS.COMMENT) // inside comments
            {
                ctx.InComments = true;
                return(ctx);
            }

            int inString = 0;

            if (style == 14)
            {
                inString = 1;
            }
            if (style == 13)
            {
                inString = 2;
            }

            bool   inWord      = true;
            bool   inComment   = false;
            bool   inPar       = false;
            string word        = "";
            int    lastCharPos = i;

            while (i > 1)
            {
                char c = (char)sci.CharAt(i--);

                if (wordChars.IndexOf(c) >= 0)
                {
                    lastCharPos = i + 1;
                    if (inWord)
                    {
                        word = c + word;
                    }
                }
                else
                {
                    inWord = false;
                }

                if (inString > 0)
                {
                    if (inString == 1 && c == '\'')
                    {
                        inString = 0;
                    }
                    else if (inString == 2 && c == '"')
                    {
                        inString = 0;
                    }
                    continue;
                }
                if (inComment)
                {
                    if (c == '*' && i > 0 && (char)sci.CharAt(i) == '/')
                    {
                        inComment = false;
                    }
                    continue;
                }
                if (c == '/' && i > 0 && (char)sci.CharAt(i) == '*') // entering comment
                {
                    inComment = true;
                }
                if (c == '\'')
                {
                    inString = 1;            // entering line
                }
                else if (c == '"')
                {
                    inString = 2;
                }

                else if (c == ')')
                {
                    inPar = true;
                }
                else if (inPar)
                {
                    if (c == '(')
                    {
                        inPar = false;
                    }
                    continue;
                }

                else if (c == ':')
                {
                    ctx.Separator = c;
                    ctx.Position  = lastCharPos;
                    string attr = ReadAttribute(sci, i);
                    if (attr.Length > 1)
                    {
                        if (attr[0] == features.Trigger || IsVarDecl(sci, i))
                        {
                            ctx.IsVar = true;
                        }
                        else if (!IsTag(attr))
                        {
                            ctx.InValue  = true;
                            ctx.Property = attr;
                        }
                    }
                    break;
                }
                else if (c == ';' || c == '{')
                {
                    ctx.Separator = c;
                    ctx.Position  = lastCharPos;
                    ctx.InBlock   = !IsVarDecl(sci, i);
                    break;
                }
                else if (c == '}' || c == ',' || c == '.' || c == '#')
                {
                    ctx.Separator = c;
                    ctx.Position  = lastCharPos;
                    break;
                }
                else if (c == '(')
                {
                    string tok = ReadWordLeft(sci, i);
                    if (tok == "url")
                    {
                        ctx.Separator = '(';
                        ctx.InUrl     = true;
                        ctx.Position  = i + 1;
                        word          = "";
                        for (int j = i + 2; j < position; j++)
                        {
                            word += (char)sci.CharAt(j);
                        }
                        break;
                    }
                }
            }
            if (word.Length > 0)
            {
                if (word[0] == '-')
                {
                    Match m = reNavPrefix.Match(word);
                    if (m.Success)
                    {
                        word = m.Groups[1].Value;
                    }
                }
            }
            ctx.Word = word;
            return(ctx);
        }