[Lazarus] LineRange [Re: Auto indentation]

Martin lazarus at mfriebe.de
Tue Nov 3 18:10:13 CET 2009


Mattias,

have you looked at using
  StartLine := Min(Old:ogCaret.Y, LogCaret.Y);
  EndLine := Max(Old:ogCaret.Y, LogCaret.Y);


That would also have the advantage that an "end" would be unindented 
correctly. e.g typing

if a > 1 then begin
  b:= 1; // the indenter has added 2 spaces => correct
  end;|

now hit return at "|".
The line with the end in it does not change, so it is not in the range. 
But it is in the caret range. And it should be unindented


Martin



Mattias Gärtner wrote:
> Zitat von Paul Ishenin <webpirat at mail.ru>:
>
>> Mattias Gärtner wrote:
>>>> the code in the buffer is:
>>>> [code]
>>>> for i := 0 to 10 do
>>>> if i = j then begin
>>>> j := i;
>>>> end;
>>>> [/code]
>>>
>>> Just a note:
>>> The indenter indents the pasted block as whole, not every line.
>>> This has pros and cons. Maybe eventually an option can be added to 
>>> indent instead every line. Indenting every line means bad and good 
>>> indenting will be undone. IMO this is the inferior technique.
>>> With the current synedit line ranges only the line-indenting can be 
>>> implemented.
>> Ok, but in any way the final 'end' in the above example should be 
>> indented and also indentation should not be switched off because of 
>> the cursor position.
>
> Synedit adds or subtracts a 1 to the FirstLinePos, LastLinePos 
> depending on various things. For example pasting one whole line or two 
> whole lines gives the same range. And when you replace a line then 
> FirstLinePos includes the line above that was not changed. So the line 
> range is unusable for what I need.





More information about the Lazarus mailing list