Skip to content

CandidateReg set_text , set_preedit, set_comment 增加警告#295

Open
shewer wants to merge 10 commits into
hchunhui:masterfrom
shewer:patch-15
Open

CandidateReg set_text , set_preedit, set_comment 增加警告#295
shewer wants to merge 10 commits into
hchunhui:masterfrom
shewer:patch-15

Conversation

@shewer

@shewer shewer commented Dec 16, 2023

Copy link
Copy Markdown
Contributor

cand.text , cand.preedit, cand.comment 無法設定時,輸出LOG(WARNING)

Comment thread src/types.cc Outdated
void set_text(T &c, const string &v) {
if (auto p = dynamic_cast<SimpleCandidate *>(&c))
p->set_text(v);
else if (auto p = (WrapShadow *) dynamic_cast<ShadowCandidate *>(&c))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShadowCandidate 并不是一种 WrapShadow,所以这个 cast 不对。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成 LuaShadowCandidate 呢?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

与名字没有关系。原来的对象是 ShadowCandidate 的实例,并不能安全地转换为 WrapShadow

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有一个巧合,是 WrapShadow 在内存中的布局恰好与 ShadowCandidate 一样了,所以表面上能工作。但实际上是不合法的。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這的確是我的動機 , 當初是想在 api 中方便操作 ShadowCandidate text ,comment

如果 只能 an to WrapShadow , 那麼就只能 在filter 中
先行置換 Shadow 了

1 在filter 中改 , 這個較易 取出 Phrase 重裝 Shadow or WrapShadow
2 在 onCommit 前 改 candidate text ,但是
沒有方法可以交換 Menu 中的成員 CandidateList
所以提供 Candidate 可以修改 text 較方便的方式

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

想到了 直接用 委任 類似 shadow 再上 委任接口 及 text , comment
那麼 就可以委任 shadow phrase Uniquified 了

Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
…s (#806)

Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
@shewer

shewer commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author
  1. LuaShadowCandidate 取代 ShadowCandidate, LuaUniquifiedCandidate 取代 UniquifideCandidate, ,增加 write_able 以便於寫入 text comment preedit
  2. 增加 vars_get "dynamic_type" 等同 :get_dynamic_type()
  3. 增加 vars_get "dynamic_candidate" 可以取得 Phrase Sentence LuaShadowCandidate LuaUniquifiedCandidate

Signed-off-by: shewer <shewer@gmail.com>
Signed-off-by: shewer <shewer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants