Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 2 commits into from
Apr 1, 2021

Conversation

shewer
Copy link
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
Owner

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

@shewer
Copy link
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

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

@shewer
Copy link
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
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

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>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants