Searching and Replacing in TRichView and TRichViewEdit

<< Click to display table of contents >>

Searching and Replacing in TRichView and TRichViewEdit

The following main functions for text searching are available:

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

function TRichViewEdit.SearchTextW(s: TRVUnicodeString; SrchOptions: TRVESearchOptions): Boolean;

These methods search for the substring s. If found, they select it an make it visible (scroll the window to it).

The methods of TRichView start searching from the current selection (if exists) or from the first (or the last, when searching up) visible item. If rvsroFromStart is included in SrchOptions, the methods start searching from the beginning (or the end, when searching up) of the document.

The methods of TRichViewEdit start searching from the caret position.

All the methods support the following options:

searching up or down;

case sensitive/insensitive searching;

searching for the whole words;

allowing matching in a single text item or in multiple items.

s may contain a tab character (#9). However, it makes sense only if the option for matching in multiple items is set.


The unit RVMisc.pas contains the functions to convert options of search dialogs:

function GetRVSearchOptions(fo: TFindOptions): TRVSearchOptions;

function GetRVESearchOptions(fo: TFindOptions):TRVESearchOptions;

It's easy to implement replacing of text in editor. SearchText selects the old substring, InsertText replaces the selected string with the new one.