You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.7 KiB

-- select_character_processor: 以词定字
-- 详见 `lua/select_character.lua`
select_character_processor = require("select_character")
--number_translator = require("number")
--reverse_lookup_filter = require("reverse")
function date_translator(input, seg)
if (input == "today") then
local weakTab = {'', '', '', '', '', '', ''}
yield(Candidate("week", seg.start, seg._end, ""..weakTab[tonumber(os.date("%w")+1)], ""))
yield(Candidate("week", seg.start, seg._end, "星期"..weakTab[tonumber(os.date("%w")+1)], ""))
end
if (input == "date") then
--- Candidate(type, start, end, text, comment)
yield(Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d"), ""))
yield(Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d daily activity"), ""))
yield(Candidate("date", seg.start, seg._end, os.date("%Y年%m月%d日"), ""))
yield(Candidate("date", seg.start, seg._end, os.date("%m-%d"), ""))
yield(Candidate("date", seg.start, seg._end, os.date("%m-%d-%Y"), ""))
yield(Candidate("date", seg.start, seg._end, os.date("%Y/%m/%d"), ""))
end
if (input == "time") then
--- Candidate(type, start, end, text, comment)
yield(Candidate("time", seg.start, seg._end, os.date("%H:%M"), ""))
yield(Candidate("time", seg.start, seg._end, os.date("%Y-%m-%d %H:%M:%S"), ""))
yield(Candidate("time", seg.start, seg._end, os.date("%Y-%m-%d %H:%M"), ""))
yield(Candidate("time", seg.start, seg._end, os.date("%m-%d %H:%M"), ""))
yield(Candidate("time", seg.start, seg._end, os.date("%H:%M:%S"), ""))
end
if (input == "timeupdate") then
--- Candidate(type, start, end, text, comment)
yield(Candidate("time", seg.start, seg._end, os.date("%Y-%m-%d %H:%M:%S update"), ""))
end
if (input == "week") then
local weakTab = {'', '', '', '', '', '', ''}
yield(Candidate("week", seg.start, seg._end, ""..weakTab[tonumber(os.date("%w")+1)], ""))
yield(Candidate("week", seg.start, seg._end, "星期"..weakTab[tonumber(os.date("%w")+1)], ""))
yield(Candidate("week", seg.start, seg._end, "今天是星期"..weakTab[tonumber(os.date("%w")+1)], ""))
yield(Candidate("week", seg.start, seg._end, "今天是周"..weakTab[tonumber(os.date("%w")+1)], ""))
end
-- @JiandanDream
-- https://github.com/KyleBing/rime-wubi86-jidian/issues/54
end
--- 过滤器:单字在先
function single_char_first_filter(input)
local l = {}
for cand in input:iter() do
if (utf8.len(cand.text) == 1) then
yield(cand)
else
table.insert(l, cand)
end
end
for cand in ipairs(l) do
yield(cand)
end
end