Skip to content

add EngineReg select_schema() env.engine:select( string schema_id )…#98

Merged
hchunhui merged 2 commits intohchunhui:masterfrom
shewer:dev05
Apr 1, 2021
Merged

add EngineReg select_schema() env.engine:select( string schema_id )…#98
hchunhui merged 2 commits intohchunhui:masterfrom
shewer:dev05

Conversation

@shewer
Copy link
Copy Markdown
Contributor

@shewer shewer commented Mar 28, 2021

copy from key_binder.cc

env.engine:select_schema("cangjit5")
env.engine.select_schema(".next")  


… .next

Signed-off-by: shewer shewer@gmail.com

…next

Signed-off-by: shewer <shewer@gmail.com>
@hchunhui
Copy link
Copy Markdown
Owner

不建议这样做。我更倾向于 #80 的做法,即导出Engine::ApplySchema()Schema

@shewer
Copy link
Copy Markdown
Contributor Author

shewer commented Mar 28, 2021

lua 內的 instance 等同在 c++中 ptr 嗎 ?
因爲不確定 engine schema context 是否可以調回 C++

SchemaReg
an make(string & schema_id) {
return New Schema(schema_id);
}

EngineREG

{ "apply_schema" , WRAPMEM(T:ApplySchema) },

@OnchiuLee
Copy link
Copy Markdown

現在能獲取已部署的所有方案列表麼?這樣就可以進行指定編碼觸發熱切換操作 不需要快捷鍵 也不擔心快捷鍵被其它程序佔用

@shewer
Copy link
Copy Markdown
Contributor Author

shewer commented Mar 28, 2021

現在能獲取已部署的所有方案列表麼?這樣就可以進行指定編碼觸發熱切換操作 不需要快捷鍵 也不擔心快捷鍵被其它程序佔用

試試
--- schema/@i/schema ( from build/default.yaml)
local config =env.engine.schema.config
local size=config:get_list_size("schema_list")
for i =0, size do
config:get_string("schema_list/@" .. i .. "/schema")

Signed-off-by: shewer <shewer@gmail.com>
@shewer
Copy link
Copy Markdown
Contributor Author

shewer commented Mar 29, 2021

function processor_func(key,env)
    if key:repr() == "Shift+Control+0" then 
            env.engine:apply_schema(  Schema("cangjie5") ) 
            return Accepted
     end 
end 

@OnchiuLee
Copy link
Copy Markdown

OnchiuLee commented Mar 31, 2021

現在能獲取已部署的所有方案列表麼?這樣就可以進行指定編碼觸發熱切換操作 不需要快捷鍵 也不擔心快捷鍵被其它程序佔用

試試

--- schema/@i/schema ( from build/default.yaml)

local config =env.engine.schema.config

local size=config:get_list_size("schema_list")

for i =0, size do

config:get_string("schema_list/@" .. i .. "/schema")

這個貌似不行,env.engine.schema.config獲取的是當前方案所配置的配置非build/default.yaml文件配置參數,经测试返回的size变量为0 无效

@hchunhui hchunhui merged commit 7d68fc8 into hchunhui:master Apr 1, 2021
shewer added a commit to shewer/librime-lua that referenced this pull request Apr 13, 2021
* add  EngineReg select_schema()  env.engine:select( string schema_id ) .next

Signed-off-by: shewer <shewer@gmail.com>

* add engine:apply_schema( Schema &)   Schema( const string &)

Signed-off-by: shewer <shewer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants