예제 #1
0
        private bool TestIfComments(int pos, bool checkStr)
        {
            var st = sci.GetStyleAt(pos);

            //exclude autocomplete in comments and strings
            var b = st == TextStyle.MultilineStyle1 || st == TextStyle.MultilineStyle2 ||
                    st == TextStyle.Style6 || st == TextStyle.Style7;

            if (st == TextStyle.None && checkStr)
            {
                var lnn = sci.GetLineFromPosition(pos);
                var ln  = sci.GetLine(lnn);
                var col = sci.GetColumnFromPosition(pos);

                for (var i = col; i > -1; i--)
                {
                    if (sci.CharAt(sci.GetPositionByColumn(lnn, i)) == '"')
                    {
                        return(true);
                    }
                }
            }

            return(b);
        }
예제 #2
0
        internal void Fold(FoldNeededEventArgs e)
        {
            var lineCount = sci.LineCount;
            var firstLine = e.StartLine;
            var lastLine  = e.EndLine;

            e.AddFoldRegion(0, firstLine, lastLine);

            var lastStart = -1;

            for (int line = firstLine; line < lastLine + 2; line++)
            {
                var li      = sci.GetLineIndentation(line);
                var posLine = sci.GetPositionFromLine(line);
                var colEnd  = sci.GetLineEndColumn(line);
                var style   = sci.GetStyleAt(posLine);
                var cmt     = style == TextStyle.MultilineStyle1 || style == TextStyle.MultilineStyle2 ||
                              style == TextStyle.Style6 || style == TextStyle.Style7;

                var hasLet = li == 0 && !cmt;

                if ((li == 0 || colEnd == li) && lastStart > -1 && line - lastStart > 1 && !cmt)
                {
                    e.AddFoldRegion(1, lastStart, line);
                    lastStart = -1;
                }
                else if (li == 0 || colEnd == li)
                {
                    lastStart = -1;
                }

                if (hasLet)
                {
                    lastStart = line;
                }

                if (line == lastLine + 1 && lastStart != -1 && lastLine < lineCount)
                {
                    lastLine++;
                }
            }

            if (lastStart > -1 && lastLine == lineCount - 1)
            {
                e.AddFoldRegion(1, lastStart, lineCount - 1);
            }
        }