How to convert Line/Column to TextPosition (Line/Char)?

SyntaxEditor for WPF Forum

Posted 8 years ago by Xinen Lee
Version: 15.1.0624
Avatar

Hi,

I'm trying to set the caret to a Line + Column pair. However ICaret only allows setting of TextPosition (Line+Character). 

I can't find a way to convert Column to Character (I can only find conversions from Character to Column through GetCharacterColumn).

ICaret's CharacterColumn is not settable.

 

How do I set the caret to a specified Line and Column? If not possible, how do I convert a Column to Character?

 

Thanks

Comments (3)

Posted 8 years ago by Xinen Lee
Avatar

And if not possible to convert Column to Character, would you be able to provide this functionality?

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Can you give more information on why you need this functionality?  Column is generally display only for end user info, whereas line/character are based on the actual document character data that you will be modifying.

The column is calculated based on the X-coordinate location of the character divided by Math.Max(1, editor.CharacterWidth), where editor.CharacterWidth gives the average width of a character in the current font.

Thus if you knew the column you could multiply it by the editor.CharacterWidth and then build a Point to pass to the view's LocationToPosition method.


Actipro Software Support

Posted 8 years ago by Xinen Lee
Avatar

Ok, thanks for your help!

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.