man m17nInputMethod () - API for Input method.

NAME

Input Method (basic) - API for Input method.

Data Structures

struct MInputDriver

Structure of input method driver. struct MInputMethod

Structure of input method. struct MInputContext

Structure of input context.

Variables: Predefined symbols for callback commands.

These are the predefined symbols that are used as the COMMAND argument of callback functions of an input method driver (see MInputDriver::callback_list ). MSymbol Minput_preedit_start

MSymbol Minput_preedit_done

MSymbol Minput_preedit_draw

MSymbol Minput_status_start

MSymbol Minput_status_done

MSymbol Minput_status_draw

MSymbol Minput_candidates_start

MSymbol Minput_candidates_done

MSymbol Minput_candidates_draw

MSymbol Minput_set_spot

MSymbol Minput_toggle

MSymbol Minput_reset

Typedefs

typedef MInputMethod MInputMethod

typedef MInputContext MInputContext

typedef void(* MInputCallbackFunc )(MInputContext *ic, MSymbol command)

Type of input method callback functions. typedef MInputDriver MInputDriver

Structure of input method driver.

Functions

MInputMethod * minput_open_im (MSymbol language, MSymbol name, void *arg)

Open an input method. void minput_close_im (MInputMethod *im)

Close an input method. MInputContext * minput_create_ic (MInputMethod *im, void *arg)

Create an input context. void minput_destroy_ic (MInputContext *ic)

Destroy an input context. int minput_filter (MInputContext *ic, MSymbol key, void *arg)

Filter an input key. int minput_lookup (MInputContext *ic, MSymbol key, void *arg, MText *mt)

Lookup a text produced in the input context. void minput_set_spot (MInputContext *ic, int x, int y, int ascent, int descent, int fontsize, MText *mt, int pos)

Set the spot of the input context. void minput_toggle (MInputContext *ic)

Toggle input method. void minput_reset_ic (MInputContext *ic)

Reset an input context.

Variables

MInputDriver minput_default_driver

The default driver for internal input methods. MSymbol Minput_driver

MInputDriver * minput_driver

The driver for internal input methods. MSymbol Minput_preedit_start

MSymbol Minput_preedit_draw

MSymbol Minput_preedit_done

MSymbol Minput_status_start

MSymbol Minput_status_draw

MSymbol Minput_status_done

MSymbol Minput_candidates_start

MSymbol Minput_candidates_draw

MSymbol Minput_candidates_done

MSymbol Minput_set_spot

MSymbol Minput_toggle

MSymbol Minput_reset

MInputDriver minput_default_driver

The default driver for internal input methods. MInputDriver * minput_driver

The driver for internal input methods. MSymbol Minput_driver

Detailed Description

An input method is an object to enable inputting various characters. An input method is identified by a pair of symbols, LANGUAGE and NAME. This pair decides a input method driver of the input method. An input method driver is a set of functions for handling the input method. There are two kinds of input methods; internal one and foreign one.

Internal Input Method

An internal input method has non Mnil LANGUAGE, and the body is defined in the m17n database by the tag <Minput_method, LANGUAGE, NAME>. For this kind of input methods, the m17n library uses two predefined input method drivers, one for CUI use and the other for GUI use. Those driver utilize the input processing engine provided by the m17n library itself. The m17n database may provides an input method that is not only for a specific language. The database uses Mt as LANGUAGE of such an input method.

An internal input method accepts an input key which is a symbol associated with an input event. As there is no way for the m17n library to know how input events are represented in an application program, an application programmer have to convert an input event to an input key by himself. See the documentation of the function minput_event_to_key() for the detail.

Foreign Input Method

A foreign input method has Mnil LANGUAGE, and the body is defined in an external resources (e.g. XIM of X Window System). For this kind of input methods, the symbol NAME must have a property of key Minput_driver, and the value must be a pointer to an input method driver. Therefore, by preparing a proper driver, any kind of input method can be treated in the framework of the m17n library.

For convenience, the m17n-X library provides an input method driver that enables the input style of OverTheSpot for XIM, and stores Minput_driver property of the symbol Mxim with a pointer to the driver. See the documentation of m17n GUI API for the detail.

PROCESSING FLOW

The typical processing flow of handling an input method is:

open an input method

create an input context for the input method

filter an input key

