Closed HowcanoeWang closed 1 year ago
simplifier 轉換後會變成 ShadowCandidate ,此candidate 無法設定
simplifier 轉換後會變成 ShadowCandidate ,此candidate 無法設定
竟然真的是繁簡轉換的問題=_=,這個無法設定是底層被鎖死的,還是該lua插件暫時沒有支持?
我看官方文檔裏面是有這個API的:
https://github.com/hchunhui/librime-lua/wiki/Scripting#shadowcandidate ShadowCandidate(cand,type,text,comment)類似 simplifier 的作法
构造方法:ShadowCandidate(cand, type, text, comment, inherit_comment) cand type text comment inherit_comment: (可选)
有沒有方法可以獲取這些shadowcandiate並修改?
方法1 最近 librime commit : simplifier 新增 一個選項 append_comment , 就是 加在 現存 comment 後面 把你的 filter 置換到 simpifier 前
方法2 方在 simplifier 以後,檢查 candidate type 分開處理
local function filter(input, env)
for cand in input:iter() do
if cand:dynamic_type() == "Shadow" then
local s_text= cand.text
local s_comment = cand.comment
local org_cand = cand:get_genuine()
yield(
ShadowCandidate( org_cand, s_text, org_cand.comment .. s_comment .. "...." ) )
else
--local comment = cand:get_geuine().comment
--cand:get_genuine().comment = comment .. "...."
cand.comment = cand.comment .. "..." -- comment
yield(cand)
end
end
end
return filter
先尝试了一下方法一,似乎archlinux还没有更新到最新版,所以不起作用
然后尝试方法二,思路很清晰,部分api的细节有点问题,我稍微对着api改了改就能用了:
cand:dynamic_type()
改为cand:get_dynamic_type()
ShadowCandidate( org_cand, s_text, org_cand.comment .. s_comment .. "...." )
改为
ShadowCandidate( org_cand, org_cand.type, s_text, org_cand.comment .. s_comment .. "...." )
最终效果没有任何问题:
感谢您的耐心解答!
将问题简化之后,使用下面的代码修改所有的candidate的comment,问题依然能复现:
lua/aux_code.lua
:但是输入法并没有给所有的candidate都加上comment,效果如下:
不确定是这个插件的bug还是fcitx5的性能限制,还是我打开的方式不对
其他的配置供参考:
input.schema.yaml
:rime.lua
: