Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

如何修改已经输入的编码? #547

Closed
tumuyan opened this issue Jun 3, 2022 · 5 comments · Fixed by #771
Closed

如何修改已经输入的编码? #547

tumuyan opened this issue Jun 3, 2022 · 5 comments · Fixed by #771

Comments

@tumuyan
Copy link

tumuyan commented Jun 3, 2022

实际上是两个问题:

  1. 修改已经输入的编码,有这种接口嘛?比如已经输入的编码是xian,我写了一段代码,用户可以一键把编码改为dian而不需要删除、重新输入,直接从dian的候选中选择,并且移动光标也不会发生编码的变化。
  2. 批量输入按键。目前rime api console这个demo,输入字符后回车,处理流程是模拟了处理每个按键输入。能不能一次性接受一列按键,然后只处理一次?

关联 hchunhui/librime-lua#170

@lotem
Copy link
Member

lotem commented Jun 3, 2022

需要加一个API函数。我记得讨论过,现在看代码好像还没加。

@tumuyan
Copy link
Author

tumuyan commented Jun 3, 2022

希望大哥近期可以加一下这个API,以我的眼光,有这个API有几大实用之处:

  1. 如果上一次没有看候选就进行了选字,导致上屏文字错误,可以透过API取消上屏、恢复编码、直接重新选字
  2. 针对类似九宫拼音的方案,可以透过API对输入的编码做确认和替换

@mokapsing
Copy link
Contributor

希望大哥近期可以加一下这个API,以我的眼光,有这个API有几大实用之处:

  1. 如果上一次没有看候选就进行了选字,导致上屏文字错误,可以透过API取消上屏、恢复编码、直接重新选字
  2. 针对类似九宫拼音的方案,可以透过API对输入的编码做确认和替换

hchunhui/librime-lua#170 (comment)

@LEOYoon-Tsaw
Copy link
Member

取消上屏和九宮格輸入碼確認都需要UI支持,不適合通過lua處理

@hoofcushion
Copy link

hoofcushion commented Aug 13, 2023

--解法1 使用 lua processor 清空原编码,插入新编码
processor=function(key,env)
 local old_code=env.engine.context.input
 local new_code=......
 env.engine.context:clear()
 env.engine.context:push_input(new_code)
 return 1
end
--解法2 根据用户给出的编码偏移量,在 lua translator 的 query 过程中将数字替换为对应的拼音编码
local spell={
 {["1234"]="wo"},
 {["1234"]="de"},
 {["1234"]="shi"},
 {["1234"]="jie"},
}
local base=#spell
local diff=0
processor=function(key,env)
 if key:repr()=="x" then
  diff=(diff+1)%base
 end
 return 2
end
translator=function(input,seg)
 local query=tran:query(input:gsub("[0-9]+",spell[diff+1]),seg)
 if not query then return end
 for cand in query:iter() do
  yield(cand)
 end
end
-- 每按一次x,真实编码1234映射的 query 编码都会从wo-de-shi-jie这个序列中轮换

imfuxiao added a commit to imfuxiao/librime that referenced this issue Dec 1, 2023
imfuxiao added a commit to imfuxiao/librime that referenced this issue Dec 1, 2023
imfuxiao added a commit to imfuxiao/librime that referenced this issue Dec 1, 2023
imfuxiao added a commit to imfuxiao/librime that referenced this issue Dec 1, 2023
imfuxiao added a commit to imfuxiao/librime that referenced this issue Dec 1, 2023
imfuxiao added a commit to imfuxiao/librime that referenced this issue Dec 7, 2023
lotem pushed a commit that referenced this issue Dec 17, 2023
groverlynn pushed a commit to groverlynn/librime that referenced this issue Dec 19, 2023
fxliang pushed a commit to fxliang/librime that referenced this issue Feb 2, 2024
graphemecluster pushed a commit to TypeDuck-HK/librime that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants