Terminal IIIMCF Input 0.5.3
Young Chol Song (nskystars at yahoo dot com)


[1] Description

Terminal IIIMCF Input(TII) simplifies the process of including many languages by combining various input methods into one interface, thus supporting the input of many languages using just a couple of pre-defined functions. TII uses IIIMCF, so you can use the same input method X-windows uses on the terminal.

Future versions will come with a generic 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 to use iiimcf facilities. You should be able to use either the binary .rpm, .deb, .tgz packages or download the source and compile it yourself. 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 Files, and it's under the im-sdk section.)

If you've downloaded the source, 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. (All you need is the 'iiimsf,' 'leif,' 'lib/EIMIL,' 'lib/iiimp,' and 'lib/iiimcf' subdirectories.)

If you have the binary packages, make sure all the iiimf-*-devel packages are installed. The following is a list of files that you need to compile and run this program.


[3] Running the test program

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

# ./configure
# make

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 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
> -liiimcf

You also need to include 'AC_CHECK_HEADER(stdint.h)' in your 'configure.ac', which generates '#define HAVE_STDINT_H' in your 'config.h' file.

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. Code needs to exit as soon as it encounters errors.

2. Implement TII_LOOKUP.

3. Include terminal input program using TII.

