AtSynEdit - Column, Row, and Position

Post Reply
TomC
Posts: 13
Joined: 29.05.2022 05:11

AtSynEdit - Column, Row, and Position

Post by TomC »

Wanted to thank "Alexey Torgashin" for his amazing ongoing dedication to AtSynEdit, ATFlatControls, ATImageBox, CudaText Etc...

I'm converting over from SynEdit to AtSynEdit ( wow, nice word wrap etc! )

Question:
- My StatusBar has "Col", "Row", but I would love to have a "Position" panel, showing the caret or caret[0] character position/count from begining of file.

Thank You Sincerely..
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

You need to use this func in ATSynEdit

Code: Select all

function TATSynEdit.CaretPosToOffset(const ACaret: TPoint): integer;
var
  Buffer: TATStringBuffer;
  Lens: TATIntArray;
begin
  Buffer:= TATStringBuffer.Create;
  try
    InitLengthArray(Lens);
    Buffer.Setup('?', Lens);
    Result:= Buffer.CaretToStr(ACaret);
  finally
    FreeAndNil(Buffer);
  end;
end;  
Read caret pos like

Code: Select all

var
  caret: TATCaretItem;
begin
  caret:= Ed.Carets[0];
  pnt:= Point(caret.PosX, caret.PosY);
TomC
Posts: 13
Joined: 29.05.2022 05:11

Post by TomC »

Worked Perfectly !!!

Thank You Alexey
( And, again, thank you for your amazing "ongoing" dedication to AtSynEdit, ATFlatControls, ATImageBox, CudaText Etc.. )
Post Reply