Terminal Input Interface 0.5
Young Chol Song (nskystars at yahoo dot com)


[1] Description

Terminal Input Interface(TII) simplifies the process of including many languages by combining various input methods into one interface, supporting the input of many languages using just a couple of pre-defined functions.

TII supports IIIMF(using IIIMCF), so you can use the same IM X-windows uses on the terminal. As of now, TII only supports IIIMF (which itself supports numerous input methods), but it is easily extensible and in the future will include more input methods, many which are not included in IIIMF.

Note: TII up to 0.4 supported a generic input interface, however the interface seemed too compilcated and difficult to debug(compared to this version)...so until it becomes somewhat stable, TII will only support interface to IIIMF, and maybe when it becomes somewhat stable I'll think of making a generic interface.

Future versions (hopefully) will come with a terminal input program, which will enable you to input various languages directly from your linux console/terminal.


[2] Downloading & Installing im-sdk

You need im-sdk source to compile the test programs. (I should be wrong here. I have not tried im-sdk with the binary packages(.deb, .rpm, etc.) so I don't know how they work.) You can get the latest im-sdk source using subversion on the IIIMF website. I also have some tar.gz'd snapshot versions of im-sdk. (Go to http://kldp.net/projects/hangul-jfbterm and click on Downloads, and under the im-sdk section.)

First try compile/installing everything, but if you're unsuccessful like me, go into the subdirectories and try compiling and installing as much as you can. (Try at least the 'iiimsf,' 'leif,' and 'lib' subdirectories, and copy the include files into '/usr/local/include'.)


[3] Running the test program

After you've succefully compiled and installed im-sdk :), return to this directory and type:

# make IIIMF_SRC=/path/to/im-sdk/src

where '/path/to/im-sdk/src' is the path to your im-sdk source. For example I have im-sdk source in '/usr/local/src/im-sdk/trunk', so I'd type 'make IIIMF_SRC=/usr/local/src/im-sdk/trunk'

Run 'htt_server' (usually in '/usr/lib/im/htt_server'). Run the test program. If everything went OK, you'll be able to see many lines showing the status of the IM and the Korean characters 'Urimal' being composed on the screen. (You'll need a terminal that supports Korean output to actually see the characters printed in the test program.)

The test program consists of two files, 'test.c' and 'test-handler.c'. 'test.c' is the main routine, where the program initalizes/finalizes and sends key input to the IM, and 'test-handler.c' is where output from the IM comes out; the preedit/stats/commit/lookup status.


[4] Using TII-IIIMCF in your programs

Now that you've got the test programs to work, let's see how you can incorperate them into your programs. (Refer back to the test program) 

1. The following files need to be included as your headers

> #include "tii-iiimcf.h"
> #include "handler.h"

Different functions are defined in the two header files. Look back at the test program and you'll notice that 'test.c' only as the header file 'tii-iiimcf.h'. That's because 'tii-iiimcf.h' includes the definitions to init/exit/sendkey functions. 'handler.h' has the definitions to all the handler(more on this below) functions.

2. Check the 'handler.h' file

> #define TII_COMMIT commit_handler
> #define TII_PREEDIT preedit_handler
> #define TII_STATUS status_handler
> #define TII_LOOKUP lookup_handler

xxxxx_handler is the function that handles output from IM. Whenever IM has a change in its status, TII calls the corresponding function with its changed status being the first argument of the function.

For example, if the IM wants to commit a character, it calls TII_COMMIT, which is defined as commit_handler (you can change the function name) with the needs-to-be-commited character as its first argument. These functions are not already defined in TII; you must create them according to the needs of your program. (Like what I did in test-handler.c)

TII_LOOKUP will be supported in the next version of TII.

3. In your code...

Initialize:
> tii_iiimcf_init("IM_NAME");

Where IM_NAME is a name to an IIIMF LEIF. (for example; hangul, newpy, CannaLE, ...) They can usually be found at '/usr/lib/im/leif'

Send a key value:
> tii_iiimcf_sendkey('KEY', SHIFT_STATE);

Finalize:
> tii_iiimcf_exit();

4. Use the following options while compiling

> -DHAVE_CONFIG_H
> -I$(IIIMF_SRC)/lib/iiimp
> -I$(IIIMF_SRC)/include
> -liiimcf

$(IIIMF_SRC) is the location of your im-sdk source. Look at the 'Makefile' for an example.

5. More...

Make sure 'htt_server' is running. For further reference Take a look at 'test.c' and 'test-handler.c'.


[5] TODO & Other stuff

1. Segfaults when encountered with errors; when htt_server is not running, or when it encounters unexpected problems. Process errors.

2. Implement TII_LOOKUP.

3. Include terminal input program using TII.

