[Lazarus] Extending the IDE

Martin lazarus at mfriebe.de
Mon Jan 30 13:02:37 CET 2012


On 30/01/2012 05:08, Reinier Napoles Martinez wrote:
> Martin how can use the property TextBetweenPoints to exchange lines.
> I tried but not work me.
>
> I have this code:
> tempStr := ASynEdit.LineText;
> ASynEdit.TextBetweenPoints[Point(1, ASynEdit.CaretY), Point(1, ASynEdit.CaretY)]:= ASynEdit.Lines.Strings[ASynEdit.CaretY - 2] +LineEnding;
> ASynEdit.TextBetweenPoints[Point(1, ASynEdit.CaretY-1), Point(1, ASynEdit.CaretY-1)]:=tempStr+LineEnding;


ASynEdit.TextBetweenPoints[Point(1, ASynEdit.CaretY), Point(1, ASynEdit.CaretY)]


Inserts the new text at the begin of the line (x=1). but start and stop 
of the old text are equal, so nothing is replaced.

ASynEdit.TextBetweenPoints

   is lixe
- set selection (or no selection
- delete selection
- insert new
- restore old selection

selecting a full line:

ASynEdit.TextBetweenPoints[Point(1, ASynEdit.CaretY), Point(1, ASynEdit.CaretY + 1)]



additionally ASynEdit.TextBetweenPointsEx  can adjust the caret pos


y := ASynEdit.CaretY;
tempStr := ASynEdit.LineText;
ASynEdit.TextBetweenPoints[Point(1, ASynEdit.CaretY), Point(1, ASynEdit.CaretY + 1)]:= ASynEdit.Lines.Strings[ASynEdit.CaretY - 2] +LineEnding;
ASynEdit.TextBetweenPoints[Point(1, ASynEdit.CaretY-1), Point(1, ASynEdit.CaretY)]:=tempStr+LineEnding;




>
> previously used this code:
>
>   procedure MoveLineUp(Sender: TObject);
>   begin
>    if CustSynEdit.CaretY -1>= 1 then
>     begin
>      CustSynEdit.Lines.Exchange(CustSynEdit.CaretY -1 ,CustSynEdit.CaretY-2);
>      CustSynEdit.CaretY:=CustSynEdit.CaretY-1;
>     end;
>   end;
>
>
>   procedure MoveLineDown(Sender: TObject);
>   begin
>    if ( CustSynEdit.CaretY + 1<= CustSynEdit.Lines.Count) then
>     begin
>      CustSynEdit.Lines.Exchange(CustSynEdit.CaretY-1,CustSynEdit.CaretY);
>      CustSynEdit.CaretY:=CustSynEdit.CaretY+1;
>     end;
>   end;
>
> which has the same problem as you pointed out to me.
>
> thanks.
>
>





More information about the Lazarus mailing list