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

使用 ConcreteEngine::ApplySchema 重載 schema 是否可行

Open shewer opened this issue 5 years ago • 2 comments

在 librime src/engine.cc 有三個function https://github.com/rime/librime/blob/6031ef34735d9bf43aef76cf15a025c5e43c436a/src/rime/engine.cc#L29

virtual void ApplySchema(Schema* schema); // reload schema void InitializeComponents(); // reload compnents void InitializeOptions(); //reload switchs

在 https://github.com/rime/librime/blob/master/src/rime/engine.cc#L270

增加 ApplySchema(schema *) api 會重新載入
在 lua 修改 schema 後 再執行 重載 是否可動態修改schema 環境

shewer avatar Dec 23 '20 23:12 shewer

在 librime src/engine.cc 有三個function https://github.com/rime/librime/blob/6031ef34735d9bf43aef76cf15a025c5e43c436a/src/rime/engine.cc#L29

virtual void ApplySchema(Schema* schema); // reload schema void InitializeComponents(); // reload compnents void InitializeOptions(); //reload switchs

在 https://github.com/rime/librime/blob/master/src/rime/engine.cc#L270

增加 ApplySchema(schema *) api 會重新載入 在 lua 修改 schema 後 再執行 重載 是否可動態修改schema 環境

我在 types.cc EngineReg 增加 { "apply_schema",WRAPMEM(T::ApplySchema) },
井在 lua script 但是 得到 error log : bad argument#1 該如何 取得 schema* schema ???

local config= env.engine.schema.config
local ps=config:get_int("menu/page_size")
config:set_int("menu/page_size", 5)
env.engine.apply_schema( env.engine.schema )
-- error.log  : bad argument #1 to 'apply_schema' (struct LuaType<class rime::Engine &> expected)

shewer avatar Dec 24 '20 08:12 shewer

在 librime src/engine.cc 有三個function https://github.com/rime/librime/blob/6031ef34735d9bf43aef76cf15a025c5e43c436a/src/rime/engine.cc#L29 virtual void ApplySchema(Schema* schema); // reload schema void InitializeComponents(); // reload compnents void InitializeOptions(); //reload switchs 在 https://github.com/rime/librime/blob/master/src/rime/engine.cc#L270 增加 ApplySchema(schema *) api 會重新載入 在 lua 修改 schema 後 再執行 重載 是否可動態修改schema 環境

我在 types.cc EngineReg 增加 { "apply_schema",WRAPMEM(T::ApplySchema) }, 井在 lua script 但是 得到 error log : bad argument#1 該如何 取得 schema* schema ???

local config= env.engine.schema.config
local ps=config:get_int("menu/page_size")
config:set_int("menu/page_size", 5)
env.engine.apply_schema( env.engine.schema ) 

-- error.log : bad argument #1 to 'apply_schema' (struct LuaType<class rime::Engine &> expected) -- 改成 engine:apply_schema -- 當掉了 env.engine:apply_schema(env.engine.schema)
--E1224 16:27:23.853719 17576 user_dictionary.cc:448] Error translating syllable_id '162803'.

shewer avatar Dec 24 '20 09:12 shewer