Page 1 of 1

AtSynEdit - Column, Row, and Position

Posted: 29.05.2022 05:35
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..

Posted: 30.05.2022 17:37
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);

Posted: 31.05.2022 01:49
by TomC
Worked Perfectly !!!

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