Auto update

This commit is contained in:
Fcitx5 Android Bot 2023-10-23 04:55:09 +00:00
parent 65ed2d60fb
commit afe33db635
30 changed files with 3813 additions and 1 deletions

BIN
chewing-dict/dictionary.dat Normal file

Binary file not shown.

BIN
chewing-dict/index_tree.dat Normal file

Binary file not shown.

117
chewing-dict/pinyin.tab Normal file
View file

@ -0,0 +1,117 @@
25
tz y
b 1
p q
m a
f z
d 2
ts h
t w
n s
l x
g e
k d
hs v
h c
jh 5
j r
q f
x v
zh 5
ch t
sh g
r b
z y
c h
s n
90
uang j;
wang j;
weng j/
wong j/
ying u/
yung m/
yong m/
iung m/
iong m/
iang u;
yang u;
yuan m0
iuan m0
ing u/
iao ul
iau ul
yao ul
yau ul
yun mp
iun mp
vn mp
iou u.
iu u.
you u.
io ui
yo ui
ian u0
ien u0
yan u0
yen u0
yin up
ang ;
eng /
uei jo
ui jo
wei jo
uen jp
yueh m,
yue m,
iue m,
ueh m,
ue m,
ve m,
uai j9
wai j9
uan j0
wan j0
un jp
wen jp
wun jp
ung j/
ong j/
van m0
er -
ai 9
ei o
ao l
au l
ou .
an 0
en p
yi u
ia u8
ya u8
ieh u,
ie u,
yeh u,
ye u,
in up
wu j
ua j8
wa j8
uo ji
wo ji
yu m
ve m,
vn mp
ih =
a 8
o i
eh ,
e k
v m
i u
u j
E ,
n p
ng /
r =
z =

26
chewing-dict/swkb.dat Normal file
View file

@ -0,0 +1,26 @@
Q 〔
W 〕
A 【
S 】
Z 《
X 》
E {
R }
D 「
F 」
C 『
V 』
T ‘
Y ’
G “
H ”
B 〝
N 〞
U +
I -
O ×
P ÷
J ≠
K ≒
L Orz
M …

13
chewing-dict/symbols.dat Normal file
View file

@ -0,0 +1,13 @@
…
※
常用符號=,、。.?!;︰‧‥﹐﹒˙·‘’“”〝〞‵′〃~$%@&#*
左右括號=()「」〔〕{}〈〉『』《》【】﹙﹚﹝﹞﹛﹜
上下括號=︵︶﹁﹂︹︺︷︸︿﹀﹃﹄︽︾︻︼
希臘字母=αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
數學符號=+-×÷=≠≒∞±√<>﹤﹥≦≧∩∪ˇ⊥∠∟⊿㏒㏑∫∮∵∴╳﹢
特殊圖形=↑↓←→↖↗↙↘㊣◎○●⊕⊙○●△▲☆★◇◆□■▽▼§¥〒¢£※♀♂
Unicode=♨☀☁☂☃♠♥♣♦♩♪♫♬☺☻
單線框=├─┼┴┬┤┌┐╞═╪╡│▕└┘╭╮╰╯
雙線框=╔╦╗╠═╬╣╓╥╖╒╤╕║╚╩╝╟╫╢╙╨╜╞╪╡╘╧╛
填色方塊=_ˍ▁▂▃▄▅▆▇█▏▎▍▌▋▊▉◢◣◥◤
線段=﹣﹦≡|∣∥–︱—︳╴¯ ̄﹉﹊﹍﹎﹋﹌﹏︴∕﹨╱╲/\

View file

@ -0,0 +1,39 @@
/*
* chewing-compat.h
*
* Copyright (c) 2014
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/* *INDENT-ON* */
/** @brief indicate the internal encoding of data processing.
* @since 0.3.0
*/
#define LIBCHEWING_ENCODING "UTF-8"
/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(const ChewingContext *ctx)
DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(const ChewingContext *, int *zuin_count)
DEPRECATED_FOR(chewing_bopomofo_String_static);
CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath)
DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd)
DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode)
DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx)
DEPRECATED_FOR(chewing_get_selKey);
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,59 @@
/*
* chewing.h
*
* Copyright (c) 2004, 2005, 2006, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_CORE_
#define _CHEWING_CORE_
/* *INDENT-ON* */
#ifdef __cplusplus
extern "C" {
#endif
/*! \file chewing.h
* \brief Chewing Headers
* \author libchewing Core Team
* \mainpage Chewing API
*
* <center>API Collection of Chewing intelligent Chinese
* phonetic IM (Input Method).</center>
*
* <h1>Overview</h1>
*
* As far as we expect, input method (in fact, the way for text input and
* output, especially in multi-lingual environments) implementations are
* becoming more and more complex in system integrations. The emerging
* standard for practical and flexible development cycles is required, so that
* we are facing the impacts from various Chinese input method implementations
* and the integration into existing framework or system designs. At the
* result, Chewing Input Method (abbreviated as "Chewing") attempts to be one
* of the approaches to solve and ease the problems with the inclusion of base
* classes, on the basis of cross-platform, and cross-operating-environment
* derivative classes, which are built as the abstract backbone of intelligent
* Chinese phonetic input method implementations. From the perspectives,
* Chewing defines the abstract behavior how an intelligent phonetic IM should
* works via the common interface, and Chewing permits the extra parameters
* and properties for the input method implementations to extend their
* specific functionality.
*/
#include "chewingio.h"
#include "global.h"
#include "mod_aux.h"
/* backward compatibility */
#include "chewing-compat.h"
#ifdef __cplusplus
}
#endif
/* *INDENT-OFF* */
#endif /* _CHEWING_CORE_ */
/* *INDENT-ON* */

View file

