您的位置:首页 > 编程语言 > Lua

google拼音支持Lua开发插件

2010-04-10 23:16 821 查看
 

 

下载最新版本的谷歌拼音,就可以通过lua来扩展它的功能了。

 

api的帮助信息在这里能看到

 
http://www.google.com/ime/pinyin/api.html
 

安装完以后,在 c:/Documents and Settings/All Users/Application Data/Google/Google Pinyin 2/Extensions 可以找到一个base.lua,里面代码写的比较清楚了。

 

比如这个计算模式。

 

function Compute(input)
  local expr = "return " .. _AddMathKeyword(input)
  local func = loadstring(expr)
  if func == nil then
    return "-- 未完整表达式 --"
  end
  local ret = func()
  if ret == math.huge then -- div/0
    return "-- 计算错误 --"
  end
  if ret ~= ret then
    -- We rely on the property that NaN is the only value not equal to itself.
    return "-- 计算错误 --"
  end
  return ret
end

 

 

ime.register_command("js", "Compute", "计算模式", "none", "输入表达式,例如3*log(4+2)")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息