Copyright and License information Home

__ A B C D E F G H I L M P R S T U V W

### wxStyledTextCtrl - Searching

- FindText
- SearchAnchor
- SearchNext
- SearchPrev

Summary:

The methods in this section allow you to search the text of the active Document. FindText is a straightforward search, while SearchNext and SearchPrev provide relocatable search support, as discussed below.

You should also examine the STC's target-based searching features.

FindText, SearchNext, and SearchPrev use flags to control the search:

- wxSTC_FIND_WHOLEWORD: a match occurs only if the characters before and after the match are not word characters
- wxSTC_FIND_MATCHCASE: a match occurs only if the case of the search string and the candidate string match.
- wxSTC_FIND_WORDSTART: a match occurs if the character before is not a word character.
- wxSTC_FIND_REGEXP: a simple regular-expression search: see Regular Expression Searches for more info.

From the Scintilla documentation.

SearchNext and SearchPrev provide relocatable search support. This allows multiple incremental interactive searches to be macro recorded while still setting the selection to found text so the find/select operation is self-contained. These three messages send a EVT_STC_MACRORECORD event if macro recording is enabled.

SearchAnchor sets the search start point used by SearchNext and SearchPrev to the start of the current selection, that is, the end of the selection that is nearer to the start of the document. You should always call SearchAnchor before calling either of SearchNext or SearchPrev.

SearchNext and SearchPrev search for the next and previous occurance of the zero terminated search string pointed at by text. The search is modified by the searchFlags. If you request a regular expression, SearchPrev finds the first occurance of the seach string in the document, not the previous one before the anchor point.

The return value is -1 if nothing is found, otherwise the return value is the start position of the matching text. The selection is updated to show the matched text, but is not scrolled into view.

FindText(minPos,maxPos,text,flags)

FindText performs a straightforward text search through the entire document. The minPos and maxPos integer arguments specify the range within the Document to search. No surprise, the text argument is a string object containing the string to search for. The flags argument controls the search, and is an OR or the flags shown at the beginning of this page.

You can set maxPos less than minPos to search in reverse, except that if wxSTC_FIND_REGEXP is one of the flags then the search is always forwards.

Returns the start position of the found text, or -1 if it isn't found. Unlike the 'raw' Scintilla version of this method, wxPython does not return the start and end positions of the found text.

top

SearchAnchor()

Set the selection to be used for SeachNext and SearchPrev. See the discussion about this at the top of the page. Returns None.

top

SearchNext(flags,text)

Search for the next occurrence of the text specified by the string object text starting at the point set by SearchAnchor. Search modes are set by the integer parameter flags. Returns start position of found text, or -1 if nothing found. See above discusssion.

top

SearchPrev(flags,text)

Search for the previous occurrence of the text specified by the string object text starting at the point set by SearchAnchor. Search modes are set by the integer parameter flags. Returns start position of found text, or -1 if nothing found. See above discusssion.

top