look up a produced text in the input context

Data Structure Documentation

MInputDriver

Structure of input method driver.

FIELD DOCUMENTATION:

int(* MInputDriver::open_im)(MInputMethod *im)

This function opens the input method im. It is called from the function minput_open_im() after all member of im but <info> set. If opening im succeeds, it returns 0. Otherwise, it returns -1. The function can setup im->info to keep various information that is referred by the other driver functions.

void(* MInputDriver::close_im)(MInputMethod *im)

This function closes the input method im. It is called from the function minput_close_im(). It frees all memory allocated for im->info (if any) after finishing all the tasks of closing the input method. But, the other members of im should not be touched.

int(* MInputDriver::create_ic)(MInputContext *ic)

This function creates the input context ic. It is called from the function minput_create_ic() after all members of ic but <info> are set. If creating ic succeeds, it returns 0. Otherwise, it returns -1. The function can setup ic->info to keep various information that is referred by the other driver functions.

void(* MInputDriver::destroy_ic)(MInputContext *ic)

This function is called from the function minput_destroy_ic() and destroys the input context ic. It frees all memory allocated for ic->info (if any) after finishing all the tasks of destroying the input method. But, the other members of ic should not be touched.

int(* MInputDriver::filter)(MInputContext *ic, MSymbol key, void *arg)

This function is called from the function minput_filter() and filters an input key. key and arg are the same as what given to minput_filter().

The task of the function is to handle key, update the internal state of ic. If key is absorbed by the input method and no text is produced, it returns 1. Otherwise, it returns 0.

It may update ic->status, ic->preedit, ic->cursor_pos, ic->ncandidates, ic->candidates, and ic->produced if that is necessary for the member <callback>.

The meaning of arg depends on the input method river. See the documentation of minput_default_driver and minput_gui_driver for instance.

int(* MInputDriver::lookup)(MInputContext *ic, MSymbol key, void *arg, MText *mt)

It is called from the function minput_lookup() and looks up a produced text in the input context ic. This function concatenate a text produced by the input key key (if any) to M-text mt. If key was correctly handled by the input method of ic, it returns 0. Otherwise, it returns 1.

The meaning of arg depends on the input method driver. See the documentation of minput_default_driver and minput_gui_driver for instance.

MPlist* MInputDriver::callback_list

List of callback functions. Keys are one of Minput_preedit_start, Minput_preedit_draw, Minput_preedit_done, Minput_status_start, Minput_status_draw, Minput_status_done, Minput_candidates_start, Minput_candidates_draw, Minput_candidates_done, Minput_set_spot, Minput_toggle, Minput_reset. Values are functions of type MInputCallbackFunc.

MInputMethod

Structure of input method.

FIELD DOCUMENTATION:

MSymbol MInputMethod::language

Which language this input method is for. The value is Mnil if the input method is foreign.

MSymbol MInputMethod::name

Name of the input method. If the input method is foreign, it must has a property of key Minput_driver and the value must be a pointer to a proper input method driver.

MInputDriver MInputMethod::driver

Input method driver of the input method.

void* MInputMethod::arg

The argument given to minput_open_im().

void* MInputMethod::info

Pointer to extra information that <driver>.open_im() setups.

MInputContext

Structure of input context.

FIELD DOCUMENTATION:

MInputMethod* MInputContext::im

Backward pointer to the input method. It is set up be the function minput_create_ic().

MText* MInputContext::produced

M-text produced by the input method. It is set up by the function minput_lookup() .

void* MInputContext::arg

Argument given to the function minput_create_im().

int MInputContext::active

Flag telling whether the input context is currently active or inactive. The value is set to 1 (active) when the input context is created. It can be toggled by the function minput_toggle ().

int MInputContext::x

X and Y coordinate of the spot.

int MInputContext::y

X and Y coordinate of the spot.

int MInputContext::ascent

Ascent and descent pixels of the line of the spot.

int MInputContext::descent

Ascent and descent pixels of the line of the spot.

int MInputContext::fontsize

Font size for preedit text in 1/10 point.

MText* MInputContext::mt

M-text at the spot, or NULL.

int MInputContext::pos

Character position in <mt> at the spot.

struct { ... } MInputContext::spot

Spot location and size of the input context.

void* MInputContext::info

