Back to index

im-sdk  12.3.91
koinput.h
Go to the documentation of this file.
00001 #ifndef _KOINPUT_H_
00002 #define _KOINPUT_H_
00003 
00004 #include <X11/Xmd.h>
00005 #include <IMProtocolStruct.h>
00006 #include "aux-message.h"
00007 #include "le-options.h"
00008 
00009 /***************************************************************************/
00010 /*                          Int'l readiness                                */
00011 /***************************************************************************/
00012 
00013 #define _(String) (String)
00014 #define N_(String) String
00015 #define textdomain(Domain)
00016 #define bindtextdomain(Package, Directory)
00017 
00018 
00019 #define MAX_SESSION         1024
00020 /***************************************************************************/
00021 /*                          Key  Definition                                */
00022 /***************************************************************************/
00023 
00024 /* Key Used by Input Method Manager */
00025 
00026 #define IMM_NOT_USED_KEY                  0
00027 #define IMM_USED_KEY                      1
00028 #define FULL_HALF_WIDTH_SWITCH_KEY        2
00029 #define HEX_INPUT_IN_EUC_MODE_KEY         3 
00030 #define HEX_INPUT_IN_UTF8_MODE_KEY        4
00031 #define ENGLISH_KOREAN_SWITCH_KEY         5
00032 #define SYMBOL_INPUT_MODE_KEY                    6
00033 #define HANJA_CONVERSION_DEFAULT_KEY             20
00034 #define HANJA_CONVERSION_HANJA_KEY        21
00035 #define HANJA_CONVERSION_HANGUL_HANJA_KEY 22
00036 #define HANJA_CONVERSION_HANJA_HANGUL_KEY 23
00037 
00038 #define KEYBOARD_LAYOUT_TOGGLE_KEY        30
00039 /*
00040   #define KEYBOARD_LAYOUT_2BEOLSIK_KEY           30
00041   #define     KEYBOARD_LAYOUT_3BEOLSIK_390_KEY   31
00042   #define KEYBOARD_LAYOUT_3BEOLSIK_FINAL_KEY     32
00043 */
00044 /* Key Used by Input Method Entry */
00045 #define IME_NOT_USED_KEY           0
00046 #define IME_USED_KEY               1
00047 #define ESC_KEY                           2
00048 #define BACKSPACE_KEY                     3
00049 #define RETURN_KEY                        4
00050 #define INSERT_KEY                 5
00051 #define DELETE_KEY                 6
00052 #define HOME_KEY                   7
00053 #define END_KEY                           8
00054 #define PAGEUP_KEY                        9
00055 #define PAGEDOWN_KEY                      10
00056 #define SPACE_KEY                         0x20
00057 
00058 /***************************************************************************/
00059 /*                    Input Method Engine  Definition                      */
00060 /***************************************************************************/
00061 #define       MAX_CANDIDATES_NUM          16
00062 #define MAX_INPUT_KEY_NUM          256
00063 #define MAX_PREEDIT_CHAR_NUM              256
00064 #define MAX_CANDIDATE_CHAR_NUM            256
00065 #define MAX_STATUS_CHAR_NUM               256
00066 #define MAX_COMMIT_CHAR_NUM               512
00067 
00068 #define MAX_KEYMAP_KEY_NUM         95
00069 
00070 #define IME_PREEDIT_AREA           1
00071 #define IME_LOOKUP_AREA            2
00072 #define IME_STATUS_AREA            4
00073 #define IME_COMMIT                 8
00074 
00075 #define ENGINE_NOT_INSTALLED              1
00076 #define ENGINE_NOT_INITIATED              2
00077 #define ENGINE_INITIATED                  3
00078 
00079 #define DEFAULT_ENGINE_PATH        "/usr/lib/iiim/le/kole/input_methods"
00080 #define DEFAULT_DICT_PATH          "data"
00081 #define COMMON_ENGINE_PATH         "common"
00082 #define LANGNAME                        "ko_KR"
00083 #define DEFAULT_DICT_NAME               "hhdict"
00084 
00085 #define CODETABLE_ENGINE_NAME      "ctim"
00086 #define USER_PROFILE_PATH                 ".Xlocale"
00087 #define USER_PROFILE_NAME                 "ime.cfg"
00088 #define SYSTEM_PROFILE_NAME        "sysime.cfg"
00089 #define USER_OPTION_FILE_NAME             "options.cfg"
00090 
00091 #define NUMERIC_LABEL                     0
00092 #define LOWER_LABEL                1
00093 #define UPPER_LABEL                2
00094 
00095 #define MAX_ENGINE_NUM                    127
00096 #define MAX_NAME_LEN               16
00097 
00098 #define MAX_OPTION_NUM                    6
00099 #define MAX_ARGS_NUM               10
00100 
00101 /***************************************************************************/
00102 /*         Protocol used by Auxiliary window and Language Engine           */
00103 /***************************************************************************/
00104 /* Conversion Status */
00105 typedef enum {
00106   CONVERSION_OFF = 0,
00107   CONVERSION_ON = 1
00108 } CONVERSION_STATUS_T;
00109 
00110 
00111 /* Types of Input Method Switching */
00112 #define IME_ROUND_SWITCH           0
00113 #define IME_SELECT_SWITCH          1
00114 
00115 
00116 /***************************************************************************/
00117 /*                 Keyboard Layout Support                               */
00118 /***************************************************************************/
00119 
00120 typedef enum _KEYBOARD_T {
00121   KEYBOARD_LAYOUT_2BEOLSIK =  0,
00122   KEYBOARD_LAYOUT_3BEOLSIK_390 = 1,
00123   KEYBOARD_LAYOUT_3BEOLSIK_FINAL = 2
00124 } KEYBOARD_T;
00125 
00126 #define KEYBOARD_2BEOLSIK                 "2벌식"
00127 #define KEYBOARD_3BEOLSIK_390                    "3벌식 390"
00128 #define KEYBOARD_3BEOLSIK_FINAL                  "3벌식 최종"
00129 /***************************************************************************/
00130 /*                 User Preference Information                            /
00131                  /***************************************************************************/
00132 
00133 #define IDX_IME_USER_ID                                        0
00134 #define IDX_IME_USER_HOME                               1
00135 #define IDX_KEYBOARD_LAYOUT                             2
00136 #define IDX_CONVERSION_FORMAT                                  3
00137 #define IDX_AUTO_COMMIT_ON_CHAR_BASIS                          4
00138 #define IDX_AUTO_COMMIT_ON_SINGLE_CANDIDATE_CONVERSION         5
00139 
00140 #define STR_IME_USER_ID                   "ime_user_id"
00141 #define STR_IME_USER_HOME          "ime_user_home"
00142 #define STR_KEYBOARD_LAYOUT        "keyboard_layout"
00143 #define STR_CONVERSION_FORMAT             "conversion_format"
00144 #define STR_AUTO_COMMIT_ON_CHAR_BASIS     "auto_commit_on_char_basis"
00145 #define STR_AUTO_COMMIT_ON_SINGLE_CANDIDATE_CONVERSION "auto_commit_on_single_candidate_conversion"
00146 
00147 #define OPTION_PAIR_NUM            6
00148 
00149 typedef enum _option_type {
00150   type_pchar, type_int
00151 }option_type;
00152 
00153 typedef struct _Option_Pair{
00154   option_type type;
00155   char *option_name;
00156   union {
00157     char *string_value;
00158     int integer_value;
00159   }value;
00160 }Option_Pair;
00161 
00162 
00163 enum conversion_key_sequence {
00164   ctrl_q = 0,
00165   ctrl_h,
00166   ctrl_e,
00167   ctrl_r,
00168   /*
00169     ctrl_w,
00170   */
00171   ctrl_x,
00172   ctrl_shift_x
00173 };
00174 enum conversion_format {
00175   hanja_only = 0,
00176   hangul_hanja,
00177   hanja_hangul
00178 };
00179 
00180 typedef enum _keyboard_layout {
00181   KBD_LAYOUT_2BEOLSIK = 0,
00182   KBD_LAYOUT_3BEOLSIK_390,
00183   KBD_LAYOUT_3BEOLSIK_FINAL,
00184 } keyboard_layout;
00185 
00186 typedef struct _UserPreference{
00187   int  ime_user_id;
00188   char *ime_user_home;
00189   int     keyboard_layout;
00190   int     conversion_format;
00191   int     auto_commit_on_char_basis;
00192   int     auto_commit_on_single_candidate_conversion;
00193 }UserPreference;
00194 
00195 
00196 /***************************************************************************/
00197 /*                 IME structure used by Language Engine                   */
00198 /***************************************************************************/
00199 
00200 #define INPUT_MODE_HANGUL_STR                   "한글"
00201 #define INPUT_MODE_HEX_IN_EUC_STR               "코드(KS X 1001)"
00202 #define INPUT_MODE_HEX_IN_UTF8_STR              "코드(UTF-8)"
00203 #define INPUT_MODE_SYMBOL_STR                   "특수 기호"
00204 #define INPUT_MODE_HANJA_STR                      "한자"
00205 
00206 typedef struct _IMEKeyEventStruct IMEKeyEventStruct, *IMEKeyEvent;
00207 
00208 struct _IMEKeyEventStruct {
00209   int key_code;
00210   int key_char;
00211   int key_modifier;
00212 };
00213 
00214 typedef enum _INPUT_MODE_T {
00215   INPUT_MODE_NONE = -1,
00216   INPUT_MODE_ENGLISH,
00217   INPUT_MODE_HANGUL,
00218   INPUT_MODE_HANJA,
00219   INPUT_MODE_HEX_EUC,
00220   INPUT_MODE_HEX_UTF8,
00221   INPUT_MODE_SYMBOL_MENU,
00222   INPUT_MODE_SYMBOL
00223 } INPUT_MODE_T;
00224 
00225 /* IMEBaseRec that shared between Language Engine and Auxiliary Window. */
00226 typedef struct {
00227   CARD8              engine_id;           /* engine identity */
00228   CARD8              locale_id;           /* supported locale idendity */
00229   CARD8              encode_id;           /* encode that dictionary used */
00230   CARD8              status;                     /* engine status: initialized or installed */
00231   char        *ename;              /* English name of this engine */
00232   char               *kname;                     /* Korean Name of this engine */
00233 } IMEBaseRec, *IMEBase;
00234 
00235 /* Arguments:
00236    system arguments ---> IMECoreRec
00237    user defined arguments   ---> Desktop_data
00238 */
00239 typedef struct {
00240   char        *name;
00241   CARD8              type;
00242   CARD8              value;
00243 } IMEArgRec, *IMEArg;
00244        
00245 typedef struct { 
00246   int         args_num;
00247   IMEArgRec   args[MAX_ARGS_NUM];
00248 } IMEArgListRec, *IMEArgList;
00249 
00250 /* Runtime Environment */
00251 typedef struct { 
00252   CARD8       output_encode_id;    /* encode that IME need output */
00253   char        *lang_name;          /* language name such as zh_CN/zh_TW... */
00254   char        *locale_name;        /* locale name defined in config file */
00255   char        *data_path;          /* directory for dictionary */
00256   char        *data_ptr;           /* memory pointer for dictionary data */
00257 } IMEEnvListRec, *IMEEnvList;
00258 
00259 /* Keymap Information */
00260 typedef struct {
00261   char               bSet;                /* whether be set by IM engine */
00262   char               *keymap[MAX_KEYMAP_KEY_NUM];
00263 } IMEKeyMapRec, *IMEKeyMap;
00264 
00265 typedef struct {
00266   int n_count;
00267   IMEKeyEventStruct **keylist;
00268 } IMEHotKeyRec, *IMEHotKey;
00269 
00270 /* IME Core Information */
00271 typedef struct {
00272   IMEBaseRec  baseinfo;            /* Input Method Entry information */
00273   IMEEnvListRec      envinfo;             /* runtime environment of IME engine */
00274   IMEArgListRec      argsinfo;            /* system arguments setting */
00275   IMEKeyMapRec       keymapinfo;          /* key mapping for the IM */
00276   IMEHotKeyRec  hotkeys;
00277 } IMECoreRec, *IMECore;
00278 
00279 typedef struct _IMEBufferRec IMEBufferRec, *IMEBuffer;
00280 typedef struct _IMEBufferMethodsRec IMEBufferMethodsRec, *IMEBufferMethods;
00281 typedef struct _IMEBufferWhatToDo IMEBufferWhatToDo;
00282 struct _IMEBufferWhatToDo {
00283   Bool do_preedit;
00284   Bool do_status;
00285   Bool do_lookup;
00286   Bool do_commit;
00287   Bool do_sendback;
00288 };
00289 
00290 
00291 struct _IMEBufferMethodsRec {
00292   Bool (*ime_engine_start)(int, KOLE_config **);
00293   /*
00294     Bool ( *ime_buffer_set_user_options) (UserPreference *);
00295   */
00296   Bool (*ime_engine_get_hotkeys)(int *, IMEKeyEventStruct ***);
00297   Bool (*ime_buffer_new) (IMEBuffer *, int session_id, int engine_id);
00298   Bool (*ime_buffer_initialize) (IMEBuffer);
00299   Bool (*ime_buffer_conversion_start) (IMEBuffer);
00300   Bool (*ime_buffer_conversion_end) (IMEBuffer);
00301 
00302   Bool (*ime_buffer_get_session_id) (IMEBuffer, int *);
00303   Bool (*ime_buffer_get_engine_id) (IMEBuffer, int *);
00304   Bool (*ime_buffer_get_input_mode) (IMEBuffer , INPUT_MODE_T *);
00305   Bool (*ime_buffer_get_keyboard_layout)(IMEBuffer, KEYBOARD_LAYOUT_T *);
00306   Bool (*ime_buffer_set_keyboard_layout)(IMEBuffer, KEYBOARD_LAYOUT_T *);
00307   Bool (*ime_buffer_get_active_repertoire)(IMEBuffer, OPTION_CHARSET *);
00308   Bool (*ime_buffer_set_active_repertoire)(IMEBuffer, OPTION_CHARSET *);
00309   Bool (*ime_buffer_get_deletion_option) (IMEBuffer, OPTION_DELETION *);
00310   Bool (*ime_buffer_get_commitmode_option) (IMEBuffer, OPTION_DELETION *);
00311   Bool (*ime_buffer_get_preedit) (IMEBuffer , UTFCHAR **);
00312   Bool (*ime_buffer_get_status) (IMEBuffer, UTFCHAR **);
00313   Bool (*ime_buffer_get_commit_string) (IMEBuffer ,UTFCHAR **);
00314 
00315   Bool (*ime_buffer_get_candidates) (IMEBuffer, int *, int *, UTFCHAR ***);
00316   Bool (*ime_buffer_lookup_do_next_page) (IMEBuffer a_buffer, int *new_page_num_return);
00317   Bool (*ime_buffer_lookup_do_previous_page) (IMEBuffer a_buffer, int *new_page_num_return);
00318   Bool (*ime_buffer_lookup_do_scroll) (IMEBuffer a_buffer);
00319   Bool (*ime_buffer_lookup_do_select_candidate) (IMEBuffer a_buffer, IMEKeyEventStruct *);
00320        
00321   Bool (*ime_buffer_get_current_lookup_pos) (IMEBuffer, int *);
00322   Bool (*ime_buffer_process_key_input) (IMEBuffer, IMEKeyEventStruct *);
00323   Bool (*ime_buffer_free) (IMEBuffer );
00324   Bool (*ime_buffer_get_what_to_do) (IMEBuffer ,IMEBufferWhatToDo **);
00325   Bool (*ime_buffer_set_what_to_do) (IMEBuffer ,IMEBufferWhatToDo *);
00326   Bool (*ime_buffer_get_configuration)(IMEBuffer, int *, KOLE_config ***);
00327   Bool (*ime_engine_finish) ();
00328 };
00329 
00330 
00331 typedef struct {
00332   IMECoreRec  core;
00333   IMEBufferMethods   so_methods;
00334   void        *so_handler;
00335 } IMEEngineRec, *IMEEngine;
00336 
00337 typedef struct {
00338   int         nIME_Num;
00339   IMEBaseRec  *arrIME_Base[MAX_ENGINE_NUM];
00340 } IMEListRec;
00341 
00342 
00343 typedef struct _SessionProperty SessionProperty;
00344 struct _SessionProperty {
00345   int count;
00346   KOLE_config *pconfig;
00347 };
00348 
00349 #endif   /* _KOINPUT_H_  */
00350