mirror of
https://github.com/d0zingcat/rime-ice.git
synced 2026-05-14 07:26:45 +00:00
refactor: Lua 模块化
删除 `rime.lua`,拆分到 `lua/` 文件夹内。 方案中的 `- lua_xxx@xxx` 修改为 `- lua_xxx@*xxx`(加一个星号)。
This commit is contained in:
19
lua/unicode.lua
Normal file
19
lua/unicode.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Unicode
|
||||
-- 示例:输入 U62fc 得到「拼」
|
||||
-- 复制自: https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua
|
||||
local function unicode(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
|
||||
Reference in New Issue
Block a user