The usage of the following members depends on the input method driver. The descriptions below are for the driver of an internal input method. They are set by the function <im>->driver.filter(). Pointer to extra information that <im>->driver.create_ic() setups. It is used to record the internal state of the input context.

MText* MInputContext::status

M-text describing the current status of the input context.

int MInputContext::status_changed

The function <im>->driver.filter() sets the value to 1 when it changes <status>.

MText* MInputContext::preedit

M-text containing the current preedit text. The function <im>->driver.filter() sets the value.

int MInputContext::preedit_changed

The function <im>->driver.filter() sets the value to 1 when it changes <preedit>.

int MInputContext::cursor_pos

Cursor position of <preedit>.

int MInputContext::cursor_pos_changed

MPlist* MInputContext::candidate_list

Array of the current candidate texts.

int MInputContext::candidate_index

int MInputContext::candidate_from

int MInputContext::candidate_to

int MInputContext::candidate_show

int MInputContext::candidates_changed

The function <im>->driver.filter() sets the value to 1 when it changes one of the above members.

MPlist* MInputContext::plist

Typedef Documentation

typedef struct MInputMethod MInputMethod

typedef struct MInputContext MInputContext

typedef void(* MInputCallbackFunc)(MInputContext *ic, MSymbol command)

This is the type of callback functions called from input method drivers. #IC is a pointer to an input context, #COMMAND is a name of callback for which the function is called.

typedef struct MInputDriver MInputDriver

The type MInputDriver is the structure of an input method driver that contains several functions to handle an input method.

Variable Documentation

MInputDriver minput_default_driver

The variable minput_default_driver is the default driver for internal input methods.

The member MInputDriver::open_im() searches the m17n database for an input method that matches the tag < #Minput_method, language, name> and loads it.

The member MInputDriver::callback_list() is NULL. Thus, it is programmers responsibility to set it to a plist of proper callback functions. Otherwise, no feedback information (e.g. preedit text) can be shown to users.

The macro M17N_INIT() sets the variable minput_driver to the pointer to this driver so that all internal input methods use it.

Therefore, unless minput_driver is set differently, the driver dependent arguments arg of the functions whose name begin with 'minput_' are all ignored.

MSymbol Minput_driver

MInputDriver* minput_driver

The variable minput_driver is a pointer to the input method driver that is used by internal input methods. The macro M17N_INIT() initializes it to a pointer to minput_default_driver (if <m17n.h> is included) or to minput_gui_driver (if <m17n-gui.h> is included).

MSymbol Minput_preedit_start

MSymbol Minput_preedit_draw

MSymbol Minput_preedit_done

MSymbol Minput_status_start

MSymbol Minput_status_draw

MSymbol Minput_status_done

MSymbol Minput_candidates_start

MSymbol Minput_candidates_draw

MSymbol Minput_candidates_done

MSymbol Minput_set_spot

MSymbol Minput_toggle

MSymbol Minput_reset

MSymbol Minput_preedit_start

MSymbol Minput_preedit_done

MSymbol Minput_preedit_draw

MSymbol Minput_status_start

MSymbol Minput_status_done

MSymbol Minput_status_draw

MSymbol Minput_candidates_start

MSymbol Minput_candidates_done

MSymbol Minput_candidates_draw

MSymbol Minput_set_spot

MSymbol Minput_toggle

MSymbol Minput_reset

MInputDriver minput_default_driver

The variable minput_default_driver is the default driver for internal input methods.

The member MInputDriver::open_im() searches the m17n database for an input method that matches the tag < #Minput_method, language, name> and loads it.

The member MInputDriver::callback_list() is NULL. Thus, it is programmers responsibility to set it to a plist of proper callback functions. Otherwise, no feedback information (e.g. preedit text) can be shown to users.

The macro M17N_INIT() sets the variable minput_driver to the pointer to this driver so that all internal input methods use it.

Therefore, unless minput_driver is set differently, the driver dependent arguments arg of the functions whose name begin with 'minput_' are all ignored.

MInputDriver* minput_driver

The variable minput_driver is a pointer to the input method driver that is used by internal input methods. The macro M17N_INIT() initializes it to a pointer to minput_default_driver (if <m17n.h> is included) or to minput_gui_driver (if <m17n-gui.h> is included).

MSymbol Minput_driver