On the Chinese platform, users can add their own input method. The design of the input part of the Chinese platform uses a leading module as the interface with the platform, and it adopts a unified and normative interface with each Input method module. Each input method can be regarded as a filter, input ASCII code, returned to the Chinese characters.
The leading module of input method exists in the form of Dynamic Connection library (LIBIMPI.A), and each Input method module is connected to a separate executable file. For each specific input method, just follow a certain data structure can link to become a new executable file, and added to Yan Chinese platform. These data structures include external variables and external functions.
1. External variables
Array extcode[]: String type, representing the input outer code string;
Array candstr[]: String type that represents the coincident of the selected string;
Array result[]: String type, representing the resulting string;
Array imname[]: String type, representing the name of the input method;
Array imdscrpt[]: String type that represents the description of the input method.
Variable Maxeclen: Integral type, indicating the maximum length of the outer code;
Variable Eclen: Integral type, representing the length of the outer code.
The variables are defined as follows:
extern int maxeclen; /* The maximum length of external code */
extern int eclen; /* The length of external code */
extern char extcode[]; /* External code */
extern char candstr[]; /* Candinate string */
extern char result[]; /* Result string */
2. External function
There are four external functions, namely Iminit (), Imcleanup (), Imselect (), and IMFilter (). The definitions of these four functions are as follows:
int IMInit();
int IMClearup();
int IMSelect(int select);
int IMFilter(int ch);
where the Iminit () function is used to initialize the input method, the Imclearup () function is used to handle the situation when the input method is released, and the Imselect () function is used to handle the situation where the current input method is selected; IMFilter () is the core function of the input method. Used to filter the received string to get the correct input result.