[Lazarus] syncro mode[Re: Auto indentation]

Martin lazarus at mfriebe.de
Wed Nov 4 21:51:57 CET 2009


Mattias Gaertner wrote:
> On Wed, 04 Nov 2009 00:27:20 +0000
> Martin <lazarus at mfriebe.de> wrote:
>
>   
>> Further thought about auto indent (for paste) and syncro/template
>> mode.
>>     
>
> I disabled auto indent during syncro/template editing.
>   
you need the same for TSynPluginTemplateEdit (template edit, which 
includes it's own syncro mode)

    TSynPluginTemplateEdit.Create(FEditor);
    FSyncroEdit := TSynPluginSyncroEdit.Create(FEditor);


>  
>   
>> - the line-range will be too big.
>> - the inital caret position will be unusable. because the if any cell 
>> was above the caret pos, then the text will have moved downwards,
>> while the initial caretpos would still be on top
>>
>>
>> syncro and template edit are created in Sourceeditor around line
>> 2565. They are owned and destroyed by synedit (however synedit only
>> knows they are plugins, and has no idea what they do)
>>
>> SourceEditor could keep a reference to the syncro and template module.
>>
>> Both of them have an Active property. If it is true, you should not 
>> indent-on-paste
>>
>> -------
>> The alternative is to have an "OnBeforePaste" event, and modify the
>> text to be pasted, *before* synedit inserts it
>> (or keep the to-be-pasted text, and act backwards on the final caret
>> pos)
>>     
>
> 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.

Martin




More information about the Lazarus mailing list