Merged
Conversation
Member
|
真是執着啊。 |
lotem
requested changes
Dec 25, 2025
Contributor
|
这样还是不够环保 可能这样?将每次RimeGetContext里的高频操作改成ctx->set_option的低频操作,代价是context要多一个成员 diff --git a/src/rime/context.cc b/src/rime/context.cc
index ec840a3e..4a976e8a 100644
--- a/src/rime/context.cc
+++ b/src/rime/context.cc
@@ -284,6 +284,8 @@ void Context::set_input(const string& value) {
}
void Context::set_option(const string& name, bool value) {
+ if (name == "_hide_candidate")
+ is_hide_candidate_on_ = value;
options_[name] = value;
DLOG(INFO) << "Context::set_option " << name << " = " << value;
option_update_notifier_(this, name);
diff --git a/src/rime/context.h b/src/rime/context.h
index d5261300..2820c95f 100644
--- a/src/rime/context.h
+++ b/src/rime/context.h
@@ -81,6 +81,7 @@ class RIME_DLL Context {
// options and properties starting with '_' are local to schema;
// others are session scoped.
void ClearTransientOptions();
+ bool is_hide_candidate_on() const { return is_hide_candidate_on_; }
Notifier& commit_notifier() { return commit_notifier_; }
Notifier& select_notifier() { return select_notifier_; }
@@ -104,6 +105,7 @@ class RIME_DLL Context {
CommitHistory commit_history_;
map<string, bool> options_;
map<string, string> properties_;
+ bool is_hide_candidate_on_ = false;
Notifier commit_notifier_;
Notifier select_notifier_;
diff --git a/src/rime_api_impl.h b/src/rime_api_impl.h
index 6e906cfe..94fce741 100644
--- a/src/rime_api_impl.h
+++ b/src/rime_api_impl.h
@@ -247,8 +247,11 @@ RIME_DEPRECATED Bool RimeGetContext(RimeSessionId session_id,
context->menu.page_no = page_no;
context->menu.is_last_page = Bool(page->is_last_page);
context->menu.highlighted_candidate_index = selected_index % page_size;
+ context->menu.num_candidates =
+ ctx->is_hide_candidate_on() ? 0 : page->candidates.size();
+ if (ctx->is_hide_candidate_on())
+ return True;
int i = 0;
- context->menu.num_candidates = page->candidates.size();
context->menu.candidates = new RimeCandidate[page->candidates.size()];
for (const an<Candidate>& cand : page->candidates) {
RimeCandidate* dest = &context->menu.candidates[i++]; |
Contributor
|
这个不应该是前端的能力嘛?真要放到librime里面嘛? |
Contributor
|
如果真想实现是不是自己写个lua的filter呢。 |
Member
確實是前端的功能。 |
Member
不要吧,雖然優化了,但這樣寫容易亂。 我考慮呢,想再漂亮一點,就定義一個 |
Contributor
Author
改动太多,您亲自操刀吧,加入experimental分支,我来测试 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request
Issue tracker
Fixes will automatically close the related issue
Fixes #1112
Feature
This pull request introduces the ability to control whether the candidate list is displayed through a Rime option (_hide_candidate).
When the option
_hide_candidateis enabled, Rime setsnum_candidatesto 0. once the frontends like squirrel and weasel detect thatnum_candidatesis 0, they will skip populating and showing the candidate list, allowing users or schemas to dynamically hide candidates without relying on theme configuration.Unit test
Manual test
Code Review
Additional Info