Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rime_api): add RimeApi::set_input #771

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/rime_api.cc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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