librime-lua
librime-lua copied to clipboard
如何用lua切換指定方案,不用依賴快捷鍵操作?
如何用lua切換指定方案,不用依賴快捷鍵操作,求教用env.engine:apply_schema如何實現
local s=Schema( "cangjie5") -- schema_id create instance of schema env.engine:apply_schema( s )
注意 因爲 engine會重導入 engine/.... 下的 component。 可能會因爲 下一個 方案 沒有 lua_componet 跳不回來唷 前面的 lua_component 會 call fini 清理 相關變數 別忘了
local s=Schema( "cangjie5") -- schema_id create instance of schema
env.engine:apply_schema( s )
注意 因爲 engine會重導入 engine/.... 下的 component。
可能會因爲 下一個 方案 沒有 lua_componet 跳不回來唷
前面的 lua_component 會 call fini 清理 相關變數 別忘了
我試過似乎沒效果……
local s=Schema( "cangjie5") -- schema_id create instance of schema
env.engine:apply_schema( s )
注意 因爲 engine會重導入 engine/.... 下的 component。
可能會因爲 下一個 方案 沒有 lua_componet 跳不回來唷
前面的 lua_component 會 call fini 清理 相關變數 別忘了
Schema( "cangjie5")這個方法無效吧,試過多次 依舊無法切換
我測試 OK 可能 檢查一下有沒有 build/cangjie5.schema.yaml 還是 你的 librime-lua version 是舊的 沒有 engine:apply_schema
``lua local function processor_func(,,,,,,,) if key:repr() == "F10" then local s= Schema("cangjie5") env.engine:apply_schema(s) return Accepted
end end
--- rime_api_console
schema: whaleliu_ext / 鯨舞倉-詞
status: ascii
(not composing)
{F10}
message: [94015771467648] [option] _auto_commit
message: [94015771467648] [option] !ascii_mode
message: [94015771467648] [schema] cangjie5/倉頡五代
schema: cangjie5 / 倉頡五代
status:
(not composing)
我測試 OK
可能 檢查一下有沒有 build/cangjie5.schema.yaml
還是 你的 librime-lua version 是舊的 沒有 engine:apply_schema
``lua
local function processor_func(,,,,,,,)
if key:repr() == "F10" then
local s= Schema("cangjie5")
env.engine:apply_schema(s)
return Accepted
end
end
--- rime_api_console schema: whaleliu_ext / 鯨舞倉-詞 status: ascii (not composing) {F10} message: [94015771467648] [option] _auto_commit message: [94015771467648] [option] !ascii_mode message: [94015771467648] [schema] cangjie5/倉頡五代 schema: cangjie5 / 倉頡五代 status: (not composing)
謝謝,我再檢查嘗試一下
#98 add EngineReg select_schema() env.engine:select( string schema_id )… #98 要到 這版 可能要 clone 自行 compile
#98
add EngineReg select_schema() env.engine:select( string schema_id )… #98
要到 這版
可能要 clone 自行 compile
env.engine:apply_schema(Schema( schema_id))的方式切換成功後會出現打字上屏四五次後卡進程然後自動切換回原來方案的情況,有時候也會自動卡退算法進程?這是何原因?
查一下 LOG file
查一下 LOG file
log.WARNING文件中的日誌
Log file created at: 2021/04/11 23:21:33 Running on machine: DESKTOP-SPHPO8L Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg W0411 23:21:33.265362 6460 registry.cc:16] replacing previously registered component: charset_filter W0411 23:21:37.218667 744 config_data.cc:62] nonexistent config file 'C:\Users\Admin\AppData\Roaming\Rime\build\.default.schema.yaml'. W0411 23:22:32.569851 4700 registry.cc:16] replacing previously registered component: charset_filter W0411 23:23:52.529285 3936 config_data.cc:62] nonexistent config file 'C:\Users\Admin\AppData\Roaming\Rime\build\.default.schema.yaml'. W0411 23:23:57.671123 3936 config_data.cc:62] nonexistent config file 'C:\Users\Admin\AppData\Roaming\Rime\build\.schema.yaml'.
log.INFO文件最新產生的日誌
I0411 23:23:38.246703 3936 engine.cc:123] updated option: ascii_mode I0411 23:23:38.246703 3936 engine.cc:136] updated property: client_type I0411 23:23:38.246703 3936 engine.cc:123] updated option: inline_preedit I0411 23:23:38.246703 3936 engine.cc:123] updated option: soft_cursor I0411 23:23:38.246703 3936 engine.cc:123] updated option: __synced I0411 23:23:38.356189 3936 engine.cc:123] updated option: ascii_mode I0411 23:23:42.922482 3936 engine.cc:203] Oops, got a futile translation. I0411 23:23:42.922482 3936 engine.cc:203] Oops, got a futile translation. I0411 23:23:43.125586 3936 engine.cc:203] Oops, got a futile translation. I0411 23:23:43.125586 3936 engine.cc:203] Oops, got a fu
上面最後一條日誌未生成完整就回滾到切換前的方案了或自動退出算法進程,求解
local s=Schema( "cangjie5") -- schema_id create instance of schema
env.engine:apply_schema( s )
注意 因爲 engine會重導入 engine/.... 下的 component。
可能會因爲 下一個 方案 沒有 lua_componet 跳不回來唷
前面的 lua_component 會 call fini 清理 相關變數 別忘了
可能會因爲 下一個 方案 沒有 lua_componet 跳不回來唷 前面的 lua_component 會 call fini 清理 相關變數
能避免被清理麼?求教!
1 兩個方案 都載入 相同的lua component 相配合
2 兩方案 整併再一起 ,利用 segment tag (類似 recognizer/patterns)
recognizer 是以 input patterns match 決定 tag
3 用 command 跳方案 效益不大 切換原因爲何
打不出字 -- 用recognize
USER不同 -- 用 hot-key / switcher
就是要切換輸入法 -- 在同一方案裡著手,
每一次 KeyEvent 進入流程 processors --> procesoor --> processor ... noop 往下傳 keyevent reject , accept 終止 -- 檢查 UPDATE 觸發 Comps segmentors(create segments) --> segmentor --> segmentor .....( true /false ) true --> nexxt segmentor false -- > stop return translators filters( segment 掛入translation )
translator--> tag match create translation --> 加入當前 segment filter --> tags match return filter --> 加入當前 segment