EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting the character position from line/col

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
mstaszew



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Fri Jul 21, 2006 3:32 pm    Post subject: Getting the character position from line/col Reply with quote

Is there a method that will allow me to pass in a line/col combination and return the character position/offset from the beggining of the edit buffer?

Thanks.
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Fri Jul 21, 2006 8:40 pm    Post subject: Reply with quote

To convert line/col to position in text buffer use TSyntaxMemo.CaretPosToStrPos(col, line).
Another coordinate functions

function MouseToCaret(X, Y: integer): TPoint;
Returns caret position (column, line) at the window coordinates.

function CaretToMouse(cX, cY: integer): TPoint;
Returns top-left corner of the caharacter position in window coordinates.

function CaretPosToStrPos(const p: TPoint): integer;
Returns zero-based character position in text buffer at the specified caret position. If caret is out of text result points on the line break.

function StrPosToCaretPos(p: integer): TPoint;
Returns caret position (column, line) of the character at specified index in text buffer.

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group