Skip to content

Commit

Permalink
feat(rime_api): add RimeApi::set_input (#771)
Browse files Browse the repository at this point in the history
resolve #547
  • Loading branch information
imfuxiao committed Dec 17, 2023
1 parent 8f2e8d6 commit de12d6a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/rime_api.cc
Expand Up @@ -1084,6 +1084,17 @@ const char* RimeGetStateLabel(RimeSessionId session_id,
.str;
}

RIME_API Bool RimeSetInput(RimeSessionId session_id, const char* input) {
an<Session> session(Service::instance().GetSession(session_id));
if (!session)
return False;
Context* ctx = session->context();
if (!ctx)
return False;
ctx->set_input(input);
return True;
}

RIME_API RimeApi* rime_get_api() {
static RimeApi s_api = {0};
if (!s_api.data_size) {
Expand Down Expand Up @@ -1177,6 +1188,7 @@ RIME_API RimeApi* rime_get_api() {
s_api.delete_candidate = &RimeDeleteCandidate;
s_api.delete_candidate_on_current_page = &RimeDeleteCandidateOnCurrentPage;
s_api.get_state_label_abbreviated = &RimeGetStateLabelAbbreviated;
s_api.set_input = &RimeSetInput;
}
return &s_api;
}
3 changes: 3 additions & 0 deletions src/rime_api.h
Expand Up @@ -387,6 +387,7 @@ RIME_API Bool RimeConfigUpdateSignature(RimeConfig* config, const char* signer);
RIME_API Bool RimeSimulateKeySequence(RimeSessionId session_id,
const char* key_sequence);

RIME_API Bool RimeSetInput(RimeSessionId session_id, const char* input);
// Module

/*!
Expand Down Expand Up @@ -644,6 +645,8 @@ typedef struct rime_api_t {
const char* option_name,
Bool state,
Bool abbreviated);

Bool (*set_input)(RimeSessionId session_id, const char* input);
} RimeApi;

//! API entry
Expand Down

0 comments on commit de12d6a

Please sign in to comment.