librime-lua icon indicating copy to clipboard operation
librime-lua copied to clipboard

請問 LuaTranslation 如何要使用

Open shewer opened this issue 4 years ago • 1 comments

LuaTransltion https://github.com/hchunhui/librime-lua/blob/67ef681a9fd03262c49cc7f850cc92fc791b1e85/src/lua_gears.cc#L11

LuaTranslator https://github.com/hchunhui/librime-lua/blob/67ef681a9fd03262c49cc7f850cc92fc791b1e85/src/lua_gears.cc#L108

1 Translation( func) func 如何設計 參數如何傳送

2 看起來 像是和 Lua_translator func 設計類似 要用 yield( candidate )

shewer avatar Oct 30 '21 16:10 shewer

自問自答: 但是還是不曉得如何在 沒有keyevent 下送出候選字

function gen_translator(str) 
    return Translation( 
       function()
         words= dict(str) -- list
         for word in  ipairs(words) do 
               yield( Candidate( "--" , 1, 1 , word, "") )
         end 
       end)
end 

shewer avatar Nov 01 '21 06:11 shewer