rvico TRichView Reference | TRichView

TCustomRichView.SearchText, SearchTextA, SearchTextW

Top  Previous  Next

The methods search for the substring s in the document.

function SearchText(s: String; SrchOptions: TRVSearchOptions): Boolean;

function SearchTextA(s: TRVAnsiString; SrchOptions: TRVSearchOptions): Boolean;

function SearchTextW(s: TRVUnicodeString; SrchOptions: TRVSearchOptions): Boolean;

When found, these methods select substring and scroll to it.

 

if rvsroDown is not included in SrchOptions, the methods search upwards. if rvsroDown is included, the methods search downwards.

If rvsroFromStart is included in SrchOptions, the search is started from the beginning/end of the document. Otherwise, the methods start searching from the current selection, if it exists. If nothing is selected, the methods start from the first visible item (when searching down) or the last visible item (when searching up).

rvsroSmartStart is used only if rvsroFromStart is not included. If rvsroSmartStart is included, and some document fragment is selected, then:

when searching down, the search starts from the second selected character;

when searching up, the search starts from the last but one selected character;

(selected characters are counted from the top of document, the selection direction is ignored). This option allows to avoid selecting the same fragment again when changing a search direction.

If rvsroMultiItem is included, the search can match substrings of several text items. If not included, the text is searched in each text item separately. For example, if the document contains the text Hello, the substring 'Hello' can be found only if this option is included, because 'He' and 'llo' belong to different items.

 

unicode Unicode note:  The methods allow searching both in ANSI and in Unicode text items. When SearchTextA compares Unicode text with s, the conversion is based on RVStyle.DefCodePage. When SearchTextW compares ANSI text with s, the conversion is based on the character set of the text style. SearchText works like SearchTextW in Delphi/C++Builder 2009 or newer, and like SearchTextA in the older versions.

 

History and compatibility

Since version 1.2 SearchText can search upwards.

Since version 1.5 SearchText can search whole words (substring must be delimited with characters from Delimiters)

SearchTextW is introduced in version 10. rvsroFromStart is introduced in version 10 as well.

rvsroMultiItem is introduced in version 12.

Note: There is incompatibility with programs written with the older version of RichView (1.0 1.1.4). Now if rvsroDown is not included in SrchOptions, the methods search upwards. In the older versions there was no rvsroDown option, and SearchText searched downwards only.

 

These methods must be called only when the document is formatted.

 

Return value: Is substring found?

 

See also methods of TRichViewEdit:

SearchText, -A, -W

See also global functions:

GetRVSearchOptions.

See also:

Searching in RichView and RichViewEdit.


TRichView © trichview.com