feat: en_spacer.lua 英文词条上屏自动添加空格 (#496)
This commit is contained in:
parent
5c9ca84031
commit
f935a9c0c4
20
lua/en_spacer.lua
Normal file
20
lua/en_spacer.lua
Normal file
@ -0,0 +1,20 @@
|
||||
local function add_space_to_english_word(input)
|
||||
-- 匹配纯英文单词并在单词后添加空格
|
||||
input = input:gsub("(%a+)", "%1 ")
|
||||
|
||||
return input
|
||||
end
|
||||
|
||||
-- 在候选项上屏时触发的函数
|
||||
function en_spacer(input, env)
|
||||
for cand in input:iter() do
|
||||
if cand.text:match("^[%a']+[%a']*$") then
|
||||
-- 如果候选项是纯英文单词,则在输入后添加一个空格
|
||||
cand = cand:to_shadow_candidate(cand.type, add_space_to_english_word(cand.text), cand.comment)
|
||||
end
|
||||
yield(cand)
|
||||
end
|
||||
end
|
||||
|
||||
return en_spacer
|
||||
|
4
rime.lua
4
rime.lua
@ -56,6 +56,10 @@ long_word_filter = require("long_word_filter")
|
||||
-- 在 engine/filters 增加 - lua_filter@cn_en_spacer
|
||||
cn_en_spacer = require("cn_en_spacer")
|
||||
|
||||
-- 英文词条上屏自动空格
|
||||
-- 在 engine/filters 增加 - lua_filter@en_spacer
|
||||
en_spacer = require("en_spacer")
|
||||
|
||||
-- 九宫格,手机用。
|
||||
-- 在 engine/filters 增加 - lua_filter@t9_preedit
|
||||
t9_preedit = require("t9_preedit")
|
||||
|
Loading…
x
Reference in New Issue
Block a user