[Lazarus] syncro mode[Re: Auto indentation]

Martin lazarus at mfriebe.de
Thu Nov 5 00:26:03 CET 2009


Martin wrote:
> Mattias Gaertner wrote:
>> I guess this is the better solution for ecPaste.
>> Can you add such an event?
>>   
> Yes, the question is, if it is ok for codetools, since it would be 
> called before the paste => that is you have to interpret the 
> to-be-pasted text before it is part of the source
>
> At the moment you can indent based on the complete source *after*  the 
> paste
>
> The alternative is a combination:
> - in the OnPaste event you store the text to be pasted (as well as the 
> mode normal, column ....)
> - in the OnIndent, you take the final caret pos and you know how far 
> to go back (since the pasted text always ends at the final caret pos)
>
>
> I'll update you, when I got it done.
Added. There are now
SynEdit.OnPaste: TSynCopyPasteEvent
SynEdit.OnCutCopy: TSynCopyPasteEvent   // you do not need

I still have to do the tests. It doesnt breek anything existing, but I 
havent checked if the events do 100% as advertised

The event is called immediately before the actual paste happens.

  TSynCopyPasteEvent = procedure(
Sender: TObject;     // the synedit
var AText: String;     // the text, which you can modify, before it will 
be pasted
var AMode: TSynSelectionMode;   // smNormal, smColumn....
ALogStartPos: TPoint;   // The position at which it will be inserted ***
var AnAction: TSynCopyPasteAction   // see below
) of object;


TSynCopyPasteAction = (
scaContinue,   // do the insert as normal
scaPlainText,  // do the insert, but (except for 
smColumn,smNormal,smLine) ignore all synedit specifics (such as fold 
info that came with the paste)
scaAbort    // do not insert anything
);

*** ALogStartPos: TPoint;   // The position at which it will be inserted ***
Is the position where the new text will start.

However the event does not include any information, if a block selection 
exists.
A BlockSelection MAY be deleted before the paste
- if it is not persistent
- if eoOverwriteSelection is set






More information about the Lazarus mailing list