[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Suggestions
. . -> [Subject]  Custom Spellchecking?

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Custom Spellchecking?

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Pages: 1  2 

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #15 on Sat 27 Nov 2004 11:36 PM (UTC)  quote  ]
Message
This is now implemented in version 3.54, in two different ways.

First is SpellCheck - a function that checks any arbitrary string of text.

Example, in Lua:


result = SpellCheck (
  "Twas brillig, and the slithy toves Did gyre and gimble in the the wabe")

print (type (result))

if result == nil then
  Note "Spell check not available"
elseif result == 0 then
  Note "No spelling errors"
else
 for _, v in result do print (v) end
end

-- output:

table  --> type of result
Twas
brillig
gimble
slithy
the the  --> duplicated word
toves
wabe


You can use that to do any custom spellchecking that you like. It returns an array of the "bad" words, which you could conceivably filter against (eg. maintain your own list of custom words).

Next there is SpellCheckCommand - this invokes the GUI spellchecker for the current command in the command window. However unlike the existing spellchecker, you can make this conditional.

The neatest way of doing this is to use the functionality of the OnPluginCommand plugin callback. This is called every time you send a command. By capturing the command here we can apply a regular expression to it (the example below only spellchecks "say" and "tell") and also limit the spell checking to certain columns. This would be useful to discard initial "command" words that you don't want spellchecked.


function OnPluginCommand (sText)

  a, b, c = rex.new ("(?:say|tell) (.+)"):exec (sText)

  if a == nil then
    return true  -- not matched our regular expression
  end	-- if

  -- matched regular expression - check the command
  check = SpellCheckCommand (c [1], c [2])

  -- if check failed, cancel sending
  if check == 0 then
    return false	-- cancelled, don't process
  end

  -- if command hasn't changed, allow it to go
  if GetCommand () == sText then
    return true
  end

  -- get the amended command, send that instead
  Send (GetCommand ())
  return false

end


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,330 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]