コード例 #1
0
        public BracketSearchResult SearchBracket(IDocument document, int offset)
        {
            if (offset > 0)
            {
                char c           = document.GetCharAt(offset - 1);
                int  index       = openingBrackets.IndexOf(c);
                int  otherOffset = -1;
                if (index > -1)
                {
                    otherOffset = SearchBracketForward(document, offset, openingBrackets[index], closingBrackets[index]);
                }

                index = closingBrackets.IndexOf(c);
                if (index > -1)
                {
                    otherOffset = SearchBracketBackward(document, offset - 2, openingBrackets[index], closingBrackets[index]);
                }

                if (otherOffset > -1)
                {
                    var result = new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1,
                                                         Math.Max(offset - 1, otherOffset), 1);
                    SearchDefinition(document, result);
                    return(result);
                }
            }

            return(null);
        }
コード例 #2
0
 public void SetHighlight(BracketSearchResult result)
 {
     if (this.result != result)
     {
         this.result = result;
         textView.InvalidateLayer(this.Layer);
     }
 }
コード例 #3
0
 public void SetHighlight(BracketSearchResult result)
 {
     if (this.result != result)
     {
         this.result = result;
         textView.InvalidateLayer(Layer);
     }
 }
コード例 #4
0
        void SearchDefinition(IDocument document, BracketSearchResult result)
        {
            if (document.GetCharAt(result.OpeningBracketOffset) != '{')
            {
                return;
            }
            var documentLine = document.GetLineByOffset(result.OpeningBracketOffset);

            while (documentLine != null && IsBracketOnly(document, documentLine))
            {
                documentLine = documentLine.PreviousLine;
            }
            if (documentLine != null)
            {
                result.DefinitionHeaderOffset = documentLine.Offset;
                result.DefinitionHeaderLength = documentLine.Length;
            }
        }
コード例 #5
0
 void SearchDefinition(IDocument document, BracketSearchResult result)
 {
     if (document.GetCharAt(result.OpeningBracketOffset) != '{')
         return;
     var documentLine = document.GetLineByOffset(result.OpeningBracketOffset);
     while (documentLine != null && IsBracketOnly(document, documentLine))
         documentLine = documentLine.PreviousLine;
     if (documentLine != null)
     {
         result.DefinitionHeaderOffset = documentLine.Offset;
         result.DefinitionHeaderLength = documentLine.Length;
     }
 }
コード例 #6
0
        public BracketSearchResult SearchBracket(IDocument document, int offset)
        {
            if (offset > 0)
            {
                char c = document.GetCharAt(offset - 1);
                int index = openingBrackets.IndexOf(c);
                int otherOffset = -1;
                if (index > -1)
                    otherOffset = SearchBracketForward(document, offset, openingBrackets[index], closingBrackets[index]);

                index = closingBrackets.IndexOf(c);
                if (index > -1)
                    otherOffset = SearchBracketBackward(document, offset - 2, openingBrackets[index], closingBrackets[index]);

                if (otherOffset > -1)
                {
                    var result = new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1,
                                                         Math.Max(offset - 1, otherOffset), 1);
                    SearchDefinition(document, result);
                    return result;
                }
            }

            return null;
        }