The m17n Library: MInputDriver Struct Reference

# MInputDriver Struct Reference
[Input Method (basic)]

Structure of input method driver. More...

## Data Fields
int(* | open_im )(MInputMethod *im)
| Open an input method.
void(* | close_im )(MInputMethod *im)
| Close an input method.
int(* | create_ic )(MInputContext *ic)
| Create an input context.
void(* | destroy_ic )(MInputContext *ic)
| Destroy an input context.
int(* | filter )(MInputContext *ic, MSymbol key, void *arg)
| Filter an input key.
int(* | lookup )(MInputContext *ic, MSymbol key, void *arg, MText *mt)
| Lookup a produced text in an input context.
MPlist * | callback_list
| List of callback functions.

## Detailed Description

Structure of input method driver.

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

## Field Documentation

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

Open an input method.

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)

Close an input method.

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)

Create an input context.

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)

Destroy an input context.

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)

Filter an input key.

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)

Lookup a produced text in an input context.

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.

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, Minput_get_surrounding_text, Minput_delete_surrounding_text. Values are functions of type MInputCallbackFunc.