@ -0,0 +1,557 @@
/*
* chewingio.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_IO_H
#define _CHEWING_IO_H
/* *INDENT-ON* */
/*! \file chewingio.h
* \brief Chewing I/O module
* \author libchewing Core Team
*/
#include "global.h"
#define KEYSTROKE_IGNORE 1
#define KEYSTROKE_COMMIT 2
#define KEYSTROKE_BELL 4
#define KEYSTROKE_ABSORB 8
/*! \name Series of functions handling key stroke.
*/
/*@{*/
/**
* @brief Handle the input key stroke: Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Space(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Escape
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Esc(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Enter/Return
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Enter(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Delete
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Del(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Backspace
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Backspace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Tab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftLeft(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Left(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftRight(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Right(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Up
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Up(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Home
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Home(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: End
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_End(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageUp
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageUp(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageDown
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageDown(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Down
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Down(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Capslock
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Capslock(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: casual key
* @param ctx Chewing IM context
* @param key scan code of key stroke
*/
CHEWING_API int chewing_handle_Default(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Ctrl + Number-key
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_CtrlNum(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Shift + Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftSpace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: double Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_DblTab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Numlock (keypad)
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_Numlock(ChewingContext *ctx, int key);
/*@}*/
/*! \name Chewing IM Instance Management
*/
/*@{*/
/**
* @brief Create new handle of the instance for Chewing IM
* @see chewing_delete()
*/
CHEWING_API ChewingContext *chewing_new();
/**
* @brief Release the handle and internal memory by given Chewing instance
* @see chewing_new()
*
* @param ctx Chewing IM context
*/
CHEWING_API void chewing_delete(ChewingContext *ctx);
/**
* @brief Release memory allocated used by given pointer used in APIs
*/
CHEWING_API void chewing_free(void *);
/*@}*/
/*! \name Chewing IM Setup
*/
/**
* @brief Reset all settings
*
* @param ctx
* @return If successed than return 0
*/
CHEWING_API int chewing_Reset(ChewingContext *ctx);
/*@}*/
/*! \name Keyboard mapping
*/
/*@{*/
/**
* @brief Set keyboard mapping type
*
* @param ctx
* @param kbtype index number of keyboard mapping type from KBStr2Num
* @return If successed then return 0
*/
CHEWING_API int chewing_set_KBType(ChewingContext *ctx, int kbtype);
/**
* @brief Get keyboard mapping type
*
* @param ctx
* @return If successed then return keyboard mapping type from KBStr2Num
*/
CHEWING_API int chewing_get_KBType(const ChewingContext *ctx);
/**
* @brief Get keyboard mapping type in C-style string format
* @see KBStr2Num()
*
* @param ctx
* @return The name of the current keyboard layout. The caller must free it.
*/
CHEWING_API char *chewing_get_KBString(const ChewingContext *ctx);
/**
* @brief Get the index number of keyboard mapping type from given string
*
* @param str[] name of kbtype eg. "KB_HSU"
*/
CHEWING_API int chewing_KBStr2Num(const char str[]);
/*@}*/
/*! \name Operating language mode of Chewing IM
*/
/*@{*/
/**
* @brief Set the operating language mode of Chewing IM.
*
* @param ctx
* @param mode CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API void chewing_set_ChiEngMode(ChewingContext *ctx, int mode);
/**
* @brief Get current operating language mode: English / Chinese
*
* @param ctx
*
* @return CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API int chewing_get_ChiEngMode(const ChewingContext *ctx);
/*@*/
/*! \name Shape mode of output symbols
*/
/*@{*/
/**
* @brief Set the shape mode of output symbols: full-shape / half-shape
*
* @param ctx
* @param mode FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API void chewing_set_ShapeMode(ChewingContext *ctx, int mode);
/**
* @brief Get current shape mode of output symbols
*
* @param ctx
*
* @return FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API int chewing_get_ShapeMode(const ChewingContext *ctx);
/*@}*/
/*! \name Number of selection candidate per page
*/
/*@{*/
/**
* @brief Set the number of selection candidate per page
*
* @param ctx
* @param n number of selection candidate
*/
CHEWING_API void chewing_set_candPerPage(ChewingContext *ctx, int n);
/**
* @brief Get the number of selection candidate per page
*
* @param ctx
*/
CHEWING_API int chewing_get_candPerPage(const ChewingContext *ctx);
/*@}*/
/*! \name Maximum length of Chinese symbols
*/
/*@{*/
/**
* @brief Set the maximum length of Chinese symbols
*
* @param ctx
* @param n maximum length
*/
CHEWING_API void chewing_set_maxChiSymbolLen(ChewingContext *ctx, int n);
/**
* @brief Get the maximum length of Chinese symbols
*
* @param ctx
*/
CHEWING_API int chewing_get_maxChiSymbolLen(const ChewingContext *ctx);
/*@}*/
/*! \name Key sequence for selecting phrases
*/
/*@{*/
/**
* @brief Set the key sequence for selecting phrases
*
* @param ctx
* @param selkeys
* @param len
*/
CHEWING_API void chewing_set_selKey(ChewingContext *ctx, const int *selkeys, int len);
/**
* @brief Get the key sequence for selecting phrases
*
* @param ctx
*/
CHEWING_API int *chewing_get_selKey(const ChewingContext *ctx);
/*@}*/
/*! \name Direction of adding new user-defined phrases
*/
/*@{*/
/**
* @brief Set the direction of adding new user-defined phrases
*
* @param ctx
* @param direction
*/
CHEWING_API void chewing_set_addPhraseDirection(ChewingContext *ctx, int direction);
/**
* @brief Get the direction of adding new user-defined phrases
*
* @param ctx
*/
CHEWING_API int chewing_get_addPhraseDirection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if space key is regarded as selection key
*/
/*@{*/
/**
* @brief Set the behavior whether if space key is regarded as selection key
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_spaceAsSelection(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior if space key is regarded as selection key or not
*
* @param ctx
*/
CHEWING_API int chewing_get_spaceAsSelection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if Escape should clean all buffer
*/
/*@{*/
/**
* @brief Set the behavior whether if Escape key should clean all buffer
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_escCleanAllBuf(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior whether if Escape key should clean all buffer
*
* @param ctx
*/
CHEWING_API int chewing_get_escCleanAllBuf(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior of automatically shifting cursor after selection
*/
/*@{*/
/**
* @brief Set the behavior of automatically shifting cursor after selection
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_autoShiftCur(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior of automatically shifting cursor after selection
*
* @param ctx
*/
CHEWING_API int chewing_get_autoShiftCur(const ChewingContext *ctx);
/*@}*/
/*! \name Operating mode during easy symbol input
*/
/*@{*/
/**
* @brief Set the operating mode during easy symbol input
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_easySymbolInput(ChewingContext *ctx, int mode);
/**
* @brief Get the operating mode during easy symbol input
*
* @param ctx
*/
CHEWING_API int chewing_get_easySymbolInput(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior for phrase choice to be rearward or not
*/
/*@{*/
/**
* @brief Set the behavior for phrase choice to be rearward or not
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_phraseChoiceRearward(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior for phrase choice to be rearward or not
*
* @param ctx
*/
CHEWING_API int chewing_get_phraseChoiceRearward(const ChewingContext *ctx);
/*@}*/
/*! \name Phonetic sequence in Chewing internal state machine
*/
/*@{*/
/**
* @brief Get phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API unsigned short *chewing_get_phoneSeq(const ChewingContext *ctx);
/**
* @brief Get the length of phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API int chewing_get_phoneSeqLen(const ChewingContext *ctx);
/*@}*/
CHEWING_API void chewing_set_logger(ChewingContext *ctx,
void (*logger) (void *data, int level, const char *fmt, ...), void *data);
CHEWING_API int chewing_userphrase_enumerate(ChewingContext *ctx);
CHEWING_API int chewing_userphrase_has_next(ChewingContext *ctx, unsigned int *phrase_len, unsigned int *bopomofo_len);
CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
char *phrase_buf, unsigned int phrase_len,
char *bopomofo_buf, unsigned int bopomofo_len);
CHEWING_API int chewing_userphrase_add(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_remove(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_lookup(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_cand_list_first(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_last(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_prev(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_prev(ChewingContext *ctx);
CHEWING_API int chewing_commit_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_bopomofo_buf(ChewingContext *ctx);
CHEWING_API ChewingContext *chewing_new2(const char *syspath,
const char *userpath,
void (*logger) (void *data, int level, const char *fmt, ...),
void *loggerdata);
/* *INDENT-OFF* */
#endif /* _CHEWING_IO_H */
/* *INDENT-ON* */

View file

@ -0,0 +1,146 @@
/*
* global.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2006, 2008, 2011
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_GLOBAL_H
#define _CHEWING_GLOBAL_H
/* *INDENT-ON* */
/*! \file global.h
* \brief Chewing Global Definitions
* \author libchewing Core Team
*/
#define CHINESE_MODE 1
#define SYMBOL_MODE 0
#define FULLSHAPE_MODE 1
#define HALFSHAPE_MODE 0
/* specified to Chewing API */
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
# define CHEWING_DLL_IMPORT __declspec(dllimport)
# define CHEWING_DLL_EXPORT __declspec(dllexport)
# ifdef CHEWINGDLL_EXPORTS
# define CHEWING_API CHEWING_DLL_EXPORT
# define CHEWING_PRIVATE
# elif CHEWINGDLL_IMPORTS
# define CHEWING_API CHEWING_DLL_IMPORT
# define CHEWING_PRIVATE
# else
# define CHEWING_API
# define CHEWING_PRIVATE
# endif
#elif (__GNUC__ > 3) && (defined(__ELF__) || defined(__PIC__))
# define CHEWING_API __attribute__((__visibility__("default")))
# define CHEWING_PRIVATE __attribute__((__visibility__("hidden")))
#else
# define CHEWING_API
# define CHEWING_PRIVATE
#endif
#ifndef UNUSED
# if defined(__GNUC__) /* gcc specific */
# define UNUSED __attribute__((unused))
# else
# define UNUSED
# endif
#endif
#ifndef DEPRECATED
# if defined(__GNUC__) && __GNUC__ > 3 || \
(__GNUC__ == 3 && __GNUC_MINOR__ >= 1) /* gcc specific */
# define DEPRECATED __attribute__((deprecated))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead")))
# else
# define DEPRECATED_FOR(f) DEPRECATED
# endif
# else
# define DEPRECATED
# define DEPRECATED_FOR(f)
# endif
#endif
/* The following macros are modified from GLIB.
* from GNU cpp Manual:
* C99 introduces the _Pragma operator. This feature addresses a major problem
* with `#pragma': being a directive, it cannot be produced as the result of
* macro expansion. _Pragma is an operator, much like sizeof or defined, and
* can be embedded in a macro.
*/
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
# define BEGIN_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define END_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic pop")
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
# define BEGIN_IGNORE_DEPRECATIONS \
__pragma (warning (push)) \
__pragma (warning (disable : 4996))
# define END_IGNORE_DEPRECATIONS \
__pragma (warning (pop))
#else
# define BEGIN_IGNORE_DEPRECATIONS
# define END_IGNORE_DEPRECATIONS
#endif
#define MIN_SELKEY 1
#define MAX_SELKEY 10
#define CHEWING_LOG_VERBOSE 1
#define CHEWING_LOG_DEBUG 2
#define CHEWING_LOG_INFO 3
#define CHEWING_LOG_WARN 4
#define CHEWING_LOG_ERROR 5
/**
* @deprecated Use chewing_set_ series of functions to set parameters instead.
*/
typedef struct ChewingConfigData {
int candPerPage;
int maxChiSymbolLen;
int selKey[MAX_SELKEY];
int bAddPhraseForward;
int bSpaceAsSelection;
int bEscCleanAllBuf;
int bAutoShiftCur;
int bEasySymbolInput;
int bPhraseChoiceRearward;
int hsuSelKeyType; // Deprecated.
} ChewingConfigData;
typedef struct IntervalType {
/*@{ */
int from; /**< starting position of certain interval */
int to; /**< ending position of certain interval */
/*@} */
} IntervalType;
/** @brief context handle used for Chewing IM APIs
*/
typedef struct ChewingContext ChewingContext;
/** @brief use "asdfjkl789" as selection key
*/
#define HSU_SELKEY_TYPE1 1
/** @brief use "asdfzxcv89" as selection key
*/
#define HSU_SELKEY_TYPE2 2
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,113 @@
/*
* mod_aux.h
*
* Copyright (c) 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef CHEWING_MOD_AUX_H
#define CHEWING_MOD_AUX_H
/* *INDENT-ON* */
/*! \file mod_aux.h
* \brief Auxiliary module
* \author libchewing Core Team
*/
#include "global.h"
/**
* @brief Chewing the state for input context during commit process
* @param ctx handle to Chewing IM context
* @retval TRUE if its currnet input state is at the "end-of-a-char"
*/
CHEWING_API int chewing_commit_Check(const ChewingContext *ctx);
/**
* @brief Get current commit string regardless of current input state
* @param ctx handle to Chewing IM context
*
* Always returns a char pointer, caller must free it.
*/
CHEWING_API char *chewing_commit_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_commit_String_static(const ChewingContext *ctx);
/*! \name Preedit string buffer
*/
/*@{*/
CHEWING_API char *chewing_buffer_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_buffer_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Check(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Len(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API const char *chewing_bopomofo_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_bopomofo_Check(const ChewingContext *ctx);
/*@}*/
CHEWING_API int chewing_cursor_Current(const ChewingContext *ctx);
/*@{*/
CHEWING_API int chewing_cand_CheckDone(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_ChoicePerPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalChoice(const ChewingContext *ctx);
CHEWING_API int chewing_cand_CurrentPage(const ChewingContext *ctx);
CHEWING_API void chewing_cand_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_cand_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_cand_String(ChewingContext *ctx);
CHEWING_API const char *chewing_cand_String_static(ChewingContext *ctx);
CHEWING_API char *chewing_cand_string_by_index(ChewingContext *ctx, int index);
CHEWING_API const char *chewing_cand_string_by_index_static(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_choose_by_index(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_open(ChewingContext *ctx);
CHEWING_API int chewing_cand_close(ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API void chewing_interval_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_interval_hasNext(ChewingContext *ctx);
CHEWING_API void chewing_interval_Get(ChewingContext *ctx, IntervalType * it);
/*@}*/
/*@{*/
CHEWING_API int chewing_aux_Check(const ChewingContext *ctx);
CHEWING_API int chewing_aux_Length(const ChewingContext *ctx);
CHEWING_API char *chewing_aux_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_aux_String_static(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_keystroke_CheckIgnore(const ChewingContext *ctx);
CHEWING_API int chewing_keystroke_CheckAbsorb(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_kbtype_Total(const ChewingContext *ctx);
CHEWING_API void chewing_kbtype_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_kbtype_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_kbtype_String(ChewingContext *ctx);
CHEWING_API const char *chewing_kbtype_String_static(ChewingContext *ctx);
/*@}*/
/* *INDENT-OFF* */
#endif /* CHEWING_MOD_AUX_H */
/* *INDENT-ON* */

Binary file not shown.

View file

@ -0,0 +1,39 @@
/*
* chewing-compat.h
*
* Copyright (c) 2014
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/* *INDENT-ON* */
/** @brief indicate the internal encoding of data processing.
* @since 0.3.0
*/
#define LIBCHEWING_ENCODING "UTF-8"
/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(const ChewingContext *ctx)
DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(const ChewingContext *, int *zuin_count)
DEPRECATED_FOR(chewing_bopomofo_String_static);
CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath)
DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd)
DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode)
DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx)
DEPRECATED_FOR(chewing_get_selKey);
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,59 @@
/*
* chewing.h
*
* Copyright (c) 2004, 2005, 2006, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_CORE_
#define _CHEWING_CORE_
/* *INDENT-ON* */
#ifdef __cplusplus
extern "C" {
#endif
/*! \file chewing.h
* \brief Chewing Headers
* \author libchewing Core Team
* \mainpage Chewing API
*
* <center>API Collection of Chewing intelligent Chinese
* phonetic IM (Input Method).</center>
*
* <h1>Overview</h1>
*
* As far as we expect, input method (in fact, the way for text input and
* output, especially in multi-lingual environments) implementations are
* becoming more and more complex in system integrations. The emerging
* standard for practical and flexible development cycles is required, so that
* we are facing the impacts from various Chinese input method implementations
* and the integration into existing framework or system designs. At the
* result, Chewing Input Method (abbreviated as "Chewing") attempts to be one
* of the approaches to solve and ease the problems with the inclusion of base
* classes, on the basis of cross-platform, and cross-operating-environment
* derivative classes, which are built as the abstract backbone of intelligent
* Chinese phonetic input method implementations. From the perspectives,
* Chewing defines the abstract behavior how an intelligent phonetic IM should
* works via the common interface, and Chewing permits the extra parameters
* and properties for the input method implementations to extend their
* specific functionality.
*/
#include "chewingio.h"
#include "global.h"
#include "mod_aux.h"
/* backward compatibility */
#include "chewing-compat.h"
#ifdef __cplusplus
}
#endif
/* *INDENT-OFF* */
#endif /* _CHEWING_CORE_ */
/* *INDENT-ON* */

View file

@ -0,0 +1,557 @@
/*
* chewingio.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_IO_H
#define _CHEWING_IO_H
/* *INDENT-ON* */
/*! \file chewingio.h
* \brief Chewing I/O module
* \author libchewing Core Team
*/
#include "global.h"
#define KEYSTROKE_IGNORE 1
#define KEYSTROKE_COMMIT 2
#define KEYSTROKE_BELL 4
#define KEYSTROKE_ABSORB 8
/*! \name Series of functions handling key stroke.
*/
/*@{*/
/**
* @brief Handle the input key stroke: Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Space(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Escape
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Esc(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Enter/Return
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Enter(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Delete
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Del(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Backspace
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Backspace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Tab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftLeft(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Left(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftRight(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Right(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Up
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Up(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Home
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Home(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: End
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_End(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageUp
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageUp(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageDown
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageDown(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Down
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Down(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Capslock
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Capslock(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: casual key
* @param ctx Chewing IM context
* @param key scan code of key stroke
*/
CHEWING_API int chewing_handle_Default(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Ctrl + Number-key
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_CtrlNum(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Shift + Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftSpace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: double Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_DblTab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Numlock (keypad)
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_Numlock(ChewingContext *ctx, int key);
/*@}*/
/*! \name Chewing IM Instance Management
*/
/*@{*/
/**
* @brief Create new handle of the instance for Chewing IM
* @see chewing_delete()
*/
CHEWING_API ChewingContext *chewing_new();
/**
* @brief Release the handle and internal memory by given Chewing instance
* @see chewing_new()
*
* @param ctx Chewing IM context
*/
CHEWING_API void chewing_delete(ChewingContext *ctx);
/**
* @brief Release memory allocated used by given pointer used in APIs
*/
CHEWING_API void chewing_free(void *);
/*@}*/
/*! \name Chewing IM Setup
*/
/**
* @brief Reset all settings
*
* @param ctx
* @return If successed than return 0
*/
CHEWING_API int chewing_Reset(ChewingContext *ctx);
/*@}*/
/*! \name Keyboard mapping
*/
/*@{*/
/**
* @brief Set keyboard mapping type
*
* @param ctx
* @param kbtype index number of keyboard mapping type from KBStr2Num
* @return If successed then return 0
*/
CHEWING_API int chewing_set_KBType(ChewingContext *ctx, int kbtype);
/**
* @brief Get keyboard mapping type
*
* @param ctx
* @return If successed then return keyboard mapping type from KBStr2Num
*/
CHEWING_API int chewing_get_KBType(const ChewingContext *ctx);
/**
* @brief Get keyboard mapping type in C-style string format
* @see KBStr2Num()
*
* @param ctx
* @return The name of the current keyboard layout. The caller must free it.
*/
CHEWING_API char *chewing_get_KBString(const ChewingContext *ctx);
/**
* @brief Get the index number of keyboard mapping type from given string
*
* @param str[] name of kbtype eg. "KB_HSU"
*/
CHEWING_API int chewing_KBStr2Num(const char str[]);
/*@}*/
/*! \name Operating language mode of Chewing IM
*/
/*@{*/
/**
* @brief Set the operating language mode of Chewing IM.
*
* @param ctx
* @param mode CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API void chewing_set_ChiEngMode(ChewingContext *ctx, int mode);
/**
* @brief Get current operating language mode: English / Chinese
*
* @param ctx
*
* @return CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API int chewing_get_ChiEngMode(const ChewingContext *ctx);
/*@*/
/*! \name Shape mode of output symbols
*/
/*@{*/
/**
* @brief Set the shape mode of output symbols: full-shape / half-shape
*
* @param ctx
* @param mode FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API void chewing_set_ShapeMode(ChewingContext *ctx, int mode);
/**
* @brief Get current shape mode of output symbols
*
* @param ctx
*
* @return FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API int chewing_get_ShapeMode(const ChewingContext *ctx);
/*@}*/
/*! \name Number of selection candidate per page
*/
/*@{*/
/**
* @brief Set the number of selection candidate per page
*
* @param ctx
* @param n number of selection candidate
*/
CHEWING_API void chewing_set_candPerPage(ChewingContext *ctx, int n);
/**
* @brief Get the number of selection candidate per page
*
* @param ctx
*/
CHEWING_API int chewing_get_candPerPage(const ChewingContext *ctx);
/*@}*/
/*! \name Maximum length of Chinese symbols
*/
/*@{*/
/**
* @brief Set the maximum length of Chinese symbols
*
* @param ctx
* @param n maximum length
*/
CHEWING_API void chewing_set_maxChiSymbolLen(ChewingContext *ctx, int n);
/**
* @brief Get the maximum length of Chinese symbols
*
* @param ctx
*/
CHEWING_API int chewing_get_maxChiSymbolLen(const ChewingContext *ctx);
/*@}*/
/*! \name Key sequence for selecting phrases
*/
/*@{*/
/**
* @brief Set the key sequence for selecting phrases
*
* @param ctx
* @param selkeys
* @param len
*/
CHEWING_API void chewing_set_selKey(ChewingContext *ctx, const int *selkeys, int len);
/**
* @brief Get the key sequence for selecting phrases
*
* @param ctx
*/
CHEWING_API int *chewing_get_selKey(const ChewingContext *ctx);
/*@}*/
/*! \name Direction of adding new user-defined phrases
*/
/*@{*/
/**
* @brief Set the direction of adding new user-defined phrases
*
* @param ctx
* @param direction
*/
CHEWING_API void chewing_set_addPhraseDirection(ChewingContext *ctx, int direction);
/**
* @brief Get the direction of adding new user-defined phrases
*
* @param ctx
*/
CHEWING_API int chewing_get_addPhraseDirection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if space key is regarded as selection key
*/
/*@{*/
/**
* @brief Set the behavior whether if space key is regarded as selection key
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_spaceAsSelection(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior if space key is regarded as selection key or not
*
* @param ctx
*/
CHEWING_API int chewing_get_spaceAsSelection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if Escape should clean all buffer
*/
/*@{*/
/**
* @brief Set the behavior whether if Escape key should clean all buffer
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_escCleanAllBuf(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior whether if Escape key should clean all buffer
*
* @param ctx
*/
CHEWING_API int chewing_get_escCleanAllBuf(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior of automatically shifting cursor after selection
*/
/*@{*/
/**
* @brief Set the behavior of automatically shifting cursor after selection
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_autoShiftCur(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior of automatically shifting cursor after selection
*
* @param ctx
*/
CHEWING_API int chewing_get_autoShiftCur(const ChewingContext *ctx);
/*@}*/
/*! \name Operating mode during easy symbol input
*/
/*@{*/
/**
* @brief Set the operating mode during easy symbol input
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_easySymbolInput(ChewingContext *ctx, int mode);
/**
* @brief Get the operating mode during easy symbol input
*
* @param ctx
*/
CHEWING_API int chewing_get_easySymbolInput(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior for phrase choice to be rearward or not
*/
/*@{*/
/**
* @brief Set the behavior for phrase choice to be rearward or not
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_phraseChoiceRearward(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior for phrase choice to be rearward or not
*
* @param ctx
*/
CHEWING_API int chewing_get_phraseChoiceRearward(const ChewingContext *ctx);
/*@}*/
/*! \name Phonetic sequence in Chewing internal state machine
*/
/*@{*/
/**
* @brief Get phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API unsigned short *chewing_get_phoneSeq(const ChewingContext *ctx);
/**
* @brief Get the length of phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API int chewing_get_phoneSeqLen(const ChewingContext *ctx);
/*@}*/
CHEWING_API void chewing_set_logger(ChewingContext *ctx,
void (*logger) (void *data, int level, const char *fmt, ...), void *data);
CHEWING_API int chewing_userphrase_enumerate(ChewingContext *ctx);
CHEWING_API int chewing_userphrase_has_next(ChewingContext *ctx, unsigned int *phrase_len, unsigned int *bopomofo_len);
CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
char *phrase_buf, unsigned int phrase_len,
char *bopomofo_buf, unsigned int bopomofo_len);
CHEWING_API int chewing_userphrase_add(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_remove(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_lookup(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_cand_list_first(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_last(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_prev(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_prev(ChewingContext *ctx);
CHEWING_API int chewing_commit_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_bopomofo_buf(ChewingContext *ctx);
CHEWING_API ChewingContext *chewing_new2(const char *syspath,
const char *userpath,
void (*logger) (void *data, int level, const char *fmt, ...),
void *loggerdata);
/* *INDENT-OFF* */
#endif /* _CHEWING_IO_H */
/* *INDENT-ON* */

View file

@ -0,0 +1,146 @@
/*
* global.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2006, 2008, 2011
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_GLOBAL_H
#define _CHEWING_GLOBAL_H
/* *INDENT-ON* */
/*! \file global.h
* \brief Chewing Global Definitions
* \author libchewing Core Team
*/
#define CHINESE_MODE 1
#define SYMBOL_MODE 0
#define FULLSHAPE_MODE 1
#define HALFSHAPE_MODE 0
/* specified to Chewing API */
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
# define CHEWING_DLL_IMPORT __declspec(dllimport)
# define CHEWING_DLL_EXPORT __declspec(dllexport)
# ifdef CHEWINGDLL_EXPORTS
# define CHEWING_API CHEWING_DLL_EXPORT
# define CHEWING_PRIVATE
# elif CHEWINGDLL_IMPORTS
# define CHEWING_API CHEWING_DLL_IMPORT
# define CHEWING_PRIVATE
# else
# define CHEWING_API
# define CHEWING_PRIVATE
# endif
#elif (__GNUC__ > 3) && (defined(__ELF__) || defined(__PIC__))
# define CHEWING_API __attribute__((__visibility__("default")))
# define CHEWING_PRIVATE __attribute__((__visibility__("hidden")))
#else
# define CHEWING_API
# define CHEWING_PRIVATE
#endif
#ifndef UNUSED
# if defined(__GNUC__) /* gcc specific */
# define UNUSED __attribute__((unused))
# else
# define UNUSED
# endif
#endif
#ifndef DEPRECATED
# if defined(__GNUC__) && __GNUC__ > 3 || \
(__GNUC__ == 3 && __GNUC_MINOR__ >= 1) /* gcc specific */
# define DEPRECATED __attribute__((deprecated))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead")))
# else
# define DEPRECATED_FOR(f) DEPRECATED
# endif
# else
# define DEPRECATED
# define DEPRECATED_FOR(f)
# endif
#endif
/* The following macros are modified from GLIB.
* from GNU cpp Manual:
* C99 introduces the _Pragma operator. This feature addresses a major problem
* with `#pragma': being a directive, it cannot be produced as the result of
* macro expansion. _Pragma is an operator, much like sizeof or defined, and
* can be embedded in a macro.
*/
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
# define BEGIN_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define END_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic pop")
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
# define BEGIN_IGNORE_DEPRECATIONS \
__pragma (warning (push)) \
__pragma (warning (disable : 4996))
# define END_IGNORE_DEPRECATIONS \
__pragma (warning (pop))
#else
# define BEGIN_IGNORE_DEPRECATIONS
# define END_IGNORE_DEPRECATIONS
#endif
#define MIN_SELKEY 1
#define MAX_SELKEY 10
#define CHEWING_LOG_VERBOSE 1
#define CHEWING_LOG_DEBUG 2
#define CHEWING_LOG_INFO 3
#define CHEWING_LOG_WARN 4
#define CHEWING_LOG_ERROR 5
/**
* @deprecated Use chewing_set_ series of functions to set parameters instead.
*/
typedef struct ChewingConfigData {
int candPerPage;
int maxChiSymbolLen;
int selKey[MAX_SELKEY];
int bAddPhraseForward;
int bSpaceAsSelection;
int bEscCleanAllBuf;
int bAutoShiftCur;
int bEasySymbolInput;
int bPhraseChoiceRearward;
int hsuSelKeyType; // Deprecated.
} ChewingConfigData;
typedef struct IntervalType {
/*@{ */
int from; /**< starting position of certain interval */
int to; /**< ending position of certain interval */
/*@} */
} IntervalType;
/** @brief context handle used for Chewing IM APIs
*/
typedef struct ChewingContext ChewingContext;
/** @brief use "asdfjkl789" as selection key
*/
#define HSU_SELKEY_TYPE1 1
/** @brief use "asdfzxcv89" as selection key
*/
#define HSU_SELKEY_TYPE2 2
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,113 @@
/*
* mod_aux.h
*
* Copyright (c) 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef CHEWING_MOD_AUX_H
#define CHEWING_MOD_AUX_H
/* *INDENT-ON* */
/*! \file mod_aux.h
* \brief Auxiliary module
* \author libchewing Core Team
*/
#include "global.h"
/**
* @brief Chewing the state for input context during commit process
* @param ctx handle to Chewing IM context
* @retval TRUE if its currnet input state is at the "end-of-a-char"
*/
CHEWING_API int chewing_commit_Check(const ChewingContext *ctx);
/**
* @brief Get current commit string regardless of current input state
* @param ctx handle to Chewing IM context
*
* Always returns a char pointer, caller must free it.
*/
CHEWING_API char *chewing_commit_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_commit_String_static(const ChewingContext *ctx);
/*! \name Preedit string buffer
*/
/*@{*/
CHEWING_API char *chewing_buffer_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_buffer_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Check(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Len(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API const char *chewing_bopomofo_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_bopomofo_Check(const ChewingContext *ctx);
/*@}*/
CHEWING_API int chewing_cursor_Current(const ChewingContext *ctx);
/*@{*/
CHEWING_API int chewing_cand_CheckDone(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_ChoicePerPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalChoice(const ChewingContext *ctx);
CHEWING_API int chewing_cand_CurrentPage(const ChewingContext *ctx);
CHEWING_API void chewing_cand_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_cand_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_cand_String(ChewingContext *ctx);
CHEWING_API const char *chewing_cand_String_static(ChewingContext *ctx);
CHEWING_API char *chewing_cand_string_by_index(ChewingContext *ctx, int index);
CHEWING_API const char *chewing_cand_string_by_index_static(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_choose_by_index(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_open(ChewingContext *ctx);
CHEWING_API int chewing_cand_close(ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API void chewing_interval_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_interval_hasNext(ChewingContext *ctx);
CHEWING_API void chewing_interval_Get(ChewingContext *ctx, IntervalType * it);
/*@}*/
/*@{*/
CHEWING_API int chewing_aux_Check(const ChewingContext *ctx);
CHEWING_API int chewing_aux_Length(const ChewingContext *ctx);
CHEWING_API char *chewing_aux_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_aux_String_static(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_keystroke_CheckIgnore(const ChewingContext *ctx);
CHEWING_API int chewing_keystroke_CheckAbsorb(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_kbtype_Total(const ChewingContext *ctx);
CHEWING_API void chewing_kbtype_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_kbtype_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_kbtype_String(ChewingContext *ctx);
CHEWING_API const char *chewing_kbtype_String_static(ChewingContext *ctx);
/*@}*/
/* *INDENT-OFF* */
#endif /* CHEWING_MOD_AUX_H */
/* *INDENT-ON* */

Binary file not shown.

View file

@ -0,0 +1,39 @@
/*
* chewing-compat.h
*
* Copyright (c) 2014
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/* *INDENT-ON* */
/** @brief indicate the internal encoding of data processing.
* @since 0.3.0
*/
#define LIBCHEWING_ENCODING "UTF-8"
/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(const ChewingContext *ctx)
DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(const ChewingContext *, int *zuin_count)
DEPRECATED_FOR(chewing_bopomofo_String_static);
CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath)
DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd)
DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode)
DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx)
DEPRECATED_FOR(chewing_get_selKey);
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,59 @@
/*
* chewing.h
*
* Copyright (c) 2004, 2005, 2006, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_CORE_
#define _CHEWING_CORE_
/* *INDENT-ON* */
#ifdef __cplusplus
extern "C" {
#endif
/*! \file chewing.h
* \brief Chewing Headers
* \author libchewing Core Team
* \mainpage Chewing API
*
* <center>API Collection of Chewing intelligent Chinese
* phonetic IM (Input Method).</center>
*
* <h1>Overview</h1>
*
* As far as we expect, input method (in fact, the way for text input and
* output, especially in multi-lingual environments) implementations are
* becoming more and more complex in system integrations. The emerging
* standard for practical and flexible development cycles is required, so that
* we are facing the impacts from various Chinese input method implementations
* and the integration into existing framework or system designs. At the
* result, Chewing Input Method (abbreviated as "Chewing") attempts to be one
* of the approaches to solve and ease the problems with the inclusion of base
* classes, on the basis of cross-platform, and cross-operating-environment
* derivative classes, which are built as the abstract backbone of intelligent
* Chinese phonetic input method implementations. From the perspectives,
* Chewing defines the abstract behavior how an intelligent phonetic IM should
* works via the common interface, and Chewing permits the extra parameters
* and properties for the input method implementations to extend their
* specific functionality.
*/
#include "chewingio.h"
#include "global.h"
#include "mod_aux.h"
/* backward compatibility */
#include "chewing-compat.h"
#ifdef __cplusplus
}
#endif
/* *INDENT-OFF* */
#endif /* _CHEWING_CORE_ */
/* *INDENT-ON* */

View file

@ -0,0 +1,557 @@
/*
* chewingio.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_IO_H
#define _CHEWING_IO_H
/* *INDENT-ON* */
/*! \file chewingio.h
* \brief Chewing I/O module
* \author libchewing Core Team
*/
#include "global.h"
#define KEYSTROKE_IGNORE 1
#define KEYSTROKE_COMMIT 2
#define KEYSTROKE_BELL 4
#define KEYSTROKE_ABSORB 8
/*! \name Series of functions handling key stroke.
*/
/*@{*/
/**
* @brief Handle the input key stroke: Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Space(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Escape
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Esc(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Enter/Return
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Enter(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Delete
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Del(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Backspace
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Backspace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Tab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftLeft(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Left(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftRight(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Right(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Up
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Up(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Home
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Home(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: End
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_End(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageUp
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageUp(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageDown
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageDown(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Down
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Down(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Capslock
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Capslock(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: casual key
* @param ctx Chewing IM context
* @param key scan code of key stroke
*/
CHEWING_API int chewing_handle_Default(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Ctrl + Number-key
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_CtrlNum(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Shift + Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftSpace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: double Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_DblTab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Numlock (keypad)
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_Numlock(ChewingContext *ctx, int key);
/*@}*/
/*! \name Chewing IM Instance Management
*/
/*@{*/
/**
* @brief Create new handle of the instance for Chewing IM
* @see chewing_delete()
*/
CHEWING_API ChewingContext *chewing_new();
/**
* @brief Release the handle and internal memory by given Chewing instance
* @see chewing_new()
*
* @param ctx Chewing IM context
*/
CHEWING_API void chewing_delete(ChewingContext *ctx);
/**
* @brief Release memory allocated used by given pointer used in APIs
*/
CHEWING_API void chewing_free(void *);
/*@}*/
/*! \name Chewing IM Setup
*/
/**
* @brief Reset all settings
*
* @param ctx
* @return If successed than return 0
*/
CHEWING_API int chewing_Reset(ChewingContext *ctx);
/*@}*/
/*! \name Keyboard mapping
*/
/*@{*/
/**
* @brief Set keyboard mapping type
*
* @param ctx
* @param kbtype index number of keyboard mapping type from KBStr2Num
* @return If successed then return 0
*/
CHEWING_API int chewing_set_KBType(ChewingContext *ctx, int kbtype);
/**
* @brief Get keyboard mapping type
*
* @param ctx
* @return If successed then return keyboard mapping type from KBStr2Num
*/
CHEWING_API int chewing_get_KBType(const ChewingContext *ctx);
/**
* @brief Get keyboard mapping type in C-style string format
* @see KBStr2Num()
*
* @param ctx
* @return The name of the current keyboard layout. The caller must free it.
*/
CHEWING_API char *chewing_get_KBString(const ChewingContext *ctx);
/**
* @brief Get the index number of keyboard mapping type from given string
*
* @param str[] name of kbtype eg. "KB_HSU"
*/
CHEWING_API int chewing_KBStr2Num(const char str[]);
/*@}*/
/*! \name Operating language mode of Chewing IM
*/
/*@{*/
/**
* @brief Set the operating language mode of Chewing IM.
*
* @param ctx
* @param mode CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API void chewing_set_ChiEngMode(ChewingContext *ctx, int mode);
/**
* @brief Get current operating language mode: English / Chinese
*
* @param ctx
*
* @return CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API int chewing_get_ChiEngMode(const ChewingContext *ctx);
/*@*/
/*! \name Shape mode of output symbols
*/
/*@{*/
/**
* @brief Set the shape mode of output symbols: full-shape / half-shape
*
* @param ctx
* @param mode FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API void chewing_set_ShapeMode(ChewingContext *ctx, int mode);
/**
* @brief Get current shape mode of output symbols
*
* @param ctx
*
* @return FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API int chewing_get_ShapeMode(const ChewingContext *ctx);
/*@}*/
/*! \name Number of selection candidate per page
*/
/*@{*/
/**
* @brief Set the number of selection candidate per page
*
* @param ctx
* @param n number of selection candidate
*/
CHEWING_API void chewing_set_candPerPage(ChewingContext *ctx, int n);
/**
* @brief Get the number of selection candidate per page
*
* @param ctx
*/
CHEWING_API int chewing_get_candPerPage(const ChewingContext *ctx);
/*@}*/
/*! \name Maximum length of Chinese symbols
*/
/*@{*/
/**
* @brief Set the maximum length of Chinese symbols
*
* @param ctx
* @param n maximum length
*/
CHEWING_API void chewing_set_maxChiSymbolLen(ChewingContext *ctx, int n);
/**
* @brief Get the maximum length of Chinese symbols
*
* @param ctx
*/
CHEWING_API int chewing_get_maxChiSymbolLen(const ChewingContext *ctx);
/*@}*/
/*! \name Key sequence for selecting phrases
*/
/*@{*/
/**
* @brief Set the key sequence for selecting phrases
*
* @param ctx
* @param selkeys
* @param len
*/
CHEWING_API void chewing_set_selKey(ChewingContext *ctx, const int *selkeys, int len);
/**
* @brief Get the key sequence for selecting phrases
*
* @param ctx
*/
CHEWING_API int *chewing_get_selKey(const ChewingContext *ctx);
/*@}*/
/*! \name Direction of adding new user-defined phrases
*/
/*@{*/
/**
* @brief Set the direction of adding new user-defined phrases
*
* @param ctx
* @param direction
*/
CHEWING_API void chewing_set_addPhraseDirection(ChewingContext *ctx, int direction);
/**
* @brief Get the direction of adding new user-defined phrases
*
* @param ctx
*/
CHEWING_API int chewing_get_addPhraseDirection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if space key is regarded as selection key
*/
/*@{*/
/**
* @brief Set the behavior whether if space key is regarded as selection key
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_spaceAsSelection(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior if space key is regarded as selection key or not
*
* @param ctx
*/
CHEWING_API int chewing_get_spaceAsSelection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if Escape should clean all buffer
*/
/*@{*/
/**
* @brief Set the behavior whether if Escape key should clean all buffer
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_escCleanAllBuf(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior whether if Escape key should clean all buffer
*
* @param ctx
*/
CHEWING_API int chewing_get_escCleanAllBuf(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior of automatically shifting cursor after selection
*/
/*@{*/
/**
* @brief Set the behavior of automatically shifting cursor after selection
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_autoShiftCur(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior of automatically shifting cursor after selection
*
* @param ctx
*/
CHEWING_API int chewing_get_autoShiftCur(const ChewingContext *ctx);
/*@}*/
/*! \name Operating mode during easy symbol input
*/
/*@{*/
/**
* @brief Set the operating mode during easy symbol input
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_easySymbolInput(ChewingContext *ctx, int mode);
/**
* @brief Get the operating mode during easy symbol input
*
* @param ctx
*/
CHEWING_API int chewing_get_easySymbolInput(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior for phrase choice to be rearward or not
*/
/*@{*/
/**
* @brief Set the behavior for phrase choice to be rearward or not
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_phraseChoiceRearward(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior for phrase choice to be rearward or not
*
* @param ctx
*/
CHEWING_API int chewing_get_phraseChoiceRearward(const ChewingContext *ctx);
/*@}*/
/*! \name Phonetic sequence in Chewing internal state machine
*/
/*@{*/
/**
* @brief Get phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API unsigned short *chewing_get_phoneSeq(const ChewingContext *ctx);
/**
* @brief Get the length of phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API int chewing_get_phoneSeqLen(const ChewingContext *ctx);
/*@}*/
CHEWING_API void chewing_set_logger(ChewingContext *ctx,
void (*logger) (void *data, int level, const char *fmt, ...), void *data);
CHEWING_API int chewing_userphrase_enumerate(ChewingContext *ctx);
CHEWING_API int chewing_userphrase_has_next(ChewingContext *ctx, unsigned int *phrase_len, unsigned int *bopomofo_len);
CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
char *phrase_buf, unsigned int phrase_len,
char *bopomofo_buf, unsigned int bopomofo_len);
CHEWING_API int chewing_userphrase_add(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_remove(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_lookup(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_cand_list_first(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_last(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_prev(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_prev(ChewingContext *ctx);
CHEWING_API int chewing_commit_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_bopomofo_buf(ChewingContext *ctx);
CHEWING_API ChewingContext *chewing_new2(const char *syspath,
const char *userpath,
void (*logger) (void *data, int level, const char *fmt, ...),
void *loggerdata);
/* *INDENT-OFF* */
#endif /* _CHEWING_IO_H */
/* *INDENT-ON* */

View file

@ -0,0 +1,146 @@
/*
* global.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2006, 2008, 2011
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_GLOBAL_H
#define _CHEWING_GLOBAL_H
/* *INDENT-ON* */
/*! \file global.h
* \brief Chewing Global Definitions
* \author libchewing Core Team
*/
#define CHINESE_MODE 1
#define SYMBOL_MODE 0
#define FULLSHAPE_MODE 1
#define HALFSHAPE_MODE 0
/* specified to Chewing API */
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
# define CHEWING_DLL_IMPORT __declspec(dllimport)
# define CHEWING_DLL_EXPORT __declspec(dllexport)
# ifdef CHEWINGDLL_EXPORTS
# define CHEWING_API CHEWING_DLL_EXPORT
# define CHEWING_PRIVATE
# elif CHEWINGDLL_IMPORTS
# define CHEWING_API CHEWING_DLL_IMPORT
# define CHEWING_PRIVATE
# else
# define CHEWING_API
# define CHEWING_PRIVATE
# endif
#elif (__GNUC__ > 3) && (defined(__ELF__) || defined(__PIC__))
# define CHEWING_API __attribute__((__visibility__("default")))
# define CHEWING_PRIVATE __attribute__((__visibility__("hidden")))
#else
# define CHEWING_API
# define CHEWING_PRIVATE
#endif
#ifndef UNUSED
# if defined(__GNUC__) /* gcc specific */
# define UNUSED __attribute__((unused))
# else
# define UNUSED
# endif
#endif
#ifndef DEPRECATED
# if defined(__GNUC__) && __GNUC__ > 3 || \
(__GNUC__ == 3 && __GNUC_MINOR__ >= 1) /* gcc specific */
# define DEPRECATED __attribute__((deprecated))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead")))
# else
# define DEPRECATED_FOR(f) DEPRECATED
# endif
# else
# define DEPRECATED
# define DEPRECATED_FOR(f)
# endif
#endif
/* The following macros are modified from GLIB.
* from GNU cpp Manual:
* C99 introduces the _Pragma operator. This feature addresses a major problem
* with `#pragma': being a directive, it cannot be produced as the result of
* macro expansion. _Pragma is an operator, much like sizeof or defined, and
* can be embedded in a macro.
*/
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
# define BEGIN_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define END_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic pop")
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
# define BEGIN_IGNORE_DEPRECATIONS \
__pragma (warning (push)) \
__pragma (warning (disable : 4996))
# define END_IGNORE_DEPRECATIONS \
__pragma (warning (pop))
#else
# define BEGIN_IGNORE_DEPRECATIONS
# define END_IGNORE_DEPRECATIONS
#endif
#define MIN_SELKEY 1
#define MAX_SELKEY 10
#define CHEWING_LOG_VERBOSE 1
#define CHEWING_LOG_DEBUG 2
#define CHEWING_LOG_INFO 3
#define CHEWING_LOG_WARN 4
#define CHEWING_LOG_ERROR 5
/**
* @deprecated Use chewing_set_ series of functions to set parameters instead.
*/
typedef struct ChewingConfigData {
int candPerPage;
int maxChiSymbolLen;
int selKey[MAX_SELKEY];
int bAddPhraseForward;
int bSpaceAsSelection;
int bEscCleanAllBuf;
int bAutoShiftCur;
int bEasySymbolInput;
int bPhraseChoiceRearward;
int hsuSelKeyType; // Deprecated.
} ChewingConfigData;
typedef struct IntervalType {
/*@{ */
int from; /**< starting position of certain interval */
int to; /**< ending position of certain interval */
/*@} */
} IntervalType;
/** @brief context handle used for Chewing IM APIs
*/
typedef struct ChewingContext ChewingContext;
/** @brief use "asdfjkl789" as selection key
*/
#define HSU_SELKEY_TYPE1 1
/** @brief use "asdfzxcv89" as selection key
*/
#define HSU_SELKEY_TYPE2 2
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,113 @@
/*
* mod_aux.h
*
* Copyright (c) 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef CHEWING_MOD_AUX_H
#define CHEWING_MOD_AUX_H
/* *INDENT-ON* */
/*! \file mod_aux.h
* \brief Auxiliary module
* \author libchewing Core Team
*/
#include "global.h"
/**
* @brief Chewing the state for input context during commit process
* @param ctx handle to Chewing IM context
* @retval TRUE if its currnet input state is at the "end-of-a-char"
*/
CHEWING_API int chewing_commit_Check(const ChewingContext *ctx);
/**
* @brief Get current commit string regardless of current input state
* @param ctx handle to Chewing IM context
*
* Always returns a char pointer, caller must free it.
*/
CHEWING_API char *chewing_commit_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_commit_String_static(const ChewingContext *ctx);
/*! \name Preedit string buffer
*/
/*@{*/
CHEWING_API char *chewing_buffer_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_buffer_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Check(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Len(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API const char *chewing_bopomofo_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_bopomofo_Check(const ChewingContext *ctx);
/*@}*/
CHEWING_API int chewing_cursor_Current(const ChewingContext *ctx);
/*@{*/
CHEWING_API int chewing_cand_CheckDone(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_ChoicePerPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalChoice(const ChewingContext *ctx);
CHEWING_API int chewing_cand_CurrentPage(const ChewingContext *ctx);
CHEWING_API void chewing_cand_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_cand_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_cand_String(ChewingContext *ctx);
CHEWING_API const char *chewing_cand_String_static(ChewingContext *ctx);
CHEWING_API char *chewing_cand_string_by_index(ChewingContext *ctx, int index);
CHEWING_API const char *chewing_cand_string_by_index_static(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_choose_by_index(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_open(ChewingContext *ctx);
CHEWING_API int chewing_cand_close(ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API void chewing_interval_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_interval_hasNext(ChewingContext *ctx);
CHEWING_API void chewing_interval_Get(ChewingContext *ctx, IntervalType * it);
/*@}*/
/*@{*/
CHEWING_API int chewing_aux_Check(const ChewingContext *ctx);
CHEWING_API int chewing_aux_Length(const ChewingContext *ctx);
CHEWING_API char *chewing_aux_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_aux_String_static(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_keystroke_CheckIgnore(const ChewingContext *ctx);
CHEWING_API int chewing_keystroke_CheckAbsorb(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_kbtype_Total(const ChewingContext *ctx);
CHEWING_API void chewing_kbtype_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_kbtype_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_kbtype_String(ChewingContext *ctx);
CHEWING_API const char *chewing_kbtype_String_static(ChewingContext *ctx);
/*@}*/
/* *INDENT-OFF* */
#endif /* CHEWING_MOD_AUX_H */
/* *INDENT-ON* */

Binary file not shown.

View file

@ -0,0 +1,39 @@
/*
* chewing-compat.h
*
* Copyright (c) 2014
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/* *INDENT-ON* */
/** @brief indicate the internal encoding of data processing.
* @since 0.3.0
*/
#define LIBCHEWING_ENCODING "UTF-8"
/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(const ChewingContext *ctx)
DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(const ChewingContext *, int *zuin_count)
DEPRECATED_FOR(chewing_bopomofo_String_static);
CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath)
DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd)
DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode)
DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx)
DEPRECATED_FOR(chewing_get_selKey);
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,59 @@
/*
* chewing.h
*
* Copyright (c) 2004, 2005, 2006, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_CORE_
#define _CHEWING_CORE_
/* *INDENT-ON* */
#ifdef __cplusplus
extern "C" {
#endif
/*! \file chewing.h
* \brief Chewing Headers
* \author libchewing Core Team
* \mainpage Chewing API
*
* <center>API Collection of Chewing intelligent Chinese
* phonetic IM (Input Method).</center>
*
* <h1>Overview</h1>
*
* As far as we expect, input method (in fact, the way for text input and
* output, especially in multi-lingual environments) implementations are
* becoming more and more complex in system integrations. The emerging
* standard for practical and flexible development cycles is required, so that
* we are facing the impacts from various Chinese input method implementations
* and the integration into existing framework or system designs. At the
* result, Chewing Input Method (abbreviated as "Chewing") attempts to be one
* of the approaches to solve and ease the problems with the inclusion of base
* classes, on the basis of cross-platform, and cross-operating-environment
* derivative classes, which are built as the abstract backbone of intelligent
* Chinese phonetic input method implementations. From the perspectives,
* Chewing defines the abstract behavior how an intelligent phonetic IM should
* works via the common interface, and Chewing permits the extra parameters
* and properties for the input method implementations to extend their
* specific functionality.
*/
#include "chewingio.h"
#include "global.h"
#include "mod_aux.h"
/* backward compatibility */
#include "chewing-compat.h"
#ifdef __cplusplus
}
#endif
/* *INDENT-OFF* */
#endif /* _CHEWING_CORE_ */
/* *INDENT-ON* */

View file

@ -0,0 +1,557 @@
/*
* chewingio.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_IO_H
#define _CHEWING_IO_H
/* *INDENT-ON* */
/*! \file chewingio.h
* \brief Chewing I/O module
* \author libchewing Core Team
*/
#include "global.h"
#define KEYSTROKE_IGNORE 1
#define KEYSTROKE_COMMIT 2
#define KEYSTROKE_BELL 4
#define KEYSTROKE_ABSORB 8
/*! \name Series of functions handling key stroke.
*/
/*@{*/
/**
* @brief Handle the input key stroke: Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Space(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Escape
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Esc(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Enter/Return
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Enter(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Delete
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Del(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Backspace
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Backspace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Tab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftLeft(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Left
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Left(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Shift + Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftRight(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Right
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Right(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Up
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Up(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Home
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Home(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: End
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_End(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageUp
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageUp(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: PageDown
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_PageDown(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Down
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Down(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Capslock
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_Capslock(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: casual key
* @param ctx Chewing IM context
* @param key scan code of key stroke
*/
CHEWING_API int chewing_handle_Default(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Ctrl + Number-key
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_CtrlNum(ChewingContext *ctx, int key);
/**
* @brief Handle the input key stroke: Shift + Space
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_ShiftSpace(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: double Tab
* @param ctx Chewing IM context
*/
CHEWING_API int chewing_handle_DblTab(ChewingContext *ctx);
/**
* @brief Handle the input key stroke: Numlock (keypad)
* @param ctx Chewing IM context
* @param key scan code of number key
*/
CHEWING_API int chewing_handle_Numlock(ChewingContext *ctx, int key);
/*@}*/
/*! \name Chewing IM Instance Management
*/
/*@{*/
/**
* @brief Create new handle of the instance for Chewing IM
* @see chewing_delete()
*/
CHEWING_API ChewingContext *chewing_new();
/**
* @brief Release the handle and internal memory by given Chewing instance
* @see chewing_new()
*
* @param ctx Chewing IM context
*/
CHEWING_API void chewing_delete(ChewingContext *ctx);
/**
* @brief Release memory allocated used by given pointer used in APIs
*/
CHEWING_API void chewing_free(void *);
/*@}*/
/*! \name Chewing IM Setup
*/
/**
* @brief Reset all settings
*
* @param ctx
* @return If successed than return 0
*/
CHEWING_API int chewing_Reset(ChewingContext *ctx);
/*@}*/
/*! \name Keyboard mapping
*/
/*@{*/
/**
* @brief Set keyboard mapping type
*
* @param ctx
* @param kbtype index number of keyboard mapping type from KBStr2Num
* @return If successed then return 0
*/
CHEWING_API int chewing_set_KBType(ChewingContext *ctx, int kbtype);
/**
* @brief Get keyboard mapping type
*
* @param ctx
* @return If successed then return keyboard mapping type from KBStr2Num
*/
CHEWING_API int chewing_get_KBType(const ChewingContext *ctx);
/**
* @brief Get keyboard mapping type in C-style string format
* @see KBStr2Num()
*
* @param ctx
* @return The name of the current keyboard layout. The caller must free it.
*/
CHEWING_API char *chewing_get_KBString(const ChewingContext *ctx);
/**
* @brief Get the index number of keyboard mapping type from given string
*
* @param str[] name of kbtype eg. "KB_HSU"
*/
CHEWING_API int chewing_KBStr2Num(const char str[]);
/*@}*/
/*! \name Operating language mode of Chewing IM
*/
/*@{*/
/**
* @brief Set the operating language mode of Chewing IM.
*
* @param ctx
* @param mode CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API void chewing_set_ChiEngMode(ChewingContext *ctx, int mode);
/**
* @brief Get current operating language mode: English / Chinese
*
* @param ctx
*
* @return CHINESE_MODE or ENGLISH_MODE
*/
CHEWING_API int chewing_get_ChiEngMode(const ChewingContext *ctx);
/*@*/
/*! \name Shape mode of output symbols
*/
/*@{*/
/**
* @brief Set the shape mode of output symbols: full-shape / half-shape
*
* @param ctx
* @param mode FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API void chewing_set_ShapeMode(ChewingContext *ctx, int mode);
/**
* @brief Get current shape mode of output symbols
*
* @param ctx
*
* @return FULLSHAPE_MODE or HALFSHAPE_MODE
*/
CHEWING_API int chewing_get_ShapeMode(const ChewingContext *ctx);
/*@}*/
/*! \name Number of selection candidate per page
*/
/*@{*/
/**
* @brief Set the number of selection candidate per page
*
* @param ctx
* @param n number of selection candidate
*/
CHEWING_API void chewing_set_candPerPage(ChewingContext *ctx, int n);
/**
* @brief Get the number of selection candidate per page
*
* @param ctx
*/
CHEWING_API int chewing_get_candPerPage(const ChewingContext *ctx);
/*@}*/
/*! \name Maximum length of Chinese symbols
*/
/*@{*/
/**
* @brief Set the maximum length of Chinese symbols
*
* @param ctx
* @param n maximum length
*/
CHEWING_API void chewing_set_maxChiSymbolLen(ChewingContext *ctx, int n);
/**
* @brief Get the maximum length of Chinese symbols
*
* @param ctx
*/
CHEWING_API int chewing_get_maxChiSymbolLen(const ChewingContext *ctx);
/*@}*/
/*! \name Key sequence for selecting phrases
*/
/*@{*/
/**
* @brief Set the key sequence for selecting phrases
*
* @param ctx
* @param selkeys
* @param len
*/
CHEWING_API void chewing_set_selKey(ChewingContext *ctx, const int *selkeys, int len);
/**
* @brief Get the key sequence for selecting phrases
*
* @param ctx
*/
CHEWING_API int *chewing_get_selKey(const ChewingContext *ctx);
/*@}*/
/*! \name Direction of adding new user-defined phrases
*/
/*@{*/
/**
* @brief Set the direction of adding new user-defined phrases
*
* @param ctx
* @param direction
*/
CHEWING_API void chewing_set_addPhraseDirection(ChewingContext *ctx, int direction);
/**
* @brief Get the direction of adding new user-defined phrases
*
* @param ctx
*/
CHEWING_API int chewing_get_addPhraseDirection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if space key is regarded as selection key
*/
/*@{*/
/**
* @brief Set the behavior whether if space key is regarded as selection key
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_spaceAsSelection(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior if space key is regarded as selection key or not
*
* @param ctx
*/
CHEWING_API int chewing_get_spaceAsSelection(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior whether if Escape should clean all buffer
*/
/*@{*/
/**
* @brief Set the behavior whether if Escape key should clean all buffer
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_escCleanAllBuf(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior whether if Escape key should clean all buffer
*
* @param ctx
*/
CHEWING_API int chewing_get_escCleanAllBuf(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior of automatically shifting cursor after selection
*/
/*@{*/
/**
* @brief Set the behavior of automatically shifting cursor after selection
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_autoShiftCur(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior of automatically shifting cursor after selection
*
* @param ctx
*/
CHEWING_API int chewing_get_autoShiftCur(const ChewingContext *ctx);
/*@}*/
/*! \name Operating mode during easy symbol input
*/
/*@{*/
/**
* @brief Set the operating mode during easy symbol input
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_easySymbolInput(ChewingContext *ctx, int mode);
/**
* @brief Get the operating mode during easy symbol input
*
* @param ctx
*/
CHEWING_API int chewing_get_easySymbolInput(const ChewingContext *ctx);
/*@}*/
/*! \name Behavior for phrase choice to be rearward or not
*/
/*@{*/
/**
* @brief Set the behavior for phrase choice to be rearward or not
*
* @param ctx
* @param mode
*/
CHEWING_API void chewing_set_phraseChoiceRearward(ChewingContext *ctx, int mode);
/**
* @brief Get the behavior for phrase choice to be rearward or not
*
* @param ctx
*/
CHEWING_API int chewing_get_phraseChoiceRearward(const ChewingContext *ctx);
/*@}*/
/*! \name Phonetic sequence in Chewing internal state machine
*/
/*@{*/
/**
* @brief Get phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API unsigned short *chewing_get_phoneSeq(const ChewingContext *ctx);
/**
* @brief Get the length of phonetic sequence in Chewing internal state machine
*
* @param ctx
*/
CHEWING_API int chewing_get_phoneSeqLen(const ChewingContext *ctx);
/*@}*/
CHEWING_API void chewing_set_logger(ChewingContext *ctx,
void (*logger) (void *data, int level, const char *fmt, ...), void *data);
CHEWING_API int chewing_userphrase_enumerate(ChewingContext *ctx);
CHEWING_API int chewing_userphrase_has_next(ChewingContext *ctx, unsigned int *phrase_len, unsigned int *bopomofo_len);
CHEWING_API int chewing_userphrase_get(ChewingContext *ctx,
char *phrase_buf, unsigned int phrase_len,
char *bopomofo_buf, unsigned int bopomofo_len);
CHEWING_API int chewing_userphrase_add(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_remove(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_userphrase_lookup(ChewingContext *ctx, const char *phrase_buf, const char *bopomofo_buf);
CHEWING_API int chewing_cand_list_first(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_last(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_has_prev(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_next(ChewingContext *ctx);
CHEWING_API int chewing_cand_list_prev(ChewingContext *ctx);
CHEWING_API int chewing_commit_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_preedit_buf(ChewingContext *ctx);
CHEWING_API int chewing_clean_bopomofo_buf(ChewingContext *ctx);
CHEWING_API ChewingContext *chewing_new2(const char *syspath,
const char *userpath,
void (*logger) (void *data, int level, const char *fmt, ...),
void *loggerdata);
/* *INDENT-OFF* */
#endif /* _CHEWING_IO_H */
/* *INDENT-ON* */

View file

@ -0,0 +1,146 @@
/*
* global.h
*
* Copyright (c) 1999, 2000, 2001
* Lu-chuan Kung and Kang-pen Chen.
* All rights reserved.
*
* Copyright (c) 2004, 2005, 2006, 2008, 2011
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef _CHEWING_GLOBAL_H
#define _CHEWING_GLOBAL_H
/* *INDENT-ON* */
/*! \file global.h
* \brief Chewing Global Definitions
* \author libchewing Core Team
*/
#define CHINESE_MODE 1
#define SYMBOL_MODE 0
#define FULLSHAPE_MODE 1
#define HALFSHAPE_MODE 0
/* specified to Chewing API */
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
# define CHEWING_DLL_IMPORT __declspec(dllimport)
# define CHEWING_DLL_EXPORT __declspec(dllexport)
# ifdef CHEWINGDLL_EXPORTS
# define CHEWING_API CHEWING_DLL_EXPORT
# define CHEWING_PRIVATE
# elif CHEWINGDLL_IMPORTS
# define CHEWING_API CHEWING_DLL_IMPORT
# define CHEWING_PRIVATE
# else
# define CHEWING_API
# define CHEWING_PRIVATE
# endif
#elif (__GNUC__ > 3) && (defined(__ELF__) || defined(__PIC__))
# define CHEWING_API __attribute__((__visibility__("default")))
# define CHEWING_PRIVATE __attribute__((__visibility__("hidden")))
#else
# define CHEWING_API
# define CHEWING_PRIVATE
#endif
#ifndef UNUSED
# if defined(__GNUC__) /* gcc specific */
# define UNUSED __attribute__((unused))
# else
# define UNUSED
# endif
#endif
#ifndef DEPRECATED
# if defined(__GNUC__) && __GNUC__ > 3 || \
(__GNUC__ == 3 && __GNUC_MINOR__ >= 1) /* gcc specific */
# define DEPRECATED __attribute__((deprecated))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define DEPRECATED_FOR(f) \
__attribute__((deprecated("Use " #f " instead")))
# else
# define DEPRECATED_FOR(f) DEPRECATED
# endif
# else
# define DEPRECATED
# define DEPRECATED_FOR(f)
# endif
#endif
/* The following macros are modified from GLIB.
* from GNU cpp Manual:
* C99 introduces the _Pragma operator. This feature addresses a major problem
* with `#pragma': being a directive, it cannot be produced as the result of
* macro expansion. _Pragma is an operator, much like sizeof or defined, and
* can be embedded in a macro.
*/
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
# define BEGIN_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define END_IGNORE_DEPRECATIONS \
_Pragma ("GCC diagnostic pop")
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
# define BEGIN_IGNORE_DEPRECATIONS \
__pragma (warning (push)) \
__pragma (warning (disable : 4996))
# define END_IGNORE_DEPRECATIONS \
__pragma (warning (pop))
#else
# define BEGIN_IGNORE_DEPRECATIONS
# define END_IGNORE_DEPRECATIONS
#endif
#define MIN_SELKEY 1
#define MAX_SELKEY 10
#define CHEWING_LOG_VERBOSE 1
#define CHEWING_LOG_DEBUG 2
#define CHEWING_LOG_INFO 3
#define CHEWING_LOG_WARN 4
#define CHEWING_LOG_ERROR 5
/**
* @deprecated Use chewing_set_ series of functions to set parameters instead.
*/
typedef struct ChewingConfigData {
int candPerPage;
int maxChiSymbolLen;
int selKey[MAX_SELKEY];
int bAddPhraseForward;
int bSpaceAsSelection;
int bEscCleanAllBuf;
int bAutoShiftCur;
int bEasySymbolInput;
int bPhraseChoiceRearward;
int hsuSelKeyType; // Deprecated.
} ChewingConfigData;
typedef struct IntervalType {
/*@{ */
int from; /**< starting position of certain interval */
int to; /**< ending position of certain interval */
/*@} */
} IntervalType;
/** @brief context handle used for Chewing IM APIs
*/
typedef struct ChewingContext ChewingContext;
/** @brief use "asdfjkl789" as selection key
*/
#define HSU_SELKEY_TYPE1 1
/** @brief use "asdfzxcv89" as selection key
*/
#define HSU_SELKEY_TYPE2 2
/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

View file

@ -0,0 +1,113 @@
/*
* mod_aux.h
*
* Copyright (c) 2005, 2008
* libchewing Core Team. See ChangeLog for details.
*
* See the file "COPYING" for information on usage and redistribution
* of this file.
*/
/* *INDENT-OFF* */
#ifndef CHEWING_MOD_AUX_H
#define CHEWING_MOD_AUX_H
/* *INDENT-ON* */
/*! \file mod_aux.h
* \brief Auxiliary module
* \author libchewing Core Team
*/
#include "global.h"
/**
* @brief Chewing the state for input context during commit process
* @param ctx handle to Chewing IM context
* @retval TRUE if its currnet input state is at the "end-of-a-char"
*/
CHEWING_API int chewing_commit_Check(const ChewingContext *ctx);
/**
* @brief Get current commit string regardless of current input state
* @param ctx handle to Chewing IM context
*
* Always returns a char pointer, caller must free it.
*/
CHEWING_API char *chewing_commit_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_commit_String_static(const ChewingContext *ctx);
/*! \name Preedit string buffer
*/
/*@{*/
CHEWING_API char *chewing_buffer_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_buffer_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Check(const ChewingContext *ctx);
CHEWING_API int chewing_buffer_Len(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API const char *chewing_bopomofo_String_static(const ChewingContext *ctx);
CHEWING_API int chewing_bopomofo_Check(const ChewingContext *ctx);
/*@}*/
CHEWING_API int chewing_cursor_Current(const ChewingContext *ctx);
/*@{*/
CHEWING_API int chewing_cand_CheckDone(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_ChoicePerPage(const ChewingContext *ctx);
CHEWING_API int chewing_cand_TotalChoice(const ChewingContext *ctx);
CHEWING_API int chewing_cand_CurrentPage(const ChewingContext *ctx);
CHEWING_API void chewing_cand_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_cand_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_cand_String(ChewingContext *ctx);
CHEWING_API const char *chewing_cand_String_static(ChewingContext *ctx);
CHEWING_API char *chewing_cand_string_by_index(ChewingContext *ctx, int index);
CHEWING_API const char *chewing_cand_string_by_index_static(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_choose_by_index(ChewingContext *ctx, int index);
CHEWING_API int chewing_cand_open(ChewingContext *ctx);
CHEWING_API int chewing_cand_close(ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API void chewing_interval_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_interval_hasNext(ChewingContext *ctx);
CHEWING_API void chewing_interval_Get(ChewingContext *ctx, IntervalType * it);
/*@}*/
/*@{*/
CHEWING_API int chewing_aux_Check(const ChewingContext *ctx);
CHEWING_API int chewing_aux_Length(const ChewingContext *ctx);
CHEWING_API char *chewing_aux_String(const ChewingContext *ctx);
CHEWING_API const char *chewing_aux_String_static(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_keystroke_CheckIgnore(const ChewingContext *ctx);
CHEWING_API int chewing_keystroke_CheckAbsorb(const ChewingContext *ctx);
/*@}*/
/*@{*/
CHEWING_API int chewing_kbtype_Total(const ChewingContext *ctx);
CHEWING_API void chewing_kbtype_Enumerate(ChewingContext *ctx);
CHEWING_API int chewing_kbtype_hasNext(ChewingContext *ctx);
CHEWING_API char *chewing_kbtype_String(ChewingContext *ctx);
CHEWING_API const char *chewing_kbtype_String_static(ChewingContext *ctx);
/*@}*/
/* *INDENT-OFF* */
#endif /* CHEWING_MOD_AUX_H */
/* *INDENT-ON* */

Binary file not shown.

View file

@ -2,5 +2,5 @@
"cmake": "3.22.1", "cmake": "3.22.1",
"ndk": " 25.2.9519653", "ndk": " 25.2.9519653",
"platform": 23, "platform": 23,
"prebuilder": "e56adcfd30d41620ec586b4c4cde0ac49b1bca38" "prebuilder": "1360e13dcab49604dbedef5fdeec90dc53784f77"
} }