Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] SWT Bidi Text Support


Adrian I am posting your question and my reply to the SWT mailing list so that others can be involved.  You can find out about the mailing lists and how to subscribe at http://www.eclipsecorner.org/.

>> Lynne,
>>
>> Is there any decision on making the bidi API public and/or when will
>> Eclipse move to Java 1.4?
>>
>> Thank you.  Best regards -
>> Adrian.
>>
>> Adrian Storisteanu
>> IBM Toronto Lab, Canada
>> Tie line 8-969-3156 * Phone 905-413-3156 * Fax 905-413-4850


Currently SWT includes an internal class, org.eclipse.swt.internal.BidiUtil, which wraps the Win32 bidi platform calls (specifically - GetCharacterPlacement, GetFontLanguageInfo, ExtTextOut, GetKeyboardLayout, GetKeyboardLayoutList).  This class is used by the org.eclipse.swt.custom.StyledText widget to provide bidi support.  The class is internal because it is only a Windows solution.  This class does nothing on the other platforms that SWT supports.

That said, you may use BidiUtil.  It should be sufficient for LPEX since it is sufficient for bidi text support in Eclipse (i.e., via the StyledText widget), BUT it will most likely change in the future as we move towards bidi support for other platforms.  Until we investigate a multi-platform solution, we are not in the position to make any of the bidi API truly public (i.e., supported and maintained).

Looking at the list of the support you said you needed:

>> - detection of RTL environment (active native RTL locale),
>> - cursor (caret) navigation (i.e., detect RTL - LTR boundaries & direction
>> changes),
>> - cursor <-> text index corelation (index n in String text <-> position m
>> on display),
>>  - text String <-> displayed text corelation (important in Arabic, where n
>> text characters may display as a smaller m glyphs as a result of
>> autoshaping).

BidiUtil will supply you with what you need except for detection of RTL environment.  You can look at the current code page using System.getProperty("file encoding") to determine this.  org.eclipse.swt.custom.StyledTextBidi will give you an example of how to utilize the information that BidiUtil gives you.

You probably also want to look at the classes org.eclipse.swt.custom.BidiSegmentListener and org.eclipse.swt.custom.BidiSegmentEvent (in R2.0 stream).  In some instances (e.g., source code editors), you may want the bidi algorithm to be applied separately to portions of the line vs. the whole line.  

If you decide to use BidiUtil, we can certainly answer questions for you, discuss the issues we ran into, etc..  It would also be useful to get your feedback as to what you (or anyone for that matter) think API for bidi support should look like.

Lynne

Back to the top