1 /**
2  * chewingio.h
3  *
4  * Copyright (c) 1999, 2000, 2001
5  *	Lu-chuan Kung and Kang-pen Chen.
6  *	All rights reserved.
7  *
8  * Copyright (c) 2004, 2005
9  *	libchewing Core Team. See ChangeLog for details.
10  *
11  * See the file "COPYING" for information on usage and redistribution
12  * of this file.
13  */
14 
15 #ifndef _CHEWING_IO_H
16 #define _CHEWING_IO_H
17 #include "global.h"
18 
19 #define KEYSTROKE_IGNORE 1
20 #define KEYSTROKE_COMMIT 2
21 #define KEYSTROKE_BELL 4
22 #define KEYSTROKE_ABSORB 8
23 
24 /**
25  * @brief Function should be called when ESC emit
26  */
27 CHEWING_API int chewing_handle_Space( ChewingContext * );
28 CHEWING_API int chewing_handle_Esc( ChewingContext * );
29 CHEWING_API int chewing_handle_Enter( ChewingContext * );
30 CHEWING_API int chewing_handle_Del( ChewingContext * );
31 CHEWING_API int chewing_handle_Backspace( ChewingContext * );
32 CHEWING_API int chewing_handle_Tab( ChewingContext * );
33 CHEWING_API int chewing_handle_ShiftLeft( ChewingContext * );
34 CHEWING_API int chewing_handle_Left( ChewingContext * );
35 CHEWING_API int chewing_handle_ShiftRight( ChewingContext * );
36 CHEWING_API int chewing_handle_Right( ChewingContext * );
37 CHEWING_API int chewing_handle_Up( ChewingContext * );
38 CHEWING_API int chewing_handle_Home( ChewingContext * );
39 CHEWING_API int chewing_handle_End( ChewingContext * );
40 CHEWING_API int chewing_handle_Down( ChewingContext * );
41 CHEWING_API int chewing_handle_Capslock( ChewingContext * );
42 CHEWING_API int chewing_handle_Default( ChewingContext *, int key );
43 CHEWING_API int chewing_handle_CtrlNum( ChewingContext *, int key );
44 CHEWING_API int chewing_handle_CtrlOption( ChewingContext *, int key );
45 CHEWING_API int chewing_handle_ShiftSpace( ChewingContext * );
46 CHEWING_API int chewing_handle_DblTab( ChewingContext * );
47 CHEWING_API int chewing_handle_Numlock( ChewingContext *, int key);
48 
49 /**
50  * @brief Set selectAreaLen, maxChiSymbolLen, selKey in pcd
51  *
52  * @param ctx Chewing IM context
53  * @param pcd
54  */
55 CHEWING_API int chewing_Configure( ChewingContext *ctx, ChewingConfigData *pcd );
56 
57 /**
58  * @brief create new handle of ChewingContext
59  */
60 CHEWING_API ChewingContext *chewing_new();
61 
62 /**
63  * @brief release handle of ChewingContext
64  *
65  * Release internal memory allocation.
66  */
67 CHEWING_API void chewing_free( ChewingContext *ctx );
68 
69 /**
70  * @brief Initialize chewing
71  *
72  * Init directory data.
73  *
74  * @param dataPath
75  * @param hashPath
76  * @retval 0 if succeed
77  */
78 CHEWING_API int chewing_Init(
79 		const char *dataPath,
80 		const char *hashPath );
81 
82 /**
83  * @breif Reset all settings
84  *
85  * @param ctx
86  * @return If successed than return 0
87  */
88 CHEWING_API int chewing_Reset( ChewingContext *ctx );
89 
90 /**
91  * @breif Set keyboard type
92  *
93  * @param ctx
94  * @param kbtype kbtype from KBStr2Num
95  * @return If successed then return 0
96  */
97 CHEWING_API int chewing_set_KBType( ChewingContext *ctx, int kbtype );
98 
99 /**
100  * @brief Terminate chewing
101  *
102  * Terminate the I/O routines for chewing.
103  */
104 CHEWING_API void chewing_Terminate();
105 
106 /**
107  * @brief Set chewing's english, chinese mode
108  *
109  * @param ctx
110  * @param mode CHINESE_MODE or ENGLISH_MODE
111  */
112 CHEWING_API void chewing_set_ChiEngMode( ChewingContext *ctx, int mode );
113 
114 /**
115  * @brief Get chewing's current mode
116  *
117  * @param ctx
118  *
119  * @return CHINESE_MODE or ENGLISH_MODE
120  */
121 CHEWING_API int chewing_get_ChiEngMode( ChewingContext *ctx );
122 
123 /**
124  * @brief Set chewing's fullshape, halfshape mode
125  *
126  * @param ctx
127  * @param mode FULLSHAPE_MODE or HALFSHAPE_MODE
128  */
129 CHEWING_API void chewing_set_ShapeMode( ChewingContext *ctx, int mode );
130 
131 /**
132  * @brief Get chewing's current shape mode
133  *
134  * @param ctx
135  *
136  * @return FULLSHAPE_MODE or HALFSHAPE_MODE
137  */
138 CHEWING_API int chewing_get_ShapeMode( ChewingContext *ctx );
139 
140 /**
141  * @brief Get kbtype number from string
142  *
143  * @param str[] name of kbtype eg. "KB_HSU"
144  */
145 CHEWING_API int chewing_KBStr2Num( char str[] );
146 
147 #endif
148 
149