|
From: stacy_maughan <sta...@my...> - 2002-11-22 02:13:02
|
Hi all, I've been working with the search engine logic, and unfortunately the current implementation can't take advantage of regular expression replacement patterns, which is arguably the most powerful part of regular expressions. The solution is pretty straight forward--let the search engine handle the replacement. Here is what I did, trying to minimize the impact to existing code. Implement a Replace method in the TSynEditSearchCustom object (SynEditMiscClasses.pas): procedure Replace(Replacement: string; ASynEdit :TObject); virtual; abstract; //slm 2002-11-16 Change SynEdit (SynEdit.pas) to call the Replace method, instead of doing the replacement directly, in function TCustomSynEdit.SearchReplace: //SetSelTextExternal(AReplace); //slm 2002-11-16 fSearchEngine.Replace(AReplace,Self); //slm 2002-11-16 Then each search engine implements it own Replace. In SynEditSearch: procedure Replace(Replacement: string; ASynEdit :TObject); override; //slm 2002-11-16 ... procedure TSynEditSearch.Replace(Replacement: string; ASynEdit :TObject); //slm 2002-11-16 begin begin TSynEdit(ASynEdit).SelText:=Replacement; end; //slm 2002-11-16 end In SynEditRegexSearch: procedure Replace(Replacement: string; ASynEdit :TObject); override; //slm 2002-11-16 ... procedure TSynEditRegexSearch.Replace(Replacement: string; ASynEdit :TObject); //slm 2002-11-16 begin begin TSynEdit(ASynEdit).SelText:=fRegex.Replace(TSynEdit(ASynEdit).SelText,Replac ement,True); end; //slm 2002-11-16 That's it! I am fairly new to SynEdit, and use it from BCB--pascal isn't my native language-- so some style/language changes may be in order, but you get the idea. Can someone apply the patch? What is involved in getting developer access? I'd be happy to apply the patch myself, if you'd like to let me join. |