Пример #1
0
        private void _caret_PositionChanged(object sender, EventArgs e)
        {
            try {
                string currentWord = AvalonLoader.GetWholeWord(_textEditor.TextArea.Document, _textEditor);

                if (_textEditor.CaretOffset > 0)
                {
                    if (currentWord.Length <= 0 || !char.IsLetterOrDigit(currentWord[0]))
                    {
                        foreach (char c in new char[] { '{', '}', '(', ')', '[', ']' })
                        {
                            if (_isBefore(c) || _isAfter(c))
                            {
                                currentWord = "" + c;
                            }
                        }
                    }
                }

                if (_currentWord != currentWord)
                {
                    _renderer.CurrentResults.Clear();
                    _textArea.TextView.InvalidateLayer(KnownLayer.Selection);
                }

                _currentWord = currentWord;
                _updateCurrentWord(currentWord);
            }
            catch {
            }
        }
Пример #2
0
        private void _caret_PositionChanged(object sender, EventArgs e)
        {
            try {
                string currentWord = AvalonLoader.GetWholeWord(_textEditor.TextArea.Document, _textEditor);

                if (_currentWord != currentWord)
                {
                    _renderer.CurrentResults.Clear();
                    _textArea.TextView.InvalidateLayer(KnownLayer.Selection);
                }

                _currentWord = currentWord;
                _updateCurrentWord(currentWord);
            }
            catch { }
        }
Пример #3
0
        public IEnumerable <ISearchResult> FindAll(ITextSource document, int offset, int length)
        {
            int endOffset = offset + length;

            foreach (Match result in _searchPattern.Matches(document.Text))
            {
                int resultEndOffset = result.Length + result.Index;
                if (offset > result.Index || endOffset < resultEndOffset)
                {
                    continue;
                }
                if (_matchWholeWords && (!AvalonLoader.IsWordBorder(document, result.Index) || !AvalonLoader.IsWordBorder(document, resultEndOffset)))
                {
                    continue;
                }
                yield return(new SearchResult {
                    StartOffset = result.Index, Length = result.Length, Data = result
                });
            }
        }