Register forum user name Search FAQ

Gammon Forum

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 ➜ Lua ➜ Aborting command within OnPluginCommandEntered without clearing command window?

Aborting command within OnPluginCommandEntered without clearing command window?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by j0nas   (56 posts)  Bio
Date Wed 12 Jul 2006 05:50 PM (UTC)

Amended on Wed 12 Jul 2006 05:55 PM (UTC) by j0nas

Message
I'm trying to implement spellchecks for certain inputs only, like says, poses, <whatever>, but not anything else like movement-commands and such. Initially, I did that using Nick's OnPluginCommand-example, but it turns out I can't have the input parsed by my aliases and OnPluginCommand at the same time, so I promptly upgraded to 3.75 and started using OnPluginCommandEntered instead.

The problem I'm having now is, I can't find a way to abort the sending of the text without also wiping the input from the input-buffer permamently, no way to get it back. I'd like to be able to cancel the spellcheck to add/remove something, without having to rewrite the entire <whatever>.

Right now, I have this Lua stuffed into a plugin:


function OnPluginCommandEntered (sText)
  a, b, c = rex.new ("(?:say |:|spoof |ooc |page \w+|whisper \w+)(.+)"):exec (sText)

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

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

  -- if check failed, cancel sending
  if check == 0 then
  	SelectCommand()
    PasteCommand(sText)
    return '\t'	-- cancelled, don't process
  end

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



Any suggestions?
Top

Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 12 Jul 2006 09:27 PM (UTC)
Message
Hmmm, I didn't think of that. :)

There is another bug too, it shouldn't clear the command window if "auto-repeat" is set.

Version 3.76 will offer a new option - if you return the \r character, the command will not be sent, but will be retained in the command window.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 12 Jul 2006 10:04 PM (UTC)

Amended on Wed 12 Jul 2006 10:05 PM (UTC) by Nick Gammon

Message
In the meantime, this seemed to work OK:


  -- if check failed, cancel sending
  if check == 0 then
    DoAfterSpecial (0.1, string.format ("PasteCommand (%q)", sText), 12)
    return '\t'	-- cancelled, don't process
  end


This introduces a slight delay, which lets MUSHclient clear the command window, and then puts the command back, that should be a workaround for now.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by j0nas   (56 posts)  Bio
Date Reply #3 on Wed 12 Jul 2006 10:08 PM (UTC)
Message
It does indeed, thank you!
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.


15,111 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.