Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] column number with caret in Styled Text

Try this code:
int caretOffset = text.getCaretOffset();
int line = text.getLineAtOffset(caretOffset);
int column =  caretOffset; - text.getContent().getOffsetAtLine(line);

Please, use the newsgroup for user questions, I'm pretty sure you will get 
a better answer there.
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=92757

Regards,
Felipe




Benoit Sauvé <benoit.sauve2@xxxxxxxxx> 
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx
28/04/2005 10:15 PM
Please respond to
Benoit Sauvé and "Eclipse Platform SWT component developers list."


To
platform-swt-dev@xxxxxxxxxxx
cc

Subject
[platform-swt-dev] column number with caret in Styled Text






Hi !

Still me, again !

I'm now working on a little thing that looks like Notepad in Windows.
I use a Styled Text widget. I want to show the line and column number
when moving the cursor in the text. I can get the line number with the
caret objet by getting the y location and dividing it by the
lineHeight. This solution works with any kind of police and height.

But i'm not able to get the column number correctly. It depends on the
police. Maybe i just don't find a getter that give me this information
!!!

Plase help me !

Thank you very much

Benoit Sauvé,
Computer Engineering Student
Sherbrooke University, Québec, Canada
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev




Back to the top