first commit
This commit is contained in:
19
Rime/lua/unicode_input.lua
Normal file
19
Rime/lua/unicode_input.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Unicode 输入支持
|
||||
-- -- @shewer
|
||||
-- -- https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua
|
||||
local function unicode_input(input, seg, env)
|
||||
local ucodestr = seg:has_tag("unicode") and input:match("U(%x+)")
|
||||
if ucodestr and #ucodestr > 1 then
|
||||
local code = tonumber(ucodestr, 16)
|
||||
local text = utf8.char(code)
|
||||
yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x", code)))
|
||||
if #ucodestr < 5 then
|
||||
for i = 0, 15 do
|
||||
local text = utf8.char(code * 16 + i)
|
||||
yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x~%x", code, i)))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return unicode_input
|
||||
Reference in New Issue
Block a user