-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CandidateReg set_text , set_preedit, set_comment 增加警告 #295
base: master
Are you sure you want to change the base?
Conversation
cand.text , cand.preedit, cand.comment 無法設定時,輸出LOG(WARNING)
src/types.cc
Outdated
@@ -118,20 +143,34 @@ namespace CandidateReg { | |||
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShadowCandidate
并不是一种 WrapShadow
,所以这个 cast 不对。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成 LuaShadowCandidate 呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
与名字没有关系。原来的对象是 ShadowCandidate
的实例,并不能安全地转换为 WrapShadow
。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里有一个巧合,是 WrapShadow
在内存中的布局恰好与 ShadowCandidate
一样了,所以表面上能工作。但实际上是不合法的。
There was a problem hiding this comment.
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 較方便的方式
There was a problem hiding this comment.
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 <[email protected]>
Signed-off-by: shewer <[email protected]>
…s (#806) Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
|
Signed-off-by: shewer <[email protected]>
Signed-off-by: shewer <[email protected]>
cand.text , cand.preedit, cand.comment 無法設定時,輸出LOG(WARNING)