Complex Text Layout Language Support in the Solaris Operating Environment

Chapter 3 Adding CTL Support to an Application

Adding CTL support to an application requires little or no change to the source code. Certain resources are set in the resource file to control the behavior of the language engine for all Text, TextField, and other static text.

If an application was compiled in an earlier version of Solaris, the code should be recompiled in Solaris 8. Ensure that the application is linked to the default Motif library in Solaris 8 (libXm.so) which is linked to the latest Motif library (libXm.so.4). Add the flag -DSUN_CTL to Makefiles for compilation.

For finer control over CTL attributes, such as cursor positioning and character and cell deletion, use the APIs provided in PLS with its configuration file. For more information about the Portable Layout Services APIs, see CAE Specification: Portable Layout Services: ISBN 1-85912-142-X

3.1 CTL Motif Resources

To control CTL functionality in an application, use the following Motif resources:

  1. layoutModifier

  2. Visual mode

  3. Default keystroke override

  4. layoutDirection

  5. Dynamically switch screen layout

Step 1. Control the behavior of the language engine through the layoutModifier resource in the application resource file. For example, the default numeral type, text type, and text orientation can be changed using the following resource:*layoutModifier: @ls numerals=nominal:contextual,typeoftext=implicit:visual, orientation=ltr:rtl

Table 3-1 Common Modifiers

Modifier 

Values 

Description 

orientation=in:out 

ltr 

left-to-right global orientation (default in and out)  

 

rtl 

right-to-left global orientation 

 

contextual 

context-sensitive orientation 

numerals=in:out 

nominal  

Arabic numerals (Latin) (default in)  

 

national  

national shaping of numerals 

 

contextual 

numeral shaping based on the context of the surrounding text (default out) 

swapping=value 

yes 

enable symmetric swapping (default)  

 

no 

disable symmetric swapping  

typeoftext=in:out 

visual 

visual order (default out)  

 

implicit 

logical order (default in)  

 

explicit 

logical order with embedded control 

For a complete list of layout modifiers, see Portable Layout Services: Context-Dependent and Directional Text: ISBN 1-85912-075-X.

Step 2. Configure Hebrew and Arabic locales to support Visual mode for editing in the resource file as follows: *editPolicy: XmEDIT_VISUAL (default is XmEDIT_LOGICAL)

Step 3. To override the default keystrokes in an application, make the necessary changes in the resource file, as shown in the following example:

*XmText.translations: #override \n\
c <Key>q:right-word() \n\
c <Key>w:left-word() \n\
c <Key>g:forward-word(extend) \n\
c <Key>h:backward-word(extend) \n\
c <Key>f:next-line(extend) \n\
c <Key>b:previous-line(extend) \n\
c <Key>>:right-character() \n\
c <Key><:left-character() \n\
c <Key>t:prev-cell() \n\
c <Key>v:forward-cell() \n\
c <Key>+:delete-right-word() \n\
c <Key>-:delete-left-word() \n\
c <Key>r:right-character(extend) \n\
c <Key>l:left-character(extend) 

Step 4. The Motif resource layoutDirection can be used to set the right to left screen layout. In this screen mode, the screen origin is the top right corner and all application Motif widgets are mirrored. The following example shows how to set this in the resource file:*layoutDirection: XmBOTTOM_TO_TOP_RIGHT_TO_LEFT

This resource changes the layout of the whole application. To change the layout of some widgets only, such as Text or TextField, use the following:

*XmText*layoutDirection: XmBOTTOM_TO_TOP_RIGHT_TO_LEFT
*XmTextField*layoutDirection: XmBOTTOM_TO_TOP_RIGHT_TO_LEFT

Step 5. The screen layout can be dynamically switched for the Text and TextField widgets by defining the dynamic switching hot keys in the Motif translation table. The following example shows how to add this function to the resource file:

1-Text:

 *XmText.translations: #override \n\
Ctrl<Key>m:toggle-rtl-mode()
2-TextField:
*XmTextField.translations: #override \n\
Ctrl<Key>m:toggle-rtl-mode()  


Note -

CTRL+m is defined as the key combination to dynamically switch the screen layout. Any key combination which doesn't interfere with the application hot keys can be defined instead. This entry can also be appended to the original key translation table as discussed in Step 3 above.


3.2 CTL Printing

Each locale provides text input and display in the locale language and in English. Solaris 8 also includes the print utilities ctlmp and ctlconvert_text which can be used to print the CTL text.