[Lazarus] Synedit and search/replace

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Sat Feb 25 19:40:33 CET 2012


Martin wrote:
> On 25/02/2012 16:48, Mark Morgan Lloyd wrote:
>> Is my understanding correct that in order to get Synedit's replace 
>> facility working, one has to write a custom OnReplaceText handler?
>>
>> What does this in the source do:
>>
>> CurReplace:=AReplace;
>> if ssoRegExpr in AOptions then
>>   CurReplace:=fTSearch.RegExprReplace;
>>
>> Is there (partial) support for regex-based S&R, and if so how does one 
>> use it?
>>
> 
> What is wrong with:
> replace one (first after x/y = 1/1)
>   SynEdit1.SearchReplaceEx('a(.)', 'b$1', [ssoReplace, ssoRegExpr], 
> Point(1,1));
> 
> or replace all (after x/y = 1/1)
>   SynEdit1.SearchReplaceEx('a(.)', 'b$1', [ssoReplaceAll, ssoRegExpr], 
> Point(1,1));
> 
> SynEdit has no build-in confirm dialog, if that is what you mean

No, I just mean I don't understand how to use it and can't find any 
usage notes. What's supposed to happen- does Synedit call the 
OnReplaceText handler and expect this to actually do the search/replace? 
Or is the handler there to allow a confirmation dialogue to be 
displayed, after which code like you've shown above should be called 
explicitly?

(I think I understand the regex usage in your example, thanks for that).

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list