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 (rime#918)
  • Loading branch information
imfuxiao committed Jul 19, 2024
1 parent f6dd300 commit b89b9d2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
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
14 changes: 13 additions & 1 deletion 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 Expand Up @@ -213,14 +221,18 @@ int main(int argc, char* argv[]) {

RIME_STRUCT(RimeTraits, traits);
traits.app_name = "rime.console";

traits.shared_data_dir = "/Library/Input Methods/Squirrel.app/Contents/SharedSupport";
traits.user_data_dir = "/Users/morse/Documents/github.com/rime/rime-ice";

rime->setup(&traits);

rime->set_notification_handler(&on_message, NULL);

fprintf(stderr, "initializing...\n");
reload:
rime->initialize(NULL);
Bool full_check = True;
Bool full_check = false;
if (rime->start_maintenance(full_check))
rime->join_maintenance_thread();
fprintf(stderr, "ready.\n");
Expand Down

0 comments on commit b89b9d2

Please sign in to comment.