|
Searching and Replacing in RichView and RichViewEdit |
Top Previous Next |
|
function TRichView.SearchText(s: String; SrchOptions: TRVSearchOptions): Boolean; function TRichView.SearchTextW(s: WideString; SrchOptions: TRVSearchOptions): Boolean;
type TRVSearchOption = (rvsroMatchCase, rvsroDown, rvsroWholeWord, rvsroFromStart); TRVSearchOptions = set of TRVSearchOption;
function TRichViewEdit.SearchText(s: String; SrchOptions: TRVESearchOptions): Boolean; function TRichViewEdit.SearchTextW(s: WideString; SrchOptions: TRVESearchOptions): Boolean; type TRVESearchOption = (rvseoMatchCase, rvseoDown, rvseoWholeWord); TRVESearchOptions = set of TRVESearchOption;
All these methods search substring s. If found, they select it an make it visible (scroll the window to it). The methods of RichView 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 RichViewEdit start searching from the caret position. There is a special unit RVMisc.pas containing 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/SearchTextW selects the old substring, InsertText/InsertTextW replaces the selected string with the new one. |