Created
January 25, 2016 04:29
-
-
Save tiansh/ddb7fce994cce3428b69 to your computer and use it in GitHub Desktop.
莫尔斯电码输入 - 谷歌拼音输入法扩展
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Morse(ori) | |
MorseMapping = { | |
["a"] = ".−", | |
["b"] = "−...", | |
["c"] = "−.−.", | |
["d"] = "−..", | |
["e"] = ".", | |
["f"] = "..−.", | |
["g"] = "−−.", | |
["h"] = "....", | |
["i"] = "..", | |
["j"] = ".−−−", | |
["k"] = "−.−", | |
["l"] = ".−..", | |
["m"] = "−−", | |
["n"] = "−.", | |
["o"] = "−−−", | |
["p"] = ".−−.", | |
["q"] = "−−.−", | |
["r"] = ".−.", | |
["s"] = "...", | |
["t"] = "−", | |
["u"] = "..−", | |
["v"] = "...−", | |
["w"] = ".−−", | |
["x"] = "−..−", | |
["y"] = "−.−−", | |
["z"] = "−−..", | |
["0"] = "−−−−−", | |
["1"] = ".−−−−", | |
["2"] = "..−−−", | |
["3"] = "...−−", | |
["4"] = "....−", | |
["5"] = ".....", | |
["6"] = "−....", | |
["7"] = "−−...", | |
["8"] = "−−−..", | |
["9"] = "−−−−.", | |
["."] = ".−.−.−", | |
[","] = "−−..−−", | |
["?"] = "..−−..", | |
["'"] = ".−−−−.", | |
["!"] = "−.−.−−", | |
["/"] = "−..−.", | |
["("] = "−.−−.", | |
[")"] = "−.−−.−", | |
["&"] = ".−...", | |
[":"] = "−−−...", | |
[";"] = "−.−.−.", | |
["="] = "−...−", | |
["+"] = ".−.−.", | |
["-"] = "−....−", | |
["_"] = "..−−.−", | |
["\""] = ".−..−.", | |
["$"] = "...−..−", | |
["@"] = ".−−.−.", | |
["_"] = "/" | |
} | |
if #ori == 0 then return end | |
local result = "" | |
ori = string.lower(ori) | |
for c in ori:gmatch"." do | |
result = result .. MorseMapping[c] .. " " | |
end | |
result = result .. "/ " | |
return {result, string.sub(result, 0, string.len(result) - 3)} | |
end | |
ime.register_command("mo", "Morse", "摩尔斯电码", "none") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment