Skip to content

Commit

Permalink
fix(engine): schema doesn't match the one used by switcher
Browse files Browse the repository at this point in the history
Closes #269
  • Loading branch information
lotem committed Apr 27, 2019
1 parent cbd8fb3 commit e41bb63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/rime/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class Engine : public Messenger {
Context* context() const { return context_.get(); }
CommitSink& sink() { return sink_; }

Context* active_context() const {
return active_context_ ? active_context_ : context_.get();
Engine* active_engine() {
return active_engine_ ? active_engine_ : this;
}
void set_active_context(Context* context = nullptr) {
active_context_ = context;
void set_active_engine(Engine* engine = nullptr) {
active_engine_ = engine;
}

RIME_API static Engine* Create();
Expand All @@ -46,7 +46,7 @@ class Engine : public Messenger {
the<Schema> schema_;
the<Context> context_;
CommitSink sink_;
Context* active_context_ = nullptr;
Engine* active_engine_ = nullptr;
};

} // namespace rime
Expand Down
4 changes: 2 additions & 2 deletions src/rime/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ void Session::OnCommit(const string& commit_text) {
}

Context* Session::context() const {
return engine_ ? engine_->active_context() : NULL;
return engine_ ? engine_->active_engine()->context() : NULL;
}

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

Service::Service() {
Expand Down
4 changes: 2 additions & 2 deletions src/rime/switcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ void Switcher::Activate() {
LOG(INFO) << "switcher is activated.";
context_->set_option("_fold_options", fold_options_);
RefreshMenu();
engine_->set_active_context(context_.get());
engine_->set_active_engine(this);
active_ = true;
}

void Switcher::Deactivate() {
context_->Clear();
engine_->set_active_context();
engine_->set_active_engine();
active_ = false;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/rime_console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RimeConsole {
const Segment &current(comp.back());
if (!current.menu)
return;
int page_size = engine_->schema()->page_size();
int page_size = engine_->active_engine()->schema()->page_size();
int page_no = current.selected_index / page_size;
the<Page> page(current.menu->CreatePage(page_size, page_no));
if (!page)
Expand Down Expand Up @@ -81,7 +81,7 @@ class RimeConsole {
for (const KeyEvent &key : keys) {
engine_->ProcessKey(key);
}
Context *ctx = engine_->active_context();
Context *ctx = engine_->active_engine()->context();
if (interactive_) {
PrintComposition(ctx);
}
Expand Down

0 comments on commit e41bb63

Please sign in to comment.