This chapter describes the input method architecture of X Window applications in Asian locales. The architecture is based on the X Window System Input Method Specification, which is included in X11R6 documentation, and on the X Window System Input Method Protocol (XIMP).
The X Window System Input Method (XIM) is a mechanism to input internationalized text, that is, text using other than ASCII characters. Before the X Window System was internationalized, the mapping between keystrokes and input characters was a simple one-to-one mapping. However, the increased demand for internationalized programs forced the abandonment of simple keymapping. For example, mappings between key strokes and Chinese, Korean, or Japanese characters are very different.
Without internationalization, the relevant parts of the X Window system could be depicted as follows:
With internationalization, there is the added facility of an intelligent input method server, which can be either a library or server. Sun's X input method for Asian Solaris facilities is in the form of a server. This can be represented as follows:
X Window System internationalization involves more than just XIM. It also involves locale support and internationalized text drawing support, such as XmbDrawString() and XwcDrawString(). The X11R6 documentation provides more information on X Window System internationalization.
This section describes how XIM works.
The current XIMP in Solaris software supports the following key event handling solutions:
XIMP_FE_TYPE1 (default)
XIMP_SYNC_BE_TYPE2
All key events go through the IM server only when input conversion mode is ON to compose text.
The Conversion ON key is recognized in the IM library.
The Conversion OFF key is recognized in the IM server.
All key events are sent first to the IM library and then to the IM server. The IM server is responsible for sending unused key events back to the IM library.
The Conversion ON/OFF key is recognized in IM server.
For XIMP_SYNC_BE_TYPE2, extra synchronization is done on XIMP_KEYPRESS.
The IM server is implemented as a separate process. The Sun IM server, named htt, supports the following Asian locales:
ko and ko.UTF-8 (Korean)
ja and ja_JP.PCK (Japanese)
zh (Simplified Chinese)
zh_TW and zh_TW.BIG5 (Traditional Chinese)
For Korean or Chinese htt usage and options, refer to the htt(1) man pages and to the input methods chapter in the Asian Solaris user's guide appropriate to your product.
The IM server comprises the following functional components:
XIMP
XIMP is one of the most commonly used protocol interfaces between the IM server and the application side of the X library. Sun's implementation supports the latest version of XIMP, which is XIMP4.0.
Event Handling
Event-handling routines handle all key events coming to the IM server directly from the X server.
Language Engine Interface
htt communicates with language engines through its internal interface.
Rendering
Rendering routines support the lookup choice region, non-callback status style, and various preedit area styles:
Lookup Choice Region
Support for lookup choice region
Status Area Style
Support for status callbacks (XIMStatusCallbacks)
Support for geometry management of status (XIMStatusArea)
Support for root window status (XIMStatusNothing)
Preedit Style
Support for "on-the-spot" style preedit area (XIMPreeditCallbacks)
Support for "over-the-spot" style preedit area (XIMPreeditPosition)
Support for "off-the-spot" style preedit area (XIMPreeditArea)
Support for "root window" style preedit area (XIMPreeditNothing)
The X Window System resource entries in the .Xdefaults resource file specify the status style and preedit style as described in the following sections.
The default CDE settings are overTheSpot and status area.
The Status Area displays which input mode is in effect in the IM server window. You can set the style by entering one of the following lines in the .Xdefaults resource file:
Table 5-1 Status Styles
Status Styles |
X Resource |
---|---|
callback |
N/A |
status area |
preeditType: overTheSpot |
root window |
preeditType: root |
Many scripts require multiple key strokes to form a single display character, syllable, symbol, ideogram, or other item. Adequate space is needed to display input keystrokes for these languages. For the Asian CDE environment, this intermediate display area is called the preedit area. The preedit area displays intermediate formations of input keystrokes while they are held in a buffer before being committed and sent to the application.
The available styles of preedit area positioning are discussed in the following sections. You can set the style by placing one of the following lines in the .Xdefaults resource file:
Table 5-2 Preedit Styles
Preedit Style |
X Resource |
---|---|
on-the-spot |
N/A |
over-the-spot |
*preeditType: overTheSpot |
off-the-spot |
*preeditType: offTheSpot |
root window |
*preeditType: root |
The on-the-spot style in the preedit area is displayed directly in the application window, and grows to the right of the insertion point as text is typed. If existing text is located to the right of the insertion point, that text is moved further to the right, accommodating the expanding preedit text as it is typed. The following shows an example of this style:
As you type text, an over-the-spot style preedit area expands to the right of the insertion point and overwrites any existing display. After you finish typing and processing the preedit area input (in other words, once the text is converted, committed, or otherwise disposed), the processed preedit text is inserted at the insertion point and the preedit area disappears.
Existing text located to the right of the insertion point appears to be overwritten during typing, but when the processed text is inserted at the insertion point, previously existing text is moved and displayed further to the right. This text movement accommodates the input text being inserted.
Before you type in an over-the-spot preedit area, the screen should resemble the following:
The following figure shows Korean text added on a line of existing text:
The following figure shows Korean text after it is committed:
Before you type text in an over-the-spot preedit area, the screen should resemble the following:
The following figure shows text added at the insertion point on a line of existing text:
The following figure shows Simplified Chinese text after it is committed:
Before you type in an over-the-spot preedit area, the screen should resemble the following:
The following figure shows text added at the insertion point on a line of existing text:
The following figure shows Traditional Chinese text after it is committed:
An off-the-spot style preedit area is located inside an application window, but it is not at the insertion point. This style preedit area is a permanent part of the application's visual interface. For ease of viewing and consistency, the proposed standard location for off-the-spot preedit areas is in the bottom margin of the application window to the right of the status area.
After you finish typing and processing preedit area input (text converted, committed, or otherwise disposed), the text is sent to the insertion point. Text to the right of the insertion point is moved farther to the right, accommodating the preedit text as it is inserted.
A root-window style preedit area is provided by the system's workspace. The proposed standard location of the preedit area is at the bottom of the workspace. Input handling works the same as with off-the-spot style preedit areas.
Two methods are available for programming applications for Asian Solaris software:
Write an application that includes its own direct interface to Xlib.
Use Motif and other X toolkits that incorporate an XIM API in their interfaces to Xlib (usually the simpler method).
For more information, see Common Desktop Environment: Internationalization Programmers Guide. This guide provides instructions on writing international programs.
To write a program that interfaces directly with Xlib, a developer must use the internationalized APIs described earlier in this chapter. For additional information on the APIs, see the X11R6 documentation.