Skip to content

Commit

Permalink
fix: Cannot get the value of the option state after switching the opt…
Browse files Browse the repository at this point in the history
…ion under the switcher (#918)
  • Loading branch information
imfuxiao committed Jul 19, 2024
1 parent f6dd300 commit 3604f90
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/rime/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Schema* Session::schema() const {
return engine_ ? engine_->active_engine()->schema() : NULL;
}

Schema* Session::inactiveSchema() const {
return engine_ ? engine_->schema() : NULL;
}

Service::Service() {
deployer_.message_sink().connect(
[this](auto type, auto value) { Notify(0, type, value); });
Expand Down
1 change: 1 addition & 0 deletions src/rime/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Session {

Context* context() const;
Schema* schema() const;
Schema* inactiveSchema() const;
time_t last_active_time() const { return last_active_time_; }
const string& commit_text() const { return commit_text_; }

Expand Down
2 changes: 1 addition & 1 deletion src/rime_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ static RimeStringSlice RimeGetStateLabelAbbreviated(RimeSessionId session_id,
an<Session> session(Service::instance().GetSession(session_id));
if (!session)
return {nullptr, 0};
Config* config = session->schema()->config();
Config* config = session->inactiveSchema()->config();
if (!config)
return {nullptr, 0};
Switches switches(config);
Expand Down
8 changes: 8 additions & 0 deletions tools/rime_api_console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ bool execute_special_command(const char* line, RimeSessionId session_id) {
printf("%s set %s.\n", option, is_on ? "on" : "off");
return true;
}

if (!strcmp(line, "switcher")) {
// 0xffc1 = f4
rime -> process_key(session_id, 0xffc1, 0);
print(session_id);
return true;
}

if (!strcmp(line, "synchronize")) {
return rime->sync_user_data();
}
Expand Down

0 comments on commit 3604f90

Please sign in to comment.