libchewing icon indicating copy to clipboard operation
libchewing copied to clipboard

Create mid-level API for internal use and external use

Open kanru opened this issue 13 years ago • 5 comments

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.)

kanru avatar Dec 06 '12 13:12 kanru

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

czchen avatar Sep 29 '13 08:09 czchen

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 avatar Sep 29 '13 08:09 czchen

// 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 avatar Sep 29 '13 14:09 czchen

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

czchen avatar Oct 06 '13 06:10 czchen

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

czchen avatar Oct 13 '13 17:10 czchen