Scim Bridge Developer Manual: IMContexts

Up

About this datatype

The IMContext is the data type for input methods. This contains context data of input method, such as focused widgets or current lines. IMContexts behave as interface between the client library of scim-bridge and GUI libraries. Every message from the agent invokes functions of the current IMContext, and GUI events should be treated as events from IMContexts (see the previous section). So basically, all the functions of IMContext is to be implemented by you.

Registering and deregistering it

In allocating and finalizing IMContexts, the client must call scim_bridge_client_register_imcontext and scim_bridge_client_degister_imcontext. See the previous section.

Showing the preedit string

In the embedded preedit mode, preedit related functions are called everytime the agent update the preedit. There are some functions to implement to show it.

Commiting a string

Commit functions are called everytime you settle the preedit string.

Handling key events

When the key is pressed, the client should call scim_bridge_handle_key_event. See the previous section.

There are also forwarding key events from the agent. Please add it into the GUI event queue.

Example:

// This function is called when a key event is forwarded from the agent.
void scim_bridge_client_imcontext_forward_key_event (const ScimBridgeClientIMContext *imcontext, const ScimBridgeKeyEvent *key_event)
{
    // Translate it into GTK key event.
    GdkEventKey gdk_event;
    scim_bridge_key_event_bridge_to_gdk (&gdk_event, imcontext->client_window, key_event);

    // Then add it into gtk event queue.
    gdk_event_put ((GdkEvent*) &gdk_event);
}
                

Handling the focus and the cursor location

The focus information and the cursor locations should be send the agent. Follow the instruction in the previous section.

Processing the surrounding text

There are some IME which use the text around input cursor. The clients should be able to handle at least one paragraph before and after the cursor. This feature is very important for IMEs of some languages. They choose which character to insert following to the characters before and after the insertation position. The following functions are called when manupulation of the surrounding text is required.

Misc functions

There are some functions you have to implement, but they can be ignored if you doesn't need it. If you wonder how to implement, leave them as dummy (empty) implimentations.