Linux culture of the Yan Chinese platform Input method add

Source: Internet
Author: User
Tags data structures

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.