chewing / libchewing

libchewing - The intelligent phonetic input method library
https://chewing.im/
GNU Lesser General Public License v2.1
359 stars 90 forks source link

Create mid-level API for internal use and external use #36

Open kanru opened 11 years ago

kanru commented 11 years ago

Currently we call high-level API like chewing_handle_CtrlNum in other high-level APIs. This means if we change the high-level API implementation would also affect the other high-level user.

We should create mid-level API to operate on the internal state and dictionary data. These API will also be useful to external users.

Example: select_candidate, add_phrase (note these API are different with the low-level API which operates on data directly. The mid-level API operates on buffers and candidates.)

czchen commented 10 years ago

The issue https://github.com/chewing/windows-chewing-tsf/issues/12 is related to high-level API changed.

czchen commented 10 years ago

The following are purposed new APIs for external use:

// candidate windows
chewing_cand_open(ChewingContext *ctx);
chewing_cand_close(ChewingContext *ctx);
chewing_cand_choose_by_index(ChewingContext *ctx, int index);
chewing_cand_String_by_index(ChewingContext *ctx, int index); // Already implemented, but not yet in any official release.
chewing_cand_next_cand_list(ChewingContext *ctx); // Change to next candidate list. For example: 2 words candidate list to 1 word candidate list

// add userphrase in preedit buffer
chewing_userphrase_add_in_preedit_buf(ChewingContext *ctx, unsigned int start, unsigned int end);

chewing_commit_preedit_buf(ChewingContext *ctx);

chewing_clean_bopomofo_buf(ChewingContext *ctx);

See also #65, #71, #92

czchen commented 10 years ago
// candidate windows
int chewing_cand_is_open(ChewingContext *ctx);
int chewing_cand_open(ChewingContext *ctx);
itn chewing_cand_close(ChewingContext *ctx);
int chewing_cand_choose_by_index(ChewingContext *ctx, int index);
int chewing_cand_String_by_index(ChewingContext *ctx, int index); // Already implemented, but not yet in any official release.

// candidate list
int chewing_cand_has_next_cand_list(ChewingContext *ctx);
int chewing_cand_next_cand_list(ChewingContext *ctx);
int chewing_cand_prev_cand_list(ChewingContext *ctx);

// add userphrase in preedit buffer
int chewing_userphrase_add_from_preedit_buf(ChewingContext *ctx, unsigned int start, unsigned int end);

int chewing_commit_preedit_buf(ChewingContext *ctx);

int chewing_clean_preedit_buf(ChewingContext *ctx);
int chewing_clean_bopomofo_buf(ChewingContext *ctx);
czchen commented 10 years ago

Also https://github.com/chewing/windows-chewing-tsf/issues/59

czchen commented 10 years ago

Also https://github.com/chewing/windows-chewing-tsf/issues/62