Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-01

Extending the IDE

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Napoles Martinez

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;

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.

********************************************************************* En la tierra hace falta personas que trabajen m?s y critiquen menos, que construyan m?s y destruyan menos, que prometan menos y resuelvan m?s que esperen recibir menos y dar m?s que digan mejor ahora que ma?ana. Che *********************************************************************

Reply by email

Martin
to Reinier Napoles Martinez
Reinier Napoles Martinez wrote 7 lines
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;
Show quoted text 27 lines
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.

Reply by email