<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, October 13, 2006, 8:55 AM -->
<!-- MuClient version 3.80 -->

<!-- Plugin "Thesaurus" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Thesaurus"
   author="Nick Gammon"
   id="fed86e24fd1ed8a47d97ecb6"
   language="Lua"
   purpose="Lookup a word in a thesaurus"
   date_written="2006-10-13 08:54:06"
   requires="3.80"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Type:

lookup

or

lookup <word>

eg. 

lookup eat
]]>
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   match="^lookup( (?P&lt;word&gt;.*)){0,1}$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>-- find the word they want
local word = "%&lt;word&gt;"

if #word == 0 then
  word = utils.inputbox ("Word to lookup in Thesaurus?", "Thesaurus")
end -- word not supplied

-- nil if dialog cancelled
if not word then
  return
end -- cancelled dialog

-- see if in index
local pos = thes [word:lower ()]

-- don't know that word?
if not pos then
  utils.msgbox ("The word '" .. word .. "' is not in the Thesaurus", "Not Found")
  return
end -- not found

-- seek to it in the main file
thes_file:seek ("set", pos)

-- read that line
local line = thes_file:read ()

-- convert into table
local t = utils.split (line, ",")

-- display in list box
local choice = utils.listbox (
  "Matching words for '" .. word .. 
  "'\\n\\nClick OK to copy to the clipboard", -- message
  "Thesaurus: " .. word,  -- title
  t)  -- table of words

if choice then
  SetClipboard (t [choice])
end -- if one chosen
</send>
  </alias>
</aliases>

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Thesaurus:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[

function OnPluginInstall ()
thes = {}
local name = GetInfo (66) .. "mobythes.aur"
thes_file = io.input (name)
repeat
  local pos = thes_file:seek ()  --> where we are
  local line = thes_file:read ()  --> read a line
  if line then
    local w = string.match (line, "[^,]+")
    thes [w:lower ()] = pos
  end -- of having a line
until not line 

ColourNote ("white", "blue", "Thesaurus loaded")

end -- OnPluginInstall 

function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>
