Search and Replace Demo
Folder: Demos\SearchReplaceDemo. Project: SearchReplaceDemo.dpr.
Shows how to implement the search and replace functions with TSynEdit: the search dialog, the replace dialog, the search of the next and previous occurrence, and the confirmation of each replace.
| Unit | Content |
|---|---|
frmMain | The main form with the actions Search, Search next, Search previous and Replace. |
dlgSearchText, dlgReplaceText | The dialogs, with the options of the search (case, whole word, backwards, selected text only, entire scope, regular expression). |
dlgConfirmReplace | The confirmation shown for each replace. |
uSearchHighlighter | Classes and routines to highlight the search term in the text (by Kiriakos Vlahos). |
Points of interest
DoSearchReplaceTextbuilds theTSynSearchOptionsfrom the state of the dialog and callsSearchReplaceof the editor.- The event
OnReplaceTextof the editor shows the confirmation dialog and answers with theTSynReplaceActionchosen by the user. - The event
OnProcessCommandrestarts the search when the user does something else in the editor, and removes the highlight of the matches when the selection is cancelled (ecCancelSelections). - The library contains the same dialogs, in the units
SynEdit.dlgSearchText,SynEdit.dlgReplaceTextandSynEdit.dlgConfirmReplace.
