Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Suggestions
➜ Custom Spellchecking?
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #15 on Sat 27 Nov 2004 11:36 PM (UTC) |
| 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 | | 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.
58,688 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top