コード例 #1
0
        public BracketSearchResult SearchBracket(IDocument document, int offset)
        {
            if (offset > 0)
            {
                var c           = document.GetCharAt(offset - 1);
                var index       = openingBrackets.IndexOf(c);
                var 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(Layer);
     }
 }
コード例 #3
0
        private 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;
            }
        }