Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » StyledText 'visual offset'(How can I get the visual offset of a character ina StyledText widget?)
StyledText 'visual offset' [message #900528] Tue, 07 August 2012 12:00
Willem Duminy is currently offline Willem DuminyFriend
Messages: 4
Registered: July 2009
Junior Member
To get the row and column of the text at the caret in a StyledText widget, I use this code:
				
int line = textWidget.getLineAtOffset(event.caretOffset);
int col = event.caretOffset - textWidget.getOffsetAtLine(line);


After this, 'col' contains the logical offset of the character in the line. Essetialy I need to determine the visual offset.

When you have western text, it is easy: 'col' happens to be the visual offset. i.e. the first character is index 0 and is on the left.

Also when the line is non-western right-to-left text things are workable: index 0 is the first character counting from the right..

My problem occurs when a line contains mixed characters -- e.g. a sentence in arabic, with an english phrase in the middle. Here, part of the line is left-to-right and parts is right-to-left.

Given a logical offset, how can I determine the 'visual offset' of a character in this mixed-mode line?

Previous Topic:Speed issue in SWT OLE Automation
Next Topic:Muliselect on swt table items?
Goto Forum:
  


Current Time: Thu Apr 25 01:31:11 GMT 2024

Powered by FUDForum. Page generated in 0.02863 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top