StyledText 'visual offset' [message #900528] |
Tue, 07 August 2012 12:00 |
Willem Duminy 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?
|
|
|
Powered by
FUDForum. Page generated in 0.03094 seconds