Easy/Text/Search.cs
/// <summary>
/// Searches for the next occurence of a string in the text after the current position
/// </summary>
/// <param name="searchString">String to find</param>
Searches for the next occurence of a string in the text after the current position
Searches for the next occurence of a string in the text after the current position
public void FindNext(string searchString)
        {
            _document.GetText(TextGetOptions.None, out this._text);
            string searchIn = _currentIndex < 0 ? _text : _text.Substring(_currentIndex + 1);
            int pos = searchIn.IndexOf(searchString, StringComparison.CurrentCultureIgnoreCase);
            if (pos > -1)
            {
                _document.Selection.SetRange(_currentIndex + pos + 1, _currentIndex + pos + searchString.Length + 1);
                _currentIndex = _currentIndex + pos + 1;
            }
            else if (_currentIndex > -1)
            {
                _currentIndex = -1;
                FindNext(searchString);
            }
        }
public void FindNext ( string searchString ) { _document . GetText ( TextGetOptions . None , out this . _text ) ; string searchIn = _currentIndex < 0 ? _text : _text . Substring ( _currentIndex + 1 ) ; int pos = searchIn . IndexOf ( searchString , StringComparison . CurrentCultureIgnoreCase ) ; if ( pos > - 1 ) { _document . Selection . SetRange ( _currentIndex + pos + 1 , _currentIndex + pos + searchString . Length + 1 ) ; _currentIndex = _currentIndex + pos + 1 ; } else if ( _currentIndex > - 1 ) { _currentIndex = - 1 ; FindNext ( searchString ) ; } }
Searches for the next occurence of a string in the text after the current position
Searches for the next occurence of a string in the text after the current position
// Text can always change while we search, so update it // Search just in the string after the current find // If we found something // Select it and update index of find // If we didn't find anything, start from the top and try again
searchString
string
String to find
String to find