diff --git a/sample/lua/charset.lua b/sample/lua/charset.lua index 77998b9..1981c6b 100644 --- a/sample/lua/charset.lua +++ b/sample/lua/charset.lua @@ -6,6 +6,9 @@ 查询unicode 编码 1. https://unicode.org/charts/ +查询 Unicode 编码区 + https://www.unicode.org/Public/UCD/latest/ucd/Blocks.txt + 导出函数 1. charset_filter: 滤除含 CJK 扩展汉字的候选项 2. charset_comment_filter: 为候选项加上其所属字符集的注释 @@ -24,7 +27,9 @@ local charset = { ["ExtD"] = { first = 0x2B740, last = 0x2B81F }, -- CJK Unified Ideographs Extension D - https://unicode.org/charts/PDF/U2B740.pdf ["ExtE"] = { first = 0x2B820, last = 0x2CEAF }, -- CJK Unified Ideographs Extension E - https://unicode.org/charts/PDF/U2B820.pdf ["ExtF"] = { first = 0x2CEB0, last = 0x2EBEF }, -- CJK Unified Ideographs Extension F - https://unicode.org/charts/PDF/U2CEB0.pdf - ["ExtG"] = { first = 0x30000, last = 0x3134A }, -- CJK Unified Ideographs Extension G - https://unicode.org/charts/PDF/U30000.pdf + ["ExtG"] = { first = 0x30000, last = 0x3134F }, -- CJK Unified Ideographs Extension G - https://unicode.org/charts/PDF/U30000.pdf + ["ExtH"] = { first = 0x31350, last = 0x323AF }, -- CJK Unified Ideographs Extension H - https://unicode.org/charts/PDF/U31350.pdf + ["ExtI"] = { first = 0x2EBF0, last = 0x2EE5F }, -- CJK Unified Ideographs Extension I - https://unicode.org/charts/PDF/U2EBF0.pdf ["Compat"] = { first = 0xF900, last = 0xFAFF }, -- CJK Compatibility Ideographs - https://unicode.org/charts/PDF/UF900.pdf ["CompatSupp"] = { first = 0x2F800, last = 0x2FA1F } -- CJK Compatibility Ideographs Supplement - https://unicode.org/charts/PDF/U2F800.pdf } @@ -46,10 +51,16 @@ local function is_charset(s) end local function is_cjk_ext(c) - return is_charset("ExtA")(c) or is_charset("ExtB")(c) or - is_charset("ExtC")(c) or is_charset("ExtD")(c) or - is_charset("ExtE")(c) or is_charset("ExtF")(c) or - is_charset("ExtG")(c) or is_charset("Compat")(c) or + return is_charset("ExtA")(c) or + is_charset("ExtB")(c) or + is_charset("ExtC")(c) or + is_charset("ExtD")(c) or + is_charset("ExtE")(c) or + is_charset("ExtF")(c) or + is_charset("ExtG")(c) or + is_charset("ExtH")(c) or + is_charset("ExtI")(c) or + is_charset("Compat")(c) or is_charset("CompatSupp")(c) end diff --git a/sample/lua/time.lua b/sample/lua/time.lua index 7cfa912..d9d9235 100644 --- a/sample/lua/time.lua +++ b/sample/lua/time.lua @@ -4,7 +4,10 @@ time_translator: 将 `time` 翻译为当前时间 local function translator(input, seg) if (input == "time") then - yield(Candidate("time", seg.start, seg._end, os.date("%H:%M:%S"), " 时间")) + yield(Candidate("time", seg.start, seg._end, os.date("%H:%M"), "时间")) + yield(Candidate("time", seg.start, seg._end, os.date("%H:%M:%S"), "时间")) + yield(Candidate("time", seg.start, seg._end, os.date("%H时%M分"),"时间")) + yield(Candidate("time", seg.start, seg._end, os.date("%H时%M分%S秒"),"时间")) end end diff --git a/sample/lua/week.lua b/sample/lua/week.lua new file mode 100644 index 0000000..5667058 --- /dev/null +++ b/sample/lua/week.lua @@ -0,0 +1,34 @@ +--[[ +week_translator: 将 `week` 翻译为当前星期 +--]] + +local function translator(input, seg) + if (input == "week") then + if (os.date("%w") == "0") then + weekstr = "日" + end + if (os.date("%w") == "1") then + weekstr = "一" + end + if (os.date("%w") == "2") then + weekstr = "二" + end + if (os.date("%w") == "3") then + weekstr = "三" + end + if (os.date("%w") == "4") then + weekstr = "四" + end + if (os.date("%w") == "5") then + weekstr = "五" + end + if (os.date("%w") == "6") then + weekstr = "六" + end + yield(Candidate("week", seg.start, seg._end, "".."星期"..weekstr.."","星期")) + yield(Candidate("week", seg.start, seg._end, os.date("%Y年%m月%d日").."".."星期"..weekstr.."","星期")) + yield(Candidate("week", seg.start, seg._end, os.date("%Y年%m月%d日").."".."星期"..weekstr..""..os.date("%H:%M:%S"),"星期")) + end +end + +return translator diff --git a/sample/rime.lua b/sample/rime.lua index 08a622e..d4ee200 100644 --- a/sample/rime.lua +++ b/sample/rime.lua @@ -64,6 +64,10 @@ date_translator = require("date") -- 详见 `lua/time.lua` time_translator = require("time") +-- week_translator: 将 `week` 翻译为当前星期 +-- 详见 `lua/week.lua` +week_translator = require("week") + -- number_translator: 将 `/` + 阿拉伯数字 翻译为大小写汉字 -- 详见 `lua/number.lua` number_translator = require("number")