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 08:00
Willem D is currently offline Willem D
Messages: 3
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: Sat Jul 26 01:08:36 EDT 2014

Powered by FUDForum. Page generated in 0.01950 seconds