public SearchResultMatch FindNext(ITextIterator textIterator, int offset, int length) { string document = textIterator.TextBuffer.GetText(0, textIterator.TextBuffer.Length); while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { Match m = regex.Match(document, textIterator.Position); if (m == null || !m.Success) { while (textIterator.Position < document.Length - 1) { if (!textIterator.MoveAhead(1)) return null; } } else { int delta = m.Index - textIterator.Position; if (delta <= 0 || textIterator.MoveAhead(delta)) { if (TextSelection.IsInsideRange(m.Index + m.Length - 1, offset, length)) { return new RegexSearchResult(m); } else { return null; } } else { return null; } } } return null; }
public SearchResultMatch FindNext(ITextIterator textIterator) { string document = textIterator.TextBuffer.GetText(0, textIterator.TextBuffer.Length); while (textIterator.MoveAhead(1)) { Match m = regex.Match(document, textIterator.Position); if (m == null || !m.Success) { while (textIterator.Position < document.Length - 1) { if (!textIterator.MoveAhead(1)) { return(null); } } } else { int delta = m.Index - textIterator.Position; if (delta <= 0 || textIterator.MoveAhead(delta)) { return(new RegexSearchResult(m)); } else { return(null); } } } return(null); }
public SearchResult FindNext(ITextIterator textIterator, int offset, int length) { string document = textIterator.TextBuffer.GetText(0, textIterator.TextBuffer.Length); while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { Match m = regex.Match(document, textIterator.Position); if (m == null || m.Index <= 0 || m.Length <= 0) { } else { int delta = m.Index - textIterator.Position; if (delta <= 0 || textIterator.MoveAhead(delta)) { if (TextSelection.IsInsideRange(m.Index + m.Length - 1, offset, length)) { return(new RegexSearchResult(m)); } else { return(null); } } else { return(null); } } } return(null); }
int InternalFindNext(ITextIterator textIterator, int offset, int length) { while (textIterator.MoveAhead(1)) { if (textIterator.Position >= offset + length) { textIterator.Position = offset; } int position = textIterator.Position; if (Match(textIterator.Document, position, !SearchOptions.MatchCase, 0)) { if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.Document, position, curMatchEndOffset - position)) { if (TextSelection.IsInsideRange(curMatchEndOffset - 1, offset, length)) { textIterator.MoveAhead(curMatchEndOffset - position - 1); return(position); } else { return(-1); } } } } return(-1); }
int InternalFindNext(ITextIterator textIterator, int offset, int length) { while (textIterator.MoveAhead(1)) { if (textIterator.Position >= offset + length) { textIterator.Position = offset; } if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.Document, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.Document, textIterator.Position, searchPattern)) { if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) { if (TextSelection.IsInsideRange(textIterator.Position + searchPattern.Length - 1, offset, length)) { return(textIterator.Position); } else { return(-1); } } } } return(-1); }
int InternalFindNext(ITextIterator textIterator) { while (textIterator.MoveAhead(1)) { int position = textIterator.Position; if (Match(textIterator.TextBuffer, position, !SearchOptions.MatchCase, 0)) { if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, position, curMatchEndOffset - position)) { textIterator.MoveAhead(curMatchEndOffset - position - 1); return(position); } } } return(-1); }
public SearchResultMatch FindNext(ITextIterator textIterator, int offset, int length) { string document = textIterator.Document.GetText(0, textIterator.Document.TextLength); while (textIterator.MoveAhead(1)) { if (textIterator.Position >= offset + length) { textIterator.Position = offset; } Match m = regex.Match(document, textIterator.Position); if (m == null || !m.Success) { while (textIterator.Position < document.Length - 1) { if (!textIterator.MoveAhead(1)) { return(null); } } } else { int delta = m.Index - textIterator.Position; if (delta <= 0 || textIterator.MoveAhead(delta)) { if (TextSelection.IsInsideRange(m.Index + m.Length - 1, offset, length)) { return(new RegexSearchResult(m)); } else { return(null); } } else { return(null); } } } return(null); }
public SearchResult FindNext(ITextIterator textIterator) { string document = textIterator.TextBuffer.GetText(0, textIterator.TextBuffer.Length); while (textIterator.MoveAhead(1)) { Match m = regex.Match(document, textIterator.Position); if (m == null || m.Index <= 0 || m.Length <= 0) { } else { int delta = m.Index - textIterator.Position; if (delta <= 0 || textIterator.MoveAhead(delta)) { return new RegexSearchResult(m); } else { return null; } } } return null; }
int InternalFindNext(ITextIterator textIterator) { while (textIterator.MoveAhead(1)) { if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.Document, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.Document, textIterator.Position, searchPattern)) { if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) { return textIterator.Position; } } } return -1; }
int InternalFindNext(ITextIterator textIterator) { while (textIterator.MoveAhead(1)) { if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.TextBuffer, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.TextBuffer, textIterator.Position, searchPattern)) { if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.TextBuffer, textIterator.Position, searchPattern.Length)) { return(textIterator.Position); } } } return(-1); }
public ISearchResult FindNext(ITextIterator textIterator, SearchOptions options, bool reverseSearch) { if (reverseSearch) throw new NotSupportedException (); if (!textIterator.MoveAhead(1)) return null; if (regex == null) return null; int pos = textIterator.Position; string document = textIterator.ReadToEnd (); textIterator.Position = pos; Match m = regex.Match (document, 0); if (m == null || m.Index <= 0 || m.Length <= 0) { return null; } else { if (textIterator.MoveAhead (m.Index)) { return new DefaultSearchResult (textIterator, m.Length); } else { return null; } } }
public SearchResultMatch FindNext(ITextIterator textIterator) { string document = textIterator.Document.Text; while (textIterator.MoveAhead(1)) { Match m = regex.Match(document, textIterator.Position); if (m == null || !m.Success) { while (textIterator.Position < document.Length - 1) { if (!textIterator.MoveAhead(1)) return null; } } else { int delta = m.Index - textIterator.Position; if (delta <= 0 || textIterator.MoveAhead(delta)) { return new RegexSearchResult(m); } else { return null; } } } return null; }
int InternalFindNext(ITextIterator textIterator, int offset, int length) { while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.Document, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.Document, textIterator.Position, searchPattern)) { if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) { if (TextSelection.IsInsideRange(textIterator.Position + searchPattern.Length - 1, offset, length)) { return textIterator.Position; } else { return -1; } } } } return -1; }
int InternalFindNext(ITextIterator textIterator, SearchOptions options) { int j = 0; if (!textIterator.MoveAhead(1)) { return -1; } while (true) { // until pattern found or Iterator finished while (j >= 0 && searchPattern[j] != (options.IgnoreCase ? Char.ToUpper(textIterator.GetCharRelative(j)) : textIterator.GetCharRelative(j))) { if (!textIterator.MoveAhead(j - overlap[j])) { return -1; } j = overlap[j]; } if (++j >= searchPattern.Length) { if ((!options.SearchWholeWordOnly || SearchReplaceUtilities.IsWholeWordAt(textIterator, searchPattern.Length))) { return textIterator.Position; } if (!textIterator.MoveAhead(j - overlap[j])) { return -1; } j = overlap[j]; } } }
int Match(ITextIterator textIterator, bool ignoreCase, int programStart) { int matchCharCount = 0; bool moreChars = true; for (int pc = programStart; pc < patternProgram.Count; ++pc) { if (!moreChars) return -1; char ch = ignoreCase ? Char.ToUpper(textIterator.Current) : textIterator.Current; Command cmd = (Command)patternProgram[pc]; switch (cmd.CommandType) { case CommandType.Match: if (ch != cmd.SingleChar) { return -1; } break; case CommandType.AnyZeroOrMore: int p = textIterator.Position; int subMatch = Match (textIterator, ignoreCase, pc + 1); if (subMatch != -1) return matchCharCount + subMatch; textIterator.Position = p; if (!textIterator.MoveAhead (1)) return -1; subMatch = Match (textIterator, ignoreCase, pc); if (subMatch != -1) return matchCharCount + subMatch; else return -1; case CommandType.AnySingle: break; case CommandType.AnyDigit: if (!Char.IsDigit(ch)) { return -1; } break; case CommandType.AnyInList: if (cmd.CharList.IndexOf(ch) < 0) { return -1; } break; case CommandType.NoneInList: if (cmd.CharList.IndexOf(ch) >= 0) { return -1; } break; } matchCharCount++; moreChars = textIterator.MoveAhead (1); } return matchCharCount; }
int InternalFindNext(ITextIterator textIterator) { while (textIterator.MoveAhead(1)) { int position = textIterator.Position; if (Match(textIterator.TextBuffer, position, !SearchOptions.MatchCase, 0)) { if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, position, curMatchEndOffset - position)) { textIterator.MoveAhead(curMatchEndOffset - position - 1); return position; } } } return -1; }
public ISearchResult FindNext(ITextIterator textIterator, SearchOptions options, bool reverseSearch) { if (textIterator.SupportsSearch (options, reverseSearch)) { if (textIterator.SearchNext (searchPattern, options, reverseSearch)) { DefaultSearchResult sr = new DefaultSearchResult (textIterator, searchPattern.Length); if (!reverseSearch) textIterator.MoveAhead (searchPattern.Length); return sr; } else return null; } if (reverseSearch) throw new NotSupportedException (); int offset = InternalFindNext(textIterator, options); if (offset >= 0) { int pos = textIterator.Position; textIterator.Position = offset; DefaultSearchResult sr = new DefaultSearchResult (textIterator, searchPattern.Length); textIterator.Position = pos; return sr; } else return null; }
int InternalFindNext(ITextIterator textIterator, SearchOptions options) { int[] compareIndex = new int [searchPattern.Length]; int[] startPositions = new int [searchPattern.Length]; int maxPoss = 0; bool ignoreCase = options.IgnoreCase; bool searchWord = options.SearchWholeWordOnly; CultureInfo cinfo = CultureInfo.InvariantCulture; int patternLength = searchPattern.Length; bool wasWordStart = true; char first = searchPattern[0]; while (textIterator.MoveAhead(1)) { char c = textIterator.Current; if (ignoreCase) c = Char.ToUpper (c, cinfo); int freePos = -1; for (int n=0; n<maxPoss; n++) { int pos = compareIndex[n]; if (pos != 0) { if (searchPattern[pos] == c) { pos++; if (pos == patternLength) { if (searchWord) { int curp = textIterator.Position; bool endw = !textIterator.MoveAhead (1); endw = endw || SearchReplaceUtilities.IsWordSeparator (textIterator.Current); textIterator.Position = curp; if (endw) return startPositions[n]; } else return startPositions[n]; } else { compareIndex[n] = pos; continue; } } compareIndex[n] = 0; if (n == maxPoss-1) maxPoss = n; } if (freePos == -1) freePos = pos; } if (c == first && (!searchWord || wasWordStart)) { if (patternLength == 1) return textIterator.Position; if (freePos == -1) { freePos = maxPoss; maxPoss++; } compareIndex [freePos] = 1; startPositions [freePos] = textIterator.Position; } wasWordStart = SearchReplaceUtilities.IsWordSeparator (c); } return -1; }
int InternalFindNext(ITextIterator textIterator, int offset, int length) { while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { int position = textIterator.Position; if (Match(textIterator.TextBuffer, position, !SearchOptions.MatchCase, 0)) { if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, position, curMatchEndOffset - position)) { if (TextSelection.IsInsideRange(curMatchEndOffset - 1, offset, length)) { textIterator.MoveAhead(curMatchEndOffset - position - 1); return position; } else { return -1; } } } } return -1; }
int InternalFindNext(ITextIterator textIterator, SearchOptions options) { while (textIterator.MoveAhead(1)) { int pos = textIterator.Position; int charCount = Match (textIterator, options.IgnoreCase, 0); textIterator.Position = pos; if (charCount != -1) { if (!options.SearchWholeWordOnly || SearchReplaceUtilities.IsWholeWordAt (textIterator, charCount)) return charCount; } } return -